Bug 725987 - Create Telemetry (opt-out) notification for Nightly and Aurora (mobile). r=bnicholson

This commit is contained in:
Theo Chevalier 2012-12-10 23:25:52 +01:00
parent 05d9dee167
commit a1cfcf43e1
3 changed files with 90 additions and 21 deletions

View File

@ -386,7 +386,7 @@ webapps.install.success = Application Installed
# Telemetry opt-out prompt for Aurora and Nightly
# LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by
# brandFullName, and %2$S by the value of the toolkit.telemetry.server_owner preference.
# brandShortName, and %2$S by the value of the toolkit.telemetry.server_owner preference.
telemetryOptOutPrompt = %1$S sends information about performance, hardware, usage and customizations back to %2$S to help improve %3$S.
# LOCALIZATION NOTE (fullscreen.entered): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).

View File

@ -7106,17 +7106,19 @@ var RemoteDebugger = {
};
var Telemetry = {
_PREF_TELEMETRY_PROMPTED: "toolkit.telemetry.prompted",
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
_PREF_TELEMETRY_ENABLED: "toolkit.telemetry.enabledPreRelease",
_PREF_TELEMETRY_DISPLAYED: "toolkit.telemetry.notifiedOptOut",
#else
_PREF_TELEMETRY_ENABLED: "toolkit.telemetry.enabled",
_PREF_TELEMETRY_DISPLAYED: "toolkit.telemetry.prompted",
#endif
_PREF_TELEMETRY_REJECTED: "toolkit.telemetry.rejected",
_PREF_TELEMETRY_SERVER_OWNER: "toolkit.telemetry.server_owner",
// This is used to reprompt users when privacy message changes
_TELEMETRY_PROMPT_REV: "@MOZ_TELEMETRY_DISPLAY_REV@",
// This is used to reprompt Beta/GA users and notify again
// Nightly/Aurora users when privacy message changes
_TELEMETRY_DISPLAY_REV: @MOZ_TELEMETRY_DISPLAY_REV@,
init: function init() {
Services.obs.addObserver(this, "Preferences:Set", false);
@ -7141,7 +7143,7 @@ var Telemetry = {
// if user changes telemetry pref, treat it like they have been prompted
let pref = JSON.parse(aData);
if (pref.name == this._PREF_TELEMETRY_ENABLED)
Services.prefs.setIntPref(this._PREF_TELEMETRY_PROMPTED, this._TELEMETRY_PROMPT_REV);
Services.prefs.setIntPref(this._PREF_TELEMETRY_DISPLAYED, this._TELEMETRY_DISPLAY_REV);
} else if (aTopic == "Telemetry:Add") {
let json = JSON.parse(aData);
this.addData(json.name, json.value);
@ -7153,40 +7155,103 @@ var Telemetry = {
},
prompt: function prompt() {
let brandShortName = Strings.brand.GetStringFromName("brandShortName");
let serverOwner = Services.prefs.getCharPref(this._PREF_TELEMETRY_SERVER_OWNER);
let telemetryPrompted = null;
let telemetryEnabled = Services.prefs.getBoolPref(this._PREF_TELEMETRY_ENABLED);
let message;
let buttons;
let self = this;
try {
telemetryPrompted = Services.prefs.getIntPref(this._PREF_TELEMETRY_PROMPTED);
} catch (e) { /* Optional */ }
// If the user has seen the latest telemetry prompt, do not prompt again
// else clear old prefs and reprompt
if (telemetryPrompted === this._TELEMETRY_PROMPT_REV)
/*
* Display an opt-out notification when telemetry is enabled by default,
* an opt-in prompt otherwise.
*
* But do not display this prompt/notification if:
*
* - The last accepted/refused policy (either by accepting the prompt or by
* manually flipping the telemetry preference) is already at version
* TELEMETRY_DISPLAY_REV.
*/
let telemetryDisplayed;
try {
telemetryDisplayed = Services.prefs.getIntPref(self._PREF_TELEMETRY_DISPLAYED);
} catch(e) {}
if (telemetryDisplayed === self._TELEMETRY_DISPLAY_REV)
return;
Services.prefs.clearUserPref(this._PREF_TELEMETRY_PROMPTED);
Services.prefs.clearUserPref(this._PREF_TELEMETRY_ENABLED);
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
/*
* Additionally, in opt-out builds, don't display the notification if:
*
* - Telemetry is disabled
* - Telemetry was explicitly refused through the UI
* - Opt-in telemetry was already enabled, don't notify the user until next
* policy update. (Do the check only at first run with opt-out builds)
*/
let buttons = [
let telemetryEnabled = Services.prefs.getBoolPref(self._PREF_TELEMETRY_ENABLED);
if (!telemetryEnabled)
return;
// If telemetry was explicitly refused through the UI,
// also disable opt-out telemetry and bail out.
let telemetryRejected = false;
try {
telemetryRejected = Services.prefs.getBoolPref(self._PREF_TELEMETRY_REJECTED);
} catch(e) {}
if (telemetryRejected) {
Services.prefs.setBoolPref(self._PREF_TELEMETRY_ENABLED, false);
Services.prefs.setIntPref(self._PREF_TELEMETRY_DISPLAYED, self._TELEMETRY_DISPLAY_REV);
return;
}
// If opt-in telemetry was already enabled, don't notify the user until next
// policy update. (Do the check only at first run with opt-out builds)
let optInTelemetryEnabled = false;
try {
optInTelemetryEnabled = Services.prefs.getBoolPref("toolkit.telemetry.enabled");
} catch(e) {}
if (optInTelemetryEnabled && telemetryDisplayed === undefined) {
Services.prefs.setBoolPref(self._PREF_TELEMETRY_REJECTED, false);
Services.prefs.setIntPref(self._PREF_TELEMETRY_DISPLAYED, self._TELEMETRY_DISPLAY_REV);
return;
}
message = Strings.browser.formatStringFromName("telemetry.optout.message",
[brandShortName, serverOwner, brandShortName], 3);
buttons = [
{
label: Strings.browser.GetStringFromName("telemetry.optout.ok"),
callback: function () {
Services.prefs.setIntPref(self._PREF_TELEMETRY_DISPLAYED, self._TELEMETRY_DISPLAY_REV);
}
}
];
#else
// Clear old prefs and reprompt
Services.prefs.clearUserPref(self._PREF_TELEMETRY_DISPLAYED);
Services.prefs.clearUserPref(self._PREF_TELEMETRY_ENABLED);
Services.prefs.clearUserPref(self._PREF_TELEMETRY_REJECTED);
message = Strings.browser.formatStringFromName("telemetry.optin.message2",
[serverOwner, brandShortName], 2);
buttons = [
{
label: Strings.browser.GetStringFromName("telemetry.optin.yes"),
callback: function () {
Services.prefs.setIntPref(self._PREF_TELEMETRY_PROMPTED, self._TELEMETRY_PROMPT_REV);
Services.prefs.setIntPref(self._PREF_TELEMETRY_DISPLAYED, self._TELEMETRY_DISPLAY_REV);
Services.prefs.setBoolPref(self._PREF_TELEMETRY_ENABLED, true);
}
},
{
label: Strings.browser.GetStringFromName("telemetry.optin.no"),
callback: function () {
Services.prefs.setIntPref(self._PREF_TELEMETRY_PROMPTED, self._TELEMETRY_PROMPT_REV);
Services.prefs.setIntPref(self._PREF_TELEMETRY_DISPLAYED, self._TELEMETRY_DISPLAY_REV);
Services.prefs.setBoolPref(self._PREF_TELEMETRY_REJECTED, true);
}
}
];
let brandShortName = Strings.brand.GetStringFromName("brandShortName");
let message = Strings.browser.formatStringFromName("telemetry.optin.message2", [serverOwner, brandShortName], 2);
#endif
let learnMoreLabel = Strings.browser.GetStringFromName("telemetry.optin.learnMore");
let learnMoreUrl = Services.urlFormatter.formatURLPref("app.support.baseURL");
learnMoreUrl += "how-can-i-help-submitting-performance-data";
@ -7196,7 +7261,7 @@ var Telemetry = {
url: learnMoreUrl
}
};
NativeWindow.doorhanger.show(message, "telemetry-optin", buttons, BrowserApp.selectedTab.id, options);
NativeWindow.doorhanger.show(message, "telemetry-prompt", buttons, BrowserApp.selectedTab.id, options);
},
};

View File

@ -67,6 +67,10 @@ telemetry.optin.message2=Send info to %1$S so that we can improve %2$S?
telemetry.optin.learnMore=Learn more
telemetry.optin.yes=Yes
telemetry.optin.no=No
# LOCALIZATION NOTE (telemetry.optout.message): %1$S and %3$S will be replaced by
# brandShortName, and %2$S by the value of the toolkit.telemetry.server_owner preference.
telemetry.optout.message=%1$S sends information about performance, hardware, usage and customizations back to %2$S to help improve %3$S.
telemetry.optout.ok=OK
# XPInstall
xpinstallPromptWarning2=%S prevented this site (%S) from asking you to install software on your device.