@sentry/replay 0.5.23 → 0.6.1
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 +59 -35
- package/dist/{jest.config.d.ts → config/types/jest.config.d.ts} +0 -0
- package/dist/{jest.setup.d.ts → config/types/jest.setup.d.ts} +0 -0
- package/dist/{src → config/types/src}/api/captureReplayEvent.d.ts +0 -0
- package/dist/{src/coreHandlers/handleFetch.test.d.ts → config/types/src/blockAllMedia.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/coreHandlers/getBreadcrumbHandler.d.ts +0 -0
- package/dist/{src → config/types/src}/coreHandlers/getSpanHandler.d.ts +0 -0
- package/dist/{src → config/types/src}/coreHandlers/handleDom.d.ts +0 -0
- package/dist/{src → config/types/src}/coreHandlers/handleFetch.d.ts +0 -0
- package/dist/{src/coreHandlers/handleScope-unit.test.d.ts → config/types/src/coreHandlers/handleFetch.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/coreHandlers/handleHistory.d.ts +0 -0
- package/dist/{src/coreHandlers/handleScope.test.d.ts → config/types/src/coreHandlers/handleScope-unit.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/coreHandlers/handleScope.d.ts +0 -0
- package/dist/{src/createPerformanceEntry.test.d.ts → config/types/src/coreHandlers/handleScope.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/coreHandlers/handleXhr.d.ts +0 -0
- package/dist/{src → config/types/src}/createPerformanceEntry.d.ts +0 -0
- package/dist/{src/flush.test.d.ts → config/types/src/createPerformanceEntry.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/eventBuffer.d.ts +0 -0
- package/dist/{src → config/types/src}/eventBuffer.test.d.ts +0 -0
- package/dist/{src → config/types/src}/flags.d.ts +0 -0
- package/dist/{src/index-captureOnlyOnError.test.d.ts → config/types/src/flush.test.d.ts} +0 -0
- package/dist/{src/index-noSticky.test.d.ts → config/types/src/index-captureOnlyOnError.test.d.ts} +0 -0
- package/dist/{src/index-sampling.test.d.ts → config/types/src/index-noSticky.test.d.ts} +0 -0
- package/dist/{src/index.test.d.ts → config/types/src/index-sampling.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/index.d.ts +5 -5
- package/dist/{src/session/Session.test.d.ts → config/types/src/index.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/Session.d.ts +0 -0
- package/dist/{src/session/createSession.test.d.ts → config/types/src/session/Session.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/constants.d.ts +0 -0
- package/dist/{src → config/types/src}/session/createSession.d.ts +0 -0
- package/dist/{src/session/deleteSession.test.d.ts → config/types/src/session/createSession.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/deleteSession.d.ts +0 -0
- package/dist/{src/session/fetchSession.test.d.ts → config/types/src/session/deleteSession.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/fetchSession.d.ts +0 -0
- package/dist/{src/session/getSession.test.d.ts → config/types/src/session/fetchSession.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/getSession.d.ts +0 -0
- package/dist/{src/session/saveSession.test.d.ts → config/types/src/session/getSession.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/session/index.d.ts +0 -0
- package/dist/{src → config/types/src}/session/saveSession.d.ts +0 -0
- package/dist/{src/stop.test.d.ts → config/types/src/session/saveSession.test.d.ts} +0 -0
- package/dist/{src/util/dedupePerformanceEntries.test.d.ts → config/types/src/stop.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/types.d.ts +7 -8
- package/dist/{src → config/types/src}/util/addInternalBreadcrumb.d.ts +0 -0
- package/dist/{src → config/types/src}/util/createBreadcrumb.d.ts +0 -0
- package/dist/{src → config/types/src}/util/createPayload.d.ts +0 -0
- package/dist/{src → config/types/src}/util/dedupePerformanceEntries.d.ts +0 -0
- package/dist/{src/util/isExpired.test.d.ts → config/types/src/util/dedupePerformanceEntries.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/util/isExpired.d.ts +0 -0
- package/dist/{src/util/isSampled.test.d.ts → config/types/src/util/isExpired.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/util/isIngestHost.d.ts +0 -0
- package/dist/{src → config/types/src}/util/isInternal.d.ts +0 -0
- package/dist/{src → config/types/src}/util/isSampled.d.ts +0 -0
- package/dist/{src/util/isSessionExpired.test.d.ts → config/types/src/util/isSampled.test.d.ts} +0 -0
- package/dist/{src → config/types/src}/util/isSessionExpired.d.ts +0 -0
- package/dist/config/types/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/{src → config/types/src}/util/logger.d.ts +1 -1
- package/dist/{test → config/types/test}/fixtures/performanceEntry/lcp.d.ts +0 -0
- package/dist/{test → config/types/test}/fixtures/performanceEntry/navigation.d.ts +0 -0
- package/dist/{test → config/types/test}/fixtures/performanceEntry/resource.d.ts +0 -0
- package/dist/{test → config/types/test}/index.d.ts +0 -0
- package/dist/{test → config/types/test}/mocks/mockRrweb.d.ts +0 -0
- package/dist/{test → config/types/test}/mocks/mockSdk.d.ts +4 -4
- package/dist/index.es.js +52 -40
- package/dist/index.js +51 -39
- package/dist/index.js.map +1 -1
- package/dist/types/src/index.d.ts +5 -5
- package/dist/types/src/types.d.ts +7 -8
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
# sentry-replay
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Note: Session Replay is currently in alpha.
|
|
4
4
|
|
|
5
|
-
## Pre-
|
|
5
|
+
## Pre-requisites
|
|
6
6
|
|
|
7
|
-
For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) installed.
|
|
7
|
+
For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) (or an equivalent framework SDK e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
To install the stable version:
|
|
12
|
-
|
|
13
11
|
with npm:
|
|
14
12
|
|
|
15
13
|
```shell
|
|
@@ -24,55 +22,81 @@ yarn add @sentry/browser @sentry/replay
|
|
|
24
22
|
|
|
25
23
|
## Setup
|
|
26
24
|
|
|
27
|
-
To set up the integration add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
|
|
28
|
-
See the
|
|
29
|
-
|
|
25
|
+
To set up the integration, add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
|
|
26
|
+
See the [configuration section](#configuration) below for more details.
|
|
30
27
|
|
|
31
28
|
```javascript
|
|
32
29
|
import * as Sentry from '@sentry/browser';
|
|
33
|
-
import {
|
|
30
|
+
import { Replay } from '@sentry/replay';
|
|
34
31
|
|
|
35
32
|
Sentry.init({
|
|
36
33
|
dsn: '__DSN__',
|
|
37
|
-
integrations: [
|
|
38
|
-
new SentryReplay({
|
|
39
|
-
maskAllText: true, // Will mask all text strings
|
|
40
|
-
recordingConfig: {
|
|
41
|
-
maskAllInputs: false, // Default is true
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
34
|
+
integrations: [new Replay()],
|
|
45
35
|
// ...
|
|
46
36
|
});
|
|
47
37
|
```
|
|
48
38
|
|
|
49
|
-
### Stop Recording
|
|
39
|
+
### Start and Stop Recording
|
|
50
40
|
|
|
51
41
|
Replay recording only starts automatically when it is included in the `integrations` key when calling `Sentry.init`. Otherwise you can initialize the plugin and manually call the `start()` method on the integration instance. To stop recording you can call the `stop()`.
|
|
52
42
|
|
|
53
43
|
```javascript
|
|
54
|
-
|
|
55
|
-
const replay = new SentryReplay(); // This will *NOT* begin recording replays
|
|
44
|
+
const replay = new Replay(); // This will *NOT* begin recording replays
|
|
56
45
|
|
|
57
46
|
replay.start(); // Start recording
|
|
58
47
|
|
|
59
48
|
replay.stop(); // Stop recording
|
|
60
|
-
|
|
61
49
|
```
|
|
62
50
|
|
|
63
51
|
## Configuration
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
53
|
+
### General Configuration
|
|
54
|
+
|
|
55
|
+
| key | type | default | description |
|
|
56
|
+
| ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| captureOnlyOnError | boolean | `false` | Only capture the recording when an error happens. The recording is currently limited to up to the last 60 seconds before the error occurs and only records up to the error. |
|
|
58
|
+
| initialFlushDelay | number | `5000` | The amount of time to wait (in ms) before sending the initial recording payload. This helps drop recordings where users visit and close the page quickly. |
|
|
59
|
+
| replaysSamplingRate | number | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
|
|
60
|
+
| 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. |
|
|
61
|
+
|
|
62
|
+
### Privacy Configuration
|
|
63
|
+
|
|
64
|
+
| key | type | default | description |
|
|
65
|
+
| ---------------- | ------------------------ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| maskAllText | boolean | `true` | Mask _all_ text content. Will pass text content through `maskTextFn` before sending to server. |
|
|
67
|
+
| blockAllMedia | boolean | `true` | Block _all_ media elements (`img, svg, video, object, picture, embed, map, audio`)
|
|
68
|
+
| maskTextFn | (text: string) => string | `(text) => '*'.repeat(text.length)` | Function to customize how text content is masked before sending to server. By default, masks text with `*`. |
|
|
69
|
+
| maskAllInputs | boolean | `true` | Mask values of `<input>` elements. Passes input values through `maskInputFn` before sending to server. |
|
|
70
|
+
| maskInputOptions | Record<string, boolean> | `{ password: true }` | Customize which inputs `type` to mask. <br /> Available `<input>` types: `color, date, datetime-local, email, month, number, range, search, tel, text, time, url, week, textarea, select, password`. |
|
|
71
|
+
| maskInputFn | (text: string) => string | `(text) => '*'.repeat(text.length)` | Function to customize how form input values are masked before sending to server. By default, masks values with `*`. |
|
|
72
|
+
| blockClass | string \| RegExp | `'sentry-block'` | Redact all elements that match the class name. See [privacy](#blocking) section for an example. |
|
|
73
|
+
| blockSelector | string | `'[data-sentry-block]'` | Redact all elements that match the DOM selector. See [privacy](#blocking) section for an example. |
|
|
74
|
+
| ignoreClass | string \| RegExp | `'sentry-ignore'` | Ignores all events on the matching input field. See [privacy](#ignoring) section for an example. |
|
|
75
|
+
| maskTextClass | string \| RegExp | `'sentry-mask'` | Mask all elements that match the class name. See [privacy](#masking) section for an example. |
|
|
76
|
+
|
|
77
|
+
### Optimization Configuration
|
|
78
|
+
|
|
79
|
+
| key | type | default | description |
|
|
80
|
+
| ---------------- | ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| collectFonts | boolean | `false` | Should collect fonts used on the website |
|
|
82
|
+
| inlineImages | boolean | `false` | Should inline `<image>` content |
|
|
83
|
+
| inlineStylesheet | boolean | `true` | Should inline stylesheets used in the recording |
|
|
84
|
+
| recordCanvas | boolean | `false` | Should record `<canvas>` elements |
|
|
85
|
+
| slimDOMOptions | Record<string, boolean> | `{}` | Remove unnecessary parts of the DOM <br /> Available keys: `script, comment, headFavicon, headWhitespace, headMetaDescKeywords, headMetaSocial, headMetaRobots, headMetaHttpEquiv, headMetaAuthorship, headMetaVerification` |
|
|
86
|
+
|
|
87
|
+
## Privacy
|
|
88
|
+
There are several ways to deal with PII. By default, the integration will mask all text content with `*` and block all media elements (`img, svg, video, object, picture, embed, map, audio`). This can be disabled by setting `maskAllText` to `false`. It is also possible to add the following CSS classes to specific DOM elements to prevent recording its contents: `sentry-block`, `sentry-ignore`, and `sentry-mask`. The following sections will show examples of how content is handled by the differing methods.
|
|
89
|
+
|
|
90
|
+
### Masking
|
|
91
|
+
Masking replaces the text content with something else. The default masking behavior is to replace each character with a `*`. In this example the relevant html code is: `<table class="sentry-mask">...</table>`.
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
### Blocking
|
|
95
|
+
Blocking replaces the element with a placeholder that has the same dimensions. The recording will show an empty space where the content was. In this example the relevant html code is: `<table data-sentry-block>...</table>`.
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
### Ignoring
|
|
99
|
+
Ignoring only applies to form inputs. Events will be ignored on the input element so that the replay does not show what occurs inside of the input. In the below example, notice how the results in the table below the input changes, but no text is visible in the input.
|
|
100
|
+
|
|
101
|
+
https://user-images.githubusercontent.com/79684/192815134-a6451c3f-d3cb-455f-a699-7c3fe04d0a2e.mov
|
|
102
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{src/coreHandlers/handleFetch.test.d.ts → config/types/src/blockAllMedia.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{src/index-noSticky.test.d.ts → config/types/src/index-captureOnlyOnError.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,12 +3,12 @@ import { CaptureReplayEventParams } from './api/captureReplayEvent';
|
|
|
3
3
|
import { Session } from './session/Session';
|
|
4
4
|
import { ReplayPerformanceEntry } from './createPerformanceEntry';
|
|
5
5
|
import { IEventBuffer } from './eventBuffer';
|
|
6
|
-
import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents,
|
|
6
|
+
import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingEvent, RecordingOptions, ReplayConfiguration, ReplayPluginOptions, ReplayRequest } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* Returns true to return control to calling function, otherwise continue with normal batching
|
|
9
9
|
*/
|
|
10
10
|
declare type AddUpdateCallback = () => boolean | void;
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class Replay implements Integration {
|
|
12
12
|
/**
|
|
13
13
|
* @inheritDoc
|
|
14
14
|
*/
|
|
@@ -25,8 +25,8 @@ export declare class SentryReplay implements Integration {
|
|
|
25
25
|
/**
|
|
26
26
|
* Options to pass to `rrweb.record()`
|
|
27
27
|
*/
|
|
28
|
-
readonly recordingOptions:
|
|
29
|
-
readonly options:
|
|
28
|
+
readonly recordingOptions: RecordingOptions;
|
|
29
|
+
readonly options: ReplayPluginOptions;
|
|
30
30
|
private performanceObserver;
|
|
31
31
|
private retryCount;
|
|
32
32
|
private retryInterval;
|
|
@@ -56,7 +56,7 @@ export declare class SentryReplay implements Integration {
|
|
|
56
56
|
private initialState;
|
|
57
57
|
private context;
|
|
58
58
|
session: Session | undefined;
|
|
59
|
-
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText,
|
|
59
|
+
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, ...recordingOptions }?: ReplayConfiguration);
|
|
60
60
|
/**
|
|
61
61
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
62
62
|
* transaction before some native SDK integrations have run and applied their
|
|
File without changes
|
|
File without changes
|
package/dist/{src/session/createSession.test.d.ts → config/types/src/session/Session.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{src/session/fetchSession.test.d.ts → config/types/src/session/deleteSession.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
package/dist/{src/session/getSession.test.d.ts → config/types/src/session/fetchSession.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
package/dist/{src/session/saveSession.test.d.ts → config/types/src/session/getSession.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{src/util/dedupePerformanceEntries.test.d.ts → config/types/src/stop.test.d.ts}
RENAMED
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { eventWithTime } from 'rrweb/typings/types';
|
|
1
|
+
import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
|
|
3
2
|
export declare type RecordingEvent = eventWithTime;
|
|
4
|
-
export declare type
|
|
3
|
+
export declare type RecordingOptions = recordOptions<eventWithTime>;
|
|
5
4
|
export declare type RecordedEvents = Uint8Array | string;
|
|
6
5
|
export declare type AllPerformanceEntry = PerformancePaintTiming | PerformanceResourceTiming | PerformanceNavigationTiming;
|
|
7
6
|
export interface ReplayRequest {
|
|
@@ -33,7 +32,7 @@ export interface WorkerResponse {
|
|
|
33
32
|
success: boolean;
|
|
34
33
|
response: string | Uint8Array;
|
|
35
34
|
}
|
|
36
|
-
export interface
|
|
35
|
+
export interface ReplayPluginOptions {
|
|
37
36
|
/**
|
|
38
37
|
* The amount of time to wait before sending a replay
|
|
39
38
|
*/
|
|
@@ -68,12 +67,12 @@ export interface SentryReplayPluginOptions {
|
|
|
68
67
|
* Mask all text in recordings. All text will be replaced with asterisks by default.
|
|
69
68
|
*/
|
|
70
69
|
maskAllText?: boolean;
|
|
71
|
-
}
|
|
72
|
-
export interface SentryReplayConfiguration extends SentryReplayPluginOptions {
|
|
73
70
|
/**
|
|
74
|
-
*
|
|
71
|
+
* Block all media (e.g. images, svg, video) in recordings.
|
|
75
72
|
*/
|
|
76
|
-
|
|
73
|
+
blockAllMedia?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface ReplayConfiguration extends ReplayPluginOptions, RecordingOptions {
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
78
|
* Some initial state captured before creating a root replay event
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{src/util/isSessionExpired.test.d.ts → config/types/src/util/isSampled.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,8 @@ declare const logger: {
|
|
|
4
4
|
log: (...args: any[]) => any;
|
|
5
5
|
disable(): void;
|
|
6
6
|
enable(): void;
|
|
7
|
-
debug: (...args: unknown[]) => void;
|
|
8
7
|
info: (...args: unknown[]) => void;
|
|
8
|
+
debug: (...args: unknown[]) => void;
|
|
9
9
|
assert: (...args: unknown[]) => void;
|
|
10
10
|
trace: (...args: unknown[]) => void;
|
|
11
11
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BrowserOptions } from '@sentry/browser';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Replay } from '@';
|
|
3
|
+
import { ReplayConfiguration } from '@/types';
|
|
4
4
|
interface MockSdkParams {
|
|
5
|
-
replayOptions?:
|
|
5
|
+
replayOptions?: ReplayConfiguration;
|
|
6
6
|
sentryOptions?: BrowserOptions;
|
|
7
7
|
}
|
|
8
8
|
export declare function mockSdk({ replayOptions, sentryOptions, }?: MockSdkParams): {
|
|
9
|
-
replay:
|
|
9
|
+
replay: Replay;
|
|
10
10
|
};
|
|
11
11
|
export {};
|