Bug 1950658 - Rely on a pref to tell us whether we should initialize Glean on shutdown r=TravisLong
Only once the user interacted with the telemetry reporting policy modal we can be sure that the preference for collection is valid. If it's not we don't initialize Glean and thus don't collect any data. Differential Revision: https://phabricator.services.mozilla.com/D239753
This commit is contained in:
@@ -16956,6 +16956,11 @@
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
- name: telemetry.fog.init_on_shutdown
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Prefs starting with "test."
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -46,6 +46,14 @@ Defaults to 120 (activity), 1200 (inactivity).
|
||||
Read-only. This pref is `true` only if `MOZ_ARTIFACT_BUILDS` was set during configure.
|
||||
If true, [JOG](./jog) is enabled so that artifact builds will exhibit changes to their Glean metrics.
|
||||
|
||||
`telemetry.fog.init_on_shutdown`
|
||||
|
||||
Defaults to `true`.
|
||||
Controls whether Glean initializes on shutdown if it hasn't been initialized, in order to capture data from very short sessions.
|
||||
In case a policy modal needs to be shown to the user, which will delay Glean initialization,
|
||||
it's set to `false` until the user has dealt with the modal. It's turned back to `true` afterwards.
|
||||
This ensures we don't capture data until the user had the chance to make an explicit choice.
|
||||
|
||||
## Defines
|
||||
|
||||
`MOZ_AUTOMATION`
|
||||
|
||||
@@ -88,7 +88,9 @@ already_AddRefed<FOG> FOG::GetSingleton() {
|
||||
MOZ_ASSERT(idleService);
|
||||
Unused << idleService->RemoveIdleObserver(gFOG, kIdleSecs);
|
||||
}
|
||||
if (!gInitializeCalled) {
|
||||
bool initOnShutdown =
|
||||
Preferences::GetBool("telemetry.fog.init_on_shutdown", true);
|
||||
if (initOnShutdown && !gInitializeCalled) {
|
||||
gInitializeCalled = true;
|
||||
// Assuming default data path and application id.
|
||||
// Consumers using non defaults _must_ initialize FOG explicitly.
|
||||
|
||||
@@ -636,6 +636,10 @@ var TelemetryReportingPolicyImpl = {
|
||||
return;
|
||||
}
|
||||
|
||||
// We're about to show the user the modal dialog.
|
||||
// Make sure Glean won't initialize on shutdown, in case the user never interacts with the modal
|
||||
Services.prefs.setBoolPref("telemetry.fog.init_on_shutdown", false);
|
||||
|
||||
if (this._nimbusVariables.enabled && this._nimbusVariables.screens) {
|
||||
if (await this._notifyUserViaMessagingSystem()) {
|
||||
this._log.trace(
|
||||
@@ -704,7 +708,11 @@ var TelemetryReportingPolicyImpl = {
|
||||
this._ensureUserIsNotifiedPromise = this._waitForUserIsNotified();
|
||||
}
|
||||
|
||||
return this._ensureUserIsNotifiedPromise;
|
||||
return this._ensureUserIsNotifiedPromise.then(() => {
|
||||
// The user has been notified and interacted with the modal.
|
||||
// Glean can now init on shutdown if necessary.
|
||||
Services.prefs.setBoolPref("telemetry.fog.init_on_shutdown", true);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user