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): use merge-aware issue queries (#76564)

Hugues Pouillotec9f6443b77b
diff --git a/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx b/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx
index f5e8e58b7fd1..302bbda02cfc 100644
--- a/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx
+++ b/products/error_tracking/frontend/components/IssueActions/issueActionsLogic.tsx
@@ -9,7 +9,8 @@ import { BehavioralFilterKey } from 'scenes/cohorts/CohortFilters/types'
import { createCohortFormData } from 'scenes/cohorts/cohortUtils'
import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
-import { BehavioralEventType, CohortType, FilterLogicalOperator, PropertyFilterType, PropertyOperator } from '~/types'
+import { escapeHogQLString } from '~/queries/utils'
+import { BehavioralEventType, CohortType, FilterLogicalOperator, PropertyFilterType } from '~/types'
import type {
ErrorTrackingIssueAssignee,
@@ -323,10 +324,8 @@ function createCohortParams(name: string, description: string, issueId: string):
event_type: TaxonomicFilterGroupType.Events,
event_filters: [
{
- key: '$exception_issue_id',
- type: PropertyFilterType.Event,
- value: [issueId],
- operator: PropertyOperator.Exact,
+ key: `issue_id = ${escapeHogQLString(issueId)}`,
+ type: PropertyFilterType.HogQL,
},
],
explicit_datetime: '-30d',
diff --git a/products/error_tracking/frontend/queries.test.ts b/products/error_tracking/frontend/queries.test.ts
index 12981f51697e..14fd2b30c2a0 100644
--- a/products/error_tracking/frontend/queries.test.ts
+++ b/products/error_tracking/frontend/queries.test.ts
@@ -94,6 +94,18 @@ describe('queries', () => {
})
expect(actual.source.tags).toEqual({ productKey: ProductKey.ERROR_TRACKING })
+ expect(actual.source).toMatchObject({
+ series: [
+ {
+ properties: [
+ {
+ key: "issue_id = 'issue-id'",
+ type: 'hogql',
+ },
+ ],
+ },
+ ],
+ })
})
})
})
diff --git a/products/error_tracking/frontend/queries.ts b/products/error_tracking/frontend/queries.ts
index b1cc53184466..3b7c8da34609 100644
--- a/products/error_tracking/frontend/queries.ts
+++ b/products/error_tracking/frontend/queries.ts
@@ -18,7 +18,6 @@ import {
ChartDisplayType,
PropertyFilterType,
PropertyGroupFilter,
- PropertyOperator,
UniversalFiltersGroup,
} from '~/types'
@@ -269,10 +268,8 @@ export const errorTrackingIssueBreakdownQuery = ({
math: BaseMathType.TotalCount,
properties: [
{
- key: '$exception_issue_id',
- type: PropertyFilterType.Event,
- value: issueId,
- operator: PropertyOperator.Exact,
+ key: `issue_id = ${escapeHogQLString(issueId)}`,
+ type: PropertyFilterType.HogQL,
},
...properties,
],
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/assignmentRuleModalLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/assignmentRuleModalLogic.ts
index 25b66b474eb6..6f20d1ca7506 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/assignmentRuleModalLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/assignmentRuleModalLogic.ts
@@ -185,7 +185,7 @@ export const assignmentRuleModalLogic = kea<assignmentRuleModalLogicType>([
const query: Record<string, any> = {
kind: NodeKind.EventsQuery,
event: '$exception',
- select: ['count()', 'count(distinct properties.$exception_issue_id)'],
+ select: ['count()', 'count(distinct issue_id)'],
after: values.dateRange,
tags: { productKey: ProductKey.ERROR_TRACKING },
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/codeOwnersModalLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/codeOwnersModalLogic.ts
index d23d015fe69f..d4a8efb83ad4 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/codeOwnersModalLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/codeOwnersModalLogic.ts
@@ -259,7 +259,7 @@ export const codeOwnersModalLogic = kea<codeOwnersModalLogicType>([
const response = (await api.query({
kind: NodeKind.EventsQuery,
event: '$exception',
- select: ['count()', 'count(distinct properties.$exception_issue_id)'],
+ select: ['count()', 'count(distinct issue_id)'],
after: values.dateRange,
fixedProperties: [{ type: filters.type, values: properties }],
tags: { productKey: ProductKey.ERROR_TRACKING },
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/grouping_rules/groupingRuleModalLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/grouping_rules/groupingRuleModalLogic.ts
index 04b8319753ef..9572ac4eebff 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/grouping_rules/groupingRuleModalLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/grouping_rules/groupingRuleModalLogic.ts
@@ -183,7 +183,7 @@ export const groupingRuleModalLogic = kea<groupingRuleModalLogicType>([
const query: Record<string, any> = {
kind: NodeKind.EventsQuery,
event: '$exception',
- select: ['count()', 'count(distinct properties.$exception_issue_id)'],
+ select: ['count()', 'count(distinct issue_id)'],
after: values.dateRange,
tags: { productKey: ProductKey.ERROR_TRACKING },
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/suppressionRuleModalLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/suppressionRuleModalLogic.ts
index 82cb2532abb3..ee2ab4e98ec7 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/suppressionRuleModalLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/suppressionRuleModalLogic.ts
@@ -194,7 +194,7 @@ export const suppressionRuleModalLogic = kea<suppressionRuleModalLogicType>([
const query: Record<string, any> = {
kind: NodeKind.EventsQuery,
event: '$exception',
- select: ['count()', 'count(distinct properties.$exception_issue_id)'],
+ select: ['count()', 'count(distinct issue_id)'],
after: values.dateRange,
tags: { productKey: ProductKey.ERROR_TRACKING },
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
index 51b3c7e9efba..d51ff7aca90f 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
@@ -28,7 +28,7 @@ import { urls } from 'scenes/urls'
import { SceneMenuBar, SceneMenuBarItem, SceneMenuBarMenu } from '~/layout/scenes/components/SceneMenuBar'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-import { FilterLogicalOperator, PropertyFilterType, PropertyOperator, ReplayTabs } from '~/types'
+import { ReplayTabs } from '~/types'
import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'
@@ -46,7 +46,7 @@ import { IssueStatusButton } from '../../components/IssueStatusButton'
import { ErrorTrackingSetupPrompt } from '../../components/SetupPrompt/SetupPrompt'
import { StyleVariables } from '../../components/StyleVariables'
import { useErrorTagRenderer } from '../../hooks/use-error-tag-renderer'
-import { getIssueReplayDateRange } from '../../utils'
+import { getIssueReplayDateRange, getIssueReplayFilterGroup } from '../../utils'
import {
ErrorTrackingIssueSceneCategory,
errorTrackingIssueSceneConfigurationLogic,
@@ -123,22 +123,7 @@ export function ErrorTrackingIssueScene(): JSX.Element {
onClick={() => {
const url = urls.replay(ReplayTabs.Home, {
...getIssueReplayDateRange(issue.first_seen, lastSeen),
- filter_group: {
- type: FilterLogicalOperator.And,
- values: [
- {
- type: FilterLogicalOperator.And,
- values: [
- {
- key: '$exception_issue_id',
- type: PropertyFilterType.Event,
- operator: PropertyOperator.Exact,
- value: [issue.id],
- },
- ],
- },
- ],
- },
+ filter_group: getIssueReplayFilterGroup(issue.id),
})
newInternalTab(url)
}}
@@ -174,22 +159,7 @@ export function ErrorTrackingIssueScene(): JSX.Element {
<ViewRecordingsPlaylistButton
filters={{
...getIssueReplayDateRange(issue.first_seen, lastSeen),
- filter_group: {
- type: FilterLogicalOperator.And,
- values: [
- {
- type: FilterLogicalOperator.And,
- values: [
- {
- key: '$exception_issue_id',
- type: PropertyFilterType.Event,
- operator: PropertyOperator.Exact,
- value: [issue.id],
- },
- ],
- },
- ],
- },
+ filter_group: getIssueReplayFilterGroup(issue.id),
}}
size="small"
type="secondary"
diff --git a/products/error_tracking/frontend/utils.test.ts b/products/error_tracking/frontend/utils.test.ts
index b6b76dc75cd0..b02c0d21f1dc 100644
--- a/products/error_tracking/frontend/utils.test.ts
+++ b/products/error_tracking/frontend/utils.test.ts
@@ -1,8 +1,15 @@
import { Dayjs, dayjs } from 'lib/dayjs'
import { ErrorTrackingIssue, ErrorTrackingIssueAggregations } from '~/queries/schema/schema-general'
+import { FilterLogicalOperator, PropertyFilterType } from '~/types'
-import { generateDateRangeLabel, getIssueReplayDateRange, mergeIssues, sourceDisplay } from './utils'
+import {
+ generateDateRangeLabel,
+ getIssueReplayDateRange,
+ getIssueReplayFilterGroup,
+ mergeIssues,
+ sourceDisplay,
+} from './utils'
function wrapVolumeBuckets(
initialDate: Dayjs,
@@ -201,6 +208,32 @@ describe('getIssueReplayDateRange', () => {
})
})
+describe('getIssueReplayFilterGroup', () => {
+ it('scopes the merge-aware issue field to exception events', () => {
+ expect(getIssueReplayFilterGroup("issue-'quoted'")).toEqual({
+ type: FilterLogicalOperator.And,
+ values: [
+ {
+ type: FilterLogicalOperator.And,
+ values: [
+ {
+ id: '$exception',
+ name: '$exception',
+ type: 'events',
+ properties: [
+ {
+ key: "issue_id = 'issue-\\'quoted\\''",
+ type: PropertyFilterType.HogQL,
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ })
+ })
+})
+
describe('sourceDisplay', () => {
it('nicely formats paths', async () => {
expect(sourceDisplay('')).toEqual('')
diff --git a/products/error_tracking/frontend/utils.ts b/products/error_tracking/frontend/utils.ts
index 11185686842c..5028b64c1187 100644
--- a/products/error_tracking/frontend/utils.ts
+++ b/products/error_tracking/frontend/utils.ts
@@ -10,7 +10,14 @@ import { componentsToDayJs, dateStringToComponents, dateStringToDayJs, isStringD
import { Params } from 'scenes/sceneTypes'
import { DateRange, ErrorTrackingIssue } from '~/queries/schema/schema-general'
-import { AccessControlLevel, AccessControlResourceType } from '~/types'
+import { escapeHogQLString } from '~/queries/utils'
+import {
+ AccessControlLevel,
+ AccessControlResourceType,
+ FilterLogicalOperator,
+ PropertyFilterType,
+ type UniversalFiltersGroup,
+} from '~/types'
/** Reason error tracking write actions are disabled, or null when the user has editor access. */
export function errorTrackingEditAccessDisabledReason(): string | null {
@@ -115,6 +122,30 @@ export function getIssueReplayDateRange(firstSeen: string, lastSeen: Dayjs | nul
}
}
+export function getIssueReplayFilterGroup(issueId: string): UniversalFiltersGroup {
+ return {
+ type: FilterLogicalOperator.And,
+ values: [
+ {
+ type: FilterLogicalOperator.And,
+ values: [
+ {
+ id: '$exception',
+ name: '$exception',
+ type: 'events',
+ properties: [
+ {
+ key: `issue_id = ${escapeHogQLString(issueId)}`,
+ type: PropertyFilterType.HogQL,
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ }
+}
+
const customOptions: Record<string, string> = {
dStart: 'Today', // today
mStart: 'Month',