Bug 1536877 - Correct the 'value' type in 'browser.telemetry.recordEvent'; r=rpl a=pascalc
☠☠ backed out by b1cb8bd44dee ☠ ☠
authorJared Hirsch <ohai@6a68.net>
Mon, 15 Apr 2019 21:23:02 +0000
changeset 523247 f350dc70a86486f45ee7e2414332d9c058445617
parent 523246 1694fdeb8a6ad706eb77001076bb6f0ba95a577a
child 523248 d2668e1efcfd00856dd3c49eec1aa52b6ed7c095
push id11115
push useraiakab@mozilla.com
push dateFri, 19 Apr 2019 16:14:22 +0000
treeherdermozilla-beta@86f6ec90b34b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl, pascalc
bugs1536877
milestone67.0
Bug 1536877 - Correct the 'value' type in 'browser.telemetry.recordEvent'; r=rpl a=pascalc MozReview-Commit-ID: EvI2FvsOjDx Differential Revision: https://phabricator.services.mozilla.com/D27404
toolkit/components/extensions/schemas/telemetry.json
toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
toolkit/components/telemetry/docs/collection/webextension-api.rst
--- a/toolkit/components/extensions/schemas/telemetry.json
+++ b/toolkit/components/extensions/schemas/telemetry.json
@@ -222,17 +222,17 @@
         },
         {
           "name": "object",
           "type": "string",
           "description": "The object name."
         },
         {
           "name": "value",
-          "type": "integer",
+          "type": "string",
           "optional": true,
           "description": "An optional string value to record."
         },
         {
           "name": "extra",
           "type": "object",
           "optional": true,
           "description": "An optional object of the form (string -> string). It should only contain registered extra keys.",
--- a/toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_telemetry.js
@@ -185,16 +185,45 @@ if (AppConstants.MOZ_BUILD_APP === "brow
     let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
     equal(events.parent.length, 1);
     equal(events.parent[0][1], "telemetry.test");
 
     Services.telemetry.setEventRecordingEnabled("telemetry.test", false);
     Services.telemetry.clearEvents();
   });
 
+  // Bug 1536877
+  add_task(async function test_telemetry_record_event_value_must_be_string() {
+    Services.telemetry.clearEvents();
+    Services.telemetry.setEventRecordingEnabled("telemetry.test", true);
+
+    await run({
+      backgroundScript: async () => {
+        try {
+          await browser.telemetry.recordEvent("telemetry.test", "test1", "object1", "value1");
+          browser.test.notifyPass("record_event_string_value");
+        } catch (ex) {
+          browser.test.fail(`Unexpected exception raised during record_event_value_must_be_string: ${ex}`);
+          browser.test.notifyPass("record_event_string_value");
+          throw ex;
+        }
+      },
+      doneSignal: "record_event_string_value",
+    });
+
+    let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS, true);
+    equal(events.parent.length, 1);
+    equal(events.parent[0][1], "telemetry.test");
+    equal(events.parent[0][3], "object1");
+    equal(events.parent[0][4], "value1");
+
+    Services.telemetry.setEventRecordingEnabled("telemetry.test", false);
+    Services.telemetry.clearEvents();
+  });
+
   add_task(async function test_telemetry_register_scalars_string() {
     Services.telemetry.clearScalars();
 
     await run({
       backgroundScript: async () => {
         await browser.telemetry.registerScalars("telemetry.test.dynamic", {
           "webext_string": {
             kind: browser.telemetry.ScalarType.STRING,
--- a/toolkit/components/telemetry/docs/collection/webextension-api.rst
+++ b/toolkit/components/telemetry/docs/collection/webextension-api.rst
@@ -113,17 +113,17 @@ Sets the scalar to the maximum of the cu
 
   browser.telemetry.recordEvent(category, method, object, value, extra);
 
 Record an event in Telemetry. Throws when trying to record an unknown event.
 
 * ``category`` - *(string)* The category name.
 * ``method`` - *(string)* The method name.
 * ``object`` - *(string)* The object name.
-* ``value`` - *(optional, integer)* An optional string value to record.
+* ``value`` - *(optional, string)* An optional string value to record.
 * ``extra`` - *(optional, object)* An optional object of the form (string -> string). It should only contain registered extra keys.
 
 ``registerScalars``
 ~~~~~~~~~~~~~~~~~~~
 
 .. code-block:: js
 
   browser.telemetry.registerScalars(category, data);