Bug 1130132 - add telemetry to determine how consistent our geoip country code is with Windows. r=gavin

This commit is contained in:
Mark Hammond 2015-02-12 12:49:18 +11:00
Родитель b803f26a9f
Коммит 769856eeb5
3 изменённых файлов: 59 добавлений и 19 удалений

Просмотреть файл

@ -555,21 +555,37 @@ function storeCountryCode(cc) {
Services.telemetry.getHistogramById("SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY").add(1);
}
// 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;
try {
gfxInfo2 = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo2);
} catch (ex) {
// not on Mac.
// not available on this platform.
}
if (gfxInfo2) {
let macCC = gfxInfo2.countryCode;
if (cc == "US" || macCC == "US") {
// one of the 2 said US, so record if they are the same.
Services.telemetry.getHistogramById("SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX").add(cc != macCC);
} else {
// different country - record if they are the same
Services.telemetry.getHistogramById("SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX").add(cc != macCC);
let probeUSMismatched, probeNonUSMismatched;
switch (Services.appinfo.OS) {
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:
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
// 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.
// NOTE: head_search.js mocks the XULRuntime values, but saves the original
// OS in an OS global
if (Services.appinfo.OS == "Darwin") {
let probeUSMismatched, probeNonUSMismatched;
switch (Services.appinfo.OS) {
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);
print("OSX says the country-code is", gfxInfo2.countryCode);
print("Platform says the country-code is", gfxInfo2.countryCode);
let expectedResult;
let hid;
// We know geoip said AU - if mac thinks US then we expect
// SEARCH_SERVICE_US_COUNTRY_MISMATCHED_PLATFORM_OSX with true (ie, a mismatch)
// We know geoip said AU - if the platform thinks US then we expect
// probeUSMismatched with true (ie, a mismatch)
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|.
} else {
// We are expecting SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX
// with false if OSX says AU (not a mismatch) and true otherwise.
hid = "SEARCH_SERVICE_NONUS_COUNTRY_MISMATCHED_PLATFORM_OSX";
// We are expecting probeNonUSMismatched with false if the platform
// says AU (not a mismatch) and true otherwise.
hid = probeNonUSMismatched;
expectedResult = gfxInfo2.countryCode == "AU" ? [1,0,0] : [0,1,0];
}

Просмотреть файл

@ -4671,6 +4671,18 @@
"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"
},
"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": {
"expires_in_version": "never",
"kind": "flag",