Bug 1400408 - Fill in basic documentation of existing Pocket telemetry. r=mcomella, a=sledru
authorChenxia Liu <liuche@mozilla.com>
Wed, 20 Sep 2017 17:11:37 -0700
changeset 431810 69860047998e81da7e12e26ba8dc1eb45a65b9e3
parent 431809 500a99cdda0b2aa301411163a6314d26640cb258
child 431811 1ac500d40e49104486b2339988d4581bd150e046
push id7819
push userryanvm@gmail.com
push dateMon, 25 Sep 2017 13:25:08 +0000
treeherdermozilla-beta@078e47662790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella, sledru
bugs1400408
milestone57.0
Bug 1400408 - Fill in basic documentation of existing Pocket telemetry. r=mcomella, a=sledru MozReview-Commit-ID: FiZI6ebihD9
mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
mobile/android/docs/activitystreamtelemetry.rst
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
@@ -177,19 +177,16 @@ public class ActivityStreamTelemetry {
             public Builder forHighlightSource(Utils.HighlightSource source) {
                 switch (source) {
                     case VISITED:
                         this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_VISITED);
                         break;
                     case BOOKMARKED:
                         this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_BOOKMARKED);
                         break;
-                    case POCKET:
-                        this.set(Contract.SOURCE_TYPE, Contract.TYPE_POCKET);
-                        break;
                     default:
                         throw new IllegalStateException("Unknown highlight source: " + source);
                 }
                 return this;
             }
 
             public Builder forTopSite(final TopSite topSite) {
                 this.set(
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -236,33 +236,33 @@ public class StreamRecyclerAdapter exten
         final WebpageRowModel model = (WebpageRowModel) recyclerViewModel.get(position);
 
         final String sourceType;
         final int actionPosition;
         final int size;
         final String referrerUri;
         final int viewType = getItemViewType(position);
 
+        final ActivityStreamTelemetry.Extras.Builder extras = ActivityStreamTelemetry.Extras.builder();
         if (viewType == RowItemType.HIGHLIGHT_ITEM.getViewType()) {
+            extras.forHighlightSource(model.getSource());
             sourceType = ActivityStreamTelemetry.Contract.TYPE_HIGHLIGHTS;
             actionPosition = getHighlightsIndexFromAdapterPosition(position);
             size = getNumOfTypeShown(RowItemType.HIGHLIGHT_ITEM);
             referrerUri = null;
         } else {
             sourceType = ActivityStreamTelemetry.Contract.TYPE_POCKET;
             actionPosition = getTopStoriesIndexFromAdapterPosition(position);
             size = getNumOfTypeShown(RowItemType.TOP_STORIES_ITEM);
             referrerUri = PocketStoriesLoader.POCKET_REFERRER_URI;
         }
 
-        ActivityStreamTelemetry.Extras.Builder extras = ActivityStreamTelemetry.Extras.builder()
-                .forHighlightSource(model.getSource())
-                .set(ActivityStreamTelemetry.Contract.SOURCE_TYPE, sourceType)
-                .set(ActivityStreamTelemetry.Contract.ACTION_POSITION, actionPosition)
-                .set(ActivityStreamTelemetry.Contract.COUNT, size);
+        extras.set(ActivityStreamTelemetry.Contract.SOURCE_TYPE, sourceType)
+              .set(ActivityStreamTelemetry.Contract.ACTION_POSITION, actionPosition)
+              .set(ActivityStreamTelemetry.Contract.COUNT, size);
 
         Telemetry.sendUIEvent(
                 TelemetryContract.Event.LOAD_URL,
                 TelemetryContract.Method.LIST_ITEM,
                 extras.build()
         );
 
         // NB: This is hacky. We need to process telemetry data first, otherwise we run a risk of
@@ -312,31 +312,31 @@ public class StreamRecyclerAdapter exten
     @Override
     public void openContextMenu(final WebpageItemRow webpageItemRow, final int position, @NonNull final String interactionExtra) {
         final WebpageRowModel model = (WebpageRowModel) recyclerViewModel.get(position);
 
         final String sourceType;
         final int actionPosition;
         final ActivityStreamContextMenu.MenuMode menuMode;
 
+        ActivityStreamTelemetry.Extras.Builder extras = ActivityStreamTelemetry.Extras.builder();
         if (model.getRowItemType() == RowItemType.HIGHLIGHT_ITEM) {
+            extras.forHighlightSource(model.getSource());
             sourceType = ActivityStreamTelemetry.Contract.TYPE_HIGHLIGHTS;
             actionPosition = getHighlightsIndexFromAdapterPosition(position);
             menuMode = ActivityStreamContextMenu.MenuMode.HIGHLIGHT;
         } else {
             sourceType = ActivityStreamTelemetry.Contract.TYPE_POCKET;
             actionPosition = getTopStoriesIndexFromAdapterPosition(position);
             menuMode = ActivityStreamContextMenu.MenuMode.TOPSTORY;
         }
 
-        ActivityStreamTelemetry.Extras.Builder extras = ActivityStreamTelemetry.Extras.builder()
-                .set(ActivityStreamTelemetry.Contract.SOURCE_TYPE, sourceType)
-                .set(ActivityStreamTelemetry.Contract.ACTION_POSITION, actionPosition)
-                .set(ActivityStreamTelemetry.Contract.INTERACTION, interactionExtra)
-                .forHighlightSource(model.getSource());
+        extras.set(ActivityStreamTelemetry.Contract.SOURCE_TYPE, sourceType)
+              .set(ActivityStreamTelemetry.Contract.ACTION_POSITION, actionPosition)
+              .set(ActivityStreamTelemetry.Contract.INTERACTION, interactionExtra);
 
         ActivityStreamContextMenu.show(webpageItemRow.itemView.getContext(),
                 webpageItemRow.getContextMenuAnchor(),
                 extras,
                 menuMode,
                 model,
                 /* shouldOverrideWithImageProvider */ true, // we use image providers in HighlightItem.pageIconLayout.
                 onUrlOpenListener, onUrlOpenInBackgroundListener,
--- a/mobile/android/docs/activitystreamtelemetry.rst
+++ b/mobile/android/docs/activitystreamtelemetry.rst
@@ -60,45 +60,71 @@ For each click event (1/2), in addition 
     }
 
 Subtype indicates a reason an item which is being interacted with appeared in the Top Sites:
 
 - "pinned": a pinned top site, specifically a non-positioned "Activity Stream pinned" site
 - "suggested": a suggested top site, one of the default ones displayed when there's not enough browsing history available
 - "top": a frecency-based top site, based on browsing history. Neither "pinned" nor "suggested".
 
+Top Stories (Pocket) interactions
+---------------------------------
+
+Two event types are recorded for row items (links):
+1) User clicked on a Story item: event="loadurl.1", method="listitem"
+2) User clicked on the menu button: event="show.1", method="contextmenu"
+
+For both event types, in addition to global extras, the following information is recorded:
+
+.. code-block:: js
+
+    extras: {
+        ...
+        "source_type": "pocket",
+        "action_position": number /* 0-based index of a story being interacted with */
+    }
+
+For "loadurl.1" event, the following extra information is also recorded:
+
+.. code-block:: js
+
+    extras: {
+        ...
+        "count": number, /* total number of stories displayed */
+    }
+
 Highlight interactions
 ----------------------
 Two event types are recorded:
 
 1) User clicked on a Highlight: event="loadurl.1", method="listitem"
 2) User clicked on the menu button: event="show.1", method="contextmenu"
 
 For both event types, in addition to global extras, the following information is recorded:
 
 .. code-block:: js
 
     extras: {
         ...
         "source_type": "highlights",
-        "source_subtype": "visited"/"bookmarked"
+        "source_subtype": "visited"/"bookmarked",
+        "action_position": number, /* 0-based index of a highlight being interacted with */
     }
 
 Subtype indicates reason an item being which is being interacted with appeared in the Highlights:
 - "visited": a website has been visited recently
 - "bookmarked": a website has been bookmarked recently
 
 For "loadurl.1" event, the following extra information is also recorded:
 
 .. code-block:: js
 
     extras: {
         ...
-        "action_position": number, /* 0-based index of a highlight being interacted with */
-        "count": number, /* total number of highlights displayed */
+        "count": number /* total number of highlights displayed */
     }
 
 Context Menu interactions
 -------------------------
 Every interaction with a context menu item is recorded using: event="action.1", method="contextmenu"
 
 For all interactions, in addition to global extras, the following information is recorded: