Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;
window.Replay = Sentry.replayIntegration({
flushMinDelay: 200,
flushMaxDelay: 200,
// Try to set to 60s - should be capped at 50s
minReplayDuration: 60000,
});

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 0.0,

integrations: [window.Replay],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Replay - minReplayDuration Limit</title>
</head>
<body>
<div id="content">
<p>Testing that minReplayDuration is capped at 50s max</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { shouldSkipReplayTest } from '../../../utils/replayHelpers';

sentryTest('caps minReplayDuration to maximum of 50 seconds', async ({ getLocalTestUrl, page }) => {
if (shouldSkipReplayTest()) {
sentryTest.skip();
}

const url = await getLocalTestUrl({ testDir: __dirname });

await page.goto(url);

const actualMinReplayDuration = await page.evaluate(() => {
// @ts-expect-error - Replay is not typed on window
const replay = window.Replay;
return replay._initialOptions.minReplayDuration;
});

// Even though we configured it to 60s (60000ms), it should be capped to 50s
expect(actualMinReplayDuration).toBe(50000);
});
8 changes: 6 additions & 2 deletions packages/replay-internal/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ export const REPLAY_MAX_EVENT_BUFFER_SIZE = 20_000_000; // ~20MB

/** Replays must be min. 5s long before we send them. */
export const MIN_REPLAY_DURATION = 4_999;
/* The max. allowed value that the minReplayDuration can be set to. */
export const MIN_REPLAY_DURATION_LIMIT = 15_000;

/*
The max. allowed value that the minReplayDuration can be set to.
This needs to be below 60s, so we don't unintentionally drop buffered replays that are longer than 60s.
Copy link
Member

Choose a reason for hiding this comment

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

We should add the comment in the replay options type so that it's visible to users. We should also be clear that this can drop onError-sampled replays

*/
export const MIN_REPLAY_DURATION_LIMIT = 50_000;

/** The max. length of a replay. */
export const MAX_REPLAY_DURATION = 3_600_000; // 60 minutes in ms;
Expand Down
Loading