Skip to content

Commit c9c43fe

Browse files
malwilleyMichaelSun48
authored andcommitted
feat(autofix): Add analytics to Autofix buttons (#69557)
- Adds `autofix_status` to the `issue_details.viewed` event - Names and adds `group_id` to all button click analytic events (start fix, provide instructions, select root cause, create/view pr)
1 parent 7909c58 commit c9c43fe

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export function AutofixBanner({groupId, triggerAutofix, hasSuccessfulSetup}: Pro
2525
const isSentryEmployee = useIsSentryEmployee();
2626
const onClickGiveInstructions = () => {
2727
openModal(deps => (
28-
<AutofixInstructionsModal {...deps} triggerAutofix={triggerAutofix} />
28+
<AutofixInstructionsModal
29+
{...deps}
30+
triggerAutofix={triggerAutofix}
31+
groupId={groupId}
32+
/>
2933
));
3034
};
3135

@@ -44,17 +48,30 @@ export function AutofixBanner({groupId, triggerAutofix, hasSuccessfulSetup}: Pro
4448
<ContextArea>
4549
{hasSuccessfulSetup ? (
4650
<Fragment>
47-
<Button onClick={() => triggerAutofix('')} size="sm">
51+
<Button
52+
onClick={() => triggerAutofix('')}
53+
size="sm"
54+
analyticsEventKey="autofix.start_fix_clicked"
55+
analyticsEventName="Autofix: Start Fix Clicked"
56+
analyticsParams={{group_id: groupId}}
57+
>
4858
{t('Gimme Fix')}
4959
</Button>
50-
<Button onClick={onClickGiveInstructions} size="sm">
60+
<Button
61+
onClick={onClickGiveInstructions}
62+
size="sm"
63+
analyticsEventKey="autofix.give_instructions_clicked"
64+
analyticsEventName="Autofix: Give Instructions Clicked"
65+
analyticsParams={{group_id: groupId}}
66+
>
5167
{t('Give Instructions')}
5268
</Button>
5369
</Fragment>
5470
) : (
5571
<Button
5672
analyticsEventKey="autofix.setup_clicked"
5773
analyticsEventName="Autofix: Setup Clicked"
74+
analyticsParams={{group_id: groupId}}
5875
onClick={() => {
5976
openModal(deps => <AutofixSetupModal {...deps} groupId={groupId} />);
6077
}}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ function AutofixRepoChange({
8282
</div>
8383
{!change.pull_request ? (
8484
<Actions>
85-
<Button size="xs" onClick={() => createPr()} busy={isLoading}>
85+
<Button
86+
size="xs"
87+
onClick={() => createPr()}
88+
busy={isLoading}
89+
analyticsEventName="Autofix: Create PR Clicked"
90+
analyticsEventKey="autofix.create_pr_clicked"
91+
analyticsParams={{group_id: groupId}}
92+
>
8693
{t('Create a Pull Request')}
8794
</Button>
8895
</Actions>
@@ -92,6 +99,9 @@ function AutofixRepoChange({
9299
icon={<IconOpen size="xs" />}
93100
href={change.pull_request.pr_url}
94101
external
102+
analyticsEventName="Autofix: View PR Clicked"
103+
analyticsEventKey="autofix.view_pr_clicked"
104+
analyticsParams={{group_id: groupId}}
95105
>
96106
{t('View Pull Request')}
97107
</LinkButton>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {t} from 'sentry/locale';
99
import {space} from 'sentry/styles/space';
1010

1111
interface AutofixContextModalProps extends ModalRenderProps {
12+
groupId: string;
1213
triggerAutofix: (value: string) => void;
1314
}
1415

@@ -17,6 +18,7 @@ export function AutofixInstructionsModal({
1718
Footer,
1819
closeModal,
1920
triggerAutofix,
21+
groupId,
2022
}: AutofixContextModalProps) {
2123
return (
2224
<Form
@@ -54,7 +56,13 @@ export function AutofixInstructionsModal({
5456
<Footer>
5557
<FooterButtons>
5658
<Button onClick={closeModal}>{t('Cancel')}</Button>
57-
<Button priority="primary" type="submit">
59+
<Button
60+
priority="primary"
61+
type="submit"
62+
analyticsEventKey="autofix.start_fix_with_instructions_clicked"
63+
analyticsEventName="Autofix: Start Fix With Instructions Clicked"
64+
analyticsParams={{group_id: groupId}}
65+
>
5866
{t("Let's go!")}
5967
</Button>
6068
</FooterButtons>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ function CauseSuggestedFix({
178178
size="xs"
179179
onClick={() => handleSelectFix({causeId, fixId: suggestedFix.id})}
180180
busy={isLoading}
181+
analyticsEventName="Autofix: Root Cause Fix Selected"
182+
analyticsEventKey="autofix.root_cause_fix_selected"
183+
analyticsParams={{group_id: groupId}}
181184
>
182185
{t('Continue With This Fix')}
183186
</Button>
@@ -296,6 +299,9 @@ function ProvideYourOwn({
296299
onClick={() => handleSelectFix({customRootCause: text})}
297300
disabled={!text}
298301
busy={isLoading}
302+
analyticsEventName="Autofix: Root Cause Custom Cause Provided"
303+
analyticsEventKey="autofix.root_cause_custom_cause_provided"
304+
analyticsParams={{group_id: groupId}}
299305
>
300306
{t('Continue With This Fix')}
301307
</Button>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {GroupWithAutofix} from 'sentry/components/events/autofix/types';
55
import {useAiAutofix} from 'sentry/components/events/autofix/useAutofix';
66
import {useAutofixSetup} from 'sentry/components/events/autofix/useAutofixSetup';
77
import type {Event} from 'sentry/types/event';
8+
import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
89

910
interface Props {
1011
event: Event;
@@ -18,6 +19,10 @@ export function Autofix({event, group}: Props) {
1819
groupId: group.id,
1920
});
2021

22+
useRouteAnalyticsParams({
23+
autofix_status: autofixData?.status ?? 'none',
24+
});
25+
2126
return (
2227
<ErrorBoundary mini>
2328
<div>

static/app/views/issueDetails/groupDetails.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ function useTrackView({
622622
// Will be updated in SuspectCommits if there are suspect commits
623623
num_suspect_commits: 0,
624624
suspect_commit_calculation: 'no suspect commit',
625+
// Will be updated in Autofix if enabled
626+
autofix_status: 'none',
625627
});
626628
useDisableRouteAnalytics(!group || !event || !project);
627629
}

0 commit comments

Comments
 (0)