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