author Nick Alexander <>
Tue, 29 Mar 2016 11:39:35 -0700
changeset 291313 230a0a44d0871347fb8215cd65d2d126cecfa93c
parent 290388 84180ddf65a78f5c7df8f2380939ac84fb81a6f5
permissions -rw-r--r--
Bug 1259507 - Add UI Telemetry probes for DOM Push API in Fennec. r=mfinkle The probes in this patch are annotated with the extra "dom-push-api" to distinguish from future Fennec-specific push messages. These probes allow to determine for each user the difference: {# sites subscribed to} - {# sites unsubscribed from}. If we assume the same site is not subscribed to multiple times, this is a good approximation to the total number of sites the user receives push messages from. To test manually: 0) Install Fennec and execute |adb shell setprop log.tag.Telemetry DEBUG|. 1) Subscribe to notifications on a site like Observe a UI Telemetry SAVE event, like: D/Telemetry( 7109): SendUIEvent: event = save.1 method = service timestamp = 277456 extras = dom-push-api 2) Send a push notification using the sites' interface. Observe a UI Telemetry PUSH_RECEIVED_MESSAGE event, like: D/Telemetry( 7109): SendUIEvent: event = action.1 method = service timestamp = 361795 extras = dom-push-api 3) Unsubscribe to notifications by revoking permission using Site Settings from the URL bar. Observe a UI Telemetry PUSH_UNSUBSCRIBED_FROM_SITE event, like: D/Telemetry( 7109): SendUIEvent: event = unsave.1 method = service timestamp = 393600 extras = dom-push-api MozReview-Commit-ID: IOCwfXFnowA

.. -*- Mode: rst; fill-column: 80; -*-

 UI Telemetry

Fennec records UI events using a telemetry framework called UITelemetry.

Some links:

- `Project page <>`_
- `Wiki page <>`_
- `User research notes <>`_


**Sessions** are essentially scopes. They are meant to provide context to
events; this allows events to be simpler and more reusable. Sessions are
usually bound to some component of the UI, some user action with a duration, or
some transient state.

For example, a session might be begun when a user begins interacting with a
menu, and stopped when the interaction ends. Or a session might encapsulate
period of no network connectivity, the first five seconds after the browser
launched, the time spent with an active download, or a guest mode session.

Sessions implicitly record the duration of the interaction.

A simple use-case for sessions is the bookmarks panel in about:home. We start a
session when the user swipes into the panel, and stop it when they swipe away.
This bookmarks session does two things: firstly, it gives scope to any generic
event that may occur within the panel (*e.g.*, loading a URL). Secondly, it
allows us to figure out how much time users are spending in the bookmarks

To start a session, call ``Telemetry.startUISession(String sessionName)``.

  The name of the session. Session names should be brief, lowercase, and should describe which UI
  component the user is interacting with. In certain cases where the UI component is dynamic, they could include an ID, essential to identifying that component. An example of this is dynamic home panels: we use session names of the format ``homepanel:<panel_id>`` to identify home panel sessions.

To stop a session, call ``Telemetry.stopUISession(String sessionName, String reason)``.

  The name of the open session

``reason`` (Optional)
  A descriptive cause for ending the session. It should be brief, lowercase, and generic so it can be reused in different places. Examples reasons are:

      The user transitioned to a UI element of equal level.

      The user left for an entirely different element.


Events capture key occurrences. They should be brief and simple, and should not contain sensitive or excess information. Context for events should come from the session (scope). An event can be created with four fields (via ``Telemetry.sendUIEvent``): ``action``, ``method``, ``extras``, and ``timestamp``.

  The name of the event. Should be brief and lowercase. If needed, you can make use of namespacing with a '``.``' separator. Example event names: ``panel.switch``, ``panel.enable``, ``panel.disable``, ``panel.install``.

``method`` (Optional)
  Used for user actions that can be performed in many ways. This field specifies the method by which the action was performed. For example, users can add an item to their reading list either by long-tapping the reader icon in the address bar, or from within reader mode. We would use the same event name for both user actions but specify two methods: ``addressbar`` and ``readermode``.

``extras`` (Optional)
  For extra information that may be useful in understanding the event. Make an effort to keep this brief.

``timestamp`` (Optional)
  The time at which the event occurred. If not specified, this field defaults to the current value of the realtime clock.


As a we improve on our Telemetry methods, it is foreseeable that our probes will change over time. Different versions of a probe could carry different data or have different interpretations on the server-side. To make it easier for the server to handle these changes, you should add version numbers to your event and session names. An example of a versioned session is ``homepanel.1``; this is version 1 of the ``homepanel`` session. This approach should also be applied to event names, an example being: ``panel.enable.1`` and ``panel.enable.2``.


Times are relative to either elapsed realtime (an arbitrary monotonically increasing clock that continues to tick when the device is asleep), or elapsed uptime (which doesn't tick when the device is in deep sleep). We default to elapsed realtime.

See the documentation in `the source <>`_ for more details.


  Generic action, usually for tracking menu and toolbar actions.

  Cancel a state, action, etc.

  Start casting a video.

  Sent when the user edits a top site.

  Launching (opening) an external application.
  Note: Only used in JavaScript for now.

  Loading a URL.

  When the user chooses "System default" in the browser locale picker.

  When the user chooses a locale in the browser locale picker. The selected
  locale is provided as the extra.

  When the user chose a different locale in the browser locale picker, this
  event is fired with the previous locale as the extra. If the previous locale
  could not be determined, "unknown" is provided.

  When the user performs actions on the in-content network error page. This should probably be a ``Session``, but it's difficult to start and stop the session reliably.

  Hide a built-in home panel.

  Move a home panel up or down.

  Remove a custom home panel.

  Set default home panel.

  Show a hidden built-in home panel.

``pin.1``, ``unpin.1``
  Sent when the user pinned or unpinned a top site.

  Sent when a user has accepted the data notification policy. Can be ``false``
  instead of ``true`` if an error occurs.

  Sent when the user chooses to clear private data.

``save.1``, ``unsave.1``
  Saving or unsaving a resource (reader, bookmark, etc.) for viewing later.

  Sent when the user performs a search. Currently used in the search activity.

  Sent when the user removes a search engine.

  Sent when the user restores the search engine configuration back to the built-in configuration.

  Sent when the user sets a search engine to be the default.

  Sharing content.

  Sent when a contextual UI element is shown to the user.

  Sent when performing an undo-style action, like undoing a closed tab.

  Action triggered from an ActionBar UI.

  Action triggered from the back button.

  Action triggered from a banner (such as HomeBanner).

  Action triggered from a button.
  Note: Only used in JavaScript for now.

  Action triggered from a content page.

  Action triggered from a contextmenu. Could be from chrome or content.

  Action triggered from a dialog.

  Action triggered from a doorhanger popup prompt.

  Action triggered from a griditem, such as those used in Top Sites panel.

  Action triggered from a homescreen shortcut icon.

  Action triggered from a system Intent, usually sent from the OS.

  Action triggered from an unmanaged list of items, usually provided by the OS.

  Action triggered from a listitem.

  Action triggered from the main menu.

  Action triggered from a system notification.

  Action triggered from a pageaction, displayed in the URL bar.

  Action triggered from an automatic system making a decision.

  Action triggered from a content page.

  Action triggered from a content page.

  Action triggered from a suggested result, like those from search engines or default tiles.

  Action triggered from an OS level action, like application foreground / background.

  Action triggered from an unobtrusive, temporary notification.

  Action triggered from a widget placed on the homescreen.

  Awesomescreen (including frecency search) is active.

  Started the very first time we believe the application has been launched.

  Awesomescreen frecency search is active.

  Started when a user enters a given home panel.
  Session name is dynamic, encoded as "homepanel.1:<panel_id>"
  Built-in home panels have fixed IDs

  Reader viewer becomes active in the foreground.

  Started when the user launches the search activity (onStart) and stopped
  when they leave the search activity.

  Settings activity is active.