Bug 1946787 - Avoid creating redundant GradientCache::OnMaxEntriesBreached tasks...
[gecko.git] / devtools / client / application / src / middleware / event-telemetry.js
blobaa4aa7b62bde7a0f5a0c1091a9f996e3ab29ce6e
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/. */
5 "use strict";
7 const {
8 START_WORKER,
9 UNREGISTER_WORKER,
10 UPDATE_SELECTED_PAGE,
11 } = require("resource://devtools/client/application/src/constants.js");
13 function eventTelemetryMiddleware(telemetry) {
14 function recordEvent(method, details = {}) {
15 telemetry.recordEvent(method, "application", null, details);
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;
33 return next(action);
37 module.exports = eventTelemetryMiddleware;