зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1665391 - Add telemetry to measure effectiveness of 2h2020 bookmarks changes. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D97251
This commit is contained in:
Родитель
d7875803f2
Коммит
e95fc55e72
|
@ -902,6 +902,13 @@ var BookmarksEventHandler = {
|
|||
var target = aEvent.originalTarget;
|
||||
if (target._placesNode) {
|
||||
PlacesUIUtils.openNodeWithEvent(target._placesNode, aEvent);
|
||||
// Only record interactions through the Bookmarks Toolbar
|
||||
if (target.closest("#PersonalToolbar")) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_opened",
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2240,6 +2247,12 @@ var BookmarkingUI = {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (ev.parentGuid == PlacesUtils.bookmarks.toolbarGuid) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
1
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "bookmark-removed":
|
||||
// If one of the tracked bookmarks has been removed, unregister it.
|
||||
|
@ -2312,12 +2325,18 @@ var BookmarkingUI = {
|
|||
this.maybeShowOtherBookmarksFolder();
|
||||
}
|
||||
|
||||
let hasMovedToOrOutOfToolbar =
|
||||
newParentGuid === PlacesUtils.bookmarks.toolbarGuid ||
|
||||
let hasMovedToToolbar = newParentGuid === PlacesUtils.bookmarks.toolbarGuid;
|
||||
let hasMovedOutOfToolbar =
|
||||
oldParentGuid === PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (hasMovedToOrOutOfToolbar) {
|
||||
if (hasMovedToToolbar || hasMovedOutOfToolbar) {
|
||||
this.updateEmptyToolbarMessage();
|
||||
}
|
||||
if (hasMovedToToolbar) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
1
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
onWidgetUnderflow(aNode, aContainer) {
|
||||
|
|
|
@ -1715,11 +1715,12 @@ var gBrowserInit = {
|
|||
let node = document.getElementById(area);
|
||||
CustomizableUI.registerToolbarNode(node);
|
||||
}
|
||||
let bookmarksToolbarVisibility = gBookmarksToolbar2h2020
|
||||
? gBookmarksToolbarVisibility
|
||||
: gBookmarksToolbarVisibility == "always";
|
||||
setToolbarVisibility(
|
||||
gNavToolbox.querySelector("#PersonalToolbar"),
|
||||
gBookmarksToolbar2h2020
|
||||
? gBookmarksToolbarVisibility
|
||||
: gBookmarksToolbarVisibility == "always",
|
||||
bookmarksToolbarVisibility,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
|
|
@ -36,6 +36,7 @@ skip-if = os != 'mac' # Mac-only functionality
|
|||
support-files =
|
||||
pageopeningwindow.html
|
||||
[browser_bookmarks_toolbar_context_menu_view_options.js]
|
||||
[browser_bookmarks_toolbar_telemetry.js]
|
||||
[browser_bookmarkProperties_addFolderDefaultButton.js]
|
||||
[browser_bookmarkProperties_addKeywordForThisSearch.js]
|
||||
skip-if = (verify && debug)
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { TelemetryTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TelemetryTestUtils.jsm"
|
||||
);
|
||||
|
||||
const SCALAR_NAME = "browser.ui.customized_widgets";
|
||||
const BOOKMARKS_H2_2020_PREF = "browser.toolbars.bookmarks.2h2020";
|
||||
const bookmarksInfo = [
|
||||
{
|
||||
title: "firefox",
|
||||
url: "http://example.com",
|
||||
},
|
||||
{
|
||||
title: "rules",
|
||||
url: "http://example.com/2",
|
||||
},
|
||||
{
|
||||
title: "yo",
|
||||
url: "http://example.com/2",
|
||||
},
|
||||
];
|
||||
|
||||
// Setup.
|
||||
add_task(async function test_bookmarks_toolbar_telemetry() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[BOOKMARKS_H2_2020_PREF, true],
|
||||
["browser.toolbars.bookmarks.visibility", "newtab"],
|
||||
],
|
||||
});
|
||||
|
||||
// This is added during startup
|
||||
await TestUtils.waitForCondition(
|
||||
() =>
|
||||
keyedScalarExists(
|
||||
"browser.ui.toolbar_widgets",
|
||||
"bookmarks-bar_pinned_newtab",
|
||||
true
|
||||
),
|
||||
`Waiting for "bookmarks-bar_pinned_newtab" to appear in Telemetry snapshot`
|
||||
);
|
||||
ok(true, `"bookmarks-bar_pinned_newtab"=true found in Telemetry`);
|
||||
|
||||
await changeToolbarVisibilityViaContextMenu("never");
|
||||
await assertUIChange(
|
||||
"bookmarks-bar_move_newtab_never_toolbar-context-menu",
|
||||
1
|
||||
);
|
||||
|
||||
await changeToolbarVisibilityViaContextMenu("newtab");
|
||||
await assertUIChange(
|
||||
"bookmarks-bar_move_never_newtab_toolbar-context-menu",
|
||||
1
|
||||
);
|
||||
|
||||
await changeToolbarVisibilityViaContextMenu("always");
|
||||
await assertUIChange(
|
||||
"bookmarks-bar_move_newtab_always_toolbar-context-menu",
|
||||
1
|
||||
);
|
||||
|
||||
Services.telemetry.getSnapshotForScalars("main", true);
|
||||
let bookmarks = await PlacesUtils.bookmarks.insertTree({
|
||||
guid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
children: bookmarksInfo,
|
||||
});
|
||||
registerCleanupFunction(() => PlacesUtils.bookmarks.remove(bookmarks));
|
||||
TelemetryTestUtils.assertScalar(
|
||||
TelemetryTestUtils.getProcessScalars("parent"),
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
3,
|
||||
"Bookmarks added value should be 3"
|
||||
);
|
||||
|
||||
let newtab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
registerCleanupFunction(() => BrowserTestUtils.removeTab(newtab));
|
||||
Services.telemetry.getSnapshotForScalars("main", true);
|
||||
let bookmarkToolbarButton = document.querySelector(
|
||||
"#PlacesToolbarItems > toolbarbutton"
|
||||
);
|
||||
bookmarkToolbarButton.click();
|
||||
TelemetryTestUtils.assertScalar(
|
||||
TelemetryTestUtils.getProcessScalars("parent", false, true),
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_opened",
|
||||
1,
|
||||
"Bookmarks opened value should be 1"
|
||||
);
|
||||
});
|
||||
|
||||
async function changeToolbarVisibilityViaContextMenu(nextState) {
|
||||
let contextMenu = document.querySelector("#toolbar-context-menu");
|
||||
let popupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
|
||||
let menuButton = document.getElementById("PanelUI-menu-button");
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
menuButton,
|
||||
{ type: "contextmenu" },
|
||||
window
|
||||
);
|
||||
await popupShown;
|
||||
let bookmarksToolbarMenu = document.querySelector("#toggle_PersonalToolbar");
|
||||
let subMenu = bookmarksToolbarMenu.querySelector("menupopup");
|
||||
popupShown = BrowserTestUtils.waitForEvent(subMenu, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarksToolbarMenu, {});
|
||||
await popupShown;
|
||||
let menuItem = document.querySelector(
|
||||
`menuitem[data-visibility-enum="${nextState}"]`
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(menuItem, {});
|
||||
contextMenu.hidePopup();
|
||||
}
|
||||
|
||||
async function assertUIChange(key, value) {
|
||||
await TestUtils.waitForCondition(
|
||||
() => keyedScalarExists(SCALAR_NAME, key, value),
|
||||
`Waiting for ${key} to appear in Telemetry snapshot`
|
||||
);
|
||||
ok(true, `${key}=${value} found in Telemetry`);
|
||||
}
|
||||
|
||||
function keyedScalarExists(scalar, key, value) {
|
||||
let snapshot = Services.telemetry.getSnapshotForKeyedScalars("main", false)
|
||||
.parent;
|
||||
if (!snapshot.hasOwnProperty(scalar)) {
|
||||
return false;
|
||||
}
|
||||
if (!snapshot[scalar].hasOwnProperty(key)) {
|
||||
info(`Looking for ${key} in ${JSON.stringify(snapshot[scalar])}`);
|
||||
return false;
|
||||
}
|
||||
return snapshot[scalar][key] == value;
|
||||
}
|
|
@ -91,7 +91,9 @@ setting the scalar key ``<widget id>_pinned_<area>`` to true. The widget ID are
|
|||
the IDs of the elements in the DOM. The area is one of the areas listed above
|
||||
from the browser UI that can be customised.
|
||||
|
||||
For the areas that can be controlled the scalar keys ``<area>_<off/on>`` are set.
|
||||
For the areas that can be controlled the scalar keys ``<area>_<off/on/newtab>`` are set.
|
||||
``newtab`` is special to the Bookmarks Toolbar and is used when the toolbar will only
|
||||
be shown on the New Tab page.
|
||||
|
||||
Widget Customization
|
||||
--------------------
|
||||
|
|
|
@ -879,14 +879,16 @@ let BrowserUsageTelemetry = {
|
|||
"browser.toolbars.bookmarks.visibility",
|
||||
"newtab"
|
||||
);
|
||||
value = (value == "never").toString();
|
||||
} else {
|
||||
value = Services.xulStore.getValue(
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
nodeId,
|
||||
"collapsed"
|
||||
);
|
||||
if (value != "newtab") {
|
||||
return value == "never" ? "off" : "on";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
value = Services.xulStore.getValue(
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
nodeId,
|
||||
"collapsed"
|
||||
);
|
||||
|
||||
if (value) {
|
||||
return value == "true" ? "off" : "on";
|
||||
|
|
|
@ -7409,13 +7409,13 @@
|
|||
"FX_MIGRATION_ENTRY_POINT": {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox"],
|
||||
"bug_numbers": [731025, 1584261, 1643431],
|
||||
"bug_numbers": [731025, 1584261, 1643431, 1665442],
|
||||
"alert_emails": ["gijs@mozilla.com", "MattN+telemetry@mozilla.com"],
|
||||
"expires_in_version": "86",
|
||||
"kind": "enumerated",
|
||||
"n_values": 10,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Where the migration wizard was entered from. 0=Other/catch-all, 1=first-run, 2=refresh-firefox, 3=Places window, 4=Password manager, 5=New tab, 6=File menu, 7=Help menu"
|
||||
"description": "Where the migration wizard was entered from. 0=Other/catch-all, 1=first-run, 2=refresh-firefox, 3=Places window, 4=Password manager, 5=New tab, 6=File menu, 7=Help menu, 8=Bookmarks toolbar"
|
||||
},
|
||||
"FX_MIGRATION_SOURCE_BROWSER": {
|
||||
"record_in_processes": ["main"],
|
||||
|
|
|
@ -339,6 +339,42 @@ browser.engagement:
|
|||
operating_systems:
|
||||
- windows
|
||||
|
||||
bookmarks_toolbar_bookmark_added:
|
||||
bug_numbers:
|
||||
- 1665391
|
||||
description: >
|
||||
The count of bookmarks added to the bookmarks toolbar. This counts bookmarks created on the
|
||||
bookmarks toolbar and bookmarks moved to the bookmarks toolbar.
|
||||
expires: never
|
||||
kind: uint
|
||||
notification_emails:
|
||||
- rtestard@mozilla.com
|
||||
- jaws@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- 'firefox'
|
||||
record_in_processes:
|
||||
- 'main'
|
||||
|
||||
bookmarks_toolbar_bookmark_opened:
|
||||
bug_numbers:
|
||||
- 1665391
|
||||
description: >
|
||||
The count of bookmarks opened from the Bookmarks Toolbar. This counts bookmarks opened on the
|
||||
toolbar and bookmarks opened from the 'symlinked' Other Bookmarks folder on the
|
||||
Bookmarks Toolbar. It does not count Bookmarks Toolbar bookmarks opened via the Library,
|
||||
Bookmarks Menu, or other UI since the goal is to measure interactions that pass through the toolbar.
|
||||
expires: never
|
||||
kind: uint
|
||||
notification_emails:
|
||||
- rtestard@mozilla.com
|
||||
- jaws@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
products:
|
||||
- 'firefox'
|
||||
record_in_processes:
|
||||
- 'main'
|
||||
|
||||
# The following section contains the browser engagement scalars.
|
||||
browser.engagement.navigation:
|
||||
urlbar:
|
||||
|
|
Загрузка…
Ссылка в новой задаче