: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(replay): stop filing a handled recording 404 as an issue (#100147)
posthog[bot]8a7b194d1a7e
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.tsindex f34bb6125089..f7fa89d6e271 100644--- a/frontend/src/initKea.ts+++ b/frontend/src/initKea.ts@@ -9,7 +9,7 @@ import { waitForPlugin } from 'kea-waitfor'import { windowValuesPlugin } from 'kea-window-values'import posthog from 'posthog-js'-import { isAccessDeniedError, shouldReportApiFailure } from 'lib/api-error'+import { isAccessDeniedError, isUnavailableEndpointError, shouldReportApiFailure } from 'lib/api-error'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import {addProjectIdIfMissing,@@ -77,6 +77,15 @@ other failures on these actions still toast.*/const ACCESS_DENIED_SELF_HANDLED = new Set(['saveFeatureFlag'])+/*+Load actions whose own UI renders the missing resource, so a 404 from them is a state the app+expects rather than a defect worth filing. `shouldReportApiFailure` keeps a plain 404 reportable on+purpose, so each caller that degrades has to name itself here, next to the toast allow list above.+*/+const NOT_FOUND_SELF_HANDLED = new Set([+ 'loadRecordingMeta', // The player renders RecordingNotFound off sessionRecordingMetaLogic's isNotFound+])+/*Write actions whose own logic toasts the duplicate-key 400 (code `unique` on attr `key`), so thegeneric toast would be a second one. Owned by featureFlagLogic's saveFeatureFlagFailure listener.@@ -210,7 +219,9 @@ export function initKea({if (!errorsSilenced) {console.error({ error, reducerKey, actionKey })}- if (shouldReportApiFailure(error)) {+ const isSelfHandledNotFound =+ NOT_FOUND_SELF_HANDLED.has(String(actionKey)) && isUnavailableEndpointError(error)+ if (shouldReportApiFailure(error) && !isSelfHandledNotFound) {posthog.captureException(error)}},diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.tsindex fdd022f2d6a1..99c9eb16c1dd 100644--- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts@@ -2,6 +2,7 @@ import { api } from 'lib/api.mock'import { expectLogic } from 'kea-test-utils'import { HttpResponse } from 'msw'+import posthog from 'posthog-js'import { processAllSnapshots, SnapshotSourceType, SourceKey, ViewportResolution } from '@posthog/replay-shared'@@ -243,6 +244,7 @@ describe('sessionRecordingDataCoordinatorLogic', () => {it('fetch metadata error with 500 sets loadMetaError but not isNotFound', async () => {silenceKeaLoadersErrors()+ const captureExceptionSpy = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined)logic.unmount()overrideSessionRecordingMocks({getMocks: {@@ -276,11 +278,14 @@ describe('sessionRecordingDataCoordinatorLogic', () => {expect(metaLogic.values.isNotFound).toBe(false)expect(metaLogic.values.loadMetaError).toBe(true)+ expect(captureExceptionSpy).toHaveBeenCalled()+ captureExceptionSpy.mockRestore()resumeKeaLoadersErrors()})it('fetch metadata error with 404 sets isNotFound but not loadMetaError', async () => {silenceKeaLoadersErrors()+ const captureExceptionSpy = jest.spyOn(posthog, 'captureException').mockImplementation(() => undefined)logic.unmount()overrideSessionRecordingMocks({getMocks: {@@ -298,6 +303,8 @@ describe('sessionRecordingDataCoordinatorLogic', () => {expect(metaLogic.values.isNotFound).toBe(true)expect(metaLogic.values.loadMetaError).toBe(false)+ expect(captureExceptionSpy).not.toHaveBeenCalled()+ captureExceptionSpy.mockRestore()resumeKeaLoadersErrors()})