Skip to content

Commit 00cbf0a

Browse files
committed
feat(analytics): Add analytics for RCA reruns and micro chat interactions
Track the following analytics events: - When the Seer drawer is opened - When users share additional context and rerun RCA or Solutions - When micro chat interactions are opened - When micro chat interactions are closed/resolved Added events: - seer.drawer.opened - autofix.root_cause.rerun_with_context - autofix.comment_thread.open - autofix.comment_thread.close Fixes AIML-1432
1 parent 49c525f commit 00cbf0a

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

static/app/components/events/autofix/autofixHighlightPopup.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ function AutofixHighlightPopupContent({
223223
);
224224
const [showLoadingAssistant, setShowLoadingAssistant] = useState(false);
225225
const messagesEndRef = useRef<HTMLDivElement>(null);
226+
const hasTrackedOpenRef = useRef(false);
227+
228+
// Track analytics when comment thread is opened
229+
useEffect(() => {
230+
if (!hasTrackedOpenRef.current) {
231+
trackAnalytics('autofix.comment_thread.open', {
232+
organization,
233+
group_id: groupId,
234+
run_id: runId,
235+
step_index: stepIndex,
236+
is_agent_comment: isAgentComment ?? false,
237+
});
238+
hasTrackedOpenRef.current = true;
239+
}
240+
}, [organization, groupId, runId, stepIndex, isAgentComment]);
226241

227242
// Fetch current autofix data to get comment thread
228243
const {data: autofixData} = useAutofixData({groupId, isUserWatching: true});
@@ -348,6 +363,14 @@ function AutofixHighlightPopupContent({
348363
step_index: stepIndex,
349364
is_agent_comment: isAgentComment ?? false,
350365
});
366+
367+
trackAnalytics('autofix.comment_thread.close', {
368+
organization,
369+
group_id: groupId,
370+
run_id: runId,
371+
step_index: stepIndex,
372+
is_agent_comment: isAgentComment ?? false,
373+
});
351374
};
352375

353376
const handleRework = (e: React.MouseEvent) => {

static/app/components/events/autofix/autofixRootCause.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ function AutofixRootCauseDisplay({
294294
}
295295

296296
const instruction = solutionText.trim();
297+
298+
trackAnalytics('autofix.root_cause.rerun_with_context', {
299+
organization,
300+
group_id: groupId,
301+
run_id: runId,
302+
has_additional_context: !!instruction,
303+
context_length: instruction ? instruction.length : undefined,
304+
});
305+
297306
if (instruction) {
298307
selectRootCause({
299308
cause_id: cause.id,

static/app/utils/analytics/issueAnalyticsEvents.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ interface SetPriorityParams extends CommonGroupAnalyticsData {
6565

6666
export type IssueEventParameters = {
6767
'actionable_items.expand_clicked': ActionableItemDebugParam;
68+
'autofix.comment_thread.close': {
69+
group_id: string;
70+
is_agent_comment: boolean;
71+
run_id: string;
72+
step_index: number;
73+
};
74+
'autofix.comment_thread.open': {
75+
group_id: string;
76+
is_agent_comment: boolean;
77+
run_id: string;
78+
step_index: number;
79+
};
80+
'autofix.root_cause.rerun_with_context': {
81+
group_id: string;
82+
has_additional_context: boolean;
83+
run_id: string;
84+
context_length?: number;
85+
};
6886
'autofix.setup_modal_viewed': {
6987
groupId: string;
7088
projectId: string;
@@ -415,6 +433,10 @@ export type IssueEventParameters = {
415433
source: string;
416434
};
417435
resolve_issue: {release: string};
436+
'seer.drawer.opened': {
437+
group_id: string;
438+
has_autofix_data: boolean;
439+
};
418440
'settings.inbound_filter_updated': {
419441
filter: string;
420442
new_state: FieldValue;
@@ -437,7 +459,11 @@ export type IssueEventParameters = {
437459
type IssueEventKey = keyof IssueEventParameters;
438460

439461
export const issueEventMap: Record<IssueEventKey, string | null> = {
462+
'autofix.comment_thread.close': 'Autofix: Comment Thread Closed',
463+
'autofix.comment_thread.open': 'Autofix: Comment Thread Opened',
464+
'autofix.root_cause.rerun_with_context': 'Autofix: Root Cause Rerun with Context',
440465
'autofix.setup_modal_viewed': 'Autofix: Setup Modal Viewed',
466+
'seer.drawer.opened': 'Seer: Drawer Opened',
441467
'breadcrumbs.issue_details.change_time_display': 'Breadcrumb Time Display Toggled',
442468
'breadcrumbs.issue_details.drawer_opened': 'Breadcrumb Drawer Opened',
443469
'breadcrumbs.drawer.action': 'Breadcrumb Drawer Action Taken',

static/app/views/issueDetails/streamline/sidebar/seerDrawer.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {space} from 'sentry/styles/space';
2828
import type {Event} from 'sentry/types/event';
2929
import type {Group} from 'sentry/types/group';
3030
import type {Project} from 'sentry/types/project';
31+
import {trackAnalytics} from 'sentry/utils/analytics';
3132
import {getShortEventId} from 'sentry/utils/events';
3233
import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
3334
import {useLocation} from 'sentry/utils/useLocation';
@@ -344,10 +345,12 @@ export const useOpenSeerDrawer = ({
344345
group,
345346
project,
346347
event,
348+
autofixData,
347349
}: {
348350
event: Event | null;
349351
group: Group;
350352
project: Project;
353+
autofixData?: any;
351354
buttonRef?: React.RefObject<HTMLButtonElement | null>;
352355
}) => {
353356
const {openDrawer} = useDrawer();
@@ -364,6 +367,12 @@ export const useOpenSeerDrawer = ({
364367
return;
365368
}
366369

370+
trackAnalytics('seer.drawer.opened', {
371+
organization,
372+
group_id: group.id,
373+
has_autofix_data: !!autofixData,
374+
});
375+
367376
openDrawer(() => <SeerDrawer group={group} project={project} event={event} />, {
368377
ariaLabel: t('Seer drawer'),
369378
drawerKey: 'seer-autofix-drawer',
@@ -384,7 +393,7 @@ export const useOpenSeerDrawer = ({
384393
);
385394
},
386395
});
387-
}, [openDrawer, event, group, project, location, navigate, organization]);
396+
}, [openDrawer, event, group, project, location, navigate, organization, autofixData]);
388397

389398
return {openSeerDrawer};
390399
};

static/app/views/issueDetails/streamline/sidebar/seerSectionCtaButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function SeerSectionCtaButton({
6060
group,
6161
project,
6262
event,
63+
autofixData,
6364
buttonRef: openButtonRef,
6465
});
6566

0 commit comments

Comments
 (0)