зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1130132
- add telemetry to determine how consistent our geoip country code is with Windows. r=gavin
This commit is contained in:
Родитель
b803f26a9f
Коммит
769856eeb5
|
@ -555,21 +555,37 @@ function storeCountryCode(cc) {
|
||||||
Services.telemetry.getHistogramById("SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY").add(1);
|
Services.telemetry.getHistogramById("SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY").add(1);
|
||||||
}
|
}
|
||||||
// telemetry to compare our geoip response with platform-specific country data.
|
// telemetry to compare our geoip response with platform-specific country data.
|
||||||
// On Mac, we can get a country code via nsIGfxInfo2
|
// On Mac and Windows, we can get a country code via nsIGfxInfo2
|
||||||
let gfxInfo2;
|
let gfxInfo2;
|
||||||
try {
|
try {
|
||||||
gfxInfo2 = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo2);
|
gfxInfo2 = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo2);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// not on Mac.
|
// not available on this platform.
|
||||||
}
|
}
|
||||||
if (gfxInfo2) {
|
if (gfxInfo2) {
|
||||||
let macCC = gfxInfo2.countryCode;
|
let probeUSMismatched, probeNonUSMismatched;
|
||||||
if (cc == "US" || macCC == "US") {
|
switch (Services.appinfo.OS) {
|
||||||
// one of the 2 said US, so record if they are the same.
|
case "Darwin":
|
||||||
Services.telemetry.getHistogramById("SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX").add(cc != macCC);
|
probeUSMismatched = "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
||||||
} else {
|
probeNonUSMismatched = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
||||||
// different country - record if they are the same
|
break;
|
||||||
Services.telemetry.getHistogramById("SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX").add(cc != macCC);
|
case "WINNT":
|
||||||
|
probeUSMismatched = "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_WIN";
|
||||||
|
probeNonUSMismatched = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_WIN";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Cu.reportError("Platform " + Services.appinfo.OS + " has nsIGfxInfo2 but no search service telemetry probes");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (probeUSMismatched && probeNonUSMismatched) {
|
||||||
|
let platformCC = gfxInfo2.countryCode;
|
||||||
|
if (cc == "US" || platformCC == "US") {
|
||||||
|
// one of the 2 said US, so record if they are the same.
|
||||||
|
Services.telemetry.getHistogramById(probeUSMismatched).add(cc != platformCC);
|
||||||
|
} else {
|
||||||
|
// different country - record if they are the same
|
||||||
|
Services.telemetry.getHistogramById(probeNonUSMismatched).add(cc != platformCC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,34 @@ function run_test() {
|
||||||
// simple checks for our platform-specific telemetry. We can't influence
|
// simple checks for our platform-specific telemetry. We can't influence
|
||||||
// what they return (as we can't influence the countryCode the platform
|
// what they return (as we can't influence the countryCode the platform
|
||||||
// thinks we are in), but we can check the values are correct given reality.
|
// thinks we are in), but we can check the values are correct given reality.
|
||||||
// NOTE: head_search.js mocks the XULRuntime values, but saves the original
|
let probeUSMismatched, probeNonUSMismatched;
|
||||||
// OS in an OS global
|
switch (Services.appinfo.OS) {
|
||||||
if (Services.appinfo.OS == "Darwin") {
|
case "Darwin":
|
||||||
|
probeUSMismatched = "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
||||||
|
probeNonUSMismatched = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
||||||
|
break;
|
||||||
|
case "WINNT":
|
||||||
|
probeUSMismatched = "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_WIN";
|
||||||
|
probeNonUSMismatched = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_WIN";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (probeUSMismatched && probeNonUSMismatched) {
|
||||||
let gfxInfo2 = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo2);
|
let gfxInfo2 = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo2);
|
||||||
print("OSX says the country-code is", gfxInfo2.countryCode);
|
print("Platform says the country-code is", gfxInfo2.countryCode);
|
||||||
let expectedResult;
|
let expectedResult;
|
||||||
let hid;
|
let hid;
|
||||||
// We know geoip said AU - if mac thinks US then we expect
|
// We know geoip said AU - if the platform thinks US then we expect
|
||||||
// SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX with true (ie, a mismatch)
|
// probeUSMismatched with true (ie, a mismatch)
|
||||||
if (gfxInfo2.countryCode == "US") {
|
if (gfxInfo2.countryCode == "US") {
|
||||||
hid = "SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
hid = probeUSMismatched;
|
||||||
expectedResult = [0,1,0]; // boolean probe so 3 buckets, expect 1 result for |1|.
|
expectedResult = [0,1,0]; // boolean probe so 3 buckets, expect 1 result for |1|.
|
||||||
} else {
|
} else {
|
||||||
// We are expecting SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX
|
// We are expecting probeNonUSMismatched with false if the platform
|
||||||
// with false if OSX says AU (not a mismatch) and true otherwise.
|
// says AU (not a mismatch) and true otherwise.
|
||||||
hid = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX";
|
hid = probeNonUSMismatched;
|
||||||
expectedResult = gfxInfo2.countryCode == "AU" ? [1,0,0] : [0,1,0];
|
expectedResult = gfxInfo2.countryCode == "AU" ? [1,0,0] : [0,1,0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4671,6 +4671,18 @@
|
||||||
"kind": "boolean",
|
"kind": "boolean",
|
||||||
"description": "If we are on OSX and neither the OSX countryCode nor the geoip countryCode indicates we are in the US, set to false if they both agree on the value or true otherwise"
|
"description": "If we are on OSX and neither the OSX countryCode nor the geoip countryCode indicates we are in the US, set to false if they both agree on the value or true otherwise"
|
||||||
},
|
},
|
||||||
|
"SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_WIN": {
|
||||||
|
"alert_emails": ["mhammond@mozilla.com", "gavin@mozilla.com"],
|
||||||
|
"expires_in_version": "never",
|
||||||
|
"kind": "boolean",
|
||||||
|
"description": "If we are on Windows and either the Windows countryCode or the geoip countryCode indicates we are in the US, set to false if they both do or true otherwise"
|
||||||
|
},
|
||||||
|
"SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_WIN": {
|
||||||
|
"alert_emails": ["mhammond@mozilla.com", "gavin@mozilla.com"],
|
||||||
|
"expires_in_version": "never",
|
||||||
|
"kind": "boolean",
|
||||||
|
"description": "If we are on Windows and neither the Windows countryCode nor the geoip countryCode indicates we are in the US, set to false if they both agree on the value or true otherwise"
|
||||||
|
},
|
||||||
"SOCIAL_ENABLED_ON_SESSION": {
|
"SOCIAL_ENABLED_ON_SESSION": {
|
||||||
"expires_in_version": "never",
|
"expires_in_version": "never",
|
||||||
"kind": "flag",
|
"kind": "flag",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче