@sentry/replay 7.24.1 → 7.25.0
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 +3 -4
- package/cjs/_virtual/_commonjsHelpers.js +42 -0
- package/cjs/_virtual/_commonjsHelpers.js.map +1 -0
- package/cjs/constants.js +8 -0
- package/cjs/constants.js.map +1 -1
- package/cjs/coreHandlers/breadcrumbHandler.js.map +1 -1
- package/cjs/coreHandlers/handleFetch.js +33 -6
- package/cjs/coreHandlers/handleFetch.js.map +1 -1
- package/cjs/coreHandlers/handleGlobalEvent.js +91 -0
- package/cjs/coreHandlers/handleGlobalEvent.js.map +1 -0
- package/cjs/coreHandlers/handleHistory.js +30 -1
- package/cjs/coreHandlers/handleHistory.js.map +1 -1
- package/cjs/coreHandlers/handleScope.js +4 -12
- package/cjs/coreHandlers/handleScope.js.map +1 -1
- package/cjs/coreHandlers/handleXhr.js +33 -4
- package/cjs/coreHandlers/handleXhr.js.map +1 -1
- package/cjs/coreHandlers/performanceObserver.js +47 -0
- package/cjs/coreHandlers/performanceObserver.js.map +1 -0
- package/cjs/createPerformanceEntry.js +0 -6
- package/cjs/createPerformanceEntry.js.map +1 -1
- package/cjs/eventBuffer.js.map +1 -1
- package/cjs/index.js +2 -185
- package/cjs/index.js.map +1 -1
- package/cjs/integration.js +194 -0
- package/cjs/integration.js.map +1 -0
- package/cjs/node_modules/lodash.debounce/index.js +384 -0
- package/cjs/node_modules/lodash.debounce/index.js.map +1 -0
- package/cjs/replay.js +201 -414
- package/cjs/replay.js.map +1 -1
- package/cjs/session/Session.js.map +1 -1
- package/cjs/session/createSession.js.map +1 -1
- package/cjs/session/fetchSession.js.map +1 -1
- package/cjs/session/getSession.js.map +1 -1
- package/cjs/session/saveSession.js.map +1 -1
- package/cjs/util/addEvent.js +47 -0
- package/cjs/util/addEvent.js.map +1 -0
- package/cjs/util/addMemoryEntry.js +23 -0
- package/cjs/util/addMemoryEntry.js.map +1 -0
- package/cjs/util/createPayload.js.map +1 -1
- package/cjs/util/createPerformanceSpans.js +30 -0
- package/cjs/util/createPerformanceSpans.js.map +1 -0
- package/cjs/util/createReplayEnvelope.js +34 -0
- package/cjs/util/createReplayEnvelope.js.map +1 -0
- package/cjs/util/getReplayEvent.js +32 -0
- package/cjs/util/getReplayEvent.js.map +1 -0
- package/cjs/util/isSessionExpired.js.map +1 -1
- package/cjs/util/monkeyPatchRecordDroppedEvent.js +44 -0
- package/cjs/util/monkeyPatchRecordDroppedEvent.js.map +1 -0
- package/cjs/util/shouldFilterRequest.js +30 -0
- package/cjs/util/shouldFilterRequest.js.map +1 -0
- package/esm/_virtual/_commonjsHelpers.js +35 -0
- package/esm/_virtual/_commonjsHelpers.js.map +1 -0
- package/esm/constants.js +7 -1
- package/esm/constants.js.map +1 -1
- package/esm/coreHandlers/breadcrumbHandler.js.map +1 -1
- package/esm/coreHandlers/handleFetch.js +33 -7
- package/esm/coreHandlers/handleFetch.js.map +1 -1
- package/esm/coreHandlers/handleGlobalEvent.js +86 -0
- package/esm/coreHandlers/handleGlobalEvent.js.map +1 -0
- package/esm/coreHandlers/handleHistory.js +30 -1
- package/esm/coreHandlers/handleHistory.js.map +1 -1
- package/esm/coreHandlers/handleScope.js +4 -9
- package/esm/coreHandlers/handleScope.js.map +1 -1
- package/esm/coreHandlers/handleXhr.js +33 -4
- package/esm/coreHandlers/handleXhr.js.map +1 -1
- package/esm/coreHandlers/performanceObserver.js +45 -0
- package/esm/coreHandlers/performanceObserver.js.map +1 -0
- package/esm/createPerformanceEntry.js +0 -6
- package/esm/createPerformanceEntry.js.map +1 -1
- package/esm/eventBuffer.js.map +1 -1
- package/esm/index.js +1 -188
- package/esm/index.js.map +1 -1
- package/esm/integration.js +192 -0
- package/esm/integration.js.map +1 -0
- package/esm/node_modules/lodash.debounce/index.js +382 -0
- package/esm/node_modules/lodash.debounce/index.js.map +1 -0
- package/esm/replay.js +200 -413
- package/esm/replay.js.map +1 -1
- package/esm/session/Session.js.map +1 -1
- package/esm/session/createSession.js.map +1 -1
- package/esm/session/fetchSession.js.map +1 -1
- package/esm/session/getSession.js.map +1 -1
- package/esm/session/saveSession.js.map +1 -1
- package/esm/util/addEvent.js +42 -0
- package/esm/util/addEvent.js.map +1 -0
- package/esm/util/addMemoryEntry.js +21 -0
- package/esm/util/addMemoryEntry.js.map +1 -0
- package/esm/util/createPayload.js.map +1 -1
- package/esm/util/createPerformanceSpans.js +28 -0
- package/esm/util/createPerformanceSpans.js.map +1 -0
- package/esm/util/createReplayEnvelope.js +32 -0
- package/esm/util/createReplayEnvelope.js.map +1 -0
- package/esm/util/getReplayEvent.js +30 -0
- package/esm/util/getReplayEvent.js.map +1 -0
- package/esm/util/isSessionExpired.js.map +1 -1
- package/esm/util/monkeyPatchRecordDroppedEvent.js +41 -0
- package/esm/util/monkeyPatchRecordDroppedEvent.js.map +1 -0
- package/esm/util/shouldFilterRequest.js +25 -0
- package/esm/util/shouldFilterRequest.js.map +1 -0
- package/package.json +7 -8
- package/types/constants.d.ts +5 -0
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/breadcrumbHandler.d.ts +1 -1
- package/types/coreHandlers/breadcrumbHandler.d.ts.map +1 -1
- package/types/coreHandlers/handleFetch.d.ts +9 -2
- package/types/coreHandlers/handleFetch.d.ts.map +1 -1
- package/types/coreHandlers/handleGlobalEvent.d.ts +7 -0
- package/types/coreHandlers/handleGlobalEvent.d.ts.map +1 -0
- package/types/coreHandlers/handleHistory.d.ts +7 -3
- package/types/coreHandlers/handleHistory.d.ts.map +1 -1
- package/types/coreHandlers/handleScope.d.ts.map +1 -1
- package/types/coreHandlers/handleXhr.d.ts +6 -3
- package/types/coreHandlers/handleXhr.d.ts.map +1 -1
- package/types/coreHandlers/performanceObserver.d.ts +6 -0
- package/types/coreHandlers/performanceObserver.d.ts.map +1 -0
- package/types/createPerformanceEntry.d.ts +1 -1
- package/types/createPerformanceEntry.d.ts.map +1 -1
- package/types/eventBuffer.d.ts +1 -7
- package/types/eventBuffer.d.ts.map +1 -1
- 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 +30 -59
- package/types/replay.d.ts.map +1 -1
- package/types/session/Session.d.ts +1 -26
- package/types/session/Session.d.ts.map +1 -1
- package/types/session/createSession.d.ts +1 -2
- package/types/session/createSession.d.ts.map +1 -1
- package/types/session/fetchSession.d.ts +1 -1
- package/types/session/fetchSession.d.ts.map +1 -1
- package/types/session/getSession.d.ts +1 -2
- package/types/session/getSession.d.ts.map +1 -1
- package/types/session/saveSession.d.ts +1 -1
- package/types/session/saveSession.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 +65 -4
- package/types/types.d.ts.map +1 -1
- package/types/util/addEvent.d.ts +6 -0
- package/types/util/addEvent.d.ts.map +1 -0
- package/types/util/addMemoryEntry.d.ts +7 -0
- package/types/util/addMemoryEntry.d.ts.map +1 -0
- package/types/util/createPayload.d.ts +1 -1
- package/types/util/createPayload.d.ts.map +1 -1
- package/types/util/createPerformanceSpans.d.ts +7 -0
- package/types/util/createPerformanceSpans.d.ts.map +1 -0
- package/types/util/createReplayEnvelope.d.ts +3 -0
- package/types/util/createReplayEnvelope.d.ts.map +1 -0
- package/types/util/getReplayEvent.d.ts +9 -0
- package/types/util/getReplayEvent.d.ts.map +1 -0
- package/types/util/isSessionExpired.d.ts +1 -1
- package/types/util/isSessionExpired.d.ts.map +1 -1
- package/types/util/monkeyPatchRecordDroppedEvent.d.ts +3 -0
- package/types/util/monkeyPatchRecordDroppedEvent.d.ts.map +1 -0
- package/types/util/shouldFilterRequest.d.ts +6 -0
- package/types/util/shouldFilterRequest.d.ts.map +1 -0
- package/cjs/coreHandlers/spanHandler.js +0 -20
- package/cjs/coreHandlers/spanHandler.js.map +0 -1
- package/cjs/util/addInternalBreadcrumb.js +0 -25
- package/cjs/util/addInternalBreadcrumb.js.map +0 -1
- package/cjs/util/captureInternalException.js +0 -18
- package/cjs/util/captureInternalException.js.map +0 -1
- package/cjs/util/isIngestHost.js +0 -26
- package/cjs/util/isIngestHost.js.map +0 -1
- package/cjs/util/isInternal.js +0 -15
- package/cjs/util/isInternal.js.map +0 -1
- package/esm/coreHandlers/spanHandler.js +0 -18
- package/esm/coreHandlers/spanHandler.js.map +0 -1
- package/esm/util/addInternalBreadcrumb.js +0 -23
- package/esm/util/addInternalBreadcrumb.js.map +0 -1
- package/esm/util/captureInternalException.js +0 -16
- package/esm/util/captureInternalException.js.map +0 -1
- package/esm/util/isIngestHost.js +0 -21
- package/esm/util/isIngestHost.js.map +0 -1
- package/esm/util/isInternal.js +0 -13
- package/esm/util/isInternal.js.map +0 -1
- package/types/coreHandlers/spanHandler.d.ts +0 -4
- package/types/coreHandlers/spanHandler.d.ts.map +0 -1
- package/types/util/addInternalBreadcrumb.d.ts +0 -6
- package/types/util/addInternalBreadcrumb.d.ts.map +0 -1
- package/types/util/captureInternalException.d.ts +0 -5
- package/types/util/captureInternalException.d.ts.map +0 -1
- package/types/util/isIngestHost.d.ts +0 -5
- package/types/util/isIngestHost.d.ts.map +0 -1
- package/types/util/isInternal.d.ts +0 -6
- package/types/util/isInternal.d.ts.map +0 -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,192 @@
|
|
|
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 { isBrowser } from './util/isBrowser.js';
|
|
5
|
+
|
|
6
|
+
const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
|
|
7
|
+
|
|
8
|
+
let _initialized = false;
|
|
9
|
+
|
|
10
|
+
class Replay {
|
|
11
|
+
/**
|
|
12
|
+
* @inheritDoc
|
|
13
|
+
*/
|
|
14
|
+
static __initStatic() {this.id = 'Replay';}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
__init() {this.name = Replay.id;}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Options to pass to `rrweb.record()`
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
get _isInitialized() {
|
|
26
|
+
return _initialized;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set _isInitialized(value) {
|
|
30
|
+
_initialized = value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor({
|
|
34
|
+
flushMinDelay = 5000,
|
|
35
|
+
flushMaxDelay = 15000,
|
|
36
|
+
initialFlushDelay = 5000,
|
|
37
|
+
stickySession = true,
|
|
38
|
+
useCompression = true,
|
|
39
|
+
sessionSampleRate,
|
|
40
|
+
errorSampleRate,
|
|
41
|
+
maskAllText = true,
|
|
42
|
+
maskAllInputs = true,
|
|
43
|
+
blockAllMedia = true,
|
|
44
|
+
_experiments = {},
|
|
45
|
+
blockClass = 'sentry-block',
|
|
46
|
+
ignoreClass = 'sentry-ignore',
|
|
47
|
+
maskTextClass = 'sentry-mask',
|
|
48
|
+
blockSelector = '[data-sentry-block]',
|
|
49
|
+
...recordingOptions
|
|
50
|
+
} = {}) {;Replay.prototype.__init.call(this);
|
|
51
|
+
this.recordingOptions = {
|
|
52
|
+
maskAllInputs,
|
|
53
|
+
blockClass,
|
|
54
|
+
ignoreClass,
|
|
55
|
+
maskTextClass,
|
|
56
|
+
blockSelector,
|
|
57
|
+
...recordingOptions,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
this.options = {
|
|
61
|
+
flushMinDelay,
|
|
62
|
+
flushMaxDelay,
|
|
63
|
+
stickySession,
|
|
64
|
+
initialFlushDelay,
|
|
65
|
+
sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,
|
|
66
|
+
errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,
|
|
67
|
+
useCompression,
|
|
68
|
+
maskAllText,
|
|
69
|
+
blockAllMedia,
|
|
70
|
+
_experiments,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (typeof sessionSampleRate === 'number') {
|
|
74
|
+
// eslint-disable-next-line
|
|
75
|
+
console.warn(
|
|
76
|
+
`[Replay] You are passing \`sessionSampleRate\` to the Replay integration.
|
|
77
|
+
This option is deprecated and will be removed soon.
|
|
78
|
+
Instead, configure \`replaysSessionSampleRate\` directly in the SDK init options, e.g.:
|
|
79
|
+
Sentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
this.options.sessionSampleRate = sessionSampleRate;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (typeof errorSampleRate === 'number') {
|
|
86
|
+
// eslint-disable-next-line
|
|
87
|
+
console.warn(
|
|
88
|
+
`[Replay] You are passing \`errorSampleRate\` to the Replay integration.
|
|
89
|
+
This option is deprecated and will be removed soon.
|
|
90
|
+
Instead, configure \`replaysOnErrorSampleRate\` directly in the SDK init options, e.g.:
|
|
91
|
+
Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
this.options.errorSampleRate = errorSampleRate;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.options.maskAllText) {
|
|
98
|
+
// `maskAllText` is a more user friendly option to configure
|
|
99
|
+
// `maskTextSelector`. This means that all nodes will have their text
|
|
100
|
+
// content masked.
|
|
101
|
+
this.recordingOptions.maskTextSelector = '*';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.options.blockAllMedia) {
|
|
105
|
+
// `blockAllMedia` is a more user friendly option to configure blocking
|
|
106
|
+
// embedded media elements
|
|
107
|
+
this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
|
|
108
|
+
? MEDIA_SELECTORS
|
|
109
|
+
: `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (isBrowser() && this._isInitialized) {
|
|
113
|
+
throw new Error('Multiple Sentry Session Replay instances are not supported');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this._isInitialized = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* We previously used to create a transaction in `setupOnce` and it would
|
|
121
|
+
* potentially create a transaction before some native SDK integrations have run
|
|
122
|
+
* and applied their own global event processor. An example is:
|
|
123
|
+
* https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
|
|
124
|
+
*
|
|
125
|
+
* So we call `replay.setup` in next event loop as a workaround to wait for other
|
|
126
|
+
* global event processors to finish. This is no longer needed, but keeping it
|
|
127
|
+
* here to avoid any future issues.
|
|
128
|
+
*/
|
|
129
|
+
setupOnce() {
|
|
130
|
+
if (!isBrowser()) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this._setup();
|
|
135
|
+
|
|
136
|
+
// XXX: See method comments above
|
|
137
|
+
setTimeout(() => this.start());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Initializes the plugin.
|
|
142
|
+
*
|
|
143
|
+
* Creates or loads a session, attaches listeners to varying events (DOM,
|
|
144
|
+
* PerformanceObserver, Recording, Sentry SDK, etc)
|
|
145
|
+
*/
|
|
146
|
+
start() {
|
|
147
|
+
if (!this._replay) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this._replay.start();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK
|
|
156
|
+
* does not support a teardown
|
|
157
|
+
*/
|
|
158
|
+
stop() {
|
|
159
|
+
if (!this._replay) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this._replay.stop();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_setup() {
|
|
167
|
+
// Client is not available in constructor, so we need to wait until setupOnce
|
|
168
|
+
this._loadReplayOptionsFromClient();
|
|
169
|
+
|
|
170
|
+
this._replay = new ReplayContainer({
|
|
171
|
+
options: this.options,
|
|
172
|
+
recordingOptions: this.recordingOptions,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Parse Replay-related options from SDK options */
|
|
177
|
+
_loadReplayOptionsFromClient() {
|
|
178
|
+
const client = getCurrentHub().getClient() ;
|
|
179
|
+
const opt = client && (client.getOptions() );
|
|
180
|
+
|
|
181
|
+
if (opt && typeof opt.replaysSessionSampleRate === 'number') {
|
|
182
|
+
this.options.sessionSampleRate = opt.replaysSessionSampleRate;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (opt && typeof opt.replaysOnErrorSampleRate === 'number') {
|
|
186
|
+
this.options.errorSampleRate = opt.replaysOnErrorSampleRate;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} Replay.__initStatic();
|
|
190
|
+
|
|
191
|
+
export { Replay };
|
|
192
|
+
//# 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 { 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 protected get _isInitialized(): boolean {\n return _initialized;\n }\n\n protected set _isInitialized(value: boolean) {\n _initialized = value;\n }\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 _experiments = {},\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 _experiments,\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() && this._isInitialized) {\n throw new Error('Multiple Sentry Session Replay instances are not supported');\n }\n\n this._isInitialized = 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\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":";;;;;AASA,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,GAAA,IAAA,cAAA,GAAA;AACA,IAAA,OAAA,YAAA,CAAA;AACA,GAAA;AACA;AACA,GAAA,IAAA,cAAA,CAAA,KAAA,EAAA;AACA,IAAA,YAAA,GAAA,KAAA,CAAA;AACA,GAAA;;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,YAAA,GAAA,EAAA;AACA,IAAA,UAAA,GAAA,cAAA;AACA,IAAA,WAAA,GAAA,eAAA;AACA,IAAA,aAAA,GAAA,aAAA;AACA,IAAA,aAAA,GAAA,qBAAA;AACA,IAAA,GAAA,gB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