From 010185bd2b880e2e76f20be9f7f0e20998d0373e Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 12 Nov 2025 17:27:02 +0100 Subject: [PATCH 1/6] bumpbumpbump --- .../replay/minReplayDurationLimit/init.js | 18 +++++++++++++++ .../minReplayDurationLimit/template.html | 12 ++++++++++ .../replay/minReplayDurationLimit/test.ts | 22 +++++++++++++++++++ packages/replay-internal/src/constants.ts | 8 +++++-- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js create mode 100644 dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/template.html create mode 100644 dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js new file mode 100644 index 000000000000..58873b85f9ec --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js @@ -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], +}); diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/template.html b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/template.html new file mode 100644 index 000000000000..06c44ed4bc9c --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/template.html @@ -0,0 +1,12 @@ + + + + + Replay - minReplayDuration Limit + + +
+

Testing that minReplayDuration is capped at 50s max

+
+ + diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts new file mode 100644 index 000000000000..c9a0cfaa2b0e --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts @@ -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); +}); diff --git a/packages/replay-internal/src/constants.ts b/packages/replay-internal/src/constants.ts index da253a68ec8f..ac24f64cddfe 100644 --- a/packages/replay-internal/src/constants.ts +++ b/packages/replay-internal/src/constants.ts @@ -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. +*/ +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; From 1113657f960081af571d8f15e1c95035114a2e3c Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 12 Nov 2025 17:33:57 +0100 Subject: [PATCH 2/6] Update dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com> --- .../suites/replay/minReplayDurationLimit/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js index 58873b85f9ec..4979729342e3 100644 --- a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js @@ -5,7 +5,7 @@ window.Replay = Sentry.replayIntegration({ flushMinDelay: 200, flushMaxDelay: 200, // Try to set to 60s - should be capped at 50s - minReplayDuration: 60000, + minReplayDuration: 60_000, }); Sentry.init({ From fb8be139a1c907106e7896d2576c60f6a495b322 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 12 Nov 2025 17:34:03 +0100 Subject: [PATCH 3/6] Update dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com> --- .../suites/replay/minReplayDurationLimit/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts index c9a0cfaa2b0e..78225c156acc 100644 --- a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts @@ -18,5 +18,5 @@ sentryTest('caps minReplayDuration to maximum of 50 seconds', async ({ getLocalT }); // Even though we configured it to 60s (60000ms), it should be capped to 50s - expect(actualMinReplayDuration).toBe(50000); + expect(actualMinReplayDuration).toBe(50_000); }); From c3fac41fcca3ec3a01cd9a0a1906a5af1d5cc7b1 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 13 Nov 2025 09:44:54 +0100 Subject: [PATCH 4/6] update jsdocs --- packages/replay-internal/src/types/replay.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/replay-internal/src/types/replay.ts b/packages/replay-internal/src/types/replay.ts index a2c84d6c4bbe..75a2d35e64f2 100644 --- a/packages/replay-internal/src/types/replay.ts +++ b/packages/replay-internal/src/types/replay.ts @@ -180,7 +180,10 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions { /** * The min. duration (in ms) a replay has to have before it is sent to Sentry. * Whenever attempting to flush a session that is shorter than this, it will not actually send it to Sentry. - * Note that this is capped at max. 15s. + * Note that this is capped at max. 50s, so we don't unintentionally drop buffered replays that are longer than 60s + * + * Warning: Setting this to a higher value can result in unintended drops of onError-sampled replays. + * */ minReplayDuration: number; From 793478af294a362fcf151b14fc011976416c64d6 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 13 Nov 2025 09:46:19 +0100 Subject: [PATCH 5/6] fix lint --- .../suites/replay/minReplayDurationLimit/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js index 4979729342e3..58873b85f9ec 100644 --- a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/init.js @@ -5,7 +5,7 @@ window.Replay = Sentry.replayIntegration({ flushMinDelay: 200, flushMaxDelay: 200, // Try to set to 60s - should be capped at 50s - minReplayDuration: 60_000, + minReplayDuration: 60000, }); Sentry.init({ From bb30696bf61dfcb0058761c57173a70c3db75412 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 13 Nov 2025 10:36:50 +0100 Subject: [PATCH 6/6] . --- .../suites/replay/minReplayDurationLimit/test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts index 78225c156acc..125af55a6985 100644 --- a/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/minReplayDurationLimit/test.ts @@ -13,8 +13,9 @@ sentryTest('caps minReplayDuration to maximum of 50 seconds', async ({ getLocalT const actualMinReplayDuration = await page.evaluate(() => { // @ts-expect-error - Replay is not typed on window - const replay = window.Replay; - return replay._initialOptions.minReplayDuration; + const replayIntegration = window.Replay; + const replay = replayIntegration._replay; + return replay.getOptions().minReplayDuration; }); // Even though we configured it to 60s (60000ms), it should be capped to 50s