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

fix: full snapshot every 10 minutes #847

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: full snapshot every 30 minutes
pauldambra committed Oct 23, 2023
commit a7af096fd5ae715c6ff328a192c2c994c13a0467
2 changes: 2 additions & 0 deletions src/__tests__/extensions/sessionrecording.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import {
RECORDING_IDLE_ACTIVITY_TIMEOUT_MS,
RECORDING_MAX_EVENT_SIZE,
SessionRecording,
THIRTY_MINUTES_IN_MS,
} from '../../extensions/sessionrecording'
import { PostHogPersistence } from '../../posthog-persistence'
import {
@@ -263,6 +264,7 @@ describe('SessionRecording', () => {
plugins: [],
inlineStylesheet: true,
recordCrossOriginIframes: false,
checkoutEveryNms: THIRTY_MINUTES_IN_MS,
})
})

14 changes: 14 additions & 0 deletions src/extensions/sessionrecording.ts
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import { logger, loadScript, _timestamp, window } from '../utils'
const BASE_ENDPOINT = '/s/'

export const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 // 5 minutes
export const THIRTY_MINUTES_IN_MS = 30 * 60 * 1000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes total sense... I even wonder if we shouldn't make it slightly lower, like say 10 mins?

export const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)
export const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds
export const SESSION_RECORDING_BATCH_KEY = 'recordings'
@@ -326,6 +327,8 @@ export class SessionRecording {
collectFonts: false,
inlineStylesheet: true,
recordCrossOriginIframes: false,
//take a full snapshot after every N ms
checkoutEveryNms: THIRTY_MINUTES_IN_MS,
}
// We switched from loading all of rrweb to just the record part, but
// keep backwards compatibility if someone hasn't upgraded PostHog
@@ -401,6 +404,17 @@ export class SessionRecording {
return
}

const typeLookup = {
0: 'DomContentLoaded',
1: 'Load',
2: 'FullSnapshot',
3: 'IncrementalSnapshot',
4: 'Meta',
5: 'Custom',
6: 'Plugin',
}
logger.info('[onRRwebEmit] event type', { type: rawEvent.type, name: typeLookup[rawEvent.type] })

if (rawEvent.type === EventType.Meta) {
const href = this._maskUrl(rawEvent.data.href)
if (!href) {