Bug 1462725 - Add 'end_study' event; r=rhelmer
This `end_study` event will be recorded when an ending condition has been met: the study has expired, the user is ineligible, or the study has been disabled (the study pref has been turned off).
MozReview-Commit-ID: JlaHioXd5WP
--- a/browser/modules/SavantShieldStudy.jsm
+++ b/browser/modules/SavantShieldStudy.jsm
@@ -48,17 +48,17 @@ class SavantShieldStudyClass {
observe(subject, topic, data) {
if (topic === "nsPref:changed" && data === this.STUDY_PREF) {
// toggle state of the pref
this.shouldCollect = !this.shouldCollect;
if (this.shouldCollect) {
this.startupStudy();
} else {
// The pref has been turned off
- this.endStudy("study-disabled");
+ this.endStudy("study_disable");
}
}
}
startupStudy() {
// enable before any possible calls to endStudy, since it sends an 'end_study' event
this.TelemetryEvents.enableCollection();
@@ -122,25 +122,21 @@ class SavantShieldStudyClass {
}
if (Date.now() > expirationDateInt) {
return true;
}
return false;
}
-
- sendEvent(method, object, value, extra) {
- this.TelemetryEvents.sendEvent(method, object, value, extra);
- }
-
endStudy(reason) {
log.debug(`Ending the study due to reason: ${ reason }`);
const isStudyEnding = true;
- // Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, "end_study", reason);
+ Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, "end_study", reason, null,
+ { subcategory: "shield" });
this.TelemetryEvents.disableCollection();
this.uninit(isStudyEnding);
// These prefs needs to persist between restarts, so only reset on endStudy
Services.prefs.clearUserPref(this.STUDY_PREF);
Services.prefs.clearUserPref(this.STUDY_EXPIRATION_DATE_PREF);
}
// Called on every Firefox shutdown and endStudy
@@ -156,19 +152,17 @@ class SavantShieldStudyClass {
Services.prefs.removeObserver(this.ALWAYS_PRIVATE_BROWSING_PREF, this);
Services.prefs.removeObserver(this.STUDY_PREF, this);
Services.prefs.removeObserver(this.STUDY_DURATION_OVERRIDE_PREF, this);
Services.prefs.clearUserPref(PREF_LOG_LEVEL);
Services.prefs.clearUserPref(this.STUDY_DURATION_OVERRIDE_PREF);
}
}
-const SavantShieldStudy = new SavantShieldStudyClass();
-
-// references:
+// References:
// - https://hg.mozilla.org/mozilla-central/file/tip/toolkit/components/normandy/lib/TelemetryEvents.jsm
// - https://hg.mozilla.org/mozilla-central/file/tip/toolkit/components/normandy/lib/PreferenceExperiments.jsm#l357
class TelemetryEvents {
constructor(studyCategory) {
this.STUDY_TELEMETRY_CATEGORY = studyCategory;
}
enableCollection() {
@@ -176,8 +170,10 @@ class TelemetryEvents {
Services.telemetry.setEventRecordingEnabled(this.STUDY_TELEMETRY_CATEGORY, true);
}
disableCollection() {
log.debug("Study has been disabled; turning OFF data collection.");
Services.telemetry.setEventRecordingEnabled(this.STUDY_TELEMETRY_CATEGORY, false);
}
}
+
+const SavantShieldStudy = new SavantShieldStudyClass();
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -101,16 +101,30 @@ savant:
bug_numbers: [1316281, 1457226, 1462725]
notification_emails:
- "bdanforth@mozilla.com"
- "shong@mozilla.com"
expiry_version: "65"
extra_keys:
subcategory: The broad event category for this probe. E.g. navigation
engine: The id of the search engine used.
+ end_study:
+ objects: ["ineligible", "study_disable", "expired"]
+ release_channel_collection: opt-out
+ record_in_processes: ["main"]
+ description: >
+ This is recorded any time a study ending condition occurs for the Savant
+ Shield study. The object field records the reason that caused the ending.
+ bug_numbers: [1457226, 1462725]
+ notification_emails:
+ - "bdanforth@mozilla.com"
+ - "shong@mozilla.com"
+ expiry_version: "65"
+ extra_keys:
+ subcategory: The broad event category for this probe. E.g. navigation
# This category contains event entries used for Telemetry tests.
# They will not be sent out with any pings.
telemetry.test:
test:
methods: ["test1", "test2"]
objects: ["object1", "object2"]
bug_numbers: [1286606]