@sentry/replay 7.24.0 → 7.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,13 +98,13 @@ You have to add it in addition to the Sentry Browser SDK bundle:
98
98
  ```js
99
99
  // Browser SDK bundle
100
100
  <script
101
- src="https://browser.sentry-cdn.com/7.24.0/bundle.tracing.min.js"
101
+ src="https://browser.sentry-cdn.com/7.24.1/bundle.tracing.min.js"
102
102
  crossorigin="anonymous"
103
103
  ></script>
104
104
 
105
105
  // Replay integration bundle
106
106
  <script
107
- src="https://browser.sentry-cdn.com/7.24.0/replay.min.js"
107
+ src="https://browser.sentry-cdn.com/7.24.1/replay.min.js"
108
108
  crossorigin="anonymous"
109
109
  ></script>
110
110
 
package/cjs/index.js CHANGED
@@ -1,191 +1,8 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
- const core = require('@sentry/core');
4
- const constants = require('./constants.js');
5
- const replay = require('./replay.js');
6
- const captureInternalException = require('./util/captureInternalException.js');
7
- const isBrowser = require('./util/isBrowser.js');
3
+ const integration = require('./integration.js');
8
4
 
9
- const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
10
5
 
11
- let _initialized = false;
12
6
 
13
- class Replay {
14
- /**
15
- * @inheritDoc
16
- */
17
- static __initStatic() {this.id = 'Replay';}
18
-
19
- /**
20
- * @inheritDoc
21
- */
22
- __init() {this.name = Replay.id;}
23
-
24
- /**
25
- * Options to pass to `rrweb.record()`
26
- */
27
-
28
- /** In tests, this is only called the first time */
29
- __init2() {this._hasCalledSetupOnce = false;}
30
-
31
- constructor({
32
- flushMinDelay = 5000,
33
- flushMaxDelay = 15000,
34
- initialFlushDelay = 5000,
35
- stickySession = true,
36
- useCompression = true,
37
- sessionSampleRate,
38
- errorSampleRate,
39
- maskAllText = true,
40
- maskAllInputs = true,
41
- blockAllMedia = true,
42
- blockClass = 'sentry-block',
43
- ignoreClass = 'sentry-ignore',
44
- maskTextClass = 'sentry-mask',
45
- blockSelector = '[data-sentry-block]',
46
- ...recordingOptions
47
- } = {}) {;Replay.prototype.__init.call(this);Replay.prototype.__init2.call(this);
48
- this.recordingOptions = {
49
- maskAllInputs,
50
- blockClass,
51
- ignoreClass,
52
- maskTextClass,
53
- blockSelector,
54
- ...recordingOptions,
55
- };
56
-
57
- this.options = {
58
- flushMinDelay,
59
- flushMaxDelay,
60
- stickySession,
61
- initialFlushDelay,
62
- sessionSampleRate: constants.DEFAULT_SESSION_SAMPLE_RATE,
63
- errorSampleRate: constants.DEFAULT_ERROR_SAMPLE_RATE,
64
- useCompression,
65
- maskAllText,
66
- blockAllMedia,
67
- };
68
-
69
- if (typeof sessionSampleRate === 'number') {
70
- // eslint-disable-next-line
71
- console.warn(
72
- `[Replay] You are passing \`sessionSampleRate\` to the Replay integration.
73
- This option is deprecated and will be removed soon.
74
- Instead, configure \`replaysSessionSampleRate\` directly in the SDK init options, e.g.:
75
- Sentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,
76
- );
77
-
78
- this.options.sessionSampleRate = sessionSampleRate;
79
- }
80
-
81
- if (typeof errorSampleRate === 'number') {
82
- // eslint-disable-next-line
83
- console.warn(
84
- `[Replay] You are passing \`errorSampleRate\` to the Replay integration.
85
- This option is deprecated and will be removed soon.
86
- Instead, configure \`replaysOnErrorSampleRate\` directly in the SDK init options, e.g.:
87
- Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
88
- );
89
-
90
- this.options.errorSampleRate = errorSampleRate;
91
- }
92
-
93
- if (this.options.maskAllText) {
94
- // `maskAllText` is a more user friendly option to configure
95
- // `maskTextSelector`. This means that all nodes will have their text
96
- // content masked.
97
- this.recordingOptions.maskTextSelector = '*';
98
- }
99
-
100
- if (this.options.blockAllMedia) {
101
- // `blockAllMedia` is a more user friendly option to configure blocking
102
- // embedded media elements
103
- this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
104
- ? MEDIA_SELECTORS
105
- : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
106
- }
107
-
108
- if (isBrowser.isBrowser() && _initialized) {
109
- const error = new Error('Multiple Sentry Session Replay instances are not supported');
110
- captureInternalException.captureInternalException(error);
111
- throw error;
112
- }
113
-
114
- _initialized = true;
115
- }
116
-
117
- /**
118
- * We previously used to create a transaction in `setupOnce` and it would
119
- * potentially create a transaction before some native SDK integrations have run
120
- * and applied their own global event processor. An example is:
121
- * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
122
- *
123
- * So we call `replay.setup` in next event loop as a workaround to wait for other
124
- * global event processors to finish. This is no longer needed, but keeping it
125
- * here to avoid any future issues.
126
- */
127
- setupOnce() {
128
- if (!isBrowser.isBrowser()) {
129
- return;
130
- }
131
-
132
- this._setup();
133
- this._hasCalledSetupOnce = true;
134
-
135
- // XXX: See method comments above
136
- setTimeout(() => this.start());
137
- }
138
-
139
- /**
140
- * Initializes the plugin.
141
- *
142
- * Creates or loads a session, attaches listeners to varying events (DOM,
143
- * PerformanceObserver, Recording, Sentry SDK, etc)
144
- */
145
- start() {
146
- if (!this._replay) {
147
- return;
148
- }
149
-
150
- this._replay.start();
151
- }
152
-
153
- /**
154
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
155
- * does not support a teardown
156
- */
157
- stop() {
158
- if (!this._replay) {
159
- return;
160
- }
161
-
162
- this._replay.stop();
163
- }
164
-
165
- _setup() {
166
- // Client is not available in constructor, so we need to wait until setupOnce
167
- this._loadReplayOptionsFromClient();
168
-
169
- this._replay = new replay.ReplayContainer({
170
- options: this.options,
171
- recordingOptions: this.recordingOptions,
172
- });
173
- }
174
-
175
- /** Parse Replay-related options from SDK options */
176
- _loadReplayOptionsFromClient() {
177
- const client = core.getCurrentHub().getClient() ;
178
- const opt = client && (client.getOptions() );
179
-
180
- if (opt && typeof opt.replaysSessionSampleRate === 'number') {
181
- this.options.sessionSampleRate = opt.replaysSessionSampleRate;
182
- }
183
-
184
- if (opt && typeof opt.replaysOnErrorSampleRate === 'number') {
185
- this.options.errorSampleRate = opt.replaysOnErrorSampleRate;
186
- }
187
- }
188
- } Replay.__initStatic();
189
-
190
- exports.Replay = Replay;
7
+ exports.Replay = integration.Replay;
191
8
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":["import type { BrowserClient, BrowserOptions } from '@sentry/browser';\nimport { getCurrentHub } from '@sentry/core';\nimport { Integration } from '@sentry/types';\n\nimport { DEFAULT_ERROR_SAMPLE_RATE, DEFAULT_SESSION_SAMPLE_RATE } from './constants';\nimport { ReplayContainer } from './replay';\nimport type { RecordingOptions, ReplayConfiguration, ReplayPluginOptions } from './types';\nimport { captureInternalException } from './util/captureInternalException';\nimport { isBrowser } from './util/isBrowser';\n\nconst MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';\n\nlet _initialized = false;\n\nexport class Replay implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Replay';\n\n /**\n * @inheritDoc\n */\n public name: string = Replay.id;\n\n /**\n * Options to pass to `rrweb.record()`\n */\n readonly recordingOptions: RecordingOptions;\n\n readonly options: ReplayPluginOptions;\n\n /** In tests, this is only called the first time */\n protected _hasCalledSetupOnce: boolean = false;\n\n private _replay?: ReplayContainer;\n\n constructor({\n flushMinDelay = 5000,\n flushMaxDelay = 15000,\n initialFlushDelay = 5000,\n stickySession = true,\n useCompression = true,\n sessionSampleRate,\n errorSampleRate,\n maskAllText = true,\n maskAllInputs = true,\n blockAllMedia = true,\n blockClass = 'sentry-block',\n ignoreClass = 'sentry-ignore',\n maskTextClass = 'sentry-mask',\n blockSelector = '[data-sentry-block]',\n ...recordingOptions\n }: ReplayConfiguration = {}) {\n this.recordingOptions = {\n maskAllInputs,\n blockClass,\n ignoreClass,\n maskTextClass,\n blockSelector,\n ...recordingOptions,\n };\n\n this.options = {\n flushMinDelay,\n flushMaxDelay,\n stickySession,\n initialFlushDelay,\n sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,\n errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,\n useCompression,\n maskAllText,\n blockAllMedia,\n };\n\n if (typeof sessionSampleRate === 'number') {\n // eslint-disable-next-line\n console.warn(\n `[Replay] You are passing \\`sessionSampleRate\\` to the Replay integration.\nThis option is deprecated and will be removed soon.\nInstead, configure \\`replaysSessionSampleRate\\` directly in the SDK init options, e.g.:\nSentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,\n );\n\n this.options.sessionSampleRate = sessionSampleRate;\n }\n\n if (typeof errorSampleRate === 'number') {\n // eslint-disable-next-line\n console.warn(\n `[Replay] You are passing \\`errorSampleRate\\` to the Replay integration.\nThis option is deprecated and will be removed soon.\nInstead, configure \\`replaysOnErrorSampleRate\\` directly in the SDK init options, e.g.:\nSentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,\n );\n\n this.options.errorSampleRate = errorSampleRate;\n }\n\n if (this.options.maskAllText) {\n // `maskAllText` is a more user friendly option to configure\n // `maskTextSelector`. This means that all nodes will have their text\n // content masked.\n this.recordingOptions.maskTextSelector = '*';\n }\n\n if (this.options.blockAllMedia) {\n // `blockAllMedia` is a more user friendly option to configure blocking\n // embedded media elements\n this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector\n ? MEDIA_SELECTORS\n : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;\n }\n\n if (isBrowser() && _initialized) {\n const error = new Error('Multiple Sentry Session Replay instances are not supported');\n captureInternalException(error);\n throw error;\n }\n\n _initialized = true;\n }\n\n /**\n * We previously used to create a transaction in `setupOnce` and it would\n * potentially create a transaction before some native SDK integrations have run\n * and applied their own global event processor. An example is:\n * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts\n *\n * So we call `replay.setup` in next event loop as a workaround to wait for other\n * global event processors to finish. This is no longer needed, but keeping it\n * here to avoid any future issues.\n */\n setupOnce(): void {\n if (!isBrowser()) {\n return;\n }\n\n this._setup();\n this._hasCalledSetupOnce = true;\n\n // XXX: See method comments above\n setTimeout(() => this.start());\n }\n\n /**\n * Initializes the plugin.\n *\n * Creates or loads a session, attaches listeners to varying events (DOM,\n * PerformanceObserver, Recording, Sentry SDK, etc)\n */\n start(): void {\n if (!this._replay) {\n return;\n }\n\n this._replay.start();\n }\n\n /**\n * Currently, this needs to be manually called (e.g. for tests). Sentry SDK\n * does not support a teardown\n */\n stop(): void {\n if (!this._replay) {\n return;\n }\n\n this._replay.stop();\n }\n\n private _setup(): void {\n // Client is not available in constructor, so we need to wait until setupOnce\n this._loadReplayOptionsFromClient();\n\n this._replay = new ReplayContainer({\n options: this.options,\n recordingOptions: this.recordingOptions,\n });\n }\n\n /** Parse Replay-related options from SDK options */\n private _loadReplayOptionsFromClient(): void {\n const client = getCurrentHub().getClient() as BrowserClient | undefined;\n const opt = client && (client.getOptions() as BrowserOptions | undefined);\n\n if (opt && typeof opt.replaysSessionSampleRate === 'number') {\n this.options.sessionSampleRate = opt.replaysSessionSampleRate;\n }\n\n if (opt && typeof opt.replaysOnErrorSampleRate === 'number') {\n this.options.errorSampleRate = opt.replaysOnErrorSampleRate;\n }\n }\n}\n"],"names":["DEFAULT_SESSION_SAMPLE_RATE","DEFAULT_ERROR_SAMPLE_RATE","isBrowser","captureInternalException","ReplayContainer","getCurrentHub"],"mappings":";;;;;;;;AAUA,MAAA,eAAA,GAAA,mEAAA,CAAA;AACA;AACA,IAAA,YAAA,GAAA,KAAA,CAAA;AACA;AACA,MAAA,MAAA,EAAA;AACA;AACA;AACA;AACA,GAAA,OAAA,YAAA,GAAA,CAAA,IAAA,CAAA,EAAA,GAAA,SAAA,CAAA;AACA;AACA;AACA;AACA;AACA,GAAA,MAAA,GAAA,CAAA,IAAA,CAAA,IAAA,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IAAA,CAAA,OAAA,CAAA,eAAA,GAAA,GAAA,CAAA,wBAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA,MAAA,CAAA,YAAA,EAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,191 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ const core = require('@sentry/core');
4
+ const constants = require('./constants.js');
5
+ const replay = require('./replay.js');
6
+ const captureInternalException = require('./util/captureInternalException.js');
7
+ const isBrowser = require('./util/isBrowser.js');
8
+
9
+ const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
10
+
11
+ let _initialized = false;
12
+
13
+ class Replay {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static __initStatic() {this.id = 'Replay';}
18
+
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ __init() {this.name = Replay.id;}
23
+
24
+ /**
25
+ * Options to pass to `rrweb.record()`
26
+ */
27
+
28
+ /** In tests, this is only called the first time */
29
+ __init2() {this._hasCalledSetupOnce = false;}
30
+
31
+ constructor({
32
+ flushMinDelay = 5000,
33
+ flushMaxDelay = 15000,
34
+ initialFlushDelay = 5000,
35
+ stickySession = true,
36
+ useCompression = true,
37
+ sessionSampleRate,
38
+ errorSampleRate,
39
+ maskAllText = true,
40
+ maskAllInputs = true,
41
+ blockAllMedia = true,
42
+ blockClass = 'sentry-block',
43
+ ignoreClass = 'sentry-ignore',
44
+ maskTextClass = 'sentry-mask',
45
+ blockSelector = '[data-sentry-block]',
46
+ ...recordingOptions
47
+ } = {}) {;Replay.prototype.__init.call(this);Replay.prototype.__init2.call(this);
48
+ this.recordingOptions = {
49
+ maskAllInputs,
50
+ blockClass,
51
+ ignoreClass,
52
+ maskTextClass,
53
+ blockSelector,
54
+ ...recordingOptions,
55
+ };
56
+
57
+ this.options = {
58
+ flushMinDelay,
59
+ flushMaxDelay,
60
+ stickySession,
61
+ initialFlushDelay,
62
+ sessionSampleRate: constants.DEFAULT_SESSION_SAMPLE_RATE,
63
+ errorSampleRate: constants.DEFAULT_ERROR_SAMPLE_RATE,
64
+ useCompression,
65
+ maskAllText,
66
+ blockAllMedia,
67
+ };
68
+
69
+ if (typeof sessionSampleRate === 'number') {
70
+ // eslint-disable-next-line
71
+ console.warn(
72
+ `[Replay] You are passing \`sessionSampleRate\` to the Replay integration.
73
+ This option is deprecated and will be removed soon.
74
+ Instead, configure \`replaysSessionSampleRate\` directly in the SDK init options, e.g.:
75
+ Sentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,
76
+ );
77
+
78
+ this.options.sessionSampleRate = sessionSampleRate;
79
+ }
80
+
81
+ if (typeof errorSampleRate === 'number') {
82
+ // eslint-disable-next-line
83
+ console.warn(
84
+ `[Replay] You are passing \`errorSampleRate\` to the Replay integration.
85
+ This option is deprecated and will be removed soon.
86
+ Instead, configure \`replaysOnErrorSampleRate\` directly in the SDK init options, e.g.:
87
+ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
88
+ );
89
+
90
+ this.options.errorSampleRate = errorSampleRate;
91
+ }
92
+
93
+ if (this.options.maskAllText) {
94
+ // `maskAllText` is a more user friendly option to configure
95
+ // `maskTextSelector`. This means that all nodes will have their text
96
+ // content masked.
97
+ this.recordingOptions.maskTextSelector = '*';
98
+ }
99
+
100
+ if (this.options.blockAllMedia) {
101
+ // `blockAllMedia` is a more user friendly option to configure blocking
102
+ // embedded media elements
103
+ this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
104
+ ? MEDIA_SELECTORS
105
+ : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
106
+ }
107
+
108
+ if (isBrowser.isBrowser() && _initialized) {
109
+ const error = new Error('Multiple Sentry Session Replay instances are not supported');
110
+ captureInternalException.captureInternalException(error);
111
+ throw error;
112
+ }
113
+
114
+ _initialized = true;
115
+ }
116
+
117
+ /**
118
+ * We previously used to create a transaction in `setupOnce` and it would
119
+ * potentially create a transaction before some native SDK integrations have run
120
+ * and applied their own global event processor. An example is:
121
+ * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
122
+ *
123
+ * So we call `replay.setup` in next event loop as a workaround to wait for other
124
+ * global event processors to finish. This is no longer needed, but keeping it
125
+ * here to avoid any future issues.
126
+ */
127
+ setupOnce() {
128
+ if (!isBrowser.isBrowser()) {
129
+ return;
130
+ }
131
+
132
+ this._setup();
133
+ this._hasCalledSetupOnce = true;
134
+
135
+ // XXX: See method comments above
136
+ setTimeout(() => this.start());
137
+ }
138
+
139
+ /**
140
+ * Initializes the plugin.
141
+ *
142
+ * Creates or loads a session, attaches listeners to varying events (DOM,
143
+ * PerformanceObserver, Recording, Sentry SDK, etc)
144
+ */
145
+ start() {
146
+ if (!this._replay) {
147
+ return;
148
+ }
149
+
150
+ this._replay.start();
151
+ }
152
+
153
+ /**
154
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
155
+ * does not support a teardown
156
+ */
157
+ stop() {
158
+ if (!this._replay) {
159
+ return;
160
+ }
161
+
162
+ this._replay.stop();
163
+ }
164
+
165
+ _setup() {
166
+ // Client is not available in constructor, so we need to wait until setupOnce
167
+ this._loadReplayOptionsFromClient();
168
+
169
+ this._replay = new replay.ReplayContainer({
170
+ options: this.options,
171
+ recordingOptions: this.recordingOptions,
172
+ });
173
+ }
174
+
175
+ /** Parse Replay-related options from SDK options */
176
+ _loadReplayOptionsFromClient() {
177
+ const client = core.getCurrentHub().getClient() ;
178
+ const opt = client && (client.getOptions() );
179
+
180
+ if (opt && typeof opt.replaysSessionSampleRate === 'number') {
181
+ this.options.sessionSampleRate = opt.replaysSessionSampleRate;
182
+ }
183
+
184
+ if (opt && typeof opt.replaysOnErrorSampleRate === 'number') {
185
+ this.options.errorSampleRate = opt.replaysOnErrorSampleRate;
186
+ }
187
+ }
188
+ } Replay.__initStatic();
189
+
190
+ exports.Replay = Replay;
191
+ //# sourceMappingURL=integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.js","sources":["../../../src/integration.ts"],"sourcesContent":["import type { BrowserClient, BrowserOptions } from '@sentry/browser';\nimport { getCurrentHub } from '@sentry/core';\nimport { Integration } from '@sentry/types';\n\nimport { DEFAULT_ERROR_SAMPLE_RATE, DEFAULT_SESSION_SAMPLE_RATE } from './constants';\nimport { ReplayContainer } from './replay';\nimport type { RecordingOptions, ReplayConfiguration, ReplayPluginOptions } from './types';\nimport { captureInternalException } from './util/captureInternalException';\nimport { isBrowser } from './util/isBrowser';\n\nconst MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';\n\nlet _initialized = false;\n\nexport class Replay implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Replay';\n\n /**\n * @inheritDoc\n */\n public name: string = Replay.id;\n\n /**\n * Options to pass to `rrweb.record()`\n */\n readonly recordingOptions: RecordingOptions;\n\n readonly options: ReplayPluginOptions;\n\n /** In tests, this is only called the first time */\n protected _hasCalledSetupOnce: boolean = false;\n\n private _replay?: ReplayContainer;\n\n constructor({\n flushMinDelay = 5000,\n flushMaxDelay = 15000,\n initialFlushDelay = 5000,\n stickySession = true,\n useCompression = true,\n sessionSampleRate,\n errorSampleRate,\n maskAllText = true,\n maskAllInputs = true,\n blockAllMedia = true,\n blockClass = 'sentry-block',\n ignoreClass = 'sentry-ignore',\n maskTextClass = 'sentry-mask',\n blockSelector = '[data-sentry-block]',\n ...recordingOptions\n }: ReplayConfiguration = {}) {\n this.recordingOptions = {\n maskAllInputs,\n blockClass,\n ignoreClass,\n maskTextClass,\n blockSelector,\n ...recordingOptions,\n };\n\n this.options = {\n flushMinDelay,\n flushMaxDelay,\n stickySession,\n initialFlushDelay,\n sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,\n errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,\n useCompression,\n maskAllText,\n blockAllMedia,\n };\n\n if (typeof sessionSampleRate === 'number') {\n // eslint-disable-next-line\n console.warn(\n `[Replay] You are passing \\`sessionSampleRate\\` to the Replay integration.\nThis option is deprecated and will be removed soon.\nInstead, configure \\`replaysSessionSampleRate\\` directly in the SDK init options, e.g.:\nSentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,\n );\n\n this.options.sessionSampleRate = sessionSampleRate;\n }\n\n if (typeof errorSampleRate === 'number') {\n // eslint-disable-next-line\n console.warn(\n `[Replay] You are passing \\`errorSampleRate\\` to the Replay integration.\nThis option is deprecated and will be removed soon.\nInstead, configure \\`replaysOnErrorSampleRate\\` directly in the SDK init options, e.g.:\nSentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,\n );\n\n this.options.errorSampleRate = errorSampleRate;\n }\n\n if (this.options.maskAllText) {\n // `maskAllText` is a more user friendly option to configure\n // `maskTextSelector`. This means that all nodes will have their text\n // content masked.\n this.recordingOptions.maskTextSelector = '*';\n }\n\n if (this.options.blockAllMedia) {\n // `blockAllMedia` is a more user friendly option to configure blocking\n // embedded media elements\n this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector\n ? MEDIA_SELECTORS\n : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;\n }\n\n if (isBrowser() && _initialized) {\n const error = new Error('Multiple Sentry Session Replay instances are not supported');\n captureInternalException(error);\n throw error;\n }\n\n _initialized = true;\n }\n\n /**\n * We previously used to create a transaction in `setupOnce` and it would\n * potentially create a transaction before some native SDK integrations have run\n * and applied their own global event processor. An example is:\n * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts\n *\n * So we call `replay.setup` in next event loop as a workaround to wait for other\n * global event processors to finish. This is no longer needed, but keeping it\n * here to avoid any future issues.\n */\n setupOnce(): void {\n if (!isBrowser()) {\n return;\n }\n\n this._setup();\n this._hasCalledSetupOnce = true;\n\n // XXX: See method comments above\n setTimeout(() => this.start());\n }\n\n /**\n * Initializes the plugin.\n *\n * Creates or loads a session, attaches listeners to varying events (DOM,\n * PerformanceObserver, Recording, Sentry SDK, etc)\n */\n start(): void {\n if (!this._replay) {\n return;\n }\n\n this._replay.start();\n }\n\n /**\n * Currently, this needs to be manually called (e.g. for tests). Sentry SDK\n * does not support a teardown\n */\n stop(): void {\n if (!this._replay) {\n return;\n }\n\n this._replay.stop();\n }\n\n private _setup(): void {\n // Client is not available in constructor, so we need to wait until setupOnce\n this._loadReplayOptionsFromClient();\n\n this._replay = new ReplayContainer({\n options: this.options,\n recordingOptions: this.recordingOptions,\n });\n }\n\n /** Parse Replay-related options from SDK options */\n private _loadReplayOptionsFromClient(): void {\n const client = getCurrentHub().getClient() as BrowserClient | undefined;\n const opt = client && (client.getOptions() as BrowserOptions | undefined);\n\n if (opt && typeof opt.replaysSessionSampleRate === 'number') {\n this.options.sessionSampleRate = opt.replaysSessionSampleRate;\n }\n\n if (opt && typeof opt.replaysOnErrorSampleRate === 'number') {\n this.options.errorSampleRate = opt.replaysOnErrorSampleRate;\n }\n }\n}\n"],"names":["DEFAULT_SESSION_SAMPLE_RATE","DEFAULT_ERROR_SAMPLE_RATE","isBrowser","captureInternalException","ReplayContainer","getCurrentHub"],"mappings":";;;;;;;;AAUA,MAAA,eAAA,GAAA,mEAAA,CAAA;AACA;AACA,IAAA,YAAA,GAAA,KAAA,CAAA;AACA;AACA,MAAA,MAAA,EAAA;AACA;AACA;AACA;AACA,GAAA,OAAA,YAAA,GAAA,CAAA,IAAA,CAAA,EAAA,GAAA,SAAA,CAAA;AACA;AACA;AACA;AACA;AACA,GAAA,MAAA,GAAA,CAAA,IAAA,CAAA,IAAA,GAAA,MAAA,CAAA,GAAA,CAAA;AACA;AACA;AACA;AACA;;AAKA;AACA,GAAA,OAAA,GAAA,CAAA,IAAA,CAAA,mBAAA,GAAA,MAAA,CAAA;;AAIA,EAAA,WAAA,CAAA;AACA,IAAA,aAAA,GAAA,IAAA;AACA,IAAA,aAAA,GAAA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we need to keep a buffer of
139
139
  // replay events.
140
140
  if (this.session.sampled === 'error') {
141
- // Checkout every minute, meaning we only get up-to one minute of events before the error happens
142
- this.recordingOptions.checkoutEveryNms = 60000;
143
141
  this._waitForError = true;
144
142
  }
145
143
 
@@ -167,6 +165,10 @@ class ReplayContainer {
167
165
  try {
168
166
  this._stopRecording = index.default({
169
167
  ...this.recordingOptions,
168
+ // When running in error sampling mode, we need to overwrite `checkoutEveryNth`
169
+ // Without this, it would record forever, until an error happens, which we don't want
170
+ // instead, we'll always keep the last 60 seconds of replay before an error happened
171
+ ...(this._waitForError && { checkoutEveryNth: 60000 }),
170
172
  emit: this.handleRecordingEmit,
171
173
  });
172
174
  } catch (err) {
@@ -450,7 +452,6 @@ class ReplayContainer {
450
452
  this._stopRecording();
451
453
  // Reset all "capture on error" configuration before
452
454
  // starting a new recording
453
- delete this.recordingOptions.checkoutEveryNms;
454
455
  this._waitForError = false;
455
456
  this.startRecording();
456
457
  }
@@ -1081,7 +1082,7 @@ class ReplayContainer {
1081
1082
 
1082
1083
  const sdkInfo = {
1083
1084
  name: 'sentry.javascript.integration.replay',
1084
- version: "7.24.0",
1085
+ version: "7.24.2",
1085
1086
  };
1086
1087
 
1087
1088
  const replayEvent = await new Promise(resolve => {