Skip to content

Commit

Permalink
Bug 1874202 - Add a stopwatch telemetry to record the time it takes t…
Browse files Browse the repository at this point in the history
…o read from the clipboard. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D198595
  • Loading branch information
klubana-m committed Jan 29, 2024
1 parent 99cd5c6 commit 1cfd238
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
13 changes: 13 additions & 0 deletions browser/components/urlbar/UrlbarProviderClipboard.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,20 @@ class ProviderClipboard extends UrlbarProvider {
) {
return false;
}
const obj = {};
if (
!TelemetryStopwatch.running(
"FX_URLBAR_PROVIDER_CLIPBOARD_READ_TIME_MS",
obj
)
) {
TelemetryStopwatch.start(
"FX_URLBAR_PROVIDER_CLIPBOARD_READ_TIME_MS",
obj
);
}
let textFromClipboard = controller.browserWindow.readFromClipboard();
TelemetryStopwatch.finish("FX_URLBAR_PROVIDER_CLIPBOARD_READ_TIME_MS", obj);

// Check for spaces in clipboard text to avoid suggesting
// clipboard content including both a url and the following text.
Expand Down
18 changes: 17 additions & 1 deletion browser/components/urlbar/tests/browser/browser_clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,22 @@ add_task(async function testClipboardSuggestToggle() {
);
});

add_task(async function testScalarTelemetry() {
add_task(async function testScalarAndStopWatchTelemetry() {
SpecialPowers.clipboardCopyString("https://example.com/6");
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:home" },
async () => {
Services.telemetry.clearScalars();
let histogram = Services.telemetry.getHistogramById(
"FX_URLBAR_PROVIDER_CLIPBOARD_READ_TIME_MS"
);
histogram.clear();
Assert.equal(
Object.values(histogram.snapshot().values).length,
0,
"histogram is empty before search"
);

await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
Expand All @@ -328,6 +338,12 @@ add_task(async function testScalarTelemetry() {
0,
1
);

Assert.greater(
Object.values(histogram.snapshot().values).length,
0,
"histogram updated after search"
);
}
);
});
13 changes: 13 additions & 0 deletions toolkit/components/telemetry/Histograms.json
Original file line number Diff line number Diff line change
Expand Up @@ -9494,6 +9494,19 @@
"bug_numbers": [1334615],
"description": "The input method the user used to select a result in the searchbar. 'enter' => The user hit the Enter key without choosing a result in the popup. 'enterSelection' => The user chose a result and then hit the Enter key. 'click' => The user clicked a result with the mouse."
},
"FX_URLBAR_PROVIDER_CLIPBOARD_READ_TIME_MS": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["[email protected]"],
"expires_in_version": "128",
"kind": "exponential",
"low": 16,
"high": 5000,
"n_buckets": 8,
"bug_numbers": [1866710],
"releaseChannelCollection": "opt-out",
"description": "Time taken to read data from the clipboard (ms)"
},
"INNERWINDOWS_WITH_MUTATION_LISTENERS": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
Expand Down

0 comments on commit 1cfd238

Please sign in to comment.