Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(error-tracking): open suppression dialog without query delay (#127459)

Aleksander Błaszkiewicz279b62831eec
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 38fcc86289d6..867a8a706384 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11370,10 +11370,14 @@ snapshots:
hash: v1.k794b7964.71fdce87c3009faea6dd25e6ac817d5790ffed494cb15d66a7043b4ebe90cb60.rYWzblIjD-Ceyh15tkUkDm10Pu7exKRUm9n9TsB9B0Q
scenes-app-errortracking-linkedreports--several-reports-across-states--light:
hash: v1.k794b7964.fe2161a3bb0e898689ef58a342d071c353ded71ac270a62998ea566055359e7a.AnoCs1sNoTY6J1yl24yuZPh_1Jkjugz-jnYxHgY8ZyU
+ scenes-app-errortracking-suppress-similar-issues-dialog--exact-message--dark:
+ hash: v1.k794b7964.84152ff066dc338cda47d926eb98d8ab94ad78875110b82b89c30147724c5a86.P-Z6JrxVkTel_pZXRwNiMPT6ClPcSSUfXk0vdxDauhI
+ scenes-app-errortracking-suppress-similar-issues-dialog--exact-message--light:
+ hash: v1.k794b7964.186b06b71c9a272537d135916f222ece3b2add909775f590a353091cb5be9dbf.EM9tFQNEVw3XSDiM67SvaJvoajRMpuEQsdC4GPH6M7c
scenes-app-errortracking-suppress-similar-issues-dialog--similar-messages--dark:
- hash: v1.k794b7964.3ece4edd55a0d626d268292993aadd6a909e6ad03cfb897d741bebda266790d6.a8rVBPiF6wrk6YAIKne9ABrV3NLalDP0EJjQQ9mZyeM
+ hash: v1.k794b7964.67d200abd3ff3bfb28f4c100e0af0f19171901798c2950bb2e78e5ddead7f296.7If2ww1CIlii1cnRqWF1RYUV5Hn-kyPrHFlr2uq7Cus
scenes-app-errortracking-suppress-similar-issues-dialog--similar-messages--light:
- hash: v1.k794b7964.8328c04966ba5a6b33fe31dede3262184b0cfa19ebb7f4e5c4bf6d052fd2a829.KKd1GJ0I_20JnUEE7ik1rNIhu_U2pREp86C629xT_fU
+ hash: v1.k794b7964.9c138dda354b1e862384532513a3b87d9272918e470b1566c310fdc915ffed69.U4gwd2pVziHHKFMchBir4Z36jdVeQ8A6tS9Fb8zwq20
scenes-app-etl--healthy--dark:
hash: v1.k794b7964.af47a2089a0e96523319000942dcf95855be7e7308011501bbfb31b622ae9e1a.-e6qEOIGiP6o9vjiFSABwNrwon1CD8l1RQSIlICCxX0
scenes-app-etl--healthy--light:
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx
index 3f9dc08e9a0d..4f399d56efa0 100644
--- a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx
@@ -18,11 +18,11 @@ const SUPPRESSED_ISSUES: SuppressedIssueSnapshot[] = [
{ id: 'http-503', exceptionType: 'Error', exceptionMessage: 'Request failed with status code 503' },
]
-function OpenDialog(): JSX.Element {
+function OpenDialog({ snapshots = SUPPRESSED_ISSUES }: { snapshots?: SuppressedIssueSnapshot[] }): JSX.Element {
const logic = useMountedLogic(suppressSimilarIssuesLogic)
useLayoutEffect(() => {
- logic.actions.openSuggestion(SUPPRESSED_ISSUES)
- }, [logic])
+ logic.actions.openSuggestion(snapshots)
+ }, [logic, snapshots])
return <SuppressSimilarIssuesDialog />
}
@@ -51,3 +51,9 @@ export default meta
type Story = StoryObj<{}>
export const SimilarMessages: Story = { render: () => <OpenDialog /> }
+
+export const ExactMessage: Story = {
+ render: () => (
+ <OpenDialog snapshots={[{ id: 'network-error', exceptionType: 'Error', exceptionMessage: 'Network error' }]} />
+ ),
+}
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx
index 1450a88b8254..a009578b4efb 100644
--- a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx
@@ -16,16 +16,19 @@ import {
FieldLegend,
FieldSet,
RadioGroup,
+ Skeleton,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'lib/ui/quill'
+import { pluralize } from 'lib/utils/strings'
import {
CLIENT_RULE_PUBLIC_NOTE,
getEvalMode,
} from '../../scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator'
import { errorTrackingEditAccessDisabledReason } from '../../utils'
+import { MessagePattern } from './MessagePattern'
import { SuppressScopeChoice } from './SuppressScopeChoice'
import { suppressSimilarIssuesLogic } from './suppressSimilarIssuesLogic'
import { SuppressScopeKey } from './suppressSimilarScopes'
@@ -34,9 +37,11 @@ export function SuppressSimilarIssuesDialog(): JSX.Element {
const {
isOpen,
snapshots,
+ snapshotsLoading,
scopeOptions,
selectedScope,
selectedOption,
+ selectedImpact,
scopeImpacts,
scopeImpactsLoading,
createdRulesLoading,
@@ -54,57 +59,86 @@ export function SuppressSimilarIssuesDialog(): JSX.Element {
<Dialog open={isOpen} onOpenChange={(open) => !open && dismissSuggestion()}>
<DialogContent>
<DialogHeader>
- <DialogTitle>Suppress similar exceptions?</DialogTitle>
+ <DialogTitle>Suppress future exceptions?</DialogTitle>
<DialogDescription>
{multiple
- ? `These ${snapshots.length} issues are suppressed, but similar exceptions can still open new issues. Choose which ones to drop too.`
- : 'This issue is suppressed, but similar exceptions can still open new issues. Choose which ones to drop too.'}
+ ? `These ${snapshots.length} issues are suppressed. You can also drop new exceptions with matching messages.`
+ : 'This issue is suppressed. You can also drop new exceptions with a matching message.'}
</DialogDescription>
</DialogHeader>
<DialogBody>
- <FieldSet>
- <FieldLegend variant="label" className="flex w-full items-center justify-between gap-2">
- <span>Drop new exceptions that match</span>
- {runsInSdk && (
- <span className="flex items-center gap-1">
- <Badge variant="success">
- <IconLaptop />
- Client
- </Badge>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="default"
- size="icon-xs"
- aria-label="Who can read this rule"
- data-attr="error-tracking-suppress-similar-public-note"
- />
- }
- >
- <IconInfo />
- </TooltipTrigger>
- <TooltipContent className="max-w-xs">{CLIENT_RULE_PUBLIC_NOTE}</TooltipContent>
- </Tooltip>
- </span>
+ {snapshotsLoading ? (
+ <div role="status" aria-label="Loading exception messages" className="flex flex-col gap-3">
+ <Skeleton className="h-5 w-48" />
+ <Skeleton className="h-10 w-full" />
+ </div>
+ ) : (
+ <FieldSet>
+ <FieldLegend variant="label" className="flex w-full items-center justify-between gap-2">
+ <span>Messages to drop</span>
+ {runsInSdk && (
+ <span className="flex items-center gap-1">
+ <Badge variant="success">
+ <IconLaptop />
+ Client
+ </Badge>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="default"
+ size="icon-xs"
+ aria-label="Who can read this rule"
+ data-attr="error-tracking-suppress-similar-public-note"
+ />
+ }
+ >
+ <IconInfo />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ {CLIENT_RULE_PUBLIC_NOTE}
+ </TooltipContent>
+ </Tooltip>
+ </span>
+ )}
+ </FieldLegend>
+ {scopeOptions.length > 1 ? (
+ <RadioGroup
+ value={selectedScope}
+ onValueChange={(scope) => selectScope(scope as SuppressScopeKey)}
+ className="gap-2"
+ aria-label="Messages to drop"
+ >
+ {scopeOptions.map((option) => (
+ <SuppressScopeChoice
+ key={option.key}
+ option={option}
+ title={titles[option.key]}
+ impact={scopeImpacts?.[option.key]}
+ impactLoading={scopeImpactsLoading}
+ />
+ ))}
+ </RadioGroup>
+ ) : (
+ <>
+ <div className="flex flex-wrap gap-1">
+ {selectedOption?.messages.map((segments, index) => (
+ <MessagePattern key={index} segments={segments} />
+ ))}
+ </div>
+ {scopeImpactsLoading ? (
+ <Skeleton className="h-4 w-44" />
+ ) : (
+ <p className="m-0 text-sm text-secondary">
+ {selectedImpact
+ ? `${pluralize(selectedImpact.exceptions, 'exception')} across ${pluralize(selectedImpact.issueCount, 'issue')} in the last 7 days`
+ : "Couldn't count matching exceptions"}
+ </p>
+ )}
+ </>
)}
- </FieldLegend>
- <RadioGroup
- value={selectedScope}
- onValueChange={(scope) => selectScope(scope as SuppressScopeKey)}
- className="gap-2"
- >
- {scopeOptions.map((option) => (
- <SuppressScopeChoice
- key={option.key}
- option={option}
- title={titles[option.key]}
- impact={scopeImpacts?.[option.key]}
- impactLoading={scopeImpactsLoading}
- />
- ))}
- </RadioGroup>
- </FieldSet>
+ </FieldSet>
+ )}
</DialogBody>
<DialogFooter>
<DialogClose
@@ -118,11 +152,11 @@ export function SuppressSimilarIssuesDialog(): JSX.Element {
loading={createdRulesLoading}
disabledReason={
errorTrackingEditAccessDisabledReason() ??
- (selectedOption ? undefined : 'Choose which exceptions to drop')
+ (selectedOption ? undefined : 'Loading exception messages')
}
data-attr="error-tracking-suppress-similar-create"
>
- Suppress similar
+ Create rule
</Button>
</DialogFooter>
</DialogContent>
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts
index 641078071d9c..71f779d4b15b 100644
--- a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts
@@ -8,6 +8,7 @@ import { initKeaTests } from '~/test/init'
import type { TeamType } from '~/types'
import { errorTrackingSuppressionRulesCreate } from '../../generated/api'
+import { issueActionsLogic } from '../IssueActions/issueActionsLogic'
import { suppressSimilarIssuesLogic } from './suppressSimilarIssuesLogic'
jest.mock('../../generated/api', () => ({
@@ -23,6 +24,8 @@ describe('suppressSimilarIssuesLogic', () => {
beforeEach(() => {
initKeaTests(true, CHILD_ENVIRONMENT)
+ jest.spyOn(api.errorTracking, 'updateIssue').mockResolvedValue({} as never)
+ jest.spyOn(api.errorTracking, 'bulkMarkStatus').mockResolvedValue({} as never)
jest.spyOn(api, 'query').mockResolvedValue({ results: [[0, 0]] } as never)
mockSuppressionRulesCreate.mockResolvedValue({} as never)
logic = suppressSimilarIssuesLogic()
@@ -48,4 +51,103 @@ describe('suppressSimilarIssuesLogic', () => {
expect.objectContaining({ sampling_rate: 1 })
)
})
+
+ it.each(['single', 'bulk'] as const)(
+ 'opens after %s suppression before the message query returns',
+ async (mode) => {
+ let finishQuery!: (response: { results: [string, string, string][] }) => void
+ jest.spyOn(api, 'queryHogQL').mockImplementation(
+ () =>
+ new Promise((resolve) => {
+ finishQuery = resolve
+ }) as never
+ )
+
+ await expectLogic(logic, () => {
+ if (mode === 'single') {
+ issueActionsLogic.actions.updateIssueStatus('issue-1', 'suppressed')
+ } else {
+ issueActionsLogic.actions.suppressIssues(['issue-1'])
+ }
+ }).toDispatchActions(['loadSnapshots'])
+
+ expect(logic.values.isOpen).toBe(true)
+ expect(logic.values.snapshotsLoading).toBe(true)
+ expect(logic.values.selectedOption).toBeNull()
+
+ await expectLogic(logic, () => {
+ finishQuery({ results: [['issue-1', '["Error"]', '["Network error"]']] })
+ }).toDispatchActions(['openSuggestion'])
+
+ expect(logic.values.snapshotsLoading).toBe(false)
+ expect(logic.values.scopeOptions.map((option) => option.key)).toEqual(['exact'])
+ expect(logic.values.selectedScope).toBe('exact')
+ }
+ )
+
+ it('does not reopen a dismissed dialog when the message query returns', async () => {
+ let finishQuery!: (response: { results: [string, string, string][] }) => void
+ jest.spyOn(api, 'queryHogQL').mockImplementation(
+ () =>
+ new Promise((resolve) => {
+ finishQuery = resolve
+ }) as never
+ )
+ logic.actions.loadSnapshots(['issue-1'])
+ logic.actions.dismissSuggestion()
+
+ await expectLogic(logic, () => {
+ finishQuery({ results: [['issue-1', '["Error"]', '["Timeout after 3000ms"]']] })
+ }).toDispatchActions(['loadSnapshotsSuccess'])
+
+ expect(logic.values.isOpen).toBe(false)
+ })
+
+ it('keeps a newer dialog open when an older message query fails', async () => {
+ let rejectFirstQuery!: (error: Error) => void
+ jest.spyOn(api, 'queryHogQL')
+ .mockImplementationOnce(
+ () =>
+ new Promise((_, reject) => {
+ rejectFirstQuery = reject
+ }) as never
+ )
+ .mockResolvedValueOnce({ results: [['issue-2', '["Error"]', '["Network error"]']] } as never)
+ logic.actions.loadSnapshots(['issue-1'])
+ logic.actions.dismissSuggestion()
+
+ await expectLogic(logic, () => {
+ logic.actions.loadSnapshots(['issue-2'])
+ }).toDispatchActions(['openSuggestion'])
+
+ await expectLogic(logic, () => {
+ rejectFirstQuery(new Error('Message query failed'))
+ }).toFinishAllListeners()
+
+ expect(logic.values.isOpen).toBe(true)
+ expect(logic.values.snapshots[0].id).toBe('issue-2')
+ })
+
+ it('closes when the issue has no exception message', async () => {
+ jest.spyOn(api, 'queryHogQL').mockResolvedValue({ results: [['issue-1', '["Error"]', '[]']] } as never)
+
+ await expectLogic(logic, () => {
+ logic.actions.loadSnapshots(['issue-1'])
+ }).toDispatchActions(['closeSuggestion'])
+
+ expect(logic.values.isOpen).toBe(false)
+ expect(logic.values.selectedOption).toBeNull()
+ })
+
+ it('does not offer suppression rules when the status update fails', async () => {
+ jest.spyOn(api.errorTracking, 'updateIssue').mockRejectedValue(new Error('Status update failed'))
+ const query = jest.spyOn(api, 'queryHogQL')
+
+ await expectLogic(issueActionsLogic, () => {
+ issueActionsLogic.actions.updateIssueStatus('issue-1', 'suppressed')
+ }).toDispatchActions(['mutationFailure'])
+
+ expect(logic.values.isOpen).toBe(false)
+ expect(query).not.toHaveBeenCalled()
+ })
})
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
index 1254749791a3..af4bbc87ee55 100644
--- a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
@@ -75,6 +75,7 @@ export interface suppressSimilarIssuesLogicValues {
selectedOption: SuppressScopeOption | null
selectedScope: SuppressScopeKey | null
snapshots: SuppressedIssueSnapshot[]
+ snapshotsLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -141,6 +142,21 @@ export interface suppressSimilarIssuesLogicActions {
scopeImpacts: Partial<Record<SuppressScopeKey, ScopeImpact>>
payload?: void
}
+ loadSnapshots: (ids: string[]) => string[]
+ loadSnapshotsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSnapshotsSuccess: (
+ snapshots: SuppressedIssueSnapshot[],
+ payload?: string[]
+ ) => {
+ snapshots: SuppressedIssueSnapshot[]
+ payload?: string[]
+ }
openSuggestion: (snapshots: SuppressedIssueSnapshot[]) => {
scope: SuppressScopeKey | null
snapshots: SuppressedIssueSnapshot[]
@@ -205,12 +221,19 @@ export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
}),
reducers({
- isOpen: [false, { openSuggestion: () => true, closeSuggestion: () => false }],
+ isOpen: [false, { loadSnapshots: () => true, openSuggestion: () => true, closeSuggestion: () => false }],
// Kept after close so the dialog does not go blank while it animates out.
- snapshots: [[] as SuppressedIssueSnapshot[], { openSuggestion: (_, { snapshots }) => snapshots }],
+ snapshots: [
+ [] as SuppressedIssueSnapshot[],
+ {
+ loadSnapshots: (_, ids) => ids.map((id) => ({ id, exceptionType: null, exceptionMessage: null })),
+ openSuggestion: (_, { snapshots }) => snapshots,
+ },
+ ],
selectedScope: [
null as SuppressScopeKey | null,
{
+ loadSnapshots: () => null,
openSuggestion: (_, { scope }) => scope,
selectScope: (_, { scope }) => scope,
},
@@ -219,6 +242,19 @@ export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
// Before selectors, because selectedImpact reads scopeImpacts.
loaders(({ values, cache }) => ({
+ snapshots: [
+ [] as SuppressedIssueSnapshot[],
+ {
+ loadSnapshots: async (ids: string[], breakpoint): Promise<SuppressedIssueSnapshot[]> => {
+ const snapshots = await loadIssueSnapshots(ids).catch((error: unknown) => {
+ breakpoint()
+ throw error
+ })
+ breakpoint()
+ return snapshots
+ },
+ },
+ ],
scopeImpacts: [
null as ScopeImpacts | null,
{
@@ -261,7 +297,11 @@ export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
})),
selectors({
- scopeOptions: [(s) => [s.snapshots], (snapshots: SuppressedIssueSnapshot[]) => buildScopeOptions(snapshots)],
+ scopeOptions: [
+ (s) => [s.snapshots],
+ (snapshots: SuppressedIssueSnapshot[]) =>
+ buildScopeOptions(snapshots).filter((option) => !option.unavailableReason),
+ ],
selectedOption: [
(s) => [s.scopeOptions, s.selectedScope],
(scopeOptions: SuppressScopeOption[], selectedScope: SuppressScopeKey | null): SuppressScopeOption | null =>
@@ -275,7 +315,6 @@ export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
}),
listeners(({ actions, values, cache }) => {
- // The dialog opens only after the suppression request succeeds, so it never offers a rule for a failed one.
const matchesPending = (mutationName: string, issueId: string | undefined): boolean => {
const pending: PendingSuppression | undefined = cache.pendingSuppression
return (
@@ -299,24 +338,31 @@ export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
cache.pendingSuppression = undefined
}
},
- mutationSuccess: async ({ mutationName, issueId }, breakpoint) => {
+ mutationSuccess: ({ mutationName, issueId }) => {
if (!matchesPending(mutationName, issueId)) {
return
}
const { ids } = cache.pendingSuppression as PendingSuppression
cache.pendingSuppression = undefined
- let snapshots: SuppressedIssueSnapshot[]
- try {
- snapshots = await loadIssueSnapshots(ids)
- } catch (error) {
- posthog.captureException(error)
- return
- }
- breakpoint()
- if (recommendedScope(buildScopeOptions(snapshots))) {
- actions.openSuggestion(snapshots)
+ actions.loadSnapshots(ids)
+ },
+ loadSnapshots: () => {
+ actions.resetScopeImpacts()
+ actions.loadScopeImpacts()
+ },
+ loadSnapshotsSuccess: ({ snapshots }) => {
+ if (values.isOpen) {
+ if (recommendedScope(buildScopeOptions(snapshots))) {
+ actions.openSuggestion(snapshots)
+ } else {
+ actions.closeSuggestion()
+ }
}
},
+ loadSnapshotsFailure: ({ errorObject }) => {
+ posthog.captureException(errorObject)
+ actions.closeSuggestion()
+ },
openSuggestion: ({ snapshots, scope }) => {
cache.createdRules = undefined
posthog.capture('error_tracking_suppress_similar_shown', {