Bug 986582 - Get rid of the toolkit.telemetry.enabledPreRelease pref and make the toolkit.telemetry.enabled pref do the right thing for beta users who are testing a final release build, r=rnewman

--HG--
extra : rebase_source : 43f70e2c1c3207f37ba0789245958cb0c34187f6
This commit is contained in:
Benjamin Smedberg 2014-04-03 14:55:42 -04:00
parent a57a16c5a5
commit cd2fddc1ce
17 changed files with 32 additions and 95 deletions

View File

@ -54,11 +54,7 @@
#ifdef MOZ_TELEMETRY_REPORTING
<preference id="toolkit.telemetry.enabled"
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
name="toolkit.telemetry.enabledPreRelease"
#else
name="toolkit.telemetry.enabled"
#endif
type="bool"/>
#endif

View File

@ -54,11 +54,7 @@
#ifdef MOZ_TELEMETRY_REPORTING
<preference id="toolkit.telemetry.enabled"
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
name="toolkit.telemetry.enabledPreRelease"
#else
name="toolkit.telemetry.enabled"
#endif
type="bool"/>
#endif

View File

@ -67,7 +67,6 @@ const PREF_HEALTHREPORT_ENABLED = "datareporting.healthreport.service.enabled";
const PREF_BRANCH_TELEMETRY = "toolkit.telemetry.";
const PREF_TELEMETRY_ENABLED = "enabled";
const PREF_TELEMETRY_PRERELEASE = "enabledPreRelease";
const TELEMETRY_LOG = {
// log(key, [kind, experimentId, details])
@ -167,8 +166,7 @@ function loadJSONAsync(file, options) {
}
function telemetryEnabled() {
return gPrefsTelemetry.get(PREF_TELEMETRY_ENABLED, false) ||
gPrefsTelemetry.get(PREF_TELEMETRY_PRERELEASE, false);
return gPrefsTelemetry.get(PREF_TELEMETRY_ENABLED, false);
}
// Returns a promise that is resolved with the AddonInstall for that URL.
@ -357,7 +355,6 @@ Experiments.Experiments.prototype = {
gPrefs.observe(PREF_ENABLED, this._toggleExperimentsEnabled, this);
gPrefsTelemetry.observe(PREF_TELEMETRY_ENABLED, this._telemetryStatusChanged, this);
gPrefsTelemetry.observe(PREF_TELEMETRY_PRERELEASE, this._telemetryStatusChanged, this);
AsyncShutdown.profileBeforeChange.addBlocker("Experiments.jsm shutdown",
this.uninit.bind(this));
@ -390,7 +387,6 @@ Experiments.Experiments.prototype = {
gPrefs.ignore(PREF_ENABLED, this._toggleExperimentsEnabled, this);
gPrefsTelemetry.ignore(PREF_TELEMETRY_ENABLED, this._telemetryStatusChanged, this);
gPrefsTelemetry.ignore(PREF_TELEMETRY_PRERELEASE, this._telemetryStatusChanged, this);
if (this._timer) {
this._timer.clear();

View File

@ -104,11 +104,7 @@ public class AppConstants {
#endif
public static final String TELEMETRY_PREF_NAME =
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
"toolkit.telemetry.enabledPreRelease";
#else
"toolkit.telemetry.enabled";
#endif
public static final boolean MOZ_TELEMETRY_REPORTING =
#ifdef MOZ_TELEMETRY_REPORTING

View File

@ -82,7 +82,7 @@ public class GeckoPreferences
private static final String PREFS_HOME_ADD_PANEL = NON_PREF_PREFIX + "home.add_panel";
private static final String PREFS_ANNOUNCEMENTS_ENABLED = NON_PREF_PREFIX + "privacy.announcements.enabled";
private static final String PREFS_DATA_REPORTING_PREFERENCES = NON_PREF_PREFIX + "datareporting.preferences";
private static final String PREFS_TELEMETRY_ENABLED = "datareporting.telemetry.enabled";
private static final String PREFS_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
private static final String PREFS_CRASHREPORTER_ENABLED = "datareporting.crashreporter.submitEnabled";
private static final String PREFS_MENU_CHAR_ENCODING = "browser.menu.showCharacterEncoding";
private static final String PREFS_MP_ENABLED = "privacy.masterpassword.enabled";

View File

@ -25,7 +25,7 @@
<PreferenceCategory android:key="android.not_a_preference.datareporting.preferences"
android:title="@string/pref_category_datareporting">
<CheckBoxPreference android:key="datareporting.telemetry.enabled"
<CheckBoxPreference android:key="toolkit.telemetry.enabled"
android:title="@string/datareporting_telemetry_title"
android:summary="@string/datareporting_telemetry_summary" />

View File

@ -1166,20 +1166,6 @@ var BrowserApp = {
#endif
}
// Pref name translation.
switch (prefName) {
#ifdef MOZ_TELEMETRY_REPORTING
// Telemetry pref differs based on build.
case Telemetry.SHARED_PREF_TELEMETRY_ENABLED:
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
prefName = "toolkit.telemetry.enabledPreRelease";
#else
prefName = "toolkit.telemetry.enabled";
#endif
break;
#endif
}
try {
switch (Services.prefs.getPrefType(prefName)) {
case Ci.nsIPrefBranch.PREF_BOOL:
@ -1295,20 +1281,6 @@ var BrowserApp = {
break;
}
// Pref name translation.
switch (json.name) {
#ifdef MOZ_TELEMETRY_REPORTING
// Telemetry pref differs based on build.
case Telemetry.SHARED_PREF_TELEMETRY_ENABLED:
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
json.name = "toolkit.telemetry.enabledPreRelease";
#else
json.name = "toolkit.telemetry.enabled";
#endif
break;
#endif
}
switch (json.type) {
case "bool":
Services.prefs.setBoolPref(json.name, json.value);
@ -5658,12 +5630,7 @@ let HealthReportStatusListener = {
PREF_TELEMETRY_ENABLED:
#ifdef MOZ_TELEMETRY_REPORTING
// Telemetry pref differs based on build.
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
"toolkit.telemetry.enabledPreRelease",
#else
"toolkit.telemetry.enabled",
#endif
#else
null,
#endif
@ -7531,8 +7498,6 @@ var RemoteDebugger = {
};
var Telemetry = {
SHARED_PREF_TELEMETRY_ENABLED: "datareporting.telemetry.enabled",
addData: function addData(aHistogramId, aValue) {
let histogram = Services.telemetry.getHistogramById(aHistogramId);
histogram.add(aValue);

View File

@ -77,6 +77,10 @@ static nsresult pref_InitInitialObjects(void);
static nsresult pref_LoadPrefsInDirList(const char *listId);
static nsresult ReadExtensionPrefs(nsIFile *aFile);
static const char kTelemetryPref[] = "toolkit.telemetry.enabled";
static const char kOldTelemetryPref[] = "toolkit.telemetry.enabledPreRelease";
static const char kChannelPref[] = "app.update.channel";
Preferences* Preferences::sPreferences = nullptr;
nsIPrefBranch* Preferences::sRootBranch = nullptr;
nsIPrefBranch* Preferences::sDefaultRootBranch = nullptr;
@ -589,6 +593,12 @@ Preferences::ReadUserPrefs(nsIFile *aFile)
// Ignore all errors related to it, so we retain 'rv' value :-|
(void) UseUserPrefFile();
// Migrate the old prerelease telemetry pref
if (!Preferences::GetBool(kOldTelemetryPref, true)) {
Preferences::SetBool(kTelemetryPref, false);
Preferences::ClearUser(kOldTelemetryPref);
}
NotifyServiceObservers(NS_PREFSERVICE_READ_TOPIC_ID);
} else {
rv = ReadAndOwnUserPrefFile(aFile);
@ -1298,6 +1308,23 @@ static nsresult pref_InitInitialObjects()
rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
NS_ENSURE_SUCCESS(rv, rv);
// Set up the correct default for toolkit.telemetry.enabled.
// If this build has MOZ_TELEMETRY_ON_BY_DEFAULT *or* we're on the beta
// channel, telemetry is on by default, otherwise not. This is necessary
// so that beta users who are testing final release builds don't flipflop
// defaults.
if (Preferences::GetDefaultType(kTelemetryPref) == PREF_INVALID) {
bool prerelease = false;
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
prerelease = true;
#else
if (Preferences::GetDefaultCString(kChannelPref).EqualsLiteral("beta")) {
prerelease = true;
}
#endif
PREF_SetBoolPref(kTelemetryPref, prerelease, true);
}
NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
nullptr, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);

View File

@ -534,12 +534,6 @@ pref("toolkit.scrollbox.verticalScrollDistance", 3);
pref("toolkit.scrollbox.horizontalScrollDistance", 5);
pref("toolkit.scrollbox.clickToScroll.scrollDelay", 150);
// Telemetry
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
pref("toolkit.telemetry.enabledPreRelease", true);
#else
pref("toolkit.telemetry.enabled", false);
#endif
pref("toolkit.telemetry.server", "https://incoming.telemetry.mozilla.org");
// Telemetry server owner. Please change if you set toolkit.telemetry.server to a different server
pref("toolkit.telemetry.server_owner", "Mozilla");

View File

@ -84,11 +84,7 @@ extern PRThread *gSocketThread;
#define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled"
#define DONOTTRACK_HEADER_VALUE "privacy.donottrackheader.value"
#define DONOTTRACK_VALUE_UNSET 2
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
#define TELEMETRY_ENABLED "toolkit.telemetry.enabledPreRelease"
#else
#define TELEMETRY_ENABLED "toolkit.telemetry.enabled"
#endif
#define ALLOW_EXPERIMENTS "network.allow-experiments"
#define UA_PREF(_pref) UA_PREF_PREFIX _pref

View File

@ -57,12 +57,7 @@ const DAILY_DISCRETE_NUMERIC_FIELD = {type: Metrics.Storage.FIELD_DAILY_DISCRETE
const DAILY_LAST_NUMERIC_FIELD = {type: Metrics.Storage.FIELD_DAILY_LAST_NUMERIC};
const DAILY_COUNTER_FIELD = {type: Metrics.Storage.FIELD_DAILY_COUNTER};
// Preprocess to use the correct telemetry pref.
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
const TELEMETRY_PREF = "toolkit.telemetry.enabledPreRelease";
#else
const TELEMETRY_PREF = "toolkit.telemetry.enabled";
#endif
/**
* Represents basic application state.

View File

@ -159,15 +159,9 @@ add_task(function test_record_telemetry() {
let storage = yield Metrics.Storage("record_telemetry");
let provider;
// We set both prefs, so we don't have to fight the preprocessor.
function setTelemetry(bool) {
Services.prefs.setBoolPref("toolkit.telemetry.enabled", bool);
Services.prefs.setBoolPref("toolkit.telemetry.enabledPreRelease", bool);
}
let now = new Date();
setTelemetry(true);
Services.prefs.setBoolPref("toolkit.telemetry.enabled", true);
provider = new AppInfoProvider();
yield provider.init(storage);
yield provider.collectConstantData();
@ -178,7 +172,7 @@ add_task(function test_record_telemetry() {
do_check_eq(1, d.isTelemetryEnabled);
yield provider.shutdown();
setTelemetry(false);
Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
provider = new AppInfoProvider();
yield provider.init(storage);
yield provider.collectConstantData();

View File

@ -349,7 +349,6 @@ class FirefoxProfile(Profile):
'toolkit.startup.max_resumed_crashes' : -1,
# Don't report telemetry information
'toolkit.telemetry.enabled' : False,
'toolkit.telemetry.enabledPreRelease' : False,
}
class MetroFirefoxProfile(Profile):
@ -393,7 +392,6 @@ class MetroFirefoxProfile(Profile):
'toolkit.startup.max_resumed_crashes' : -1,
# Don't report telemetry information
'toolkit.telemetry.enabled' : False,
'toolkit.telemetry.enabledPreRelease' : False,
}
class ThunderbirdProfile(Profile):

View File

@ -30,11 +30,7 @@ const PAYLOAD_VERSION = 1;
const PREF_BRANCH = "toolkit.telemetry.";
const PREF_SERVER = PREF_BRANCH + "server";
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
const PREF_ENABLED = PREF_BRANCH + "enabledPreRelease";
#else
const PREF_ENABLED = PREF_BRANCH + "enabled";
#endif
const PREF_PREVIOUS_BUILDID = PREF_BRANCH + "previousBuildID";
// Do not gather data more than once a minute

View File

@ -7,11 +7,7 @@
const Cu = Components.utils;
const PREF_BRANCH = "toolkit.telemetry.";
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
const PREF_ENABLED = PREF_BRANCH + "enabledPreRelease";
#else
const PREF_ENABLED = PREF_BRANCH + "enabled";
#endif
this.EXPORTED_SYMBOLS = [
"UITelemetry",

View File

@ -22,11 +22,7 @@ const brandBundle = Services.strings.createBundle(
const MAX_BAR_HEIGHT = 18;
const MAX_BAR_CHARS = 25;
const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner";
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabledPreRelease";
#else
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
#endif
const PREF_DEBUG_SLOW_SQL = "toolkit.telemetry.debugSlowSql";
const PREF_SYMBOL_SERVER_URI = "profiler.symbolicationUrl";
const DEFAULT_SYMBOL_SERVER_URI = "http://symbolapi.mozilla.org";

View File

@ -36,11 +36,7 @@ volatile bool gDebugDisableHangMonitor = false;
const char kHangMonitorPrefName[] = "hangmonitor.timeout";
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
const char kTelemetryPrefName[] = "toolkit.telemetry.enabledPreRelease";
#else
const char kTelemetryPrefName[] = "toolkit.telemetry.enabled";
#endif
// Monitor protects gShutdown and gTimeout, but not gTimestamp which rely on
// being atomically set by the processor; synchronization doesn't really matter