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.

feat(error-tracking): suggest a rule when an issue is suppressed (#121921)

Aleksander Błaszkiewiczddd5664f64bb
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6953316590aa..4cf841b12641 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11044,6 +11044,10 @@ 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--similar-messages--dark:
+ hash: v1.k794b7964.3ece4edd55a0d626d268292993aadd6a909e6ad03cfb897d741bebda266790d6.a8rVBPiF6wrk6YAIKne9ABrV3NLalDP0EJjQQ9mZyeM
+ scenes-app-errortracking-suppress-similar-issues-dialog--similar-messages--light:
+ hash: v1.k794b7964.8328c04966ba5a6b33fe31dede3262184b0cfa19ebb7f4e5c4bf6d052fd2a829.KKd1GJ0I_20JnUEE7ik1rNIhu_U2pREp86C629xT_fU
scenes-app-etl--healthy--dark:
hash: v1.k794b7964.342346c35b32e21a02a09fe488480c9d100dbfda52c5b7c6b8dac3d2f83f3cf2.conExopWBDSppCq6BcJkzZ7MFg2JFCvBC0FF5QDc_xs
scenes-app-etl--healthy--light:
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/MessagePattern.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/MessagePattern.tsx
new file mode 100644
index 000000000000..faa72b6f1ff1
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/MessagePattern.tsx
@@ -0,0 +1,27 @@
+import { MessageSegment, MessageSegmentKind } from './suppressSimilarScopes'
+
+const PLACEHOLDER_LABELS: Record<Exclude<MessageSegmentKind, 'literal'>, string> = {
+ number: 'number',
+ id: 'ID',
+ hex: 'hash',
+}
+
+// It uses app surface tokens, because the web app's own `--muted` overrides quill's inside the dialog portal.
+export function MessagePattern({ segments }: { segments: MessageSegment[] }): JSX.Element {
+ return (
+ <code className="w-fit rounded-sm border border-primary bg-surface-secondary px-1 font-mono text-xs break-all">
+ {segments.map((segment, index) =>
+ segment.kind === 'literal' ? (
+ <span key={index}>{segment.text}</span>
+ ) : (
+ <span
+ key={index}
+ className="mx-px rounded-xs bg-accent-highlight-secondary px-0.5 font-sans text-xxs text-accent"
+ >
+ {PLACEHOLDER_LABELS[segment.kind]}
+ </span>
+ )
+ )}
+ </code>
+ )
+}
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressScopeChoice.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressScopeChoice.tsx
new file mode 100644
index 000000000000..f77d14fecf87
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressScopeChoice.tsx
@@ -0,0 +1,51 @@
+import { Field, FieldContent, FieldDescription, FieldLabel, FieldTitle, RadioGroupItem, Skeleton } from 'lib/ui/quill'
+import { pluralize } from 'lib/utils/strings'
+
+import { MessagePattern } from './MessagePattern'
+import { ScopeImpact, SuppressScopeOption } from './suppressSimilarScopes'
+
+export interface SuppressScopeChoiceProps {
+ option: SuppressScopeOption
+ title: string
+ impact: ScopeImpact | undefined
+ impactLoading: boolean
+}
+
+export function SuppressScopeChoice({ option, title, impact, impactLoading }: SuppressScopeChoiceProps): JSX.Element {
+ const id = `suppress-similar-scope-${option.key}`
+ const unavailable = !!option.unavailableReason
+
+ return (
+ <FieldLabel htmlFor={id} className="w-full">
+ <Field orientation="horizontal" data-disabled={unavailable}>
+ <FieldContent className="min-w-0 gap-1.5">
+ <FieldTitle>{title}</FieldTitle>
+ {!unavailable && option.messages.length > 0 && (
+ <span className="flex flex-wrap gap-1">
+ {option.messages.map((segments, index) => (
+ <MessagePattern key={index} segments={segments} />
+ ))}
+ </span>
+ )}
+ {unavailable ? (
+ <FieldDescription className="m-0">{option.unavailableReason}</FieldDescription>
+ ) : impactLoading ? (
+ <Skeleton className="h-4 w-44" />
+ ) : impact ? (
+ <FieldDescription className="m-0">
+ {`${pluralize(impact.exceptions, 'exception')} across ${pluralize(impact.issueCount, 'issue')} in the last 7 days`}
+ </FieldDescription>
+ ) : (
+ <FieldDescription className="m-0">Couldn't count matching exceptions</FieldDescription>
+ )}
+ </FieldContent>
+ <RadioGroupItem
+ value={option.key}
+ id={id}
+ disabled={unavailable}
+ data-attr={`error-tracking-suppress-similar-scope-${option.key}`}
+ />
+ </Field>
+ </FieldLabel>
+ )
+}
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx
new file mode 100644
index 000000000000..3f9dc08e9a0d
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.stories.tsx
@@ -0,0 +1,53 @@
+import { Meta, StoryObj } from '@storybook/react'
+import { useMountedLogic } from 'kea'
+import { useLayoutEffect } from 'react'
+
+import { mswDecorator } from '~/mocks/browser'
+import { NodeKind } from '~/queries/schema/schema-general'
+
+import { SuppressSimilarIssuesDialog } from './SuppressSimilarIssuesDialog'
+import { suppressSimilarIssuesLogic } from './suppressSimilarIssuesLogic'
+import { SuppressedIssueSnapshot, SuppressionEventFilter } from './suppressSimilarScopes'
+
+const IMPACT_BY_MESSAGE_OPERATOR: Record<string, [exceptions: number, issues: number]> = {
+ exact: [40, 1],
+ regex: [71, 3],
+}
+
+const SUPPRESSED_ISSUES: SuppressedIssueSnapshot[] = [
+ { id: 'http-503', exceptionType: 'Error', exceptionMessage: 'Request failed with status code 503' },
+]
+
+function OpenDialog(): JSX.Element {
+ const logic = useMountedLogic(suppressSimilarIssuesLogic)
+ useLayoutEffect(() => {
+ logic.actions.openSuggestion(SUPPRESSED_ISSUES)
+ }, [logic])
+ return <SuppressSimilarIssuesDialog />
+}
+
+const meta: Meta = {
+ title: 'Scenes-App/ErrorTracking/Suppress similar issues dialog',
+ parameters: { layout: 'fullscreen', viewMode: 'story' },
+ decorators: [
+ mswDecorator({
+ post: {
+ '/api/environments/:team_id/query/:kind/': async ({ request }) => {
+ const body = (await request.json()) as {
+ query?: { kind?: string; fixedProperties?: { values: SuppressionEventFilter[] }[] }
+ }
+ const messageFilter = body.query?.fixedProperties?.[0]?.values.find(
+ (filter) => filter.key === '$exception_values'
+ )
+ const impact = messageFilter?.operator ? IMPACT_BY_MESSAGE_OPERATOR[messageFilter.operator] : null
+ return [200, { results: body.query?.kind === NodeKind.EventsQuery && impact ? [impact] : [] }]
+ },
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+export const SimilarMessages: Story = { render: () => <OpenDialog /> }
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx
new file mode 100644
index 000000000000..1450a88b8254
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog.tsx
@@ -0,0 +1,131 @@
+import { useActions, useValues } from 'kea'
+
+import { IconInfo, IconLaptop } from '@posthog/icons'
+
+import {
+ Badge,
+ Button,
+ Dialog,
+ DialogBody,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ FieldLegend,
+ FieldSet,
+ RadioGroup,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from 'lib/ui/quill'
+
+import {
+ CLIENT_RULE_PUBLIC_NOTE,
+ getEvalMode,
+} from '../../scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator'
+import { errorTrackingEditAccessDisabledReason } from '../../utils'
+import { SuppressScopeChoice } from './SuppressScopeChoice'
+import { suppressSimilarIssuesLogic } from './suppressSimilarIssuesLogic'
+import { SuppressScopeKey } from './suppressSimilarScopes'
+
+export function SuppressSimilarIssuesDialog(): JSX.Element {
+ const {
+ isOpen,
+ snapshots,
+ scopeOptions,
+ selectedScope,
+ selectedOption,
+ scopeImpacts,
+ scopeImpactsLoading,
+ createdRulesLoading,
+ } = useValues(suppressSimilarIssuesLogic)
+ const { selectScope, createRules, dismissSuggestion } = useActions(suppressSimilarIssuesLogic)
+
+ const multiple = snapshots.length > 1
+ const runsInSdk = !!selectedOption?.rules.some((rule) => getEvalMode(rule) !== 'server')
+ const titles: Record<SuppressScopeKey, string> = {
+ exact: multiple ? 'These messages only' : 'This message only',
+ similar: 'Similar messages',
+ }
+
+ return (
+ <Dialog open={isOpen} onOpenChange={(open) => !open && dismissSuggestion()}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Suppress similar 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.'}
+ </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>
+ )}
+ </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>
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose
+ render={<Button variant="outline" data-attr="error-tracking-suppress-similar-dismiss" />}
+ >
+ Not now
+ </DialogClose>
+ <Button
+ variant="primary"
+ onClick={createRules}
+ loading={createdRulesLoading}
+ disabledReason={
+ errorTrackingEditAccessDisabledReason() ??
+ (selectedOption ? undefined : 'Choose which exceptions to drop')
+ }
+ data-attr="error-tracking-suppress-similar-create"
+ >
+ Suppress similar
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts
new file mode 100644
index 000000000000..641078071d9c
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.test.ts
@@ -0,0 +1,51 @@
+import { MOCK_DEFAULT_TEAM, MOCK_TEAM_ID } from 'lib/api.mock'
+
+import { expectLogic } from 'kea-test-utils'
+
+import api from 'lib/api'
+
+import { initKeaTests } from '~/test/init'
+import type { TeamType } from '~/types'
+
+import { errorTrackingSuppressionRulesCreate } from '../../generated/api'
+import { suppressSimilarIssuesLogic } from './suppressSimilarIssuesLogic'
+
+jest.mock('../../generated/api', () => ({
+ errorTrackingSuppressionRulesCreate: jest.fn(),
+}))
+
+const mockSuppressionRulesCreate = jest.mocked(errorTrackingSuppressionRulesCreate)
+
+const CHILD_ENVIRONMENT: TeamType = { ...MOCK_DEFAULT_TEAM, id: MOCK_TEAM_ID + 1, project_id: MOCK_TEAM_ID }
+
+describe('suppressSimilarIssuesLogic', () => {
+ let logic: ReturnType<typeof suppressSimilarIssuesLogic.build>
+
+ beforeEach(() => {
+ initKeaTests(true, CHILD_ENVIRONMENT)
+ jest.spyOn(api, 'query').mockResolvedValue({ results: [[0, 0]] } as never)
+ mockSuppressionRulesCreate.mockResolvedValue({} as never)
+ logic = suppressSimilarIssuesLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ jest.restoreAllMocks()
+ })
+
+ it('creates rules in the current environment, not in its parent project', async () => {
+ logic.actions.openSuggestion([
+ { id: 'issue-1', exceptionType: 'Error', exceptionMessage: 'Request failed with status code 503' },
+ ])
+
+ await expectLogic(logic, () => {
+ logic.actions.createRules()
+ }).toDispatchActions(['createRulesSuccess'])
+
+ expect(mockSuppressionRulesCreate).toHaveBeenCalledWith(
+ String(CHILD_ENVIRONMENT.id),
+ expect.objectContaining({ sampling_rate: 1 })
+ )
+ })
+})
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
new file mode 100644
index 000000000000..2ad8307d9589
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
@@ -0,0 +1,356 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
+import posthog from 'posthog-js'
+
+import api from 'lib/api'
+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { pluralize } from 'lib/utils/strings'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { EventsQuery, NodeKind, ProductKey } from '~/queries/schema/schema-general'
+import { hogql } from '~/queries/utils'
+import { PropertyGroupFilterValue } from '~/types'
+
+import { errorTrackingSuppressionRulesCreate } from '../../generated/api'
+import type { ErrorTrackingSuppressionRuleApi } from '../../generated/api.schemas'
+import { issueActionsLogic } from '../IssueActions/issueActionsLogic'
+import {
+ ScopeImpact,
+ SuppressScopeKey,
+ SuppressScopeOption,
+ SuppressedIssueSnapshot,
+ buildScopeOptions,
+ combinedFilter,
+ recommendedScope,
+ snapshotFromLatestEvent,
+} from './suppressSimilarScopes'
+
+export type ScopeImpacts = Partial<Record<SuppressScopeKey, ScopeImpact>>
+
+interface PendingSuppression {
+ mutationName: 'updateIssueStatus' | 'suppressIssues'
+ ids: string[]
+}
+
+const SUPPRESSION_RULES_URL = `${urls.errorTrackingConfiguration()}#selectedSetting=error-tracking-suppression-rules`
+
+// A person can rename an issue or edit its description, so those labels can stop matching
+// the exceptions a rule must catch. The latest event carries the real type and message.
+async function loadIssueSnapshots(ids: string[]): Promise<SuppressedIssueSnapshot[]> {
+ const response = await api.queryHogQL<[string, unknown, unknown][]>(
+ hogql`SELECT issue_id, argMax(properties.$exception_types, timestamp), argMax(properties.$exception_values, timestamp)
+ FROM events
+ WHERE event = '$exception' AND timestamp > now() - INTERVAL 30 DAY AND has(${ids}, toString(issue_id))
+ GROUP BY issue_id`,
+ { productKey: ProductKey.ERROR_TRACKING }
+ )
+ return response.results.map(snapshotFromLatestEvent)
+}
+
+async function loadImpact(filter: PropertyGroupFilterValue): Promise<ScopeImpact> {
+ const query: EventsQuery = {
+ kind: NodeKind.EventsQuery,
+ event: '$exception',
+ select: ['count()', 'count(distinct issue_id)'],
+ after: '-7d',
+ fixedProperties: [filter],
+ tags: { productKey: ProductKey.ERROR_TRACKING },
+ }
+ const response = await api.query(query)
+ const [exceptions = 0, issueCount = 0] = response.results?.[0] ?? []
+ return { exceptions, issueCount }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface suppressSimilarIssuesLogicValues {
+ createdRules: ErrorTrackingSuppressionRuleApi[] | null
+ createdRulesLoading: boolean
+ isOpen: boolean
+ scopeImpacts: ScopeImpacts | null
+ scopeImpactsLoading: boolean
+ scopeOptions: SuppressScopeOption[]
+ selectedImpact: ScopeImpact | null
+ selectedOption: SuppressScopeOption | null
+ selectedScope: SuppressScopeKey | null
+ snapshots: SuppressedIssueSnapshot[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface suppressSimilarIssuesLogicActions {
+ mutationFailure: (
+ mutationName: string,
+ error: unknown,
+ issueId?: string | undefined
+ ) => {
+ error: unknown
+ issueId: string | undefined
+ mutationName: string
+ } // issueActionsLogic
+ mutationSuccess: (
+ mutationName: string,
+ issueId?: string | undefined
+ ) => {
+ issueId: string | undefined
+ mutationName: string
+ } // issueActionsLogic
+ suppressIssues: (ids: string[]) => {
+ ids: string[]
+ } // issueActionsLogic
+ updateIssueStatus: (
+ id: string,
+ status: import('~/queries/schema').ErrorTrackingIssueStatus
+ ) => {
+ id: string
+ status: import('~/queries/schema').ErrorTrackingIssueStatus
+ } // issueActionsLogic
+ closeSuggestion: () => {
+ value: true
+ }
+ createRules: () => any
+ createRulesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ createRulesSuccess: (
+ createdRules: ErrorTrackingSuppressionRuleApi[] | null,
+ payload?: any
+ ) => {
+ createdRules: ErrorTrackingSuppressionRuleApi[] | null
+ payload?: any
+ }
+ dismissSuggestion: () => {
+ value: true
+ }
+ loadScopeImpacts: (_: void) => void
+ loadScopeImpactsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadScopeImpactsSuccess: (
+ scopeImpacts: Partial<Record<SuppressScopeKey, ScopeImpact>>,
+ payload?: void
+ ) => {
+ scopeImpacts: Partial<Record<SuppressScopeKey, ScopeImpact>>
+ payload?: void
+ }
+ openSuggestion: (snapshots: SuppressedIssueSnapshot[]) => {
+ scope: SuppressScopeKey | null
+ snapshots: SuppressedIssueSnapshot[]
+ }
+ resetScopeImpacts: () => any
+ resetScopeImpactsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ resetScopeImpactsSuccess: (
+ scopeImpacts: null,
+ payload?: any
+ ) => {
+ scopeImpacts: null
+ payload?: any
+ }
+ selectScope: (scope: SuppressScopeKey) => {
+ scope: SuppressScopeKey
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface suppressSimilarIssuesLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ scopeOptions: (snapshots: SuppressedIssueSnapshot[]) => SuppressScopeOption[]
+ selectedOption: (
+ scopeOptions: SuppressScopeOption[],
+ selectedScope: SuppressScopeKey | null
+ ) => SuppressScopeOption | null
+ selectedImpact: (
+ scopeImpacts: Partial<Record<SuppressScopeKey, ScopeImpact>> | null,
+ selectedScope: SuppressScopeKey | null
+ ) => ScopeImpact | null
+ }
+}
+
+export type suppressSimilarIssuesLogicType = MakeLogicType<
+ suppressSimilarIssuesLogicValues,
+ suppressSimilarIssuesLogicActions,
+ Record<string, any>,
+ suppressSimilarIssuesLogicMeta
+>
+
+export const suppressSimilarIssuesLogic = kea<suppressSimilarIssuesLogicType>([
+ path(['products', 'error_tracking', 'components', 'SuppressSimilarIssues', 'suppressSimilarIssuesLogic']),
+
+ connect(() => ({
+ actions: [issueActionsLogic, ['updateIssueStatus', 'suppressIssues', 'mutationSuccess', 'mutationFailure']],
+ })),
+
+ actions({
+ openSuggestion: (snapshots: SuppressedIssueSnapshot[]) => ({
+ snapshots,
+ scope: recommendedScope(buildScopeOptions(snapshots)),
+ }),
+ selectScope: (scope: SuppressScopeKey) => ({ scope }),
+ dismissSuggestion: true,
+ closeSuggestion: true,
+ }),
+
+ reducers({
+ isOpen: [false, { openSuggestion: () => true, closeSuggestion: () => false }],
+ // Kept after close so the dialog does not go blank while it animates out.
+ snapshots: [[] as SuppressedIssueSnapshot[], { openSuggestion: (_, { snapshots }) => snapshots }],
+ selectedScope: [
+ null as SuppressScopeKey | null,
+ {
+ openSuggestion: (_, { scope }) => scope,
+ selectScope: (_, { scope }) => scope,
+ },
+ ],
+ }),
+
+ // Before selectors, because selectedImpact reads scopeImpacts.
+ loaders(({ values, cache }) => ({
+ scopeImpacts: [
+ null as ScopeImpacts | null,
+ {
+ resetScopeImpacts: () => null,
+ loadScopeImpacts: async (_: void, breakpoint): Promise<ScopeImpacts> => {
+ await breakpoint(100)
+ const available = values.scopeOptions.filter((option) => !option.unavailableReason)
+ const impacts = await Promise.all(
+ available.map(async (option) => [option.key, await loadImpact(combinedFilter(option))] as const)
+ )
+ breakpoint()
+ return Object.fromEntries(impacts)
+ },
+ },
+ ],
+ createdRules: [
+ null as ErrorTrackingSuppressionRuleApi[] | null,
+ {
+ createRules: async () => {
+ if (!values.selectedOption) {
+ return null
+ }
+ // The rules route reads this ID as the environment, as the rest of the rules UI does.
+ const teamId = String(teamLogic.values.currentTeamIdStrict)
+ // When a request fails part way, a retry must not create the earlier rules a second time.
+ const created: Map<string, ErrorTrackingSuppressionRuleApi> = (cache.createdRules ??= new Map())
+ for (const filters of values.selectedOption.rules) {
+ const key = JSON.stringify(filters)
+ if (!created.has(key)) {
+ created.set(
+ key,
+ await errorTrackingSuppressionRulesCreate(teamId, { filters, sampling_rate: 1 })
+ )
+ }
+ }
+ return values.selectedOption.rules.map((filters) => created.get(JSON.stringify(filters))!)
+ },
+ },
+ ],
+ })),
+
+ selectors({
+ scopeOptions: [(s) => [s.snapshots], (snapshots: SuppressedIssueSnapshot[]) => buildScopeOptions(snapshots)],
+ selectedOption: [
+ (s) => [s.scopeOptions, s.selectedScope],
+ (scopeOptions: SuppressScopeOption[], selectedScope: SuppressScopeKey | null): SuppressScopeOption | null =>
+ scopeOptions.find((option) => option.key === selectedScope && !option.unavailableReason) ?? null,
+ ],
+ selectedImpact: [
+ (s) => [s.scopeImpacts, s.selectedScope],
+ (scopeImpacts: ScopeImpacts | null, selectedScope: SuppressScopeKey | null): ScopeImpact | null =>
+ selectedScope ? (scopeImpacts?.[selectedScope] ?? null) : null,
+ ],
+ }),
+
+ 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 (
+ !!pending &&
+ pending.mutationName === mutationName &&
+ (mutationName !== 'updateIssueStatus' || pending.ids[0] === issueId)
+ )
+ }
+
+ return {
+ updateIssueStatus: ({ id, status }) => {
+ if (status === 'suppressed') {
+ cache.pendingSuppression = { mutationName: 'updateIssueStatus', ids: [id] }
+ }
+ },
+ suppressIssues: ({ ids }) => {
+ cache.pendingSuppression = { mutationName: 'suppressIssues', ids }
+ },
+ mutationFailure: ({ mutationName, issueId }) => {
+ if (matchesPending(mutationName, issueId)) {
+ cache.pendingSuppression = undefined
+ }
+ },
+ mutationSuccess: async ({ mutationName, issueId }, breakpoint) => {
+ 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)
+ }
+ },
+ openSuggestion: ({ snapshots, scope }) => {
+ cache.createdRules = undefined
+ posthog.capture('error_tracking_suppress_similar_shown', {
+ issue_count: snapshots.length,
+ recommended_scope: scope,
+ })
+ actions.resetScopeImpacts()
+ actions.loadScopeImpacts()
+ },
+ dismissSuggestion: () => {
+ posthog.capture('error_tracking_suppress_similar_dismissed', {
+ issue_count: values.snapshots.length,
+ })
+ actions.closeSuggestion()
+ },
+ createRulesSuccess: ({ createdRules }) => {
+ if (!createdRules) {
+ return
+ }
+ posthog.capture('error_tracking_suppress_similar_rule_created', {
+ issue_count: values.snapshots.length,
+ rule_count: createdRules.length,
+ scope: values.selectedScope,
+ matched_exceptions: values.selectedImpact?.exceptions ?? null,
+ matched_issues: values.selectedImpact?.issueCount ?? null,
+ })
+ actions.closeSuggestion()
+ lemonToast.success(
+ createdRules.length === 1
+ ? 'Suppression rule created'
+ : `${pluralize(createdRules.length, 'suppression rule')} created`,
+ { button: { label: 'View rules', action: () => router.actions.push(SUPPRESSION_RULES_URL) } }
+ )
+ },
+ }
+ }),
+])
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.test.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.test.ts
new file mode 100644
index 000000000000..36614f2c8173
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.test.ts
@@ -0,0 +1,178 @@
+import { PropertyOperator } from '~/types'
+
+import {
+ SuppressedIssueSnapshot,
+ buildScopeOptions,
+ generalizeExceptionMessage,
+ recommendedScope,
+ snapshotFromLatestEvent,
+} from './suppressSimilarScopes'
+
+function snapshot(overrides: Partial<SuppressedIssueSnapshot>): SuppressedIssueSnapshot {
+ return { id: 'issue-1', exceptionType: 'TypeError', exceptionMessage: null, ...overrides }
+}
+
+describe('suppressSimilarScopes', () => {
+ test.each([
+ {
+ message: 'Request failed with status code 503',
+ similar: 'Request failed with status code 404',
+ different: 'Request failed with status code unknown',
+ },
+ {
+ message: 'User 6f1c2a3e-1b2c-4d5e-8f90-123456789abc not found (attempt 2.5)',
+ similar: 'User 0a1b2c3d-4e5f-4a7b-8c9d-0e1f2a3b4c5d not found (attempt 10)',
+ different: 'User admin not found (attempt 2)',
+ },
+ {
+ message: 'Chunk a1b2c3d4e5f60718 failed to load from /static/[id].js?v=1',
+ similar: 'Chunk ffee00112233aabb failed to load from /static/[id].js?v=42',
+ different: 'Chunk a1b2c3d4e5f60718 failed to load from /static/xid.js?v=1',
+ },
+ {
+ message: 'Address 0XDEADBEEF failed',
+ similar: 'Address 0x1f3a failed',
+ different: 'Address main failed',
+ },
+ ])('generalized pattern for "$message" matches similar messages only', ({ message, similar, different }) => {
+ const generalized = generalizeExceptionMessage(message)
+ expect(generalized).not.toBeNull()
+ const regex = new RegExp(`^${generalized!.regex}$`)
+ expect(regex.test(message)).toBe(true)
+ expect(regex.test(similar)).toBe(true)
+ expect(regex.test(different)).toBe(false)
+ })
+
+ test.each(["Cannot read properties of undefined (reading 'map')", 'utf8 decoding failed in base64 payload'])(
+ 'leaves "%s" without variable parts ungeneralized',
+ (message) => {
+ expect(generalizeExceptionMessage(message)).toBeNull()
+ }
+ )
+
+ test.each([
+ {
+ name: 'a variable message recommends similar messages',
+ snapshots: [snapshot({ exceptionMessage: 'Timeout after 3000ms' })],
+ recommended: 'similar',
+ unavailable: [],
+ },
+ {
+ name: 'a fixed message recommends the exact message',
+ snapshots: [snapshot({ exceptionMessage: 'Network error' })],
+ recommended: 'exact',
+ unavailable: ['similar'],
+ },
+ {
+ name: 'no message offers nothing',
+ snapshots: [snapshot({ exceptionMessage: null })],
+ recommended: null,
+ unavailable: ['exact', 'similar'],
+ },
+ ])('scopes: $name', ({ snapshots, recommended, unavailable }) => {
+ const options = buildScopeOptions(snapshots)
+ expect(recommendedScope(options)).toEqual(recommended)
+ expect(options.filter((option) => option.unavailableReason).map((option) => option.key)).toEqual(unavailable)
+ })
+
+ test.each([
+ {
+ name: 'different messages',
+ messages: ['Timeout after 3000ms', 'Network error'],
+ expectedPatternCount: 2,
+ unmatched: 'Network error 2',
+ },
+ {
+ name: 'messages that differ only by a number',
+ messages: ['Loading chunk 482 failed.', 'Loading chunk 917 failed.'],
+ expectedPatternCount: 1,
+ unmatched: 'Loading chunk main failed.',
+ },
+ ])(
+ 'combines several issues into one pattern that matches each of them: $name',
+ ({ messages, expectedPatternCount, unmatched }) => {
+ const similar = buildScopeOptions(
+ messages.map((exceptionMessage, index) => snapshot({ id: `issue-${index}`, exceptionMessage }))
+ ).find((option) => option.key === 'similar')!
+ expect(similar.rules).toHaveLength(1)
+ const messageFilter = similar.rules[0].values.find((filter) => filter.key === '$exception_values')!
+ const regex = new RegExp(messageFilter.value as string)
+ expect(messages.every((message) => regex.test(message))).toBe(true)
+ expect(regex.test(unmatched)).toBe(false)
+ expect(similar.messages).toHaveLength(expectedPatternCount)
+ }
+ )
+
+ it('keeps each exception type with its own messages when several types are suppressed together', () => {
+ const similar = buildScopeOptions([
+ snapshot({ id: 'type-error', exceptionType: 'TypeError', exceptionMessage: 'alpha 1' }),
+ snapshot({ id: 'range-error', exceptionType: 'RangeError', exceptionMessage: 'beta 1' }),
+ ]).find((option) => option.key === 'similar')!
+ const rules = similar.rules.map((rule) => ({
+ type: rule.values.find((filter) => filter.key === '$exception_types')!.value,
+ message: new RegExp(rule.values.find((filter) => filter.key === '$exception_values')!.value as string),
+ }))
+ expect(rules.map((rule) => rule.type)).toEqual([['TypeError'], ['RangeError']])
+ expect(rules.map((rule) => [rule.message.test('alpha 2'), rule.message.test('beta 2')])).toEqual([
+ [true, false],
+ [false, true],
+ ])
+ })
+
+ test.each([
+ { name: 'a JSON array, as HogQL returns it', raw: '["Error","TypeError"]', expected: 'Error' },
+ { name: 'a plain string', raw: 'Error', expected: 'Error' },
+ { name: 'no value', raw: null, expected: null },
+ ])('reads the outermost exception from $name', ({ raw, expected }) => {
+ expect(snapshotFromLatestEvent(['issue-1', raw, raw])).toEqual({
+ id: 'issue-1',
+ exceptionType: expected,
+ exceptionMessage: expected,
+ })
+ })
+
+ it('reads a dotted run of numbers as one placeholder', () => {
+ const generalized = generalizeExceptionMessage('Upgrade to 1.2.3.4 failed')!
+ expect(generalized.segments.filter((segment) => segment.kind === 'number')).toEqual([
+ { kind: 'number', text: '1.2.3.4' },
+ ])
+ expect(new RegExp(`^${generalized.regex}$`).test('Upgrade to 10.0 failed')).toBe(true)
+ })
+
+ test.each([
+ {
+ name: 'many messages split across rules',
+ messages: Array.from(
+ { length: 40 },
+ (_, index) => `Worker ${'w'.repeat(30)}${index} stopped after 5 retries`
+ ),
+ exactRules: 0,
+ },
+ {
+ name: 'a message too long for any pattern falls back to an exact match',
+ messages: [`Payload ${'x'.repeat(1100)} rejected with code 413`],
+ exactRules: 1,
+ },
+ ])('keeps every similar pattern within the regex cache limit: $name', ({ messages, exactRules }) => {
+ const similar = buildScopeOptions(
+ messages.map((exceptionMessage, index) => snapshot({ id: `issue-${index}`, exceptionMessage }))
+ ).find((option) => option.key === 'similar')!
+ const messageFilters = similar.rules.map(
+ (rule) => rule.values.find((filter) => filter.key === '$exception_values')!
+ )
+ const regexes = messageFilters
+ .filter((filter) => filter.operator === PropertyOperator.Regex)
+ .map((filter) => String(filter.value))
+ expect(regexes.every((regex) => new TextEncoder().encode(regex).length <= 1024)).toBe(true)
+ expect(messageFilters.filter((filter) => filter.operator === PropertyOperator.Exact)).toHaveLength(exactRules)
+ expect(
+ messages.every(
+ (message) =>
+ regexes.some((regex) => new RegExp(regex).test(message)) ||
+ messageFilters.some(
+ (filter) => filter.operator === PropertyOperator.Exact && filter.value.includes(message)
+ )
+ )
+ ).toBe(true)
+ })
+})
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.ts
new file mode 100644
index 000000000000..2f520f375772
--- /dev/null
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarScopes.ts
@@ -0,0 +1,264 @@
+import {
+ EventPropertyFilter,
+ FilterLogicalOperator,
+ PropertyFilterType,
+ PropertyGroupFilterValue,
+ PropertyOperator,
+} from '~/types'
+
+export interface SuppressedIssueSnapshot {
+ id: string
+ exceptionType: string | null
+ exceptionMessage: string | null
+}
+
+export type MessageSegmentKind = 'literal' | 'number' | 'id' | 'hex'
+
+export interface MessageSegment {
+ kind: MessageSegmentKind
+ text: string
+}
+
+export interface GeneralizedMessage {
+ regex: string
+ segments: MessageSegment[]
+}
+
+export interface SuppressionEventFilter extends EventPropertyFilter {
+ value: string | string[]
+}
+
+export interface SuppressionFilterGroup {
+ type: FilterLogicalOperator.And
+ values: SuppressionEventFilter[]
+}
+
+export type SuppressScopeKey = 'exact' | 'similar'
+
+export interface SuppressScopeOption {
+ key: SuppressScopeKey
+ // One rule per exception type. A single rule would also match one issue's type with another issue's message.
+ rules: SuppressionFilterGroup[]
+ messages: MessageSegment[][]
+ unavailableReason?: string
+}
+
+export interface ScopeImpact {
+ exceptions: number
+ issueCount: number
+}
+
+// The pattern ends up in posthog-js (JS RegExp), cymbal (Rust regex) and HogQL (re2),
+// so it only uses syntax all three engines read the same way.
+const VARIABLE_PART_REGEX: Record<Exclude<MessageSegmentKind, 'literal'>, string> = {
+ id: '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}',
+ hex: '(?:0[xX])?[0-9a-fA-F]+',
+ // Not `\d`, because the Rust regex crate in cymbal reads it as any Unicode digit.
+ number: '[0-9]+(?:\\.[0-9]+)*',
+}
+
+// hogvm in cymbal caches compiled patterns up to this many bytes and recompiles longer ones on every event.
+const MAX_CACHED_PATTERN_LENGTH = 1024
+
+// A number may run into a unit ("3000ms"), so it has no trailing word boundary. The leading one keeps "utf8" intact.
+// A dotted run such as "1.2.3" is one number. Two number patterns next to each other would make
+// posthog-js backtrack exponentially on a long run that does not match.
+const VARIABLE_PART =
+ /(?<id>\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b)|(?<hex>\b0x[0-9a-f]+\b|\b(?=[0-9a-f]*\d)(?=[0-9a-f]*[a-f])[0-9a-f]{16,}\b)|(?<number>\b\d+(?:\.\d+)*)/gi
+
+function escapeRegexLiteral(text: string): string {
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+}
+
+function distinctNonEmpty(values: (string | null | undefined)[]): string[] {
+ return Array.from(new Set(values.filter((value): value is string => !!value && value.trim().length > 0)))
+}
+
+function eventFilter(key: string, operator: PropertyOperator, value: string | string[]): SuppressionEventFilter {
+ return { key, operator, value, type: PropertyFilterType.Event }
+}
+
+function literal(text: string): MessageSegment[] {
+ return [{ kind: 'literal', text }]
+}
+
+function filterGroup(values: SuppressionEventFilter[]): SuppressionFilterGroup {
+ return { type: FilterLogicalOperator.And, values }
+}
+
+/** Replaces IDs, hashes and numbers in an exception message with wildcards. Returns null when nothing varies. */
+export function generalizeExceptionMessage(message: string): GeneralizedMessage | null {
+ const segments: MessageSegment[] = []
+ let regex = ''
+ let lastIndex = 0
+
+ for (const match of message.matchAll(VARIABLE_PART)) {
+ const kind = (Object.keys(VARIABLE_PART_REGEX) as (keyof typeof VARIABLE_PART_REGEX)[]).find(
+ (group) => match.groups?.[group] !== undefined
+ )
+ if (!kind || match.index === undefined) {
+ continue
+ }
+ const text = message.slice(lastIndex, match.index)
+ if (text) {
+ segments.push({ kind: 'literal', text })
+ regex += escapeRegexLiteral(text)
+ }
+ segments.push({ kind, text: match[0] })
+ regex += VARIABLE_PART_REGEX[kind]
+ lastIndex = match.index + match[0].length
+ }
+
+ if (segments.length === 0) {
+ return null
+ }
+
+ const tail = message.slice(lastIndex)
+ if (tail) {
+ segments.push({ kind: 'literal', text: tail })
+ regex += escapeRegexLiteral(tail)
+ }
+
+ return { regex, segments }
+}
+
+interface PatternWithSources {
+ pattern: GeneralizedMessage
+ messages: string[]
+}
+
+function messagePatterns(messages: string[]): PatternWithSources[] {
+ const byRegex = new Map<string, PatternWithSources>()
+ for (const message of messages) {
+ // A message with no variable parts still joins the pattern as an escaped literal.
+ const pattern = generalizeExceptionMessage(message) ?? {
+ regex: escapeRegexLiteral(message),
+ segments: literal(message),
+ }
+ const existing = byRegex.get(pattern.regex)
+ byRegex.set(pattern.regex, { pattern, messages: [...(existing?.messages ?? []), message] })
+ }
+ return Array.from(byRegex.values())
+}
+
+function byteLength(text: string): number {
+ return new TextEncoder().encode(text).length
+}
+
+function anchoredAlternation(patterns: GeneralizedMessage[]): string {
+ return patterns.length === 1
+ ? `^${patterns[0].regex}$`
+ : `^(?:${patterns.map((pattern) => pattern.regex).join('|')})$`
+}
+
+interface SimilarRules {
+ rules: SuppressionFilterGroup[]
+ messages: MessageSegment[][]
+}
+
+function similarRules(typeFilters: SuppressionEventFilter[], messages: string[]): SimilarRules {
+ const rules: SuppressionFilterGroup[] = []
+ const shown: MessageSegment[][] = []
+ const exactMessages: string[] = []
+ let chunk: GeneralizedMessage[] = []
+ const flush = (): void => {
+ if (chunk.length > 0) {
+ rules.push(
+ filterGroup([
+ ...typeFilters,
+ eventFilter('$exception_values', PropertyOperator.Regex, anchoredAlternation(chunk)),
+ ])
+ )
+ chunk = []
+ }
+ }
+ for (const { pattern, messages: sources } of messagePatterns(messages)) {
+ if (byteLength(anchoredAlternation([pattern])) > MAX_CACHED_PATTERN_LENGTH) {
+ exactMessages.push(...sources)
+ shown.push(...sources.map(literal))
+ continue
+ }
+ if (byteLength(anchoredAlternation([...chunk, pattern])) > MAX_CACHED_PATTERN_LENGTH) {
+ flush()
+ }
+ chunk.push(pattern)
+ shown.push(pattern.segments)
+ }
+ flush()
+ if (exactMessages.length > 0) {
+ rules.push(
+ filterGroup([...typeFilters, eventFilter('$exception_values', PropertyOperator.Exact, exactMessages)])
+ )
+ }
+ return { rules, messages: shown }
+}
+
+export function buildScopeOptions(snapshots: SuppressedIssueSnapshot[]): SuppressScopeOption[] {
+ const messagesByType = new Map<string | null, string[]>()
+ for (const snapshot of snapshots) {
+ const message = snapshot.exceptionMessage?.trim() ? snapshot.exceptionMessage : null
+ if (message) {
+ const type = snapshot.exceptionType?.trim() ? snapshot.exceptionType : null
+ messagesByType.set(type, distinctNonEmpty([...(messagesByType.get(type) ?? []), message]))
+ }
+ }
+ const groups = Array.from(messagesByType.entries())
+ const typeFilters = (type: string | null): SuppressionEventFilter[] =>
+ type ? [eventFilter('$exception_types', PropertyOperator.Exact, [type])] : []
+ const messages = distinctNonEmpty(groups.flatMap(([, groupMessages]) => groupMessages))
+ const similar = groups.map(([type, groupMessages]) => similarRules(typeFilters(type), groupMessages))
+ const noMessageReason = snapshots.length === 1 ? 'This issue has no message' : 'These issues have no message'
+
+ return [
+ {
+ key: 'exact',
+ rules: groups.map(([type, groupMessages]) =>
+ filterGroup([
+ ...typeFilters(type),
+ eventFilter('$exception_values', PropertyOperator.Exact, groupMessages),
+ ])
+ ),
+ messages: messages.map(literal),
+ unavailableReason: messages.length === 0 ? noMessageReason : undefined,
+ },
+ {
+ key: 'similar',
+ rules: similar.flatMap((group) => group.rules),
+ messages: similar.flatMap((group) => group.messages),
+ unavailableReason:
+ messages.length === 0
+ ? noMessageReason
+ : messages.every((message) => generalizeExceptionMessage(message) === null)
+ ? 'Nothing in the message changes between occurrences, such as a number or an ID'
+ : undefined,
+ },
+ ]
+}
+
+export function combinedFilter(option: SuppressScopeOption): PropertyGroupFilterValue {
+ return option.rules.length === 1 ? option.rules[0] : { type: FilterLogicalOperator.Or, values: option.rules }
+}
+
+export function recommendedScope(options: SuppressScopeOption[]): SuppressScopeKey | null {
+ const available = (key: SuppressScopeKey): boolean =>
+ options.some((option) => option.key === key && !option.unavailableReason)
+ return (['similar', 'exact'] as const).find(available) ?? null
+}
+
+/** One exception property as HogQL returns it: a JSON array in a string. Takes the outermost exception. */
+function firstValue(raw: unknown): string | null {
+ if (typeof raw !== 'string' || !raw) {
+ return null
+ }
+ try {
+ const parsed: unknown = JSON.parse(raw)
+ const first = Array.isArray(parsed) ? parsed[0] : parsed
+ return typeof first === 'string' ? first : null
+ } catch {
+ return raw
+ }
+}
+
+export function snapshotFromLatestEvent([id, types, values]: [string, unknown, unknown]): SuppressedIssueSnapshot {
+ return { id: String(id), exceptionType: firstValue(types), exceptionMessage: firstValue(values) }
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator.tsx
index 0110106db2e1..c6a6394dbdae 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/EvaluationIndicator.tsx
@@ -1,4 +1,4 @@
-import { IconLaptop, IconServer } from '@posthog/icons'
+import { IconInfo, IconLaptop, IconServer } from '@posthog/icons'
import { Tooltip } from '@posthog/lemon-ui'
import { FilterLogicalOperator, UniversalFiltersGroup, UniversalFiltersGroupValue } from '~/types'
@@ -34,6 +34,10 @@ function isFilterClientSafe(f: UniversalFiltersGroupValue): boolean {
export type EvalMode = 'client' | 'partial' | 'server'
+// The backend publishes client rules at 100% sampling in the public SDK configuration (`get_client_safe_suppression_rules`).
+export const CLIENT_RULE_PUBLIC_NOTE =
+ "This rule is part of your project's public SDK configuration, so anyone with your project token can read its filters. Keep personal data and secrets out of it."
+
export function getEvalMode(filters: UniversalFiltersGroup): EvalMode {
const values = filters.values ?? []
if (values.length === 0) {
@@ -143,7 +147,13 @@ export function SamplingRateIndicator({ samplingRate }: { samplingRate: number }
)
}
-export function EvaluationIndicator({ mode }: { mode: EvalMode }): JSX.Element {
+export function EvaluationIndicator({
+ mode,
+ samplingRate = 1,
+}: {
+ mode: EvalMode
+ samplingRate?: number
+}): JSX.Element {
const clientActive = mode === 'client' || mode === 'partial'
return (
<div className="inline-flex items-center gap-1">
@@ -155,6 +165,15 @@ export function EvaluationIndicator({ mode }: { mode: EvalMode }): JSX.Element {
tooltip={CLIENT_TOOLTIPS[mode]}
/>
)}
+ {clientActive && samplingRate === 1 && (
+ <Tooltip title={CLIENT_RULE_PUBLIC_NOTE}>
+ <IconInfo
+ className="shrink-0 text-base text-secondary"
+ aria-label={CLIENT_RULE_PUBLIC_NOTE}
+ data-attr="error-tracking-suppression-rule-public-note"
+ />
+ </Tooltip>
+ )}
{mode !== 'client' && (
<Pill
activeClasses="bg-warning-highlight text-warning"
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRuleModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRuleModal.tsx
index 0e565db61ac6..62c4b55f25b0 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRuleModal.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRuleModal.tsx
@@ -34,7 +34,12 @@ export function SuppressionRuleModal(): JSX.Element {
</>
)}
filtersOptional
- filterLabels={<EvaluationIndicator mode={evalMode} />}
+ filterLabels={
+ <EvaluationIndicator
+ mode={evalMode}
+ samplingRate={(rule as ErrorTrackingSuppressionRule).sampling_rate}
+ />
+ }
samplingRate={(rule as ErrorTrackingSuppressionRule).sampling_rate}
extraFields={
<div>
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
index 20cb610c18de..12243960e15c 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
@@ -20,7 +20,7 @@ export function SuppressionRules(): JSX.Element {
renderCardHeaderExtra={(rule: ErrorTrackingSuppressionRule) => (
<>
<span className="text-muted">·</span>
- <EvaluationIndicator mode={getEvalMode(rule.filters)} />
+ <EvaluationIndicator mode={getEvalMode(rule.filters)} samplingRate={rule.sampling_rate} />
{rule.sampling_rate < 1.0 && (
<>
<span className="text-muted">·</span>
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
index 2afe7749f9d9..cf20c1399d3e 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
@@ -52,6 +52,7 @@ import { IssueStatusButton } from '../../components/IssueStatusButton'
import { IssueStatusSelect } from '../../components/IssueStatusSelect'
import { ErrorTrackingSetupPrompt } from '../../components/SetupPrompt/SetupPrompt'
import { StyleVariables } from '../../components/StyleVariables'
+import { SuppressSimilarIssuesDialog } from '../../components/SuppressSimilarIssues/SuppressSimilarIssuesDialog'
import { useErrorTagRenderer } from '../../hooks/use-error-tag-renderer'
import { getIssueReplayDateRange, getIssueReplayFilterGroup, issueVisionScannerHandoff } from '../../utils'
import { ErrorTrackingIssueSceneLogicProps, errorTrackingIssueSceneLogic } from './errorTrackingIssueSceneLogic'
@@ -298,6 +299,7 @@ export function ErrorTrackingIssueScene(): JSX.Element {
<ErrorTrackingIssueScenePanel issue={issue} />
{hasIssueSplitting && <ManageFingerprintsModal issueId={issueId} />}
+ <SuppressSimilarIssuesDialog />
<div className="ErrorTrackingIssue flex flex-grow min-h-0 overflow-hidden">
<div className="relative flex flex-1 h-full w-full min-h-0">
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/IssuesList.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/IssuesList.tsx
index 2accd99d8b05..56b517eb0535 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/IssuesList.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/IssuesList.tsx
@@ -21,6 +21,7 @@ import { InsightLogicProps } from '~/types'
import { IssueActions } from 'products/error_tracking/frontend/components/IssueActions/IssueActions'
import { issueQueryOptionsLogic } from 'products/error_tracking/frontend/components/IssueQueryOptions/issueQueryOptionsLogic'
+import { SuppressSimilarIssuesDialog } from 'products/error_tracking/frontend/components/SuppressSimilarIssues/SuppressSimilarIssuesDialog'
import { IssueListTitleColumn, IssueListTitleHeader } from 'products/error_tracking/frontend/components/TableColumns'
import { errorTrackingVolumeSparklineLogic } from 'products/error_tracking/frontend/components/VolumeSparkline/errorTrackingVolumeSparklineLogic'
import {
@@ -185,6 +186,7 @@ export function IssuesList(): JSX.Element {
>
<Query query={query} context={context} />
</div>
+ <SuppressSimilarIssuesDialog />
</BindLogic>
)
}