Bug 1536877 - Correct the 'value' type in 'browser.telemetry.recordEvent'; r?rpl a=pascalc
authorJared Hirsch <ohai@6a68.net>
Wed, 24 Apr 2019 16:05:34 +0300
changeset 523329 521037994bf751d45f8acd5f2f32982a85e80947
parent 523328 34fee7231b147dd5fb2ccc6a7cfc7e5b3495b02b
child 523330 a08cdd143e57dbd4bc062851b790ef53d82196ed
push id11147
push usernerli@mozilla.com
push dateWed, 24 Apr 2019 13:33:15 +0000
treeherdermozilla-beta@a08cdd143e57 [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 Summary: MozReview-Commit-ID: EvI2FvsOjDx Reviewers: rpl Reviewed By: rpl Subscribers: reviewbot Bug #: 1536877 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);