Bug 1536877 - Correct the 'value' type in 'browser.telemetry.recordEvent'; r=rpl
authorJared Hirsch <ohai@6a68.net>
Mon, 15 Apr 2019 21:23:02 +0000
changeset 469578 eb866ced3ffa9dadcc1cda5970f164e7e050368a
parent 469577 095d253f97be7112a6f0ffa0b9d892964f5264d7
child 469579 4574b686fdd4e421ead2e87b8ca39abc25c41c36
push id35874
push userccoroiu@mozilla.com
push dateTue, 16 Apr 2019 04:04:58 +0000
treeherdermozilla-central@be3f40425b52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1536877
milestone68.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 1536877 - Correct the 'value' type in 'browser.telemetry.recordEvent'; r=rpl 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_PRERELEASE_CHANNELS, 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);