tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

event-telemetry.js (1020B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  START_WORKER,
      9  UNREGISTER_WORKER,
     10  UPDATE_SELECTED_PAGE,
     11 } = require("resource://devtools/client/application/src/constants.js");
     12 
     13 function eventTelemetryMiddleware(telemetry) {
     14  function recordEvent(method, details = {}) {
     15    telemetry.recordEvent(method, "application", null, details);
     16  }
     17 
     18  return () => next => action => {
     19    switch (action.type) {
     20      // ui telemetry
     21      case UPDATE_SELECTED_PAGE:
     22        recordEvent("select_page", { page_type: action.selectedPage });
     23        break;
     24      // service-worker related telemetry
     25      case UNREGISTER_WORKER:
     26        recordEvent("unregister_worker");
     27        break;
     28      case START_WORKER:
     29        recordEvent("start_worker");
     30        break;
     31    }
     32 
     33    return next(action);
     34  };
     35 }
     36 
     37 module.exports = eventTelemetryMiddleware;