PART 4: current target draft
authorFred Lin <gasolin@gmail.com>
Mon, 13 Nov 2017 17:22:08 +0800
changeset 697058 63892a63f22b46883e4812f3a412a5e290fb9ba0
parent 697057 c5cada674c0d41198e8daa4333a731adbef7c78f
child 740001 23c504c0d7782f09efc4d9383df52bb98ba56005
push id88874
push userbmo:gasolin@mozilla.com
push dateMon, 13 Nov 2017 09:23:16 +0000
milestone59.0a1
PART 4: current target MozReview-Commit-ID: 9umJZ1KI9mi
browser/extensions/onboarding/OnboardingTelemetry.jsm
browser/extensions/onboarding/content/onboarding.js
browser/extensions/onboarding/data_events.md
--- a/browser/extensions/onboarding/OnboardingTelemetry.jsm
+++ b/browser/extensions/onboarding/OnboardingTelemetry.jsm
@@ -205,19 +205,20 @@ let OnboardingTelemetry = {
   },
 
   // send out pings by topic
   _send(topic, data) {
     let {
       addon_version,
     } = this.state;
     let {
+      current_tour_id,
       event,
-      tour_id = "",
       session_key,
+      target_tour_id,
     } = data;
     let {
       notification_session_begin,
       notification_session_id,
       notification_state,
       onboarding_session_begin,
       onboarding_session_id,
       overlay_session_begin,
@@ -296,20 +297,25 @@ let OnboardingTelemetry = {
         let timestamp = Date.now();
         let payload = {
           addon_version,
           category,
           page,
           parent_session_id,
           root_session_id,
           timestamp,
-          tour_id,
           tour_type,
           type: event,
         }
+        if (current_tour_id) {
+          payload.current_tour_id = current_tour_id;
+        }
+        if (target_tour_id) {
+          payload.target_tour_id = target_tour_id;
+        }
         if (sendImpression) {
           payload.notification_impression =
             Services.prefs.getIntPref("browser.onboarding.notification.prompt-count", 0);
         }
         if (sendLogoState) {
           // 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");
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -551,76 +551,77 @@ class Onboarding {
 
     switch (id) {
       case "onboarding-overlay-button":
         this.showOverlay();
         let target_tour_id = this._firstUncompleteTour.id;
         this.gotoPage(target_tour_id);
         telemetry({
           event: "onboarding-logo-click",
-          tour_id: target_tour_id,
           session_key: this._session_key,
         });
         break;
       case "onboarding-skip-tour-button":
         this.hideNotification();
         this.hideOverlay();
         this.skipTour();
         break;
       case "onboarding-overlay-close-btn":
         telemetry({
           event: "overlay-close-button-click",
-          tour_id: this._activeTourId,
+          current_tour_id: this._activeTourId,
           session_key: this._session_key,
         });
         this.hideOverlay();
         break;
       // If the clicking target is directly on the outer-most overlay,
       // that means clicking outside the tour content area.
       // Let's toggle the overlay.
       case "onboarding-overlay":
         telemetry({
           event: "overlay-close-outside-click",
-          tour_id: this._activeTourId,
+          current_tour_id: this._activeTourId,
           session_key: this._session_key,
         });
         this.hideOverlay();
         break;
       case "onboarding-notification-close-btn":
         let tour_id = this._notificationBar.dataset.targetTourId;
         this.hideNotification();
         this._removeTourFromNotificationQueue(tour_id);
         telemetry({
           event: "notification-close-button-click",
-          tour_id,
+          current_tour_id: tour_id,
           session_key: this._session_key,
         });
         break;
       case "onboarding-notification-action-btn":
         let tourId = this._notificationBar.dataset.targetTourId;
         this.showOverlay();
         this.gotoPage(tourId);
         telemetry({
           event: "notification-cta-click",
-          tour_id: tourId,
+          current_tour_id: tourId,
+          target_tour_id: tourId,
           session_key: this._session_key,
         });
         this._removeTourFromNotificationQueue(tourId);
         break;
     }
     if (classList.contains("onboarding-tour-item")) {
+      telemetry({
+        event: "overlay-nav-click",
+        current_tour_id: this._activeTourId,
+        target_tour_id: id,
+        session_key: this._session_key,
+      });
       this.gotoPage(id);
       // Keep focus (not visible) on current item for potential keyboard
       // navigation.
       target.focus();
-      telemetry({
-        event: "overlay-nav-click",
-        tour_id: id,
-        session_key: this._session_key,
-      });
     } else if (classList.contains("onboarding-tour-action-button")) {
       this.setToursCompleted([ this._activeTourId ]);
       telemetry({
         event: "overlay-cta-click",
         tour_id: this._activeTourId,
         session_key: this._session_key,
       });
     }
@@ -854,27 +855,28 @@ class Onboarding {
       }
     }
     for (let tab of this._tourItems) {
       if (tab.id == tourId) {
         tab.classList.add("onboarding-active");
         tab.setAttribute("aria-selected", true);
         telemetry({
           event: "overlay-current-tour",
-          tour_id: tourId,
+          current_tour_id: tourId,
           session_key: this._session_key,
         });
 
         // Some tours should complete instantly upon showing.
         if (tab.getAttribute("data-instant-complete")) {
           this.setToursCompleted([tourId]);
           // Also track auto-completed tour so we can filter data with the same event.
           telemetry({
             event: "overlay-cta-click",
-            tour_id: tourId,
+            current_tour_id: tourId,
+            target_tour_id: tourId,
             session_key: this._session_key,
           });
         }
       } else {
         tab.classList.remove("onboarding-active");
         tab.setAttribute("aria-selected", false);
       }
     }
@@ -1135,17 +1137,17 @@ class Onboarding {
     }
     sendMessageToChrome("set-prefs", params);
     telemetry({
       event: "notification-session-begin",
       session_key: this._session_key
     });
     telemetry({
       event: "notification-appear",
-      tour_id: targetTourId,
+      current_tour_id: targetTourId,
       session_key: this._session_key
     });
   }
 
   hideNotification() {
     if (this._notificationBar) {
       if (this._notificationBar.classList.contains("onboarding-opened")) {
         this._notificationBar.classList.remove("onboarding-opened");
@@ -1191,17 +1193,17 @@ class Onboarding {
       },
       {
         name: "browser.onboarding.state",
         value: ICON_STATE_WATERMARK
       }
     ]);
     telemetry({
       event: "overlay-skip-tour",
-      tour_id: this._activeTourId,
+      current_tour_id: this._activeTourId,
       session_key: this._session_key
     });
   }
 
   _renderOverlay() {
     let div = this._window.document.createElement("div");
     div.id = "onboarding-overlay";
     // We use `innerHTML` for more friendly reading.
--- a/browser/extensions/onboarding/data_events.md
+++ b/browser/extensions/onboarding/data_events.md
@@ -65,17 +65,18 @@ are defined in the below section | :one:
   "client_id": "374dc4d8-0cb2-4ac5-a3cf-c5a9bc3c602e",
   "locale": "en-US",
   "logo_state": ["logo" | "watermark"],
   "notification_impression": [1-8],
   "notification_state": ["show" | "hide" | "finished"],
   "page": ["about:newtab" | "about:home"],
   "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'
+  "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'
   "timestamp": 1505440017019,
   "tour_type" ["new" | "update"],
   "type": ["onboarding-logo-click" | "notification-appear" | "notification-cta-click" | "notification-close-button-click" | "overlay-cta-click" | "overlay-current-tour"  | "overlay-nav-click" | "overlay-skip-tour" | "overlay-close-button-click" | "overlay-close-outside-click" | "onboarding-small-resize"],
 
   // These fields are generated on the server
   "ip": "10.192.171.13",
   "ua": "python-requests/2.9.1",
   "receive_at": 1457396660000,
@@ -96,17 +97,18 @@ are defined in the below section | :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:
-| `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:
+| `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:
+| `target_tour_id` | id of the target switched 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:
 | `tour_type` | [Required] One of ["new", "update"] indicates the user is a `new` user or the `update` user upgrade from the older version | :one:
 | `type` | [Required] The type of event. Allowed event strings are defined in the below section | :one:
 | `ua` | [Auto populated by Onyx] The user agent string. | :two:
 | `ver` | [Auto populated by Onyx] The version of the Onyx API the ping was sent to. | :one:
 
 **Where:**
 
 :one: Firefox data