bug 1406391 - Lock toolkit.telemetry.enabled based on channel r?froydnj draft
authorChris H-C <chutten@mozilla.com>
Fri, 13 Oct 2017 16:17:18 -0400
changeset 686872 0ac3ce12c53d235470dea4eadccead165a0aff48
parent 685447 967c95cee709756596860ed2a3e6ac06ea3a053f
child 687046 1aa8d16efdb7e4558d4d3d9db2cf09162ac0a239
child 687575 03c8b8731dc849486e25bf16dbb4cd12fac6d8be
push id86332
push userbmo:chutten@mozilla.com
push dateThu, 26 Oct 2017 14:54:37 +0000
reviewersfroydnj
bugs1406391
milestone58.0a1
bug 1406391 - Lock toolkit.telemetry.enabled based on channel r?froydnj In Unified Telemetry toolkit.telemetry.enabled controls whether we send base collection data or extended collection. The difference is mostly in volume, not in kind (though extended collection has a little stricter testing and monitoring requirements). Since the Preferences UI change in Firefox 56, users no longer have the ability to change toolkit.telemetry.enabled. This is a good thing as for pre-release users very few disabled extended collection, and even fewer release users enabled it. This provides uniform collection based on channel which should eventually net us some efficiencies. Until then we need to align our use of the toolkit.telemetry.enabled pref with the UI change that has already shipped. This is accomplished by locking t.t.e to 'true' on pre-release channels and locking it to 'false' on everything else. This doesn't apply to Android as it doesn't (yet) use Unified Telemetry. t.t.e means something rather different there. MozReview-Commit-ID: EOpWm8b0jWA
modules/libpref/Preferences.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -4850,16 +4850,17 @@ pref_InitInitialObjects()
       }
     }
   }
 
   rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
   NS_ENSURE_SUCCESS(
     rv, Err("pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST) failed"));
 
+#ifdef MOZ_WIDGET_ANDROID
   // 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) ==
       nsIPrefBranch::PREF_INVALID) {
     bool prerelease = false;
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
@@ -4868,16 +4869,29 @@ pref_InitInitialObjects()
     nsAutoCString prefValue;
     Preferences::GetDefaultCString(kChannelPref, prefValue);
     if (prefValue.EqualsLiteral("beta")) {
       prerelease = true;
     }
 #endif
     PREF_SetBoolPref(kTelemetryPref, prerelease, true);
   }
+#else
+  // For platforms with Unified Telemetry (here meaning not-Android),
+  // toolkit.telemetry.enabled determines whether we send "extended" data.
+  // We only want extended data from pre-release channels due to size.
+  if (!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "nightly") ||
+      !strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "aurora") ||
+      !strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "beta")) {
+    PREF_SetBoolPref(kTelemetryPref, true, true);
+  } else {
+    PREF_SetBoolPref(kTelemetryPref, false, true);
+  }
+  PREF_LockPref(kTelemetryPref, true);
+#endif // MOZ_WIDGET_ANDROID
 
   NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
                                 nullptr,
                                 NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
 
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   NS_ENSURE_SUCCESS(rv, Err("GetObserverService() failed (2)"));