From f4cd9ca53bb6114b18dfb5c894dd1aeeb5b555f4 Mon Sep 17 00:00:00 2001 From: Domagoj Gavranic Date: Tue, 7 Jan 2025 00:48:28 +0100 Subject: [PATCH 1/5] feat(replay): Expose rrweb recordCrossOriginIframes under _experiments (#14809) Expose the `recordCrossOriginIframes` option under `_experiments`. This option records cross-origin iframes for session replay. --- packages/replay-internal/src/integration.ts | 5 +++++ packages/replay-internal/src/types/replay.ts | 1 + packages/replay-internal/src/types/rrweb.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/packages/replay-internal/src/integration.ts b/packages/replay-internal/src/integration.ts index 49383d9da3b7..940bd612151e 100644 --- a/packages/replay-internal/src/integration.ts +++ b/packages/replay-internal/src/integration.ts @@ -152,6 +152,11 @@ export class Replay implements Integration { }, }; + // experimental support for recording iframes from different origins + if (_experiments.recordCrossOriginIframes) { + this._recordingOptions.recordCrossOriginIframes = true; + } + this._initialOptions = { flushMinDelay, flushMaxDelay, diff --git a/packages/replay-internal/src/types/replay.ts b/packages/replay-internal/src/types/replay.ts index 7cd4c78a21c5..d9308cecabe9 100644 --- a/packages/replay-internal/src/types/replay.ts +++ b/packages/replay-internal/src/types/replay.ts @@ -239,6 +239,7 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions { captureExceptions: boolean; traceInternals: boolean; continuousCheckout: number; + recordCrossOriginIframes: boolean; }>; } diff --git a/packages/replay-internal/src/types/rrweb.ts b/packages/replay-internal/src/types/rrweb.ts index 60e562cadf55..33f5e1b3bf7f 100644 --- a/packages/replay-internal/src/types/rrweb.ts +++ b/packages/replay-internal/src/types/rrweb.ts @@ -43,6 +43,7 @@ export type RrwebRecordOptions = { maskTextSelector?: string; blockSelector?: string; maskInputOptions?: Record; + recordCrossOriginIframes?: boolean; } & Record; export interface CanvasManagerInterface { From 578332d035fdfc050b677038edb45f37105d1de8 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 14 Feb 2025 13:37:45 -0500 Subject: [PATCH 2/5] Apply suggestions from code review --- packages/replay-internal/src/integration.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/replay-internal/src/integration.ts b/packages/replay-internal/src/integration.ts index b9ce8fed56ba..4ec1a357eac4 100644 --- a/packages/replay-internal/src/integration.ts +++ b/packages/replay-internal/src/integration.ts @@ -150,13 +150,10 @@ export class Replay implements Integration { // this can happen if the error is frozen or does not allow mutation for other reasons } }, + // experimental support for recording iframes from different origins + recordCrossOriginIframes: Boolean(_experiments.recordCrossOriginIframes), }; - // experimental support for recording iframes from different origins - if (_experiments.recordCrossOriginIframes) { - this._recordingOptions.recordCrossOriginIframes = true; - } - this._initialOptions = { flushMinDelay, flushMaxDelay, From 928c63a89ee87ab6499431d7efdc0a8886cb5e81 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 14 Feb 2025 14:33:56 -0500 Subject: [PATCH 3/5] update tests --- packages/replay-internal/test/integration/rrweb.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/replay-internal/test/integration/rrweb.test.ts b/packages/replay-internal/test/integration/rrweb.test.ts index 7f156c542f08..0e6ada8b0d2a 100644 --- a/packages/replay-internal/test/integration/rrweb.test.ts +++ b/packages/replay-internal/test/integration/rrweb.test.ts @@ -40,6 +40,7 @@ describe('Integration | rrweb', () => { "maskTextFn": undefined, "maskTextSelector": ".sentry-mask,[data-sentry-mask]", "onMutation": [Function], + "recordCrossOriginIframes": false, "slimDOMOptions": "all", "unblockSelector": "", "unmaskTextSelector": "", @@ -80,6 +81,7 @@ describe('Integration | rrweb', () => { "maskTextFn": undefined, "maskTextSelector": ".sentry-mask,[data-sentry-mask]", "onMutation": [Function], + "recordCrossOriginIframes": false, "slimDOMOptions": "all", "unblockSelector": "", "unmaskTextSelector": "", @@ -131,6 +133,7 @@ describe('Integration | rrweb', () => { "maskTextFn": undefined, "maskTextSelector": ".sentry-mask,[data-sentry-mask]", "onMutation": [Function], + "recordCrossOriginIframes": false, "sampling": { "mousemove": false, }, From 6bb656bb74653e9370b53f6fda28c57bdbda26f8 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 14 Feb 2025 14:34:23 -0500 Subject: [PATCH 4/5] bump size limit --- .size-limit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.size-limit.js b/.size-limit.js index c6e86836fd4c..157c1243021e 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -54,7 +54,7 @@ module.exports = [ path: 'packages/browser/build/npm/esm/index.js', import: createImport('init', 'browserTracingIntegration', 'replayIntegration'), gzip: true, - limit: '68 KB', + limit: '70 KB', modifyWebpackConfig: function (config) { const webpack = require('webpack'); const TerserPlugin = require('terser-webpack-plugin'); From 812313154eb64873eb4f8ca3d6fd0949a2b28aff Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Tue, 18 Feb 2025 15:13:20 -0500 Subject: [PATCH 5/5] add note about considerations --- packages/replay-internal/src/types/replay.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/replay-internal/src/types/replay.ts b/packages/replay-internal/src/types/replay.ts index 3dc384532d01..cc8e6f1827ac 100644 --- a/packages/replay-internal/src/types/replay.ts +++ b/packages/replay-internal/src/types/replay.ts @@ -229,6 +229,10 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions { captureExceptions: boolean; traceInternals: boolean; continuousCheckout: number; + /** + * Before enabling, please read the security considerations: + * https://github.com/rrweb-io/rrweb/blob/master/docs/recipes/cross-origin-iframes.md#considerations + */ recordCrossOriginIframes: boolean; autoFlushOnFeedback: boolean; }>;