Skip to content

Commit 7efb1d2

Browse files
feat(replay): Bump limit for minReplayDuration (#18190)
With this PR users can set their min replay duration to max 50s, previously this was capped at 15s. We cannot bump this value further as this would lead to dropping buffered replays (we keep max. 60s in-memory at this point) closes #18109 --------- Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com>
1 parent 090a3e3 commit 7efb1d2

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
});

packages/replay-internal/src/constants.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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. */
4747
export 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. */
5256
export const MAX_REPLAY_DURATION = 3_600_000; // 60 minutes in ms;

packages/replay-internal/src/types/replay.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)