File tree Expand file tree Collapse file tree 5 files changed +63
-3
lines changed
dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit
packages/replay-internal/src Expand file tree Collapse file tree 5 files changed +63
-3
lines changed Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/browser' ;
2+
3+ window . Sentry = Sentry ;
4+ window . Replay = Sentry . replayIntegration ( {
5+ flushMinDelay : 200 ,
6+ flushMaxDelay : 200 ,
7+ // Try to set to 60s - should be capped at 50s
8+ minReplayDuration : 60000 ,
9+ } ) ;
10+
11+ Sentry . init ( {
12+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
13+ sampleRate : 0 ,
14+ replaysSessionSampleRate : 1.0 ,
15+ replaysOnErrorSampleRate : 0.0 ,
16+
17+ integrations : [ window . Replay ] ,
18+ } ) ;
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < title > Replay - minReplayDuration Limit</ title >
6+ </ head >
7+ < body >
8+ < div id ="content ">
9+ < p > Testing that minReplayDuration is capped at 50s max</ p >
10+ </ div >
11+ </ body >
12+ </ html >
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+ import { sentryTest } from '../../../utils/fixtures' ;
3+ import { shouldSkipReplayTest } from '../../../utils/replayHelpers' ;
4+
5+ sentryTest ( 'caps minReplayDuration to maximum of 50 seconds' , async ( { getLocalTestUrl, page } ) => {
6+ if ( shouldSkipReplayTest ( ) ) {
7+ sentryTest . skip ( ) ;
8+ }
9+
10+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
11+
12+ await page . goto ( url ) ;
13+
14+ const actualMinReplayDuration = await page . evaluate ( ( ) => {
15+ // @ts -expect-error - Replay is not typed on window
16+ const replayIntegration = window . Replay ;
17+ const replay = replayIntegration . _replay ;
18+ return replay . getOptions ( ) . minReplayDuration ;
19+ } ) ;
20+
21+ // Even though we configured it to 60s (60000ms), it should be capped to 50s
22+ expect ( actualMinReplayDuration ) . toBe ( 50_000 ) ;
23+ } ) ;
Original file line number Diff line number Diff line change @@ -45,8 +45,12 @@ export const REPLAY_MAX_EVENT_BUFFER_SIZE = 20_000_000; // ~20MB
4545
4646/** Replays must be min. 5s long before we send them. */
4747export const MIN_REPLAY_DURATION = 4_999 ;
48- /* The max. allowed value that the minReplayDuration can be set to. */
49- export const MIN_REPLAY_DURATION_LIMIT = 15_000 ;
48+
49+ /*
50+ The max. allowed value that the minReplayDuration can be set to.
51+ This needs to be below 60s, so we don't unintentionally drop buffered replays that are longer than 60s.
52+ */
53+ export const MIN_REPLAY_DURATION_LIMIT = 50_000 ;
5054
5155/** The max. length of a replay. */
5256export const MAX_REPLAY_DURATION = 3_600_000 ; // 60 minutes in ms;
Original file line number Diff line number Diff line change @@ -180,7 +180,10 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions {
180180 /**
181181 * The min. duration (in ms) a replay has to have before it is sent to Sentry.
182182 * Whenever attempting to flush a session that is shorter than this, it will not actually send it to Sentry.
183- * Note that this is capped at max. 15s.
183+ * Note that this is capped at max. 50s, so we don't unintentionally drop buffered replays that are longer than 60s
184+ *
185+ * Warning: Setting this to a higher value can result in unintended drops of onError-sampled replays.
186+ *
184187 */
185188 minReplayDuration : number ;
186189
You can’t perform that action at this time.
0 commit comments