Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename method #20767

Merged
merged 9 commits into from
Mar 8, 2024
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventWithTime } from '@rrweb/types'
import { prepareRecordingSnapshots } from 'scenes/session-recordings/player/sessionRecordingDataLogic'
import { deduplicateSnapshots } from 'scenes/session-recordings/player/sessionRecordingDataLogic'

import { RecordingSnapshot } from '~/types'

Expand Down Expand Up @@ -27,7 +27,7 @@ export const convertSnapshotsResponse = (
snapshotsByWindowId: { [key: string]: eventWithTime[] },
existingSnapshots?: RecordingSnapshot[]
): RecordingSnapshot[] => {
return prepareRecordingSnapshots(convertSnapshotsByWindowId(snapshotsByWindowId), existingSnapshots)
return deduplicateSnapshots(convertSnapshotsByWindowId(snapshotsByWindowId), existingSnapshots)
}

export const sortedRecordingSnapshots = (): { snapshot_data_by_window_id: Record<string, RecordingSnapshot[]> } => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { urls } from 'scenes/urls'
import { Breadcrumb, PersonType, RecordingSnapshot, ReplayTabs, SessionRecordingType } from '~/types'

import {
deduplicateSnapshots,
parseEncodedSnapshots,
prepareRecordingSnapshots,
sessionRecordingDataLogic,
} from '../player/sessionRecordingDataLogic'
import type { sessionRecordingDataLogicType } from '../player/sessionRecordingDataLogicType'
Expand Down Expand Up @@ -177,7 +177,7 @@ export const sessionRecordingFilePlaybackLogic = kea<sessionRecordingFilePlaybac
return
}

const snapshots = prepareRecordingSnapshots(
const snapshots = deduplicateSnapshots(
await parseEncodedSnapshots(
values.sessionRecording.snapshots,
values.sessionRecording.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
snapshotsAsRealTimeJSONPayload,
} from 'scenes/session-recordings/__mocks__/recording_snapshots'
import {
prepareRecordingSnapshots,
deduplicateSnapshots,
sessionRecordingDataLogic,
} from 'scenes/session-recordings/player/sessionRecordingDataLogic'
import { teamLogic } from 'scenes/teamLogic'
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('sessionRecordingDataLogic', () => {

expect(snapshotsWithDuplicates.length).toEqual(snapshots.length + 2)

expect(prepareRecordingSnapshots(snapshots)).toEqual(prepareRecordingSnapshots(snapshotsWithDuplicates))
expect(deduplicateSnapshots(snapshots)).toEqual(deduplicateSnapshots(snapshotsWithDuplicates))
})

it('should cope with two not duplicate snapshots with the same timestamp and delay', () => {
Expand All @@ -326,13 +326,13 @@ describe('sessionRecordingDataLogic', () => {
},
]
// we call this multiple times and pass existing data in, so we need to make sure it doesn't change
expect(prepareRecordingSnapshots(verySimilarSnapshots, verySimilarSnapshots)).toEqual(verySimilarSnapshots)
expect(deduplicateSnapshots(verySimilarSnapshots, verySimilarSnapshots)).toEqual(verySimilarSnapshots)
})

it('should match snapshot', () => {
const snapshots = convertSnapshotsByWindowId(sortedRecordingSnapshotsJson.snapshot_data_by_window_id)

expect(prepareRecordingSnapshots(snapshots)).toMatchSnapshot()
expect(deduplicateSnapshots(snapshots)).toMatchSnapshot()
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const getHrefFromSnapshot = (snapshot: RecordingSnapshot): string | undefined =>
return (snapshot.data as any)?.href || (snapshot.data as any)?.payload?.href
}

export const prepareRecordingSnapshots = (
export const deduplicateSnapshots = (
newSnapshots?: RecordingSnapshot[],
existingSnapshots?: RecordingSnapshot[]
): RecordingSnapshot[] => {
Expand Down Expand Up @@ -210,7 +210,7 @@ async function processEncodedResponse(
): Promise<{ transformed: RecordingSnapshot[]; untransformed: RecordingSnapshot[] | null }> {
let untransformed: RecordingSnapshot[] | null = null

const transformed = prepareRecordingSnapshots(
const transformed = deduplicateSnapshots(
await parseEncodedSnapshots(
encodedResponse,
props.sessionRecordingId,
Expand All @@ -220,7 +220,7 @@ async function processEncodedResponse(
)

if (featureFlags[FEATURE_FLAGS.SESSION_REPLAY_EXPORT_MOBILE_DATA]) {
untransformed = prepareRecordingSnapshots(
untransformed = deduplicateSnapshots(
await parseEncodedSnapshots(
encodedResponse,
props.sessionRecordingId,
Expand Down
Loading