@sentry/replay 7.116.0 → 7.117.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 +104 -81
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -10,21 +10,29 @@
|
|
|
10
10
|
[](https://www.npmjs.com/package/@sentry/replay)
|
|
11
11
|
[](https://www.npmjs.com/package/@sentry/replay)
|
|
12
12
|
|
|
13
|
+
## Package Discontinued
|
|
14
|
+
|
|
15
|
+
The standalone `@sentry/replay` package is no longer published with version 8.0.0 of the Sentry JavaScript SDKs.
|
|
16
|
+
Instead, the replay integration is now directly exported in all client-side SDK packages (e.g `@sentry/react` or
|
|
17
|
+
`@sentry/nextjs`). Head over to our v8
|
|
18
|
+
[Migration Guide](https://docs.sentry.io/platforms/javascript/migration/v7-to-v8/#removal-of-sentryreplay-package) for
|
|
19
|
+
more information.
|
|
20
|
+
|
|
13
21
|
## Pre-requisites
|
|
14
22
|
|
|
15
23
|
`@sentry/replay` requires Node 12+, and browsers newer than IE11.
|
|
16
24
|
|
|
17
25
|
## Installation
|
|
18
26
|
|
|
19
|
-
Replay can be imported from `@sentry/browser`, or a respective SDK package like `@sentry/react` or `@sentry/vue`.
|
|
20
|
-
|
|
27
|
+
Replay can be imported from `@sentry/browser`, or a respective SDK package like `@sentry/react` or `@sentry/vue`. You
|
|
28
|
+
don't need to install anything in order to use Session Replay. The minimum version that includes Replay is 7.27.0.
|
|
21
29
|
|
|
22
30
|
For details on using Replay when using Sentry via the CDN bundles, see [CDN bundle](#loading-replay-as-a-cdn-bundle).
|
|
23
31
|
|
|
24
32
|
## Setup
|
|
25
33
|
|
|
26
|
-
To set up the integration, add the following to your Sentry initialization. Several options are supported and passable
|
|
27
|
-
See the [configuration section](#configuration) below for more details.
|
|
34
|
+
To set up the integration, add the following to your Sentry initialization. Several options are supported and passable
|
|
35
|
+
via the integration constructor. See the [configuration section](#configuration) below for more details.
|
|
28
36
|
|
|
29
37
|
```javascript
|
|
30
38
|
import * as Sentry from '@sentry/browser';
|
|
@@ -45,9 +53,9 @@ Sentry.init({
|
|
|
45
53
|
new Sentry.Replay({
|
|
46
54
|
// Additional SDK configuration goes in here, for example:
|
|
47
55
|
maskAllText: true,
|
|
48
|
-
blockAllMedia: true
|
|
56
|
+
blockAllMedia: true,
|
|
49
57
|
// See below for all available options
|
|
50
|
-
})
|
|
58
|
+
}),
|
|
51
59
|
],
|
|
52
60
|
// ...
|
|
53
61
|
});
|
|
@@ -55,9 +63,8 @@ Sentry.init({
|
|
|
55
63
|
|
|
56
64
|
### Lazy loading Replay
|
|
57
65
|
|
|
58
|
-
Replay will start automatically when you add the integration.
|
|
59
|
-
|
|
60
|
-
you can also use `addIntegration` to load it later:
|
|
66
|
+
Replay will start automatically when you add the integration. If you do not want to start Replay immediately (e.g. if
|
|
67
|
+
you want to lazy-load it), you can also use `addIntegration` to load it later:
|
|
61
68
|
|
|
62
69
|
```js
|
|
63
70
|
import * as Sentry from "@sentry/react";
|
|
@@ -78,17 +85,20 @@ client?.addIntegration(new Replay());
|
|
|
78
85
|
|
|
79
86
|
### Identifying Users
|
|
80
87
|
|
|
81
|
-
If you have only followed the above instructions to setup session replays, you will only see IP addresses in Sentry's
|
|
88
|
+
If you have only followed the above instructions to setup session replays, you will only see IP addresses in Sentry's
|
|
89
|
+
UI. In order to associate a user identity to a session replay, use
|
|
90
|
+
[`setUser`](https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/).
|
|
82
91
|
|
|
83
92
|
```javascript
|
|
84
|
-
import * as Sentry from
|
|
93
|
+
import * as Sentry from '@sentry/browser';
|
|
85
94
|
|
|
86
|
-
Sentry.setUser({ email:
|
|
95
|
+
Sentry.setUser({ email: 'jane.doe@example.com' });
|
|
87
96
|
```
|
|
88
97
|
|
|
89
98
|
### Stopping & starting Replays manually
|
|
90
99
|
|
|
91
|
-
Replay recording only starts when it is included in the `integrations` array when calling `Sentry.init` or calling
|
|
100
|
+
Replay recording only starts when it is included in the `integrations` array when calling `Sentry.init` or calling
|
|
101
|
+
`addIntegration` from the a Sentry client instance. To stop recording you can call `stop()`.
|
|
92
102
|
|
|
93
103
|
```js
|
|
94
104
|
import * as Sentry from "@sentry/react";
|
|
@@ -109,20 +119,19 @@ client?.addIntegration(replay);
|
|
|
109
119
|
replay.stop();
|
|
110
120
|
```
|
|
111
121
|
|
|
112
|
-
When both `replaysSessionSampleRate` and `replaysOnErrorSampleRate` are `0`, recording will _not_ start.
|
|
113
|
-
|
|
122
|
+
When both `replaysSessionSampleRate` and `replaysOnErrorSampleRate` are `0`, recording will _not_ start. In this case,
|
|
123
|
+
you can manually start recording:
|
|
114
124
|
|
|
115
125
|
```js
|
|
116
126
|
replay.start(); // Will start a session in "session" mode, regardless of sample rates
|
|
117
127
|
replay.startBuffering(); // Will start a session in "buffer" mode, regardless of sample rates
|
|
118
128
|
```
|
|
119
129
|
|
|
120
|
-
|
|
121
|
-
|
|
122
130
|
## Loading Replay as a CDN Bundle
|
|
123
131
|
|
|
124
|
-
As an alternative to the NPM package, you can use Replay as a CDN bundle.
|
|
125
|
-
|
|
132
|
+
As an alternative to the NPM package, you can use Replay as a CDN bundle. Please refer to the
|
|
133
|
+
[Session Replay installation guide](https://docs.sentry.io/platforms/javascript/session-replay/#install) for CDN bundle
|
|
134
|
+
instructions.
|
|
126
135
|
|
|
127
136
|
<details>
|
|
128
137
|
<summary>Deprecated Replay integration bundle</summary>
|
|
@@ -131,44 +140,47 @@ complete CDN bundles that already contain the replay integration. No need to kee
|
|
|
131
140
|
The `replay.(min.)js` bundle will be removed in v8 of the JS SDKs.
|
|
132
141
|
|
|
133
142
|
```html
|
|
134
|
-
<script
|
|
135
|
-
|
|
136
|
-
crossorigin="anonymous"
|
|
137
|
-
></script>
|
|
138
|
-
<script
|
|
139
|
-
src="https://browser.sentry-cdn.com/7.41.0/replay.min.js"
|
|
140
|
-
crossorigin="anonymous"
|
|
141
|
-
></script>
|
|
143
|
+
<script src="https://browser.sentry-cdn.com/7.41.0/bundle.min.js" crossorigin="anonymous"></script>
|
|
144
|
+
<script src="https://browser.sentry-cdn.com/7.41.0/replay.min.js" crossorigin="anonymous"></script>
|
|
142
145
|
```
|
|
146
|
+
|
|
143
147
|
</details>
|
|
144
148
|
|
|
145
149
|
## Sessions
|
|
146
150
|
|
|
147
|
-
A session starts when the Session Replay SDK is first loaded and initialized. The session will continue until 5 minutes
|
|
151
|
+
A session starts when the Session Replay SDK is first loaded and initialized. The session will continue until 5 minutes
|
|
152
|
+
passes without any user interactions[^1] with the application _OR_ until a maximum of 30 minutes have elapsed. Closing
|
|
153
|
+
the browser tab will end the session immediately according to the rules for
|
|
154
|
+
[SessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).
|
|
148
155
|
|
|
149
156
|
[^1]: An 'interaction' refers to either a mouse click or a browser navigation event.
|
|
150
157
|
|
|
151
158
|
### Accessing the Replay Session ID
|
|
152
159
|
|
|
153
|
-
You can get the ID of the currently running session via `replay.getReplayId()`.
|
|
154
|
-
|
|
160
|
+
You can get the ID of the currently running session via `replay.getReplayId()`. This will return `undefined` if no
|
|
161
|
+
session is ongoing.
|
|
155
162
|
|
|
156
163
|
### Replay Captures Only on Errors
|
|
157
164
|
|
|
158
|
-
Alternatively, rather than recording an entire session, you can capture a replay only when an error occurs. In this
|
|
165
|
+
Alternatively, rather than recording an entire session, you can capture a replay only when an error occurs. In this
|
|
166
|
+
case, the integration will buffer up to one minute worth of events prior to the error being thrown. It will continue to
|
|
167
|
+
record the session following the rules above regarding session life and activity. Read the [sampling](#Sampling) section
|
|
168
|
+
for configuration options.
|
|
159
169
|
|
|
160
170
|
## Sampling
|
|
161
171
|
|
|
162
|
-
Sampling allows you to control how much of your website's traffic will result in a Session Replay. There are two sample
|
|
172
|
+
Sampling allows you to control how much of your website's traffic will result in a Session Replay. There are two sample
|
|
173
|
+
rates you can adjust to get the replays more relevant to your interests:
|
|
163
174
|
|
|
164
|
-
- `replaysSessionSampleRate` - The sample rate for replays that begin recording immediately and last the entirety of the
|
|
165
|
-
|
|
175
|
+
- `replaysSessionSampleRate` - The sample rate for replays that begin recording immediately and last the entirety of the
|
|
176
|
+
user's session.
|
|
177
|
+
- `replaysOnErrorSampleRate` - The sample rate for replays that are recorded when an error happens. This type of replay
|
|
178
|
+
will record up to a minute of events prior to the error and continue recording until the session ends.
|
|
166
179
|
|
|
167
|
-
When Replay is initialized, we check the `replaysSessionSampleRate`.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
If it is sampled, when we'll upload the Replay to Sentry and continue recording normally.
|
|
180
|
+
When Replay is initialized, we check the `replaysSessionSampleRate`. If it is sampled, then we start recording & sending
|
|
181
|
+
Replay data immediately. Else, if `replaysOnErrorSampleRate > 0`, we'll start recording in buffering mode. In this mode,
|
|
182
|
+
whenever an error occurs we'll check `replaysOnErrorSampleRate`. If it is sampled, when we'll upload the Replay to
|
|
183
|
+
Sentry and continue recording normally.
|
|
172
184
|
|
|
173
185
|
## Configuration
|
|
174
186
|
|
|
@@ -176,76 +188,87 @@ If it is sampled, when we'll upload the Replay to Sentry and continue recording
|
|
|
176
188
|
|
|
177
189
|
The following options can be configured on the root level of your browser-based Sentry SDK, in `init({})`:
|
|
178
190
|
|
|
179
|
-
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
|
|
|
183
|
-
| replaysOnErrorSampleRate | number | `0` |The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends. 1.0 capturing all sessions with an error, and 0 capturing none.
|
|
191
|
+
| key | type | default | description |
|
|
192
|
+
| ------------------------ | ------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
193
|
+
| replaysSessionSampleRate | number | `0` | The sample rate for replays that begin recording immediately and last the entirety of the user's session. 1.0 will collect all replays, 0 will collect no replays. |
|
|
194
|
+
| replaysOnErrorSampleRate | number | `0` | The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends. 1.0 capturing all sessions with an error, and 0 capturing none. |
|
|
184
195
|
|
|
185
196
|
### General Integration Configuration
|
|
186
197
|
|
|
187
198
|
The following options can be configured as options to the integration, in `new Replay({})`:
|
|
188
199
|
|
|
189
|
-
| key
|
|
190
|
-
|
|
|
191
|
-
| stickySession
|
|
192
|
-
|
|
200
|
+
| key | type | default | description |
|
|
201
|
+
| ------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
202
|
+
| stickySession | boolean | `true` | Keep track of the user across page loads. Note a single user using multiple tabs will result in multiple sessions. Closing a tab will result in the session being closed as well. |
|
|
193
203
|
|
|
194
204
|
### Privacy Configuration
|
|
195
205
|
|
|
196
206
|
The following options can be configured as options to the integration, in `new Replay({})`:
|
|
197
207
|
|
|
198
|
-
| key
|
|
199
|
-
|
|
|
200
|
-
| maskAllText
|
|
201
|
-
| maskAllInputs
|
|
202
|
-
| blockAllMedia
|
|
203
|
-
| maskFn
|
|
204
|
-
| block
|
|
205
|
-
| unblock
|
|
206
|
-
| mask
|
|
207
|
-
| unmask
|
|
208
|
-
| ignore
|
|
208
|
+
| key | type | default | description |
|
|
209
|
+
| ------------- | ------------------------ | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
210
|
+
| maskAllText | boolean | `true` | Mask _all_ text content. Will pass text content through `maskFn` before sending to server. |
|
|
211
|
+
| maskAllInputs | boolean | `true` | Mask values of `<input>` elements. Passes input values through `maskInputFn` before sending to server. |
|
|
212
|
+
| blockAllMedia | boolean | `true` | Block _all_ media elements (`img, svg, video, object, picture, embed, map, audio`) |
|
|
213
|
+
| maskFn | (text: string) => string | `(text) => '*'.repeat(text.length)` | Function to customize how text content is masked before sending to server. By default, masks text with `*`. |
|
|
214
|
+
| block | Array<string> | `.sentry-block, [data-sentry-block]` | Redact any elements that match the DOM selectors. See [privacy](#blocking) section for an example. |
|
|
215
|
+
| unblock | Array<string> | `.sentry-unblock, [data-sentry-unblock]` | Do not redact any elements that match the DOM selectors. Useful when using `blockAllMedia`. See [privacy](#blocking) section for an example. |
|
|
216
|
+
| mask | Array<string> | `.sentry-mask, [data-sentry-mask]` | Mask all elements that match the given DOM selectors. See [privacy](#masking) section for an example. |
|
|
217
|
+
| unmask | Array<string> | `.sentry-unmask, [data-sentry-unmask]` | Unmask all elements that match the given DOM selectors. Useful when using `maskAllText`. See [privacy](#masking) section for an example. |
|
|
218
|
+
| ignore | Array<string> | `.sentry-ignore, [data-sentry-ignore]` | Ignores all events on the matching input fields. See [privacy](#ignoring) section for an example. |
|
|
209
219
|
|
|
210
220
|
#### Deprecated options
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
|
216
|
-
|
|
|
217
|
-
|
|
|
218
|
-
|
|
|
219
|
-
|
|
|
221
|
+
|
|
222
|
+
In order to streamline our privacy options, the following have been deprecated in favor for the respective options
|
|
223
|
+
above.
|
|
224
|
+
|
|
225
|
+
| deprecated key | replaced by | description |
|
|
226
|
+
| ---------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
227
|
+
| maskInputOptions | mask | Use CSS selectors in `mask` in order to mask all inputs of a certain type. For example, `input[type="address"]` |
|
|
228
|
+
| blockSelector | block | The selector(s) can be moved directly in the `block` array. |
|
|
229
|
+
| blockClass | block | Convert the class name to a CSS selector and add to `block` array. For example, `first-name` becomes `.first-name`. Regexes can be moved as-is. |
|
|
230
|
+
| maskClass | mask | Convert the class name to a CSS selector and add to `mask` array. For example, `first-name` becomes `.first-name`. Regexes can be moved as-is. |
|
|
231
|
+
| maskSelector | mask | The selector(s) can be moved directly in the `mask` array. |
|
|
220
232
|
| ignoreClass | ignore | Convert the class name to a CSS selector and add to `ignore` array. For example, `first-name` becomes `.first-name`. Regexes can be moved as-is. |
|
|
221
233
|
|
|
222
234
|
## Privacy
|
|
223
|
-
|
|
235
|
+
|
|
236
|
+
There are several ways to deal with PII. By default, the integration will mask all text content with `*` and block all
|
|
237
|
+
media elements (`img, svg, video, object, picture, embed, map, audio`). This can be disabled by setting `maskAllText` to
|
|
238
|
+
`false`. It is also possible to add the following CSS classes to specific DOM elements to prevent recording its
|
|
239
|
+
contents: `sentry-block`, `sentry-ignore`, and `sentry-mask`. The following sections will show examples of how content
|
|
240
|
+
is handled by the differing methods.
|
|
224
241
|
|
|
225
242
|
### Masking
|
|
226
|
-
|
|
243
|
+
|
|
244
|
+
Masking replaces the text content with something else. The default masking behavior is to replace each character with a
|
|
245
|
+
`*`. In this example the relevant html code is: `<table class="sentry-mask">...</table>`.
|
|
227
246
|

|
|
228
247
|
|
|
229
248
|
### Blocking
|
|
230
|
-
|
|
249
|
+
|
|
250
|
+
Blocking replaces the element with a placeholder that has the same dimensions. The recording will show an empty space
|
|
251
|
+
where the content was. In this example the relevant html code is: `<table data-sentry-block>...</table>`.
|
|
231
252
|

|
|
232
253
|
|
|
233
254
|
### Ignoring
|
|
234
|
-
|
|
255
|
+
|
|
256
|
+
Ignoring only applies to form inputs. Events will be ignored on the input element so that the replay does not show what
|
|
257
|
+
occurs inside of the input. In the below example, notice how the results in the table below the input changes, but no
|
|
258
|
+
text is visible in the input.
|
|
235
259
|
|
|
236
260
|
https://user-images.githubusercontent.com/79684/192815134-a6451c3f-d3cb-455f-a699-7c3fe04d0a2e.mov
|
|
237
261
|
|
|
238
262
|
## Error Linking
|
|
239
263
|
|
|
240
|
-
Currently, errors that happen on the page while a replay is running are linked to the Replay,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
This should not happen to often, but be aware that it is theoretically possible.
|
|
264
|
+
Currently, errors that happen on the page while a replay is running are linked to the Replay, making it as easy as
|
|
265
|
+
possible to jump between related issues/replays. However, please note that it is _possible_ that the error count
|
|
266
|
+
reported on the Replay Detail page does not match the actual errors that have been captured. The reason for that is that
|
|
267
|
+
errors _can_ be lost, e.g. a network request fails, or similar. This should not happen to often, but be aware that it is
|
|
268
|
+
theoretically possible.
|
|
246
269
|
|
|
247
270
|
## Manually sending replay data
|
|
248
271
|
|
|
249
|
-
You can use `replay.flush()` to immediately send all currently captured replay data.
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
You can use `replay.flush()` to immediately send all currently captured replay data. When Replay is currently in
|
|
273
|
+
buffering mode, this will send up to the last 60 seconds of replay data, and also continue sending afterwards, similar
|
|
274
|
+
to when an error happens & is recorded.
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/replay",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.117.0",
|
|
4
4
|
"description": "User replays for Sentry",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"tag": "v7"
|
|
11
|
+
},
|
|
8
12
|
"typesVersions": {
|
|
9
13
|
"<4.9": {
|
|
10
14
|
"types/index.d.ts": [
|
|
@@ -31,17 +35,17 @@
|
|
|
31
35
|
"homepage": "https://docs.sentry.io/platforms/javascript/session-replay/",
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@babel/core": "^7.17.5",
|
|
34
|
-
"@sentry-internal/replay-worker": "7.
|
|
38
|
+
"@sentry-internal/replay-worker": "7.117.0",
|
|
35
39
|
"@sentry-internal/rrweb": "2.15.0",
|
|
36
40
|
"@sentry-internal/rrweb-snapshot": "2.15.0",
|
|
37
41
|
"fflate": "^0.8.1",
|
|
38
42
|
"jsdom-worker": "^0.2.1"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@sentry-internal/tracing": "7.
|
|
42
|
-
"@sentry/core": "7.
|
|
43
|
-
"@sentry/types": "7.
|
|
44
|
-
"@sentry/utils": "7.
|
|
45
|
+
"@sentry-internal/tracing": "7.117.0",
|
|
46
|
+
"@sentry/core": "7.117.0",
|
|
47
|
+
"@sentry/types": "7.117.0",
|
|
48
|
+
"@sentry/utils": "7.117.0"
|
|
45
49
|
},
|
|
46
50
|
"engines": {
|
|
47
51
|
"node": ">=12"
|