@sentry/replay 0.4.6 → 0.4.7
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 +16 -0
- package/dist/dist/api/captureReplayUpdate.d.ts +2 -0
- package/dist/dist/coreHandlers/handleScope.d.ts +1 -1
- package/dist/dist/eventBuffer.d.ts +8 -1
- package/dist/dist/index.d.ts +16 -4
- package/dist/dist/session/Session.d.ts +18 -7
- package/dist/dist/session/createSession.d.ts +6 -1
- package/dist/dist/session/getSession.d.ts +6 -1
- package/dist/dist/types.d.ts +7 -1
- package/dist/dist/util/isSampled.d.ts +7 -0
- package/dist/esm/index.js +1454 -0
- package/dist/esm/worker-aa3eb59a.js +4 -0
- package/dist/index.es.js +361 -291
- package/dist/index.js +359 -289
- package/dist/index.js.map +1 -1
- package/dist/{config/dist/jest.config.d.ts → jest.config.d.ts} +0 -0
- package/dist/{config/dist/jest.setup.d.ts → jest.setup.d.ts} +0 -0
- package/dist/{config/dist/src → src}/api/captureReplay.d.ts +0 -0
- package/dist/src/api/captureReplayUpdate.d.ts +2 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleDom.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleFetch.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleFetch.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleScope-unit.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleScope.d.ts +1 -1
- package/dist/{config/dist/src → src}/coreHandlers/handleScope.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/handleXhr.d.ts +0 -0
- package/dist/{config/dist/src → src}/coreHandlers/index.d.ts +0 -0
- package/dist/{config/dist/src → src}/createPerformanceEntry.d.ts +0 -0
- package/dist/{config/dist/src → src}/createPerformanceEntry.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/eventBuffer.d.ts +0 -0
- package/dist/{config/dist/src → src}/eventBuffer.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/flags.d.ts +0 -0
- package/dist/{config/dist/src → src}/index-captureOnlyOnError.test.d.ts +0 -0
- package/dist/{config/dist/src → src}/index-noSticky.test.d.ts +0 -0
- package/dist/{config/dist/src/index.test.d.ts → src/index-sampling.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/index.d.ts +20 -4
- package/dist/{config/dist/src/session/Session.test.d.ts → src/index.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/Session.d.ts +18 -7
- package/dist/{config/dist/src/session/createSession.test.d.ts → src/session/Session.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/constants.d.ts +0 -0
- package/dist/{config/dist/src → src}/session/createSession.d.ts +6 -1
- package/dist/{config/dist/src/session/fetchSession.test.d.ts → src/session/createSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/fetchSession.d.ts +0 -0
- package/dist/{config/dist/src/session/getSession.test.d.ts → src/session/fetchSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/getSession.d.ts +6 -1
- package/dist/{config/dist/src/session/saveSession.test.d.ts → src/session/getSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/session/index.d.ts +0 -0
- package/dist/{config/dist/src → src}/session/saveSession.d.ts +0 -0
- package/dist/{config/dist/src/util/isExpired.test.d.ts → src/session/saveSession.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/types.d.ts +5 -1
- package/dist/{config/dist/src → src}/util/createBreadcrumb.d.ts +0 -0
- package/dist/{config/dist/src → src}/util/isExpired.d.ts +0 -0
- package/dist/{config/dist/src/util/isSessionExpired.test.d.ts → src/util/isExpired.test.d.ts} +0 -0
- package/dist/{config/dist/src → src}/util/isIngestHost.d.ts +0 -0
- package/dist/src/util/isSampled.d.ts +7 -0
- package/dist/src/util/isSampled.test.d.ts +1 -0
- package/dist/{config/dist/src → src}/util/isSessionExpired.d.ts +0 -0
- package/dist/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/{config/dist/src → src}/util/logger.d.ts +0 -0
- package/dist/{config/dist/src → src}/util/supportsSendBeacon.d.ts +0 -0
- package/dist/{config/dist/test → test}/index.d.ts +0 -0
- package/dist/{config/dist/test → test}/mocks/mockRrweb.d.ts +0 -0
- package/dist/{config/dist/test → test}/mocks/mockSdk.d.ts +1 -1
- package/dist/types/jest.config.d.ts +3 -0
- package/dist/types/jest.setup.d.ts +10 -0
- package/dist/types/src/api/captureReplay.d.ts +3 -0
- package/dist/types/src/api/captureReplayUpdate.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleDom.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleFetch.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleFetch.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleScope-unit.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleScope.d.ts +2 -0
- package/dist/types/src/coreHandlers/handleScope.test.d.ts +1 -0
- package/dist/types/src/coreHandlers/handleXhr.d.ts +2 -0
- package/dist/types/src/coreHandlers/index.d.ts +4 -0
- package/dist/types/src/createPerformanceEntry.d.ts +42 -0
- package/dist/types/src/createPerformanceEntry.test.d.ts +1 -0
- package/dist/types/src/eventBuffer.d.ts +31 -0
- package/dist/types/src/eventBuffer.test.d.ts +1 -0
- package/dist/types/src/flags.d.ts +2 -0
- package/dist/types/src/index-captureOnlyOnError.test.d.ts +1 -0
- package/dist/types/src/index-noSticky.test.d.ts +1 -0
- package/dist/types/src/index-sampling.test.d.ts +1 -0
- package/dist/types/src/index.d.ts +209 -0
- package/dist/types/src/index.test.d.ts +1 -0
- package/dist/types/src/session/Session.d.ts +63 -0
- package/dist/types/src/session/Session.test.d.ts +1 -0
- package/dist/types/src/session/constants.d.ts +5 -0
- package/dist/types/src/session/createSession.d.ts +19 -0
- package/dist/types/src/session/createSession.test.d.ts +1 -0
- package/dist/types/src/session/fetchSession.d.ts +5 -0
- package/dist/types/src/session/fetchSession.test.d.ts +1 -0
- package/dist/types/src/session/getSession.d.ts +28 -0
- package/dist/types/src/session/getSession.test.d.ts +1 -0
- package/dist/types/src/session/index.d.ts +1 -0
- package/dist/types/src/session/saveSession.d.ts +2 -0
- package/dist/types/src/session/saveSession.test.d.ts +1 -0
- package/dist/types/src/session/types.d.ts +0 -0
- package/dist/types/src/types.d.ts +76 -0
- package/dist/types/src/util/createBreadcrumb.d.ts +4 -0
- package/dist/types/src/util/isExpired.d.ts +5 -0
- package/dist/types/src/util/isExpired.test.d.ts +1 -0
- package/dist/types/src/util/isIngestHost.d.ts +4 -0
- package/dist/types/src/util/isSampled.d.ts +7 -0
- package/dist/types/src/util/isSampled.test.d.ts +1 -0
- package/dist/types/src/util/isSessionExpired.d.ts +5 -0
- package/dist/types/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/types/src/util/logger.d.ts +12 -0
- package/dist/types/src/util/supportsSendBeacon.d.ts +4 -0
- package/dist/types/test/index.d.ts +3 -0
- package/dist/types/test/mocks/mockRrweb.d.ts +15 -0
- package/dist/types/test/mocks/mockSdk.d.ts +11 -0
- package/dist/types/worker/src/Compressor.d.ts +15 -0
- package/dist/types/worker/src/handleMessage.d.ts +2 -0
- package/dist/worker-aa3eb59a.js +4 -0
- package/dist/worker-f4750cfb.js +7 -0
- package/dist/worker-f4750cfb.js.map +1 -0
- package/package.json +18 -6
- package/dist/config/dist/src/api/captureReplayUpdate.d.ts +0 -2
- package/dist/config/dist/src/util/createPayload.d.ts +0 -5
package/README.md
CHANGED
|
@@ -46,3 +46,19 @@ Sentry.init({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
| key | type | default | description |
|
|
53
|
+
| --- | ---- | ------- | ----------- |
|
|
54
|
+
| flushMinDelay | number | 5000 | The minimum time to wait (in ms) before sending the recording payload. The payload is sent if `flushMinDelay` ms have elapsed between two events. |
|
|
55
|
+
| flushMaxDelay | number | 15000 | The maximum time to wait (in ms) when sending the recording payload. The payload is sent if events occur at an interval less than `flushMinDelay` and `flushMaxDelay` ms have elapsed since the last time a payload was sent. |
|
|
56
|
+
| 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. |
|
|
57
|
+
| stickySession | boolean | false | 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. |
|
|
58
|
+
| useCompression | boolean | true | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
|
|
59
|
+
| captureOnlyOnError | boolean | false | Only capture the recording when an error happens. |
|
|
60
|
+
| replaysSamplingRate | number | 1.0 | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
|
|
61
|
+
| maskAllInputs | boolean | true | Mask all `<input>` elements |
|
|
62
|
+
| blockClass | string | `'sr-block'` | Redact all elements with the class name `sr-block` |
|
|
63
|
+
| ignoreClass | string | `'sr-ignore'` | Ignores all elements with the class name `sr-ignore` |
|
|
64
|
+
| maskTextClass | string | `'sr-mask'` | Mask all elements with the class name `sr-ignore` |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Breadcrumb, Scope } from '@sentry/types';
|
|
2
2
|
export declare function handleScope(scope: Scope): Breadcrumb;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RecordingEvent } from './types';
|
|
1
|
+
import { RecordingEvent, WorkerRequest } from './types';
|
|
2
2
|
interface CreateEventBufferParams {
|
|
3
3
|
useCompression: boolean;
|
|
4
4
|
}
|
|
@@ -20,12 +20,19 @@ declare class EventBufferArray implements IEventBuffer {
|
|
|
20
20
|
export declare class EventBufferCompressionWorker implements IEventBuffer {
|
|
21
21
|
private worker;
|
|
22
22
|
private eventBufferItemLength;
|
|
23
|
+
private _id;
|
|
23
24
|
constructor(worker: Worker);
|
|
25
|
+
/**
|
|
26
|
+
* Read-only incrementing counter
|
|
27
|
+
*/
|
|
28
|
+
get id(): number;
|
|
29
|
+
postMessage(args: WorkerRequest): void;
|
|
24
30
|
init(): void;
|
|
25
31
|
destroy(): void;
|
|
26
32
|
get length(): number;
|
|
27
33
|
addEvent(event: RecordingEvent, isCheckout?: boolean): void;
|
|
28
34
|
sendEventToWorker(event: RecordingEvent): void;
|
|
35
|
+
finishRequest: (id: number) => Promise<Uint8Array>;
|
|
29
36
|
finish(): Promise<Uint8Array>;
|
|
30
37
|
}
|
|
31
38
|
export {};
|
package/dist/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DsnComponents, Event, Integration
|
|
1
|
+
import { Breadcrumb, DsnComponents, Event, Integration } from '@sentry/types';
|
|
2
|
+
import { Session } from './session/Session';
|
|
2
3
|
import { ReplayPerformanceEntry } from './createPerformanceEntry';
|
|
3
4
|
import { IEventBuffer } from './eventBuffer';
|
|
4
|
-
import type { InstrumentationType, RecordingEvent,
|
|
5
|
-
import { Session } from './session/Session';
|
|
5
|
+
import type { InstrumentationType, RecordingConfig, RecordingEvent, ReplayRequest, ReplaySpan, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Returns true to return control to calling function, otherwise continue with normal batching
|
|
8
8
|
*/
|
|
@@ -54,11 +54,23 @@ export declare class SentryReplay implements Integration {
|
|
|
54
54
|
* immediately before sending recording)
|
|
55
55
|
*/
|
|
56
56
|
private needsCaptureReplay;
|
|
57
|
+
/**
|
|
58
|
+
* Captured state when integration is first initialized
|
|
59
|
+
*/
|
|
57
60
|
private initialState;
|
|
58
61
|
session: Session | undefined;
|
|
59
62
|
static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
|
|
60
63
|
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
|
|
61
|
-
useCompression, captureOnlyOnError, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
64
|
+
useCompression, captureOnlyOnError, replaysSamplingRate, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
65
|
+
/**
|
|
66
|
+
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
67
|
+
* transaction before some native SDK integrations have run and applied their
|
|
68
|
+
* own global event processor. An example is:
|
|
69
|
+
* https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
|
|
70
|
+
*
|
|
71
|
+
* So we call `this.setup` in next event loop as a workaround to wait for
|
|
72
|
+
* other global event processors to finish
|
|
73
|
+
*/
|
|
62
74
|
setupOnce(): void;
|
|
63
75
|
/**
|
|
64
76
|
* Initializes the plugin.
|
|
@@ -9,12 +9,17 @@ interface SessionObject {
|
|
|
9
9
|
*/
|
|
10
10
|
lastActivity: number;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Segment ID for replay events
|
|
13
|
+
*/
|
|
14
|
+
segmentId: number;
|
|
15
|
+
/**
|
|
16
|
+
* Is the session sampled?
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
sampled: boolean;
|
|
15
19
|
}
|
|
16
20
|
interface SessionOptions {
|
|
17
21
|
stickySession?: boolean;
|
|
22
|
+
samplingRate?: number;
|
|
18
23
|
}
|
|
19
24
|
export declare class Session {
|
|
20
25
|
/**
|
|
@@ -32,21 +37,27 @@ export declare class Session {
|
|
|
32
37
|
/**
|
|
33
38
|
* Sequence ID specific to replay updates
|
|
34
39
|
*/
|
|
35
|
-
private
|
|
40
|
+
private _segmentId;
|
|
36
41
|
/**
|
|
37
42
|
* Previous session ID
|
|
38
43
|
*/
|
|
39
44
|
private _previousSessionId;
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Is the Session sampled?
|
|
47
|
+
*/
|
|
48
|
+
private _sampled;
|
|
49
|
+
readonly options: Required<Pick<SessionOptions, 'stickySession'>>;
|
|
50
|
+
constructor(session?: Partial<SessionObject>, { stickySession, samplingRate }?: SessionOptions);
|
|
42
51
|
get id(): string;
|
|
43
52
|
get started(): number;
|
|
44
53
|
get lastActivity(): number;
|
|
45
54
|
set lastActivity(newDate: number);
|
|
46
|
-
get
|
|
47
|
-
set
|
|
55
|
+
get segmentId(): number;
|
|
56
|
+
set segmentId(id: number);
|
|
48
57
|
get previousSessionId(): string;
|
|
49
58
|
set previousSessionId(id: string);
|
|
59
|
+
get sampled(): boolean;
|
|
60
|
+
set sampled(_isSampled: boolean);
|
|
50
61
|
toJSON(): SessionObject;
|
|
51
62
|
}
|
|
52
63
|
export {};
|
|
@@ -4,11 +4,16 @@ interface CreateSessionParams {
|
|
|
4
4
|
* Should save to sessionStorage?
|
|
5
5
|
*/
|
|
6
6
|
stickySession: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The sampling rate of the Session. See integration configuration comments
|
|
9
|
+
* for `replaysSamplingRate`.
|
|
10
|
+
*/
|
|
11
|
+
samplingRate?: number;
|
|
7
12
|
}
|
|
8
13
|
/**
|
|
9
14
|
* Create a new session, which in its current implementation is a Sentry event
|
|
10
15
|
* that all replays will be saved to as attachments. Currently, we only expect
|
|
11
16
|
* one of these Sentry events per "replay session".
|
|
12
17
|
*/
|
|
13
|
-
export declare function createSession({ stickySession, }: CreateSessionParams): Session;
|
|
18
|
+
export declare function createSession({ stickySession, samplingRate, }: CreateSessionParams): Session;
|
|
14
19
|
export {};
|
|
@@ -12,11 +12,16 @@ interface GetSessionParams {
|
|
|
12
12
|
* The current session (e.g. if stickySession is off)
|
|
13
13
|
*/
|
|
14
14
|
currentSession?: Session;
|
|
15
|
+
/**
|
|
16
|
+
* The sampling rate of the Session. See integration configuration comments
|
|
17
|
+
* for `replaysSamplingRate`.
|
|
18
|
+
*/
|
|
19
|
+
samplingRate?: number;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Get or create a session
|
|
18
23
|
*/
|
|
19
|
-
export declare function getSession({ expiry, currentSession, stickySession, }: GetSessionParams): {
|
|
24
|
+
export declare function getSession({ expiry, currentSession, stickySession, samplingRate, }: GetSessionParams): {
|
|
20
25
|
type: string;
|
|
21
26
|
session: Session;
|
|
22
27
|
};
|
package/dist/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { eventWithTime } from 'rrweb/typings/types';
|
|
2
1
|
import { record } from 'rrweb';
|
|
2
|
+
import type { eventWithTime } from 'rrweb/typings/types';
|
|
3
3
|
export declare type RecordingEvent = eventWithTime;
|
|
4
4
|
export declare type RecordingConfig = Parameters<typeof record>[0];
|
|
5
5
|
export interface ReplaySpan {
|
|
@@ -18,6 +18,7 @@ export declare type InstrumentationType = 'scope' | 'dom' | 'fetch' | 'xhr';
|
|
|
18
18
|
* The request payload to worker
|
|
19
19
|
*/
|
|
20
20
|
export interface WorkerRequest {
|
|
21
|
+
id: number;
|
|
21
22
|
method: string;
|
|
22
23
|
args: any[];
|
|
23
24
|
}
|
|
@@ -25,6 +26,7 @@ export interface WorkerRequest {
|
|
|
25
26
|
* The response from the worker
|
|
26
27
|
*/
|
|
27
28
|
export interface WorkerResponse {
|
|
29
|
+
id: number;
|
|
28
30
|
method: string;
|
|
29
31
|
success: boolean;
|
|
30
32
|
response: string | Uint8Array;
|
|
@@ -56,6 +58,10 @@ export interface SentryReplayPluginOptions {
|
|
|
56
58
|
* Only capture replays when an error happens
|
|
57
59
|
*/
|
|
58
60
|
captureOnlyOnError?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The sampling rate for replays. 1.0 will record all replays, 0 will record none.
|
|
63
|
+
*/
|
|
64
|
+
replaysSamplingRate?: number;
|
|
59
65
|
}
|
|
60
66
|
export interface SentryReplayConfiguration extends SentryReplayPluginOptions {
|
|
61
67
|
/**
|