Bug 1121001 - Record a uitour ping when a tag is set, r=gfritzsche
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 27 Apr 2015 15:00:20 -0400
changeset 249075 c418add0c07f124d074425dab9404399897f6cd7
parent 249074 c2522b713a74c54513abcb2d496c4bb5e0cb78b7
child 249076 59851463cc094045b0a59ab8b3a762aad501e06c
push id61139
push usercbook@mozilla.com
push dateTue, 16 Jun 2015 14:53:44 +0000
treeherdermozilla-inbound@7299b8b5a8a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1121001
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1121001 - Record a uitour ping when a tag is set, r=gfritzsche
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour.js
toolkit/components/telemetry/docs/pings.rst
toolkit/components/telemetry/docs/uitour-ping.rst
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -7,16 +7,17 @@
 this.EXPORTED_SYMBOLS = ["UITour", "UITourMetricsProvider"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/TelemetryController.jsm");
 
 Cu.importGlobalProperties(["URL"]);
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
   "resource://gre/modules/LightweightThemeManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ResetProfile",
   "resource://gre/modules/ResetProfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
@@ -1973,16 +1974,26 @@ this.UITour.init();
  */
 const DAILY_DISCRETE_TEXT_FIELD = Metrics.Storage.FIELD_DAILY_DISCRETE_TEXT;
 
 /**
  * Public API to be called by the UITour code
  */
 const UITourHealthReport = {
   recordTreatmentTag: function(tag, value) {
+  TelemetryController.submitExternalPing("uitour-tag",
+    {
+      version: 1,
+      tagName: tag,
+      tagValue: value,
+    },
+    {
+      addClientId: true,
+      addEnvironment: true,
+    });
 #ifdef MOZ_SERVICES_HEALTHREPORT
     Task.spawn(function*() {
       let reporter = Cc["@mozilla.org/datareporting/service;1"]
                        .getService()
                        .wrappedJSObject
                        .healthReporter;
 
       // This can happen if the FHR component of the data reporting service is
--- a/browser/components/uitour/test/browser_UITour.js
+++ b/browser/components/uitour/test/browser_UITour.js
@@ -3,16 +3,17 @@
 
 "use strict";
 
 let gTestTab;
 let gContentAPI;
 let gContentWindow;
 
 Components.utils.import("resource:///modules/UITour.jsm");
+Components.utils.import("resource://testing-common/TelemetryArchiveTesting.jsm", this);
 
 function test() {
   UITourTest();
 }
 
 let tests = [
   function test_untrusted_host(done) {
     loadUITourTestPage(function() {
@@ -395,23 +396,34 @@ let tests = [
           Services.obs.removeObserver(observe, "browser-search-engine-modified");
           Services.search.defaultEngine = defaultEngine;
         });
 
         gContentAPI.setDefaultSearchEngine(someOtherEngineID);
       });
     });
   },
-  function test_treatment_tag(done) {
+  taskify(function* test_treatment_tag(done) {
+    let ac = new TelemetryArchiveTesting.Checker();
+    yield ac.promiseInit();
     gContentAPI.setTreatmentTag("foobar", "baz");
     gContentAPI.getTreatmentTag("foobar", (data) => {
       is(data.value, "baz", "set and retrieved treatmentTag");
-      done();
+      ac.promiseFindPing("uitour-tag", [
+        [["payload", "tagName"], "foobar"],
+        [["payload", "tagValue"], "baz"],
+      ]).then((found) => {
+        ok(found, "Telemetry ping submitted for setTreatmentTag");
+        done();
+      }, (err) => {
+        ok(false, "Exeption finding uitour telemetry ping: " + err);
+        done();
+      });
     });
-  },
+  }),
 
   // Make sure this test is last in the file so the appMenu gets left open and done will confirm it got tore down.
   taskify(function* cleanupMenus() {
     let shownPromise = promisePanelShown(window);
     gContentAPI.showMenu("appMenu");
     yield shownPromise;
   }),
 ];
--- a/toolkit/components/telemetry/docs/pings.rst
+++ b/toolkit/components/telemetry/docs/pings.rst
@@ -26,16 +26,17 @@ The telemetry server team is working tow
 * `5XX` - there was a server-side error, the client should try to resubmit later
 
 Ping types
 ==========
 
 * :doc:`main <main-ping>` - contains the information collected by Telemetry (Histograms, hang stacks, ...)
 * :doc:`saved-session <main-ping>` - has the same format as a main ping, but it contains the *"classic"* Telemetry payload with measurements covering the whole browser session. This is only a separate type to make storage of saved-session easier server-side. This is temporary and will be removed soon.
 * :doc:`crash <crash-ping>` - a ping that is captured and sent after Firefox crashes.
+* :doc:`uitour-ping` - a ping submitted via the UITour API
 * ``activation`` - *planned* - sent right after installation or profile creation
 * ``upgrade`` - *planned* - sent right after an upgrade
 * ``deletion`` - *planned* - on opt-out we may have to tell the server to delete user data
 
 Archiving
 =========
 
 When archiving is enabled through the relative preference, pings submitted to ``TelemetryController`` are also stored locally in the user profile directory, in `<profile-dir>/datareporting/archived`.
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/docs/uitour-ping.rst
@@ -0,0 +1,24 @@
+
+"uitour-tag" ping
+=================
+
+This ping is submitted via the UITour setTreatmentTag API. It may be used by
+the tour to record what settings were made by a user or to track the result of
+A/B experiments.
+
+The client ID is submitted with this ping.
+
+Structure::
+
+    {
+      version: 1,
+      type: "uitour-tag",
+      clientId: <string>,
+      payload: {
+        tagName: <string>,
+        tagValue: <string>
+      }
+    }
+
+See also: :doc:`common ping fields <common-ping>`
+