: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(error-tracking): derive eventsQueryKey from query content, not uuid() (#68536)
Paul D'Ambra5018bc400833
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.tsnew file mode 100644index 000000000000..3f9570076cb4--- /dev/null+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts@@ -0,0 +1,58 @@+import { ErrorTrackingFingerprint } from 'lib/components/Errors/types'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { errorTrackingIssueSceneLogic } from './errorTrackingIssueSceneLogic'++const makeFingerprints = (fingerprint: string = 'fp-1'): ErrorTrackingFingerprint[] => [+ { fingerprint, issue_id: 'issue-1', created_at: '2026-01-01T00:00:00Z' },+]++describe('errorTrackingIssueSceneLogic', () => {+ let logic: ReturnType<typeof errorTrackingIssueSceneLogic.build>++ beforeEach(() => {+ useMocks({+ get: {+ '/api/environments/:team_id/error_tracking/issues/:id/': {},+ '/api/environments/:team_id/error_tracking/issues/:id/fingerprints/': [],+ },+ post: {+ '/api/environments/:team_id/query/': { results: [] },+ },+ })+ initKeaTests()+ logic = errorTrackingIssueSceneLogic({ id: 'issue-1' })+ logic.mount()+ })++ afterEach(() => logic?.unmount())++ // eventsQueryKey is the kea key of the events table's data source logic: every key change+ // unmounts and remounts the whole table tree. It used to be uuid() per recompute, so even a+ // deep-equal fingerprints refetch rebuilt the table. These lock in the key contract both ways.+ it('keeps eventsQuery and eventsQueryKey stable across deep-equal fingerprint loads', () => {+ logic.actions.loadIssueFingerprintsSuccess(makeFingerprints())+ const initialQuery = logic.values.eventsQuery+ const initialKey = logic.values.eventsQueryKey++ // Freshly constructed but deep-equal — as a refetch would deliver.+ logic.actions.loadIssueFingerprintsSuccess(makeFingerprints())++ expect(logic.values.eventsQuery).toBe(initialQuery)+ expect(logic.values.eventsQueryKey).toBe(initialKey)+ })++ it.each<[string, (logic: ReturnType<typeof errorTrackingIssueSceneLogic.build>) => void]>([+ ['fingerprints change', (l) => l.actions.loadIssueFingerprintsSuccess(makeFingerprints('fp-2'))],+ ['search query changes', (l) => l.actions.setSearchQuery('needle')],+ ])('changes eventsQueryKey when the %s', (_name, mutate) => {+ logic.actions.loadIssueFingerprintsSuccess(makeFingerprints())+ const initialKey = logic.values.eventsQueryKey++ mutate(logic)++ expect(logic.values.eventsQueryKey).not.toBe(initialKey)+ })+})diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.tsindex bc14ccc9ea61..ca96b2b3274c 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts@@ -13,7 +13,7 @@ import {} from 'lib/components/Errors/types'import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'import { Dayjs, dayjs } from 'lib/dayjs'-import { uuid } from 'lib/utils/dom'+import { objectsEqual } from 'lib/utils/objects'import { MaxContextInput, createMaxContextHelpers } from 'scenes/max/maxTypes'import { Scene } from 'scenes/sceneTypes'import { Params } from 'scenes/sceneTypes'@@ -378,14 +378,16 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicTypedateRange,columns: ['*', 'timestamp', 'person'],}),+ // Deep-equal recomputes (e.g. a fingerprints refetch returning the same list) must not+ // produce a new query identity, or the key below remounts the whole events table.+ { resultEqualityCheck: objectsEqual },],- eventsQueryKey: [- (s) => [s.eventsQuery],- () => {- return uuid()- },- ],+ // The key is the kea key of eventsSourceLogic, whose dataNodeLogic is wired in connect()+ // once per key: it MUST change when the query content changes (that's how a new query+ // reaches the data layer) and must NOT change otherwise — every key change unmounts and+ // remounts the entire events table tree.+ eventsQueryKey: [(s) => [s.eventsQuery], (eventsQuery): string => JSON.stringify(eventsQuery)],maxContext: [(s) => [s.issue, s.issueId],