Skip to content

Commit 25e624e

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
Track ElementsPanel new badge with Promotion Tracker
For the ElementsPanel we currently use two separate features for showing the new badge: "DevToolsAiDebugWithAi" and the "DevToolsAiSubmenPrompts" (since DevToolsFreestyler is taken by the MainView for the 3dot menu). At launch time, we don't want users that have been in on study group (e.g. in DevToolsAiSubmenuPrompts) and have seen the new badge, to see the new badge again if we launch the other study group (e.g. the DevToolsAiDebugWithAi). Since the back-end doesn't know that it is the same kind of menu item, additionally register this new badge with the Promotion Tracker. Bug: 438371138 Change-Id: I542c51e5a676ed24f234611b151116cba17b7801 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6842541 Auto-Submit: Kim-Anh Tran <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent c80f7fa commit 25e624e

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

front_end/panels/elements/ElementsTreeElement.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -915,16 +915,24 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
915915
function appendSubmenuPromptAction(
916916
submenu: UI.ContextMenu.SubMenu, action: UI.ActionRegistration.Action, label: Common.UIString.LocalizedString,
917917
prompt: string, jslogContext: string): void {
918-
submenu.defaultSection().appendItem(
919-
label, () => action.execute({prompt}), {disabled: !action.enabled(), jslogContext});
918+
submenu.defaultSection().appendItem(label, () => {
919+
void action.execute({prompt});
920+
UI.UIUtils.PromotionManager.instance().recordFeatureInteraction(openAiAssistanceId);
921+
}, {disabled: !action.enabled(), jslogContext});
920922
}
921923

922924
UI.Context.Context.instance().setFlavor(SDK.DOMModel.DOMNode, this.nodeInternal);
923925
if (Root.Runtime.hostConfig.devToolsAiSubmenuPrompts?.enabled) {
924926
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(openAiAssistanceId);
925927
// Register new badge under the `devToolsAiSubmenuPrompts` feature, as the freestyler one is already used in ViewManager.
926-
const submenu = contextMenu.footerSection().appendSubMenuItem(
927-
action.title(), false, openAiAssistanceId, Root.Runtime.hostConfig.devToolsAiSubmenuPrompts?.featureName);
928+
// Additionally register with the PromotionManager. Since we use two features for freeestyler here (submenu or debug with ai),
929+
// the back-end will not be able to identify them as one as soon as we launch, and show the new badge
930+
// on the 'Debug with Ai' item even if the user was already seeing it during the study if they were in the other study group.
931+
const featureName = UI.UIUtils.PromotionManager.instance().maybeShowPromotion(openAiAssistanceId) ?
932+
Root.Runtime.hostConfig.devToolsAiSubmenuPrompts?.featureName :
933+
undefined;
934+
const submenu =
935+
contextMenu.footerSection().appendSubMenuItem(action.title(), false, openAiAssistanceId, featureName);
928936
submenu.defaultSection().appendAction(openAiAssistanceId, i18nString(UIStrings.startAChat));
929937

930938
const submenuConfigs = [
@@ -1058,9 +1066,18 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
10581066
}
10591067
} else if (Root.Runtime.hostConfig.devToolsAiDebugWithAi?.enabled) {
10601068
// Register new badge under the `devToolsAiDebugWithAi` feature, as the freestyler one is already used in ViewManager.
1061-
contextMenu.footerSection().appendAction(
1062-
openAiAssistanceId, undefined, false, undefined,
1063-
Root.Runtime.hostConfig.devToolsAiDebugWithAi?.featureName);
1069+
// Additionally register with the PromotionManager. Since we use two different features for freeestyler here (submenu or debug with ai),
1070+
// the back-end will not be able to identify them as one as soon as we launch, and show the new badge
1071+
// on the 'Debug with Ai' item even if the user was already seeing it during the study if they were in the other study group.
1072+
const featureName = UI.UIUtils.PromotionManager.instance().maybeShowPromotion(openAiAssistanceId) ?
1073+
Root.Runtime.hostConfig.devToolsAiDebugWithAi?.featureName :
1074+
undefined;
1075+
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(openAiAssistanceId);
1076+
contextMenu.footerSection().appendItem(action.title(), () => {
1077+
void action.execute();
1078+
UI.UIUtils.PromotionManager.instance().recordFeatureInteraction(openAiAssistanceId);
1079+
}, {jslogContext: openAiAssistanceId, disabled: !action.enabled(), featureName});
1080+
10641081
} else {
10651082
contextMenu.footerSection().appendAction(openAiAssistanceId);
10661083
}

0 commit comments

Comments
 (0)