Skip to content

feat(autofix): Add key analytics events #92533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions static/app/components/events/autofix/autofixChanges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export function AutofixChanges({
borderless
title={t('Chat with Seer')}
onClick={handleSelectFirstChange}
analyticsEventName="Autofix: Changes Chat"
analyticsEventKey="autofix.changes.chat"
>
<IconChat size="xs" />
</ChatButton>
Expand Down
11 changes: 11 additions & 0 deletions static/app/components/events/autofix/autofixHighlightPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import LoadingIndicator from 'sentry/components/loadingIndicator';
import {IconClose} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like mistake?

import testableTransition from 'sentry/utils/testableTransition';
import useApi from 'sentry/utils/useApi';
import useMedia from 'sentry/utils/useMedia';
Expand Down Expand Up @@ -140,6 +141,8 @@ function AutofixHighlightPopupContent({
isFocused,
onShouldPersistChange,
}: Props & {isFocused?: boolean}) {
const organization = useOrganization();

const {mutate: submitComment} = useCommentThread({groupId, runId});
const {mutate: closeCommentThread} = useCloseCommentThread({groupId, runId});

Expand Down Expand Up @@ -247,6 +250,14 @@ function AutofixHighlightPopupContent({
is_agent_comment: isAgentComment ?? false,
});
setComment('');

trackAnalytics('autofix.comment_thread.submit', {
organization,
group_id: groupId,
run_id: runId,
step_index: stepIndex,
is_agent_comment: isAgentComment ?? false,
});
};

const handleContainerClick = (e: React.MouseEvent) => {
Expand Down
33 changes: 33 additions & 0 deletions static/app/components/events/autofix/autofixInsightCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {useTypingAnimation} from 'sentry/components/events/autofix/useTypingAnim
import {IconChevron, IconClose} from 'sentry/icons';
import {t, tn} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also mistake?

import {singleLineRenderer} from 'sentry/utils/marked/marked';
import {MarkedText} from 'sentry/utils/marked/markedText';
import {useMutation, useQueryClient} from 'sentry/utils/queryClient';
Expand Down Expand Up @@ -166,6 +167,14 @@ function AutofixInsightCard({
size="sm"
title={t('Redo work from here')}
aria-label={t('Redo work from here')}
analyticsEventName="Autofix: Insight Card Rethink Open"
analyticsEventKey="autofix.insight.rethink_open"
analyticsParams={{
insight_card_index: index,
step_index: stepIndex,
group_id: groupId,
run_id: runId,
}}
>
{'\u23CE'}
</Button>
Expand Down Expand Up @@ -213,6 +222,14 @@ function AutofixInsightCard({
icon={<FlippedReturnIcon />}
aria-label={t('Edit insight')}
title={t('Rethink the answer from here')}
analyticsEventName="Autofix: Insight Card Rethink"
analyticsEventKey="autofix.insight.rethink"
analyticsParams={{
insight_card_index: index,
step_index: stepIndex,
group_id: groupId,
run_id: runId,
}}
/>
</RightSection>
</InsightCardRow>
Expand Down Expand Up @@ -307,6 +324,8 @@ function CollapsibleChainLink({
const [newInsightText, setNewInsightText] = useState('');
const {mutate: updateInsight} = useUpdateInsightCard({groupId, runId});

const organization = useOrganization();

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
setIsAdding(false);
Expand All @@ -317,6 +336,13 @@ function CollapsibleChainLink({
insightCount !== undefined && insightCount > 0 ? insightCount : null,
});
setNewInsightText('');

trackAnalytics('autofix.step.rethink', {
step_index: stepIndex,
group_id: groupId,
run_id: runId,
organization,
});
};

const handleCancel = () => {
Expand Down Expand Up @@ -405,6 +431,13 @@ function CollapsibleChainLink({
onClick={() => setIsAdding(true)}
title={t('Give feedback and rethink the answer')}
aria-label={t('Give feedback and rethink the answer')}
analyticsEventName="Autofix: Step Rethink Open"
analyticsEventKey="autofix.step.rethink_open"
analyticsParams={{
step_index: stepIndex,
group_id: groupId,
run_id: runId,
}}
>
<RethinkLabel>{t('Rethink this answer')}</RethinkLabel>
<FlippedReturnIcon />
Expand Down
4 changes: 4 additions & 0 deletions static/app/components/events/autofix/autofixRootCause.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ function CopyRootCauseButton({
text={text}
borderless
title="Copy root cause as Markdown"
analyticsEventName="Autofix: Copy Root Cause as Markdown"
analyticsEventKey="autofix.root_cause.copy"
/>
);
}
Expand Down Expand Up @@ -245,6 +247,8 @@ function AutofixRootCauseDisplay({
borderless
title={t('Chat with Seer')}
onClick={handleSelectDescription}
analyticsEventName="Autofix: Root Cause Chat"
analyticsEventKey="autofix.root_cause.chat"
>
<IconChat size="xs" />
</ChatButton>
Expand Down
55 changes: 45 additions & 10 deletions static/app/components/events/autofix/autofixSolution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {Timeline} from 'sentry/components/timeline';
import {IconAdd, IconChat, IconFix} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mistake?

import {singleLineRenderer} from 'sentry/utils/marked/marked';
import {valueIsEqual} from 'sentry/utils/object/valueIsEqual';
import {setApiQueryData, useMutation, useQueryClient} from 'sentry/utils/queryClient';
Expand Down Expand Up @@ -305,6 +306,8 @@ function CopySolutionButton({
text={text}
borderless
title="Copy solution as Markdown"
analyticsEventName="Autofix: Copy Solution as Markdown"
analyticsEventKey="autofix.solution.copy"
/>
);
}
Expand All @@ -320,6 +323,8 @@ function AutofixSolutionDisplay({
solutionSelected,
agentCommentThread,
}: Omit<AutofixSolutionProps, 'repos'>) {
const organization = useOrganization();

const {repos} = useAutofixRepos(groupId);
const {mutate: handleContinue, isPending} = useSelectSolution({groupId, runId});
const [isEditing, _setIsEditing] = useState(false);
Expand Down Expand Up @@ -367,6 +372,12 @@ function AutofixSolutionDisplay({

// Clear the input
setInstructions('');

trackAnalytics('autofix.solution.add_step', {
organization,
solution: solutionItems,
newStep,
});
}
};

Expand All @@ -375,17 +386,37 @@ function AutofixSolutionDisplay({
handleAddInstruction();
};

const handleDeleteItem = useCallback((index: number) => {
setSolutionItems(current => current.filter((_, i) => i !== index));
}, []);
const handleDeleteItem = useCallback(
(index: number) => {
setSolutionItems(current => current.filter((_, i) => i !== index));

const handleToggleActive = useCallback((index: number) => {
setSolutionItems(current =>
current.map((item, i) =>
i === index ? {...item, is_active: item.is_active === false ? true : false} : item
)
);
}, []);
trackAnalytics('autofix.solution.delete_step', {
organization,
solution: solutionItems,
deletedStep: solutionItems[index],
});
},
[organization, solutionItems]
);

const handleToggleActive = useCallback(
(index: number) => {
setSolutionItems(current =>
current.map((item, i) =>
i === index
? {...item, is_active: item.is_active === false ? true : false}
: item
)
);

trackAnalytics('autofix.solution.toggle_step', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name should probably be more clear that this is disabling the agent's step vs deleting the human's own step

organization,
solution: solutionItems,
toggledStep: solutionItems[index],
});
},
[organization, solutionItems]
);

useEffect(() => {
setSolutionItems(
Expand Down Expand Up @@ -439,6 +470,8 @@ function AutofixSolutionDisplay({
borderless
title={t('Chat with Seer')}
onClick={handleSelectDescription}
analyticsEventName="Autofix: Solution Chat"
analyticsEventKey="autofix.solution.chat"
>
<IconChat size="xs" />
</ChatButton>
Expand Down Expand Up @@ -476,6 +509,8 @@ function AutofixSolutionDisplay({
solution: solutionItems,
});
}}
analyticsEventName="Autofix: Code It Up"
analyticsEventKey="autofix.solution.code"
>
{t('Code It Up')}
</Button>
Expand Down
8 changes: 8 additions & 0 deletions static/app/components/group/groupSummaryWithAutofix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ interface InsightCardObject {
id: string;
insight: string | null | undefined;
title: string;
copyAnalyticsEventKey?: string;
copyAnalyticsEventName?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this doing?

copyText?: string | null;
copyTitle?: string | null;
icon?: React.ReactNode;
Expand Down Expand Up @@ -175,6 +177,8 @@ function AutofixSummary({
},
copyTitle: t('Copy root cause as Markdown'),
copyText: rootCauseCopyText,
copyAnalyticsEventName: 'Autofix: Copy Root Cause as Markdown',
copyAnalyticsEventKey: 'autofix.root_cause.copy',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this doing?

},

...(solutionDescription || solutionIsLoading
Expand All @@ -200,6 +204,8 @@ function AutofixSummary({
},
copyTitle: t('Copy solution as Markdown'),
copyText: solutionCopyText,
copyAnalyticsEventName: 'Autofix: Copy Solution as Markdown',
copyAnalyticsEventKey: 'autofix.solution.copy',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this doing?

},
]
: []),
Expand Down Expand Up @@ -256,6 +262,8 @@ function AutofixSummary({
onClick={e => {
e.stopPropagation();
}}
analyticsEventName={card.copyAnalyticsEventName}
analyticsEventKey={card.copyAnalyticsEventKey}
/>
)}
</CardTitle>
Expand Down
Loading