Bug 1463147 - Instrument inspection of "Throttling" in the Network Panel with event telemetry r=miker

Differential Revision: https://phabricator.services.mozilla.com/D3239

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Odvarko 2018-08-15 10:29:47 +00:00
Родитель e871f2be95
Коммит dde56f8ebf
6 изменённых файлов: 81 добавлений и 0 удалений

Просмотреть файл

@ -442,6 +442,8 @@ class FirefoxConnector {
latency,
});
}
this.emit(EVENTS.THROTTLING_CHANGED, { profile });
}
/**

Просмотреть файл

@ -105,6 +105,9 @@ const EVENTS = {
// When request payload (HTTP details data) are fetched from the backend.
PAYLOAD_READY: "NetMonitor:PayloadReady",
// When throttling is set on the backend.
THROTTLING_CHANGED: "NetMonitor:ThrottlingChanged",
};
const UPDATE_PROPS = [

Просмотреть файл

@ -14,6 +14,10 @@ const {
SEND_CUSTOM_REQUEST,
} = require("../constants");
const {
CHANGE_NETWORK_THROTTLING,
} = require("devtools/client/shared/components/throttling/actions");
/**
* Event telemetry middleware is responsible for logging
* various events to telemetry. This helps to track Network
@ -66,6 +70,15 @@ function eventTelemetryMiddleware(connector, telemetry) {
});
}
// Record telemetry event when throttling is changed.
if (action.type == CHANGE_NETWORK_THROTTLING) {
throttlingChange({
action,
telemetry,
sessionId,
});
}
return res;
};
}
@ -132,4 +145,15 @@ function sendCustomRequest({telemetry, sessionId}) {
});
}
/**
* This helper function is executed when network throttling is changed.
* It's responsible for recording "throttle_changed" telemetry event.
*/
function throttlingChange({action, telemetry, sessionId}) {
telemetry.recordEvent("devtools.main", "throttle_changed", "netmonitor", null, {
"mode": action.profile,
"session_id": sessionId,
});
}
module.exports = eventTelemetryMiddleware;

Просмотреть файл

@ -188,6 +188,7 @@ skip-if = true # Bug 1373558
[browser_net_telemetry_edit_resend.js]
[browser_net_telemetry_filters_changed.js]
[browser_net_telemetry_sidepanel_changed.js]
[browser_net_telemetry_throttle_changed.js]
[browser_net_throttle.js]
[browser_net_timeline_ticks.js]
skip-if = true # TODO: fix the test

Просмотреть файл

@ -0,0 +1,40 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
/**
* Test the throttle_change telemetry event.
*/
add_task(async function() {
const { monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
// Remove all telemetry events.
Services.telemetry.clearEvents();
// Ensure no events have been logged
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
ok(!snapshot.parent, "No events have been logged for the main process");
document.querySelector("#global-network-throttling-selector").click();
monitor.panelWin.parent.document.querySelector("menuitem[label='GPRS']").click();
await waitFor(monitor.panelWin.api, EVENTS.THROTTLING_CHANGED);
// Verify existence of the telemetry event.
checkTelemetryEvent({
mode: "GPRS",
}, {
method: "throttle_changed",
});
return teardown(monitor);
});

Просмотреть файл

@ -549,6 +549,17 @@ devtools.main:
expiry_version: never
extra_keys:
session_id: The toolbox session start time e.g. 13963.
throttle_changed:
objects: ["netmonitor"]
bug_numbers: [1463147]
notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
record_in_processes: ["main"]
description: User has changed the throttle setting in the netmonitor.
release_channel_collection: opt-out
expiry_version: never
extra_keys:
mode: No throttling, GPRS, Regular 2G, Good 2G, Regular 3G, Good 3G, Regular 4G / LTE, DSL or WI-FI.
session_id: The toolbox session start time e.g. 13963.
execute_js:
objects: ["webconsole"]
bug_numbers: [1463083]