browser/extensions/shield-recipe-client/lib/TelemetryEvents.jsm
author Kris Maglione <maglione.k@gmail.com>
Mon, 29 Jan 2018 15:20:18 -0800
changeset 456545 e6a7b5e11ba856ee3535f76c6bcca17ea29e3d5f
parent 456311 76b7611c6dc2d3acb95eec8aa9458ecff1f46463
child 457640 b38d59f71915f78922b46a7c7bc65a48488c45f1
permissions -rw-r--r--
Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian This was done using the following script: https://bitbucket.org/kmaglione/m-c-rewrites/src/37e3803c7a23385bab5ea077ba8692bcfe1608fc/processors/chromeutils-import.jsm MozReview-Commit-ID: 1Nc3XDu0wGl

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const {utils: Cu, interfaces: Ci} = Components;
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");

this.EXPORTED_SYMBOLS = ["TelemetryEvents"];

const TELEMETRY_CATEGORY = "normandy";

const TelemetryEvents = {
  init() {
    Services.telemetry.registerEvents(TELEMETRY_CATEGORY, {
      enroll: {
        methods: ["enroll"],
        objects: ["preference_study", "addon_study"],
        extra_keys: ["experimentType", "branch", "addonId", "addonVersion"],
        record_on_release: true,
      },

      unenroll: {
        methods: ["unenroll"],
        objects: ["preference_study", "addon_study"],
        extra_keys: ["reason", "didResetValue", "addonId", "addonVersion"],
        record_on_release: true,
      },
    });
  },

  sendEvent(method, object, value, extra) {
    Services.telemetry.recordEvent(TELEMETRY_CATEGORY, method, object, value, extra);
  },
};