: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): index matching events in inspector (#117668)
Paul D'Ambra184a3e194c48
diff --git a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.tsindex f023d4d6a981..0bf6ff4489a7 100644--- a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts+++ b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.test.ts@@ -16,7 +16,7 @@ import { snapshotDataLogic } from 'scenes/session-recordings/player/snapshotDataimport { DEFAULT_RECORDING_FILTERS } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'import { useMocks } from '~/mocks/jest'-import { RRWebRecordingConsoleLogPayload, SessionRecordingType } from '~/types'+import { RecordingEventType, RRWebRecordingConsoleLogPayload, SessionRecordingType } from '~/types'import { makeExperimentSessionContextItem } from '../../__mocks__/experiment_session_context'import { BLOB_SOURCE_V2, overrideSessionRecordingMocks, setupSessionRecordingTest } from '../__mocks__/test-setup'@@ -309,6 +309,33 @@ describe('playerInspectorLogic', () => {} as SessionRecordingType)}+ it('highlights only events with matching UUIDs', async () => {+ const { playerLogic, matchingLogic } = mountLogics(matchingProps('highlight-matching-events'))+ await expectLogic(matchingLogic).toDispatchActions(['loadMatchingEventsSuccess'])++ const event = (id: string, timestamp: string): RecordingEventType => ({+ id,+ event: '$pageview',+ timestamp,+ elements: [],+ properties: {},+ playerTime: 0,+ fullyLoaded: false,+ })+ dataLogic.actions.loadEventsSuccess([+ event('matching-event', '2025-01-01T00:00:10.000Z'),+ event('other-event', '2025-01-01T00:00:20.000Z'),+ ])++ expect(matchingLogic.values.allItems.items.filter((item) => item.type === 'events')).toMatchObject([+ { key: 'event-matching-event', highlightColor: 'primary' },+ { key: 'event-other-event', highlightColor: undefined },+ ])++ matchingLogic.unmount()+ playerLogic.unmount()+ })+it.each([['armed via the skipToFirstMatchingEvent prop', { skipToFirstMatchingEvent: true }],['armed during player initialization', {}],diff --git a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.ts b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.tsindex 5c23db5eec98..3a87c46c82c7 100644--- a/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.ts+++ b/frontend/src/scenes/session-recordings/player/inspector/playerInspectorLogic.ts@@ -1721,6 +1721,7 @@ export const playerInspectorLogic = kea<playerInspectorLogicType>([}let errorCount = 0+ const matchingEventUuids = new Set(matchingEvents?.map((event) => event.uuid))for (const event of eventsData || []) {// A malformed or missing event row must not crash the whole inspector list.if (!event) {@@ -1733,10 +1734,8 @@ export const playerInspectorLogic = kea<playerInspectorLogicType>([errorCount += 1}- if (matchingEvents?.length) {- isMatchingEvent = !!matchingEvents.find(- (x: MatchedRecordingEvent) => x.uuid === String(event.id)- )+ if (matchingEventUuids.size) {+ isMatchingEvent = matchingEventUuids.has(String(event.id))} else if (props.matchingEventsMatchType?.matchType === 'name') {isMatchingEvent = props.matchingEventsMatchType?.eventNames?.includes(event.event)}