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.

chore(replay): remove oversized mutation excision and its flag (#105771)

Hayne Ryu235a861e2ad3
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index d93a771f348e..d9615090c153 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -221,7 +221,6 @@ export const FEATURE_FLAGS = {
PERSONLESS_EVENTS_NOT_SUPPORTED: 'personless-events-not-supported', // owner: #team-analytics-platform
QUERY_RUNNING_TIME: 'query_running_time', // owner: #team-analytics-platform
REPLAY_HOGQL_FILTERS: 'replay-hogql-filters', // owner: @pauldambra #team-replay
- REPLAY_OVERSIZED_RECORDING_GATE: 'replay-oversized-recording-gate', // owner: #team-replay
REPLAY_PLAYER_PERSON_SESSIONS_TAB: 'replay-player-person-sessions-tab', // owner: @ksvat #team-replay
REPLAY_SETTINGS_HELP: 'replay-settings-help', // owner: @veryayskiy #team-replay
SCOUTS_MODEL_CONFIG: 'scouts-model-config', // owner: #team-self-driving, gates the per-scout model pin in the inbox scout settings (also checked server-side)
diff --git a/frontend/src/scenes/session-recordings/player/PurePlayer.tsx b/frontend/src/scenes/session-recordings/player/PurePlayer.tsx
index e8fe4f923cc3..2e432ff845c8 100644
--- a/frontend/src/scenes/session-recordings/player/PurePlayer.tsx
+++ b/frontend/src/scenes/session-recordings/player/PurePlayer.tsx
@@ -98,7 +98,6 @@ export function PurePlayer({ noMeta = false, noBorder = false }: PurePlayerProps
leadingUnplayableMs,
hasUnrenderableWindow,
unrenderableWindowMs,
- hasOversizedMutations,
fullyLoaded,
} = useValues(sessionRecordingPlayerLogic)
@@ -429,19 +428,6 @@ export function PurePlayer({ noMeta = false, noBorder = false }: PurePlayerProps
</Link>
</LemonBanner>
) : null}
- {hasOversizedMutations && !hidePlayerElements ? (
- <LemonBanner
- type="warning"
- className="shrink-0"
- dismissKey={`oversized-mutations-${sessionRecordingId}`}
- >
- Parts of this recording captured too much changing content to render.
- Playback skips those sections to keep the player responsive.{' '}
- <Link to="https://posthog.com/docs/session-replay/troubleshooting">
- Learn more
- </Link>
- </LemonBanner>
- ) : null}
<div className="relative">{showMeta ? <PlayerMetaBar /> : null}</div>
<div
className="SessionRecordingPlayer__body"
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
index 99c9eb16c1dd..aad51e2b3d55 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
@@ -6,9 +6,7 @@ import posthog from 'posthog-js'
import { processAllSnapshots, SnapshotSourceType, SourceKey, ViewportResolution } from '@posthog/replay-shared'
-import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { convertSnapshotsByWindowId } from 'scenes/session-recordings/__mocks__/recording_snapshots'
import { sessionRecordingDataCoordinatorLogic } from 'scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic'
import { sessionRecordingMetaLogic } from 'scenes/session-recordings/player/sessionRecordingMetaLogic'
@@ -80,14 +78,8 @@ describe('sessionRecordingDataCoordinatorLogic', () => {
const mountWithMeta = (
sessionRecordingId: string,
- meta: Record<string, any>,
- flagEnabled: boolean
+ meta: Record<string, any>
): ReturnType<typeof sessionRecordingDataCoordinatorLogic.build> => {
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags(
- flagEnabled ? [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE] : [],
- flagEnabled ? { [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]: true } : {}
- )
overrideSessionRecordingMocks({
getMocks: { '/api/environments/:team_id/session_recordings/:id': meta },
})
@@ -98,7 +90,7 @@ describe('sessionRecordingDataCoordinatorLogic', () => {
}
it('never loads snapshots for an unplayably large recording', async () => {
- const gatedLogic = mountWithMeta('oversized-gated', oversizedMeta, true)
+ const gatedLogic = mountWithMeta('oversized-gated', oversizedMeta)
await expectLogic(gatedLogic)
.toDispatchActions(['loadRecordingMetaSuccess'])
@@ -108,114 +100,20 @@ describe('sessionRecordingDataCoordinatorLogic', () => {
})
it.each([
- ['the flag is disabled', 'oversized-flag-off', oversizedMeta, false],
- ['the recording is mobile', 'oversized-mobile', { ...oversizedMeta, snapshot_source: 'mobile' }, true],
+ ['the recording is mobile', 'oversized-mobile', { ...oversizedMeta, snapshot_source: 'mobile' }],
[
'the recording is large but made of ordinary small events',
'oversized-small-events',
{ ...oversizedMeta, event_count: 1_000_000 },
- true,
- ],
- [
- 'the recording is small',
- 'oversized-small',
- { ...oversizedMeta, total_size: 1024, event_count: 10 },
- true,
],
- ])('auto-loads snapshots when %s', async (_name, sessionRecordingId, meta, flagEnabled) => {
- const gatedLogic = mountWithMeta(sessionRecordingId, meta, flagEnabled)
+ ['the recording is small', 'oversized-small', { ...oversizedMeta, total_size: 1024, event_count: 10 }],
+ ])('auto-loads snapshots when %s', async (_name, sessionRecordingId, meta) => {
+ const gatedLogic = mountWithMeta(sessionRecordingId, meta)
await expectLogic(gatedLogic)
.toDispatchActions(['loadRecordingMetaSuccess', 'loadSnapshotSources'])
.toMatchValues({ recordingTooLargeToPlay: false })
})
-
- const mutationSnapshots = (
- eventCount: number,
- addsPerEvent: number,
- gapMs: number = 1,
- startTs: number = 1000
- ): RecordingSnapshot[] =>
- Array.from(
- { length: eventCount },
- (_, i) =>
- ({
- windowId: '1',
- timestamp: startTs + i * gapMs,
- type: 3,
- data: { source: 0, adds: new Array(addsPerEvent).fill({}) },
- }) as unknown as RecordingSnapshot
- )
-
- it.each([
- ['a concentrated burst of adds', mutationSnapshots(10, 5000), true, true],
- ['the same adds spread over minutes', mutationSnapshots(10, 5000, 30_000), true, false],
- ['a single large render', mutationSnapshots(2, 5000), true, false],
- [
- 'malformed mutations without adds',
- mutationSnapshots(10, 0).map((s) => ({ ...s, data: { source: 0 } }) as unknown as RecordingSnapshot),
- true,
- false,
- ],
- ['the flag is disabled', mutationSnapshots(10, 5000), false, false],
- ])('detects oversized mutations with %s', (_name, snapshots, flagEnabled, expected) => {
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags(
- flagEnabled ? [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE] : [],
- flagEnabled ? { [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]: true } : {}
- )
- logic.actions.setProcessedSnapshots(snapshots)
-
- expect(logic.values.hasOversizedMutations).toBe(expected)
- })
-
- const fullSnapshot = (timestamp: number): RecordingSnapshot =>
- ({ windowId: '1', timestamp, type: 2, data: {} }) as unknown as RecordingSnapshot
-
- it.each([
- [
- 'excises the burst but keeps the recovering full snapshot and everything around it',
- [
- ...mutationSnapshots(1, 10, 1, -5000), // a small mutation more than a second before the burst
- ...mutationSnapshots(10, 5000),
- fullSnapshot(20_000),
- ...mutationSnapshots(1, 10, 1, 30_000),
- ],
- [-5000, 20_000, 30_000],
- ],
- [
- 'recovers at a full snapshot inside the burst window',
- [...mutationSnapshots(2, 5000), fullSnapshot(1002), ...mutationSnapshots(2, 5000, 1, 1003)],
- [1002, 1003, 1004],
- ],
- [
- 'excises everything after a burst with no later full snapshot',
- [
- ...mutationSnapshots(1, 10, 1, -5000),
- ...mutationSnapshots(10, 5000),
- ...mutationSnapshots(1, 10, 1, 30_000),
- ],
- [-5000],
- ],
- ])('%s', (_name, snapshots, expectedTimestamps) => {
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE], {
- [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]: true,
- })
- logic.actions.setProcessedSnapshots(snapshots)
-
- expect(logic.values.playableSnapshotsByWindowId['1'].map((s) => s.timestamp)).toEqual(expectedTimestamps)
- })
-
- it('passes snapshots through unchanged when nothing is oversized', () => {
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE], {
- [FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]: true,
- })
- logic.actions.setProcessedSnapshots(mutationSnapshots(2, 5000))
-
- expect(logic.values.playableSnapshotsByWindowId).toBe(logic.values.snapshotsByWindowId)
- })
})
describe('loading session core', () => {
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
index 08b17387e063..b7f05288e87d 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
@@ -25,9 +25,7 @@ import {
SourceLoadingState,
} from '@posthog/replay-shared'
-import { FEATURE_FLAGS } from 'lib/constants'
import { Dayjs, dayjs, now } from 'lib/dayjs'
-import { featureFlagLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { metricCount } from 'lib/operationalMetrics'
import {
@@ -62,64 +60,6 @@ import { createSegments, mapSnapshotsToWindowId } from './utils/segmenter'
// mutations); most large recordings are ordinary small events and play fine, so both must trip
export const OVERSIZED_RECORDING_AUTOLOAD_LIMIT_BYTES = 30 * 1024 * 1024
export const OVERSIZED_RECORDING_AVG_EVENT_BYTES = 100 * 1024
-// Adds concentrated in one playback second freeze the tab; the same adds spread out play fine
-export const OVERSIZED_MUTATION_WINDOW_MS = 1000
-export const OVERSIZED_MUTATION_WINDOW_ADDED_NODES = 15000
-
-export interface OversizedMutationRange {
- start: number
- // Exclusive; Infinity when no full snapshot follows the burst
- end: number
-}
-
-// A full snapshot rebuilds the DOM from scratch, so a burst and everything up to the next full snapshot can be dropped safely
-export function findOversizedMutationRanges(events: eventWithTime[]): OversizedMutationRange[] {
- const ranges: OversizedMutationRange[] = []
- const windowMutations: { timestamp: number; adds: number; index: number }[] = []
- let windowAdds = 0
- for (let i = 0; i < events.length; i++) {
- const event = events[i]
- if (
- event.type !== EventType.IncrementalSnapshot ||
- event.data?.source !== IncrementalSource.Mutation ||
- !Array.isArray(event.data.adds) ||
- event.data.adds.length === 0
- ) {
- continue
- }
- windowMutations.push({ timestamp: event.timestamp, adds: event.data.adds.length, index: i })
- windowAdds += event.data.adds.length
- while (event.timestamp - windowMutations[0].timestamp > OVERSIZED_MUTATION_WINDOW_MS) {
- windowAdds -= windowMutations.shift()!.adds
- }
- if (windowAdds < OVERSIZED_MUTATION_WINDOW_ADDED_NODES) {
- continue
- }
- const start = windowMutations[0].timestamp
- // The recovery point can sit inside the sliding window, before the mutation that tripped the threshold
- let end = Infinity
- for (let j = windowMutations[0].index; j < events.length; j++) {
- if (events[j].type === EventType.FullSnapshot && events[j].timestamp > start) {
- end = events[j].timestamp
- break
- }
- }
- ranges.push({ start, end })
- if (end === Infinity) {
- break
- }
- // Rescan from the recovery point so mutations kept past it count toward the next window
- let resume = windowMutations[0].index
- while (resume < events.length && events[resume].timestamp < end) {
- resume++
- }
- i = resume - 1
- windowMutations.length = 0
- windowAdds = 0
- }
- return ranges
-}
-
type ScrollEventData = { id: number; x: number; y: number }
function isScrollEvent(event: eventWithTime): boolean {
@@ -143,27 +83,26 @@ function pickWindow(byWindowId: Record<number, eventWithTime[]>, windowId: numbe
return windowId !== null ? (byWindowId[windowId] ?? []) : []
}
-// The window the player spends the timeline in (the most events), plus the processed/dropped totals
-function summarizeWindows(
- snapshotsByWindowId: Record<number, eventWithTime[]>,
- playableSnapshotsByWindowId: Record<number, eventWithTime[]>
-): { windowCount: number; processedEventCount: number; droppedEventCount: number; primaryWindowId: number | null } {
+// The window the player spends the timeline in (the most events), plus the processed total
+function summarizeWindows(snapshotsByWindowId: Record<number, eventWithTime[]>): {
+ windowCount: number
+ processedEventCount: number
+ primaryWindowId: number | null
+} {
const windowIds = Object.keys(snapshotsByWindowId)
let primaryWindowId: number | null = null
let primaryCount = -1
let processedEventCount = 0
- let droppedEventCount = 0
for (const windowIdKey of windowIds) {
const windowId = Number(windowIdKey)
const rawCount = snapshotsByWindowId[windowId]?.length ?? 0
processedEventCount += rawCount
- droppedEventCount += rawCount - (playableSnapshotsByWindowId[windowId]?.length ?? 0)
if (rawCount > primaryCount) {
primaryCount = rawCount
primaryWindowId = windowId
}
}
- return { windowCount: windowIds.length, processedEventCount, droppedEventCount, primaryWindowId }
+ return { windowCount: windowIds.length, processedEventCount, primaryWindowId }
}
// The node scrolled most often — the main page scroll rather than an inner carousel or table
@@ -219,14 +158,6 @@ function scrollOffsetAt(
return { x, y }
}
-function countOversizedRanges(oversizedMutationRanges: Record<number, OversizedMutationRange[]>): number {
- let total = 0
- for (const ranges of Object.values(oversizedMutationRanges)) {
- total += ranges.length
- }
- return total
-}
-
function countSources(sources: SessionRecordingSnapshotSource[] | null): Record<string, number> {
const sourceCounts: Record<string, number> = {}
for (const source of sources ?? []) {
@@ -243,19 +174,14 @@ function countSources(sources: SessionRecordingSnapshotSource[] | null): Record<
export function buildAnchorDiagnostic(
meta: SessionRecordingType | null,
snapshotsByWindowId: Record<number, eventWithTime[]>,
- playableSnapshotsByWindowId: Record<number, eventWithTime[]>,
start: Dayjs | null,
- oversizedMutationRanges: Record<number, OversizedMutationRange[]>,
segments: RecordingSegment[],
- sources: SessionRecordingSnapshotSource[] | null,
- oversizedGateOn: boolean
+ sources: SessionRecordingSnapshotSource[] | null
): Record<string, unknown> {
- const windows = summarizeWindows(snapshotsByWindowId, playableSnapshotsByWindowId)
+ const windows = summarizeWindows(snapshotsByWindowId)
const primaryRaw = pickWindow(snapshotsByWindowId, windows.primaryWindowId)
- const primaryPlayable = pickWindow(playableSnapshotsByWindowId, windows.primaryWindowId)
const rawBaseMs = firstTimestamp(primaryRaw)
- const rrwebBaseMs = firstTimestamp(primaryPlayable)
const eventStartMs = toMs(meta?.start_time)
const serverEventCount = meta?.event_count ?? null
const firstSegmentStartMs = segments[0]?.startTimestamp ?? null
@@ -280,11 +206,6 @@ export function buildAnchorDiagnostic(
chosen_start_ms: start?.valueOf() ?? null,
start_gap_ms: nullableDiff(rawBaseMs, eventStartMs),
raw_base_ms: rawBaseMs,
- rrweb_base_ms: rrwebBaseMs,
- base_shift_ms: nullableDiff(rrwebBaseMs, rawBaseMs),
- oversized_gate_on: oversizedGateOn,
- oversized_ranges_count: countOversizedRanges(oversizedMutationRanges),
- dropped_event_count: windows.droppedEventCount,
source_counts: countSources(sources),
source_count: sources?.length ?? 0,
primary_scroll_node_id: scroll.nodeId,
@@ -328,7 +249,6 @@ export interface sessionRecordingDataCoordinatorLogicValues {
sessionEventsDataLoading: boolean // eventsLogic
viewportForTimestamp: (timestamp: number) => ViewportResolution | undefined // eventsLogic
webVitalsEvents: RecordingEventType[] // eventsLogic
- featureFlags: FeatureFlagsSet // featureFlagLogic
annotations: AnnotationType[] // metaLogic
annotationsLoading: boolean // metaLogic
currentTeam: TeamPublicType | TeamType | null // metaLogic
@@ -356,11 +276,8 @@ export interface sessionRecordingDataCoordinatorLogicValues {
effectiveSourceLoadingStates: SourceLoadingState[]
end: Dayjs | null
fullyLoaded: boolean
- hasOversizedMutations: boolean
isOldAndInvalid: boolean
isRecentAndInvalid: boolean
- oversizedMutationRanges: Record<number, OversizedMutationRange[]>
- playableSnapshotsByWindowId: Record<number, eventWithTime[]>
processedSnapshots: RecordingSnapshot[]
recordingTooLargeToPlay: boolean
reportedLoaded: boolean
@@ -560,19 +477,7 @@ export interface sessionRecordingDataCoordinatorLogicActions {
export interface sessionRecordingDataCoordinatorLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- recordingTooLargeToPlay: (
- sessionPlayerMetaData: SessionRecordingType | null,
- featureFlags: FeatureFlagsSet
- ) => boolean
- oversizedMutationRanges: (
- snapshotsByWindowId: Record<number, eventWithTime[]>,
- featureFlags: FeatureFlagsSet
- ) => Record<number, OversizedMutationRange[]>
- hasOversizedMutations: (oversizedMutationRanges: Record<number, OversizedMutationRange[]>) => boolean
- playableSnapshotsByWindowId: (
- snapshotsByWindowId: Record<number, eventWithTime[]>,
- oversizedMutationRanges: Record<number, OversizedMutationRange[]>
- ) => Record<number, eventWithTime[]>
+ recordingTooLargeToPlay: (sessionPlayerMetaData: SessionRecordingType | null) => boolean
snapshots: (processedSnapshots: import('@posthog/replay-shared').RecordingSnapshot[]) => RecordingSnapshot[]
start: (
snapshots: import('@posthog/replay-shared').RecordingSnapshot[],
@@ -749,8 +654,6 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
],
snapLogic,
['snapshotStore', 'storeVersion', 'sourceLoadingStates'],
- featureFlagLogic,
- ['featureFlags'],
],
}
}),
@@ -924,12 +827,9 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
buildAnchorDiagnostic(
values.sessionPlayerMetaData,
values.snapshotsByWindowId,
- values.playableSnapshotsByWindowId,
values.start,
- values.oversizedMutationRanges,
values.segments,
- values.snapshotSources,
- !!values.featureFlags[FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]
+ values.snapshotSources
)
)
} catch {
@@ -940,11 +840,8 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
})),
selectors(() => ({
recordingTooLargeToPlay: [
- (s) => [s.sessionPlayerMetaData, s.featureFlags],
- (meta: SessionRecordingType | null, featureFlags: FeatureFlagsSet): boolean => {
- if (!featureFlags[FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]) {
- return false
- }
+ (s) => [s.sessionPlayerMetaData],
+ (meta: SessionRecordingType | null): boolean => {
// Mobile recordings are screenshot-based: large events, but cheap to play
if (meta?.snapshot_source !== 'web') {
return false
@@ -959,58 +856,6 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
},
],
- oversizedMutationRanges: [
- (s) => [s.snapshotsByWindowId, s.featureFlags],
- (
- snapshotsByWindowId: Record<number, eventWithTime[]>,
- featureFlags: FeatureFlagsSet
- ): Record<number, OversizedMutationRange[]> => {
- if (!featureFlags[FEATURE_FLAGS.REPLAY_OVERSIZED_RECORDING_GATE]) {
- return {}
- }
- const rangesByWindowId: Record<number, OversizedMutationRange[]> = {}
- for (const [windowId, events] of Object.entries(snapshotsByWindowId)) {
- const ranges = findOversizedMutationRanges(events)
- if (ranges.length > 0) {
- rangesByWindowId[windowId as unknown as number] = ranges
- }
- }
- return rangesByWindowId
- },
- ],
-
- hasOversizedMutations: [
- (s) => [s.oversizedMutationRanges],
- (oversizedMutationRanges: Record<number, OversizedMutationRange[]>): boolean => {
- return Object.keys(oversizedMutationRanges).length > 0
- },
- ],
-
- // Replayer input only; export, segments, and the inspector keep the raw events
- playableSnapshotsByWindowId: [
- (s) => [s.snapshotsByWindowId, s.oversizedMutationRanges],
- (
- snapshotsByWindowId: Record<number, eventWithTime[]>,
- oversizedMutationRanges: Record<number, OversizedMutationRange[]>
- ): Record<number, eventWithTime[]> => {
- if (Object.keys(oversizedMutationRanges).length === 0) {
- return snapshotsByWindowId
- }
- const result = { ...snapshotsByWindowId }
- for (const [windowId, ranges] of Object.entries(oversizedMutationRanges)) {
- result[windowId as unknown as number] = snapshotsByWindowId[windowId as unknown as number].filter(
- // Mutations only; a ViewportResize dropped here never comes back, since rrweb reads
- // dimensions from Meta rather than FullSnapshot
- (event) =>
- event.type !== EventType.IncrementalSnapshot ||
- event.data?.source !== IncrementalSource.Mutation ||
- !ranges.some((range) => event.timestamp >= range.start && event.timestamp < range.end)
- )
- }
- return result
- },
- ],
-
snapshots: [
(s) => [s.processedSnapshots],
(processedSnapshots: RecordingSnapshot[]): RecordingSnapshot[] => {
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
index 7393cc54714b..7330514ca528 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
@@ -565,8 +565,6 @@ export interface sessionRecordingPlayerLogicValues {
createExportJSON: () => ExportedSessionRecordingFileV2 // sessionRecordingDataCoordinatorLogic
customRRWebEvents: customEvent[] // sessionRecordingDataCoordinatorLogic
fullyLoaded: boolean // sessionRecordingDataCoordinatorLogic
- hasOversizedMutations: boolean // sessionRecordingDataCoordinatorLogic
- playableSnapshotsByWindowId: Record<number, eventWithTime[]> // sessionRecordingDataCoordinatorLogic
recordingTooLargeToPlay: boolean // sessionRecordingDataCoordinatorLogic
sessionPlayerData: SessionPlayerData // sessionRecordingDataCoordinatorLogic
sessionPlayerMetaData: SessionRecordingType | null // sessionRecordingDataCoordinatorLogic
@@ -1106,11 +1104,11 @@ export interface sessionRecordingPlayerLogicMeta {
currentPlayerTime: (currentTimestamp: number | undefined, sessionPlayerData: SessionPlayerData) => number
currentPlayerTimeSeconds: (currentPlayerTime: number) => number
toRRWebPlayerTime: (
- playableSnapshotsByWindowId: Record<number, eventWithTime[]>,
+ sessionPlayerData: SessionPlayerData,
currentSegment: null | import('@posthog/replay-shared').RecordingSegment
) => (timestamp: number) => number | undefined
fromRRWebPlayerTime: (
- playableSnapshotsByWindowId: Record<number, eventWithTime[]>,
+ sessionPlayerData: SessionPlayerData,
currentSegment: null | import('@posthog/replay-shared').RecordingSegment
) => (time?: number | undefined) => number | undefined
jumpTimeMs: (speed: number) => number
@@ -1221,8 +1219,6 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
'fullyLoaded',
'trackedWindow',
'recordingTooLargeToPlay',
- 'hasOversizedMutations',
- 'playableSnapshotsByWindowId',
],
playerSettingsLogic,
['speed', 'skipInactivitySetting', 'showMetadataFooter', 'playerControlsOverlay'],
@@ -1776,15 +1772,14 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
// The relative time for the player, i.e. the offset between the current timestamp, and the window start for the current segment
toRRWebPlayerTime: [
- (s) => [s.playableSnapshotsByWindowId, s.currentSegment],
- (playableSnapshotsByWindowId: Record<number, eventWithTime[]>, currentSegment: RecordingSegment | null) => {
+ (s) => [s.sessionPlayerData, s.currentSegment],
+ (sessionPlayerData: SessionPlayerData, currentSegment: RecordingSegment | null) => {
return (timestamp: number): number | undefined => {
if (!currentSegment || !currentSegment.windowId) {
return
}
- // The replayer's time base is the first event it was fed, so use the filtered set
- const snapshots = playableSnapshotsByWindowId[currentSegment.windowId]
+ const snapshots = sessionPlayerData.snapshotsByWindowId[currentSegment.windowId]
if (!snapshots?.length) {
return
}
@@ -1796,13 +1791,13 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
// The relative time for the player, i.e. the offset between the current timestamp, and the window start for the current segment
fromRRWebPlayerTime: [
- (s) => [s.playableSnapshotsByWindowId, s.currentSegment],
- (playableSnapshotsByWindowId: Record<number, eventWithTime[]>, currentSegment: RecordingSegment | null) => {
+ (s) => [s.sessionPlayerData, s.currentSegment],
+ (sessionPlayerData: SessionPlayerData, currentSegment: RecordingSegment | null) => {
return (time?: number): number | undefined => {
if (time === undefined || !currentSegment?.windowId) {
return
}
- const snapshots = playableSnapshotsByWindowId[currentSegment.windowId]
+ const snapshots = sessionPlayerData.snapshotsByWindowId[currentSegment.windowId]
if (!snapshots?.length) {
return
}
@@ -2421,8 +2416,8 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
if (
!values.rootFrame ||
windowId === undefined ||
- !values.playableSnapshotsByWindowId[windowId] ||
- values.playableSnapshotsByWindowId[windowId].length < 2
+ !values.sessionPlayerData.snapshotsByWindowId[windowId] ||
+ values.sessionPlayerData.snapshotsByWindowId[windowId].length < 2
) {
actions.setPlayer(null)
return
@@ -2436,7 +2431,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
plugins.push(CorsPlugin)
}
- const canvasPlugin = CanvasReplayerPlugin(values.playableSnapshotsByWindowId[windowId], (error) =>
+ const canvasPlugin = CanvasReplayerPlugin(values.sessionPlayerData.snapshotsByWindowId[windowId], (error) =>
posthog.captureException(error)
)
plugins.push(canvasPlugin)
@@ -2502,7 +2497,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
// the config.onError callback only covers its async internal errors. Without this
// catch the throw escapes the listener and the player buffers forever.
try {
- const replayer = new Replayer(values.playableSnapshotsByWindowId[windowId], config)
+ const replayer = new Replayer(values.sessionPlayerData.snapshotsByWindowId[windowId], config)
const iframeCleanups: (() => void)[] = []
replayer.on('fullsnapshot-rebuilded', () => {
@@ -2651,7 +2646,8 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
if (!values.player || values.player.windowId !== segment.windowId) {
// Only reinitialize if we have valid data for this segment's window
const canReinit =
- segment.windowId !== undefined && values.playableSnapshotsByWindowId[segment.windowId]?.length >= 2
+ segment.windowId !== undefined &&
+ values.sessionPlayerData.snapshotsByWindowId[segment.windowId]?.length >= 2
if (canReinit) {
values.player?.replayer?.pause()
@@ -2832,7 +2828,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
}
if (values.currentSegment?.windowId !== undefined) {
- const allSnapshots = values.playableSnapshotsByWindowId[values.currentSegment?.windowId] ?? []
+ const allSnapshots = values.sessionPlayerData.snapshotsByWindowId[values.currentSegment?.windowId] ?? []
// NOTE: not `push(...array)` — spreading an unbounded snapshot array into a call
// blows the argument stack (RangeError) on very large recordings
for (const event of findNewEvents(allSnapshots, currentEvents)) {
@@ -3607,13 +3603,6 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
})),
subscriptions(({ actions, values }) => ({
- hasOversizedMutations: (detected: boolean) => {
- if (detected) {
- posthog.capture('recording player skipped oversized mutations', {
- watchedSessionId: values.sessionRecordingId,
- })
- }
- },
sessionPlayerData: (value, oldValue) => {
const hasSnapshotChanges = value?.snapshotsByWindowId !== oldValue?.snapshotsByWindowId