Bug 1902667 - Add new trigger and callout for sidebar survey r=sidebar-reviewers,mviar,omc-reviewers,jsudiaman

Differential Revision: https://phabricator.services.mozilla.com/D226831
This commit is contained in:
Kelly Cochrane
2024-10-30 17:56:14 +00:00
parent 7019d9da7e
commit e0e4fc4145
3 changed files with 89 additions and 2 deletions

View File

@@ -12,6 +12,11 @@ import {
} from "chrome://global/content/vendor/lit.all.mjs";
import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
ASRouter: "resource:///modules/asrouter/ASRouter.sys.mjs",
});
const TOOLS_OVERFLOW_LIMIT = 5;
/**
@@ -48,6 +53,10 @@ export default class SidebarMain extends MozLitElement {
this.open = window.SidebarController.isOpen;
this.contextMenuTarget = null;
this.expanded = false;
this.clickCounts = {
genai: 0,
totalToolsMinusGenai: 0,
};
}
connectedCallback() {
@@ -240,7 +249,32 @@ export default class SidebarMain extends MozLitElement {
}
}
showView(view) {
async checkShouldShowCalloutSurveys(view) {
const { currentID, toolsAndExtensions } = window.SidebarController;
let isToolOpening =
(!currentID || (currentID && currentID !== view)) &&
toolsAndExtensions.has(view);
if (isToolOpening) {
if (view == "viewGenaiChatSidebar") {
this.clickCounts.genai++;
} else {
this.clickCounts.totalToolsMinusGenai++;
}
await lazy.ASRouter.waitForInitialized;
lazy.ASRouter.sendTriggerMessage({
browser: window.gBrowser.selectedBrowser,
id: "sidebarToolOpened",
context: {
view,
clickCounts: this.clickCounts,
},
});
}
}
async showView(view) {
await this.checkShouldShowCalloutSurveys(view);
window.SidebarController.recordIconClick(view, this.expanded);
window.SidebarController.toggle(view);
if (view === "viewCustomizeSidebar") {
@@ -287,7 +321,7 @@ export default class SidebarMain extends MozLitElement {
type=${isActiveView ? "icon" : "icon ghost"}
aria-pressed="${isActiveView}"
view=${action.view}
@click=${() => this.showView(action.view)}
@click=${async () => await this.showView(action.view)}
title=${!this.expanded ? actionLabel : nothing}
.iconSrc=${action.iconUrl}
?extension=${action.view?.includes("-sidebar-action")}