Skip to content

Commit b33f10f

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[Freestyler] Add UMA instrumentation for the funnel steps
Bug: 374667861 Change-Id: I14c430f7a9c12fa1c725e0f2c0a44beefed555e3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5965793 Commit-Queue: Ergün Erdoğmuş <[email protected]> Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Alex Rudenko <[email protected]> Auto-Submit: Ergün Erdoğmuş <[email protected]>
1 parent 53bff70 commit b33f10f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

front_end/core/host/UserMetrics.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,14 @@ export enum Action {
570570
DrJonesOpenedFromSourcesPanelFloatingButton = 172,
571571
DrJonesOpenedFromPerformancePanel = 173,
572572
DrJonesOpenedFromNetworkPanelFloatingButton = 174,
573-
MAX_VALUE = 175,
573+
AiAssistancePanelOpened = 175,
574+
AiAssistanceQuerySubmitted = 176,
575+
AiAssistanceAnswerReceived = 177,
576+
AiAssistanceDynamicSuggestionClicked = 178,
577+
AiAssistanceSideEffectConfirmed = 179,
578+
AiAssistanceSideEffectRejected = 180,
579+
AiAssistanceError = 181,
580+
MAX_VALUE = 182,
574581
/* eslint-enable @typescript-eslint/naming-convention */
575582
}
576583

front_end/panels/freestyler/FreestylerPanel.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ export class FreestylerPanel extends UI.Panel.Panel {
183183
messages: [],
184184
inspectElementToggled: this.#toggleSearchElementAction.toggled(),
185185
isLoading: false,
186-
onTextSubmit: this.#startConversation.bind(this),
186+
onTextSubmit: (text: string) => {
187+
void this.#startConversation(text);
188+
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistanceQuerySubmitted);
189+
},
187190
onInspectElementClick: this.#handleSelectElementClick.bind(this),
188191
onFeedbackSubmit: this.#handleFeedbackSubmit.bind(this),
189192
onCancelClick: this.#cancel.bind(this),
@@ -295,6 +298,8 @@ export class FreestylerPanel extends UI.Panel.Panel {
295298
Trace.Helpers.TreeHelpers.AINode, this.#handleTraceEntryNodeFlavorChange);
296299
UI.Context.Context.instance().addFlavorChangeListener(
297300
Workspace.UISourceCode.UISourceCode, this.#handleUISourceCodeFlavorChange);
301+
302+
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistancePanelOpened);
298303
}
299304

300305
override willHide(): void {
@@ -619,6 +624,7 @@ export class FreestylerPanel extends UI.Panel.Panel {
619624
}
620625
step.isLoading = false;
621626
this.#viewProps.isLoading = false;
627+
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistanceAnswerReceived);
622628
break;
623629
}
624630
case ResponseType.ERROR: {
@@ -635,6 +641,10 @@ export class FreestylerPanel extends UI.Panel.Panel {
635641
systemMessage.steps.pop();
636642
}
637643
}
644+
645+
if (data.error !== ErrorType.ABORT) {
646+
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistanceError);
647+
}
638648
}
639649
}
640650

front_end/panels/freestyler/components/FreestylerChatUi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ export class FreestylerChatUi extends HTMLElement {
481481
#handleSuggestionClick = (suggestion: string): void => {
482482
this.#setInputText(suggestion);
483483
this.focusTextInput();
484+
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistanceDynamicSuggestionClicked);
484485
};
485486

486487
#renderRateButtons(rpcId: number): LitHtml.TemplateResult {
@@ -661,6 +662,11 @@ export class FreestylerChatUi extends HTMLElement {
661662
step.sideEffect?.onAnswer(answer);
662663
step.sideEffect = undefined;
663664
this.#render();
665+
666+
Host.userMetrics.actionTaken(
667+
answer ? Host.UserMetrics.Action.AiAssistanceSideEffectConfirmed :
668+
Host.UserMetrics.Action.AiAssistanceSideEffectRejected,
669+
);
664670
};
665671

666672
// clang-format off

0 commit comments

Comments
 (0)