Bug 1413830 - PART 3: send notification_state;r=fischer
MozReview-Commit-ID: DD0YWuaNWsB
--- a/browser/extensions/onboarding/OnboardingTelemetry.jsm
+++ b/browser/extensions/onboarding/OnboardingTelemetry.jsm
@@ -48,30 +48,35 @@ const EVENT_WHITELIST = {
// track when click the notification Call-To-Action button
"notification-cta-click": {
topic: "firefox-onboarding-event",
category: "notification-interactions",
parent: "notification",
sendImpression: true,
sendLogoState: true,
},
+ // track when notification is finished
+ "notification-finished": {topic: "internal"},
+ // track when notification is hidden
+ "notification-hide": {topic: "internal"},
// track when notification is shown
"notification-session-begin": {topic: "internal"},
// track when the notification closed
"notification-session-end": {
topic: "firefox-onboarding-session",
category: "notification-interactions",
parent: "notification",
},
// track when click the onboarding logo or the watermark
"onboarding-logo-click": {
topic: "firefox-onboarding-event",
category: "overlay-interactions",
parent: "onboarding",
sendLogoState: true,
+ sendNotificationState: true,
},
// init onboarding session with session_key and page url
"onboarding-register-session": {topic: "internal"},
// track when the onboarding script inited
"onboarding-session-begin": {topic: "internal"},
// track when the onboarding script destoryed
"onboarding-session-end": {
topic: "firefox-onboarding-session",
@@ -147,16 +152,17 @@ let OnboardingTelemetry = {
throw new Error("session_key, page url, and tour_type are required for onboarding-register-session");
}
let onboarding_session_id = gUUIDGenerator.generateUUID().toString();
this.state.sessions[session_key] = {
page,
onboarding_session_id,
overlay_session_id: "",
notification_session_id: "",
+ notification_state: "hide",
tour_type,
};
},
process(data) {
let { event, session_key } = data;
let topic = EVENT_WHITELIST[event] && EVENT_WHITELIST[event].topic;
@@ -179,16 +185,23 @@ let OnboardingTelemetry = {
break;
case "overlay-session-begin":
this.state.sessions[session_key].overlay_session_id = gUUIDGenerator.generateUUID().toString();
this.state.sessions[session_key].overlay_session_begin = Date.now();
break;
case "notification-session-begin":
this.state.sessions[session_key].notification_session_id = gUUIDGenerator.generateUUID().toString();
this.state.sessions[session_key].notification_session_begin = Date.now();
+ this.state.sessions[session_key].notification_state = "show";
+ break;
+ case "notification-finished":
+ this.state.sessions[session_key].notification_state = "finished";
+ break;
+ case "notification-hide":
+ this.state.sessions[session_key].notification_state = "hide";
break;
}
} else {
this._send(topic, data);
}
},
// send out pings by topic
@@ -200,28 +213,30 @@ let OnboardingTelemetry = {
current_tour_id,
event,
session_key,
target_tour_id,
} = data;
let {
notification_session_begin,
notification_session_id,
+ notification_state,
onboarding_session_begin,
onboarding_session_id,
overlay_session_begin,
overlay_session_id,
page,
tour_type,
} = this.state.sessions[session_key];
let {
category,
parent,
sendImpression,
sendLogoState,
+ sendNotificationState,
} = EVENT_WHITELIST[event];
let session_begin;
let session_id;
let root_session_id = onboarding_session_id;
let parent_session_id = onboarding_session_id;
switch (topic) {
case "firefox-onboarding-session":
switch (event) {
@@ -304,14 +319,17 @@ let OnboardingTelemetry = {
// the field is used to identify how user open the overlay (through default logo or watermark),
// the number of open from notification can be retrieved via `notification-cta-click` event
let logo_state = Services.prefs.getStringPref("browser.onboarding.state", "default");
if (logo_state === "default") {
logo_state = "logo";
}
payload.logo_state = logo_state;
}
+ if (sendNotificationState) {
+ payload.notification_state = notification_state;
+ }
this.eventProbe && this.eventProbe.sendPing(payload,
{filter: ONBOARDING_ID});
break;
}
}
};
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -1031,21 +1031,29 @@ class Onboarding {
this._overlayIcon.classList.add("onboarding-speech-bubble");
} else {
this._overlayIcon.classList.remove("onboarding-speech-bubble");
}
}
showNotification() {
if (Services.prefs.getBoolPref("browser.onboarding.notification.finished", false)) {
+ telemetry({
+ event: "notification-finished",
+ session_key: this._session_key
+ });
return;
}
let lastTime = this._getLastTourChangeTime();
if (this._muteNotificationOnFirstSession(lastTime)) {
+ telemetry({
+ event: "notification-hide",
+ session_key: this._session_key
+ });
return;
}
// After the notification mute on the 1st session,
// we don't want to show the speech bubble by default
this._overlayIcon.classList.remove("onboarding-speech-bubble");
let queue = this._getNotificationQueue();
let totalMaxTime = Services.prefs.getIntPref("browser.onboarding.notification.max-life-time-all-tours-ms");
--- a/browser/extensions/onboarding/data_events.md
+++ b/browser/extensions/onboarding/data_events.md
@@ -61,16 +61,17 @@ For reference, Onyx is a Mozilla owned s
"addon_version": "1.0.0",
"category": ["overlay-interactions"|"notification-interactions"],
"client_id": "374dc4d8-0cb2-4ac5-a3cf-c5a9bc3c602e",
"timestamp": 1505440017019,
"type": ["notification-cta-click" | "overlay-cta-click" | "overlay-nav-click" | "overlay-skip-tour"],
"locale": "en-US",
"logo_state": ["logo" | "watermark"],
"notification_impression": [1-8],
+ "notification_state": ["show" | "hide" | "finished"],
"page": ["about:newtab" | "about:home"],
"current_tour_id": ["onboarding-tour-private-browsing" | "onboarding-tour-addons"|...], // tour ids defined in 'onboardingTourset'
"target_tour_id": ["onboarding-tour-private-browsing" | "onboarding-tour-addons"|...], // tour ids defined in 'onboardingTourset',
"parent_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"root_session_id": "{45cddbeb-2bec-4f3a-bada-fb87d4b79a6c}",
"tour_id": ["onboarding-tour-private-browsing" | "onboarding-tour-addons"|...], // tour ids defined in 'onboardingTourset'
"timestamp": 1505440017019,
"tour_type" ["new" | "update"],
@@ -90,16 +91,17 @@ For reference, Onyx is a Mozilla owned s
| `addon_version` | [Required] The version of the Onboarding addon. | :one:
| `category` | [Required] Either ("overlay-interactions", "notification-interactions") to identify which kind of the interaction | :one:
| `client_id` | [Required] An identifier generated by [ClientID](https://github.com/mozilla/gecko-dev/blob/master/toolkit/modules/ClientID.jsm) module to provide an identifier for this device. This data is automatically appended by `ping-centre` module | :one:
| `type` | [Required] The type of event. allowed event strings are defined in the below section | :one:
| `ip` | [Auto populated by Onyx] The IP address of the client. Onyx does use (with the permission) the IP address to infer user's geo-information so that it could prepare the corresponding tiles for the country she lives in. However, Ping-centre will NOT store IP address in the database, where only authorized Mozilla employees can access the telemetry data, and all the raw logs are being strictly managed by the Ops team and will expire according to the Mozilla's data retention policy.| :two:
| `locale` | The browser chrome's language (e.g. en-US). | :two:
| `logo_state` | [Required] One of ["logo", "watermark"] indicates the overlay is opened while in the logo or the watermark state. Open from the notification bar is counted via 'notification-cta-click event'. | :one:
| `notification_impression` | [Optional] An integer to record how many times the current notification tour is shown to the user. Each Notification tour can show not more than 8 times. We put `-1` when this field is not relevant to this event | :one:
+| `notification_state` | [Optional] One of ["show", "hide", "finished"] indicates the current notification bar state | :one:
| `page` | [Required] One of ["about:newtab", "about:home"] | :one:
| `parent_session_id` | [Required] The unique identifier generated by `gUUIDGenerator` service to identify this event belong to which parent session. | :one:
| `root_session_id` | [Required] The unique identifier generated by `gUUIDGenerator` service to identify this event belong to which root session. | :one:
| `session_begin` | Timestamp in (integer) milliseconds when onboarding/overlay/notification becoming visible. | :one:
| `session_end` | Timestamp in (integer) milliseconds when onboarding/overlay/notification losing focus. | :one:
| `session_id` | [Required] The unique identifier generated by `gUUIDGenerator` service to identify the specific user session when onboarding is inited/when the overlay is opened/when notification is shown. | :one:
| `timestamp` | Timestamp in (integer) milliseconds when the event triggered | :one:
| `current_tour_id` | id of the current tour. The number of open from notification can be retrieved via 'notification-cta-click event'. We put ` ` when this field is not relevant to this event | :one:
@@ -146,13 +148,15 @@ Here are all allowed `event` strings tha
| `overlay-session` | event is sent when close the overlay |
| `overlay-skip-tour` | event is sent when clicking the overlay `skip tour` button |
### Notification events
| EVENT | DESCRIPTION |
|-----------|---------------------|
| `notification-appear` | event is sent when user open the notification. |
+| `notification-finished` | internal event triggered when notification is finished
+| `notification-hide` | internal event triggered when notification is hidden
| `notification-session-begin` | internal event triggered when user open the notification, will not send out any data. |
| `notification-session-end` | internal event is triggered when user closes the notification. `notification-session` event is sent to the server. |
| `notification-session` | event is sent when user closes the notification |
| `notification-close-button-click` | event is sent when clicking the notification close button |
| `notification-cta-click` | event is sent when clicking the notification CTA button |