Bug 1549970 - Record telemetry events for about:debugging connection attempts r=daisuke,janerik

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-05-13 12:02:40 +00:00
Родитель 978abcee6f
Коммит a2fc32b207
5 изменённых файлов: 59 добавлений и 5 удалений

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

@ -86,8 +86,11 @@ function onMultiE10sUpdated() {
}
function connectRuntime(id) {
// Create a random connection id to track the connection attempt in telemetry.
const connectionId = (Math.random() * 100000) | 0;
return async (dispatch, getState) => {
dispatch({ type: CONNECT_RUNTIME_START, id });
dispatch({ type: CONNECT_RUNTIME_START, connectionId, id });
// The preferences test-connection-timing-out-delay and test-connection-cancel-delay
// don't have a default value but will be overridden during our tests.
@ -101,7 +104,7 @@ function connectRuntime(id) {
// If connecting to the runtime takes time over CONNECTION_TIMING_OUT_DELAY,
// we assume the connection prompt is showing on the runtime, show a dialog
// to let user know that.
dispatch({ type: CONNECT_RUNTIME_NOT_RESPONDING, id });
dispatch({ type: CONNECT_RUNTIME_NOT_RESPONDING, connectionId, id });
}, connectionTimingOutDelay);
const connectionCancelTimer = setTimeout(() => {
// Connect button of the runtime will be disabled during connection, but the status
@ -109,7 +112,7 @@ function connectRuntime(id) {
// possibility that the disabling continues unless page reloading, user will not be
// able to click again. To avoid this, revert the connect button status after
// CONNECTION_CANCEL_DELAY ms.
dispatch({ type: CONNECT_RUNTIME_CANCEL, id });
dispatch({ type: CONNECT_RUNTIME_CANCEL, connectionId, id });
}, connectionCancelDelay);
try {
@ -183,6 +186,7 @@ function connectRuntime(id) {
dispatch({
type: CONNECT_RUNTIME_SUCCESS,
connectionId,
runtime: {
id,
runtimeDetails,
@ -190,7 +194,7 @@ function connectRuntime(id) {
},
});
} catch (e) {
dispatch({ type: CONNECT_RUNTIME_FAILURE, id, error: e });
dispatch({ type: CONNECT_RUNTIME_FAILURE, connectionId, id, error: e });
} finally {
clearTimeout(connectionNotRespondingTimer);
clearTimeout(connectionCancelTimer);

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

@ -10,6 +10,10 @@ loader.lazyGetter(this, "telemetry", () => new Telemetry());
loader.lazyGetter(this, "sessionId", () => parseInt(telemetry.msSinceProcessStart(), 10));
const {
CONNECT_RUNTIME_CANCEL,
CONNECT_RUNTIME_FAILURE,
CONNECT_RUNTIME_NOT_RESPONDING,
CONNECT_RUNTIME_START,
CONNECT_RUNTIME_SUCCESS,
DISCONNECT_RUNTIME_SUCCESS,
REMOTE_RUNTIMES_UPDATED,
@ -146,13 +150,41 @@ function onRemoteRuntimesUpdated(action, store) {
}
}
function recordConnectionAttempt(connectionId, runtimeId, status, store) {
const runtime = findRuntimeById(runtimeId, store.getState().runtimes);
if (runtime.type === RUNTIMES.THIS_FIREFOX) {
// Only record connection_attempt events for remote runtimes.
return;
}
recordEvent("connection_attempt", {
"connection_id": connectionId,
"connection_type": runtime.type,
"runtime_id": getTelemetryRuntimeId(runtimeId),
"status": status,
});
}
/**
* This middleware will record events to telemetry for some specific actions.
*/
function eventRecordingMiddleware(store) {
return next => action => {
switch (action.type) {
case CONNECT_RUNTIME_CANCEL:
recordConnectionAttempt(action.connectionId, action.id, "cancelled", store);
break;
case CONNECT_RUNTIME_FAILURE:
recordConnectionAttempt(action.connectionId, action.id, "failed", store);
break;
case CONNECT_RUNTIME_NOT_RESPONDING:
recordConnectionAttempt(action.connectionId, action.id, "not responding", store);
break;
case CONNECT_RUNTIME_START:
recordConnectionAttempt(action.connectionId, action.id, "start", store);
break;
case CONNECT_RUNTIME_SUCCESS:
recordConnectionAttempt(action.connectionId, action.runtime.id, "success", store);
onConnectRuntimeSuccess(action, store);
break;
case DISCONNECT_RUNTIME_SUCCESS:

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

@ -77,6 +77,8 @@ add_task(async function testUsbRuntimeUpdates() {
checkTelemetryEvents([
{ method: "runtime_connected", extras: runtime1ConnectedExtras },
{ method: "connection_attempt", extras: { status: "start" } },
{ method: "connection_attempt", extras: { status: "success" } },
], sessionId);
info("Add a second runtime");

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

@ -50,6 +50,8 @@ add_task(async function testNetworkRuntimeUpdates() {
await connectToRuntime(NETWORK_RUNTIME.host, document);
checkTelemetryEvents([
{ method: "runtime_connected", extras: connectedNetworkRuntimeExtras },
{ method: "connection_attempt", extras: { status: "start" } },
{ method: "connection_attempt", extras: { status: "success" } },
], sessionId);
info("Remove network runtime");

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

@ -591,6 +591,20 @@ devtools.main:
extra_keys:
width: Toolbox width rounded up to the nearest 50px.
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
connection_attempt:
objects: ["aboutdebugging"]
bug_numbers: [1549970]
notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
record_in_processes: ["main"]
description: User is trying to connect to a remote runtime.
release_channel_collection: opt-out
expiry_version: never
extra_keys:
connection_id: Randomly generated id to keep to group various events related to the same connection attempt.
connection_type: Connection type
runtime_id: Random id generated to track events related to a single runtime
status: One of (cancelled, failed, not responding, start, success).
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
continue:
objects: ["debugger"]
bug_numbers: [1463122]
@ -826,7 +840,7 @@ devtools.main:
release_channel_collection: opt-out
expiry_version: never
extra_keys:
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
pretty_print:
objects: ["debugger"]
bug_numbers: [1463125]