@sentry/replay 0.6.10-0 → 0.6.11-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.
@@ -30,11 +30,6 @@ export declare class Replay implements Integration {
30
30
  private retryCount;
31
31
  private retryInterval;
32
32
  private debouncedFlush;
33
- /**
34
- * Flag when a new session has been created. Captured replay events behave
35
- * slightly differently in this case: `replay_start_timestamp` is included.
36
- */
37
- private newSessionCreated;
38
33
  private flushLock;
39
34
  /**
40
35
  * Timestamp of the last user activity. This lives across sessions.
@@ -45,12 +40,16 @@ export declare class Replay implements Integration {
45
40
  */
46
41
  private isEnabled;
47
42
  /**
48
- *
49
43
  * Paused is a state where:
50
44
  * - DOM Recording is not listening at all
51
45
  * - Nothing will be added to event buffer (e.g. core SDK events)
52
46
  */
53
47
  private isPaused;
48
+ /**
49
+ * Integration will wait until an error occurs before creating and sending a
50
+ * replay.
51
+ */
52
+ private waitForError;
54
53
  /**
55
54
  * Have we attached listeners to the core SDK?
56
55
  * Note we have to track this as there is no way to remove instrumentation handlers.
@@ -66,7 +65,7 @@ export declare class Replay implements Integration {
66
65
  private initialState;
67
66
  private context;
68
67
  session: Session | undefined;
69
- constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, ...recordingOptions }?: ReplayConfiguration);
68
+ constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, sessionSampleRate, errorSampleRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, replaysSamplingRate, captureOnlyOnError, ...recordingOptions }?: ReplayConfiguration);
70
69
  /**
71
70
  * Because we create a transaction in `setupOnce`, we can potentially create a
72
71
  * transaction before some native SDK integrations have run and applied their
@@ -239,7 +238,7 @@ export declare class Replay implements Integration {
239
238
  expiry?: number;
240
239
  }): boolean | undefined;
241
240
  /**
242
- * Only flush if `captureOnlyOnError` is false.
241
+ * Only flush if `this.waitForError` is false.
243
242
  */
244
243
  conditionalFlush(): void;
245
244
  /**
@@ -275,7 +274,7 @@ export declare class Replay implements Integration {
275
274
  * from calling both `flush` and `debouncedFlush`. Otherwise, there could be
276
275
  * cases of mulitple flushes happening closely together.
277
276
  */
278
- flushImmediate(): void;
277
+ flushImmediate(): any;
279
278
  /**
280
279
  * Send replay attachment using `fetch()`
281
280
  */
@@ -1,3 +1,5 @@
1
+ import { SampleRates, SessionOptions } from '../types';
2
+ declare type StickyOption = Required<Pick<SessionOptions, 'stickySession'>>;
1
3
  interface SessionObject {
2
4
  id: string;
3
5
  /**
@@ -17,10 +19,6 @@ interface SessionObject {
17
19
  */
18
20
  sampled: boolean;
19
21
  }
20
- interface SessionOptions {
21
- stickySession?: boolean;
22
- samplingRate?: number;
23
- }
24
22
  export declare class Session {
25
23
  /**
26
24
  * Session ID
@@ -46,8 +44,8 @@ export declare class Session {
46
44
  * Is the Session sampled?
47
45
  */
48
46
  private _sampled;
49
- readonly options: Required<Pick<SessionOptions, 'stickySession'>>;
50
- constructor(session?: Partial<SessionObject>, { stickySession, samplingRate }?: SessionOptions);
47
+ readonly options: StickyOption;
48
+ constructor(session: Partial<SessionObject> | undefined, { stickySession, sessionSampleRate, errorSampleRate, }: StickyOption & SampleRates);
51
49
  get id(): string;
52
50
  get started(): number;
53
51
  get lastActivity(): number;
@@ -4,3 +4,8 @@ export declare const RECORDING_EVENT_NAME = "replay_recording";
4
4
  export declare const SESSION_IDLE_DURATION = 300000;
5
5
  export declare const VISIBILITY_CHANGE_TIMEOUT = 300000;
6
6
  export declare const MAX_SESSION_LIFE = 1800000;
7
+ /**
8
+ * Defaults for sampling rates
9
+ */
10
+ export declare const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
11
+ export declare const DEFAULT_ERROR_SAMPLE_RATE = 1;
@@ -1,19 +1,8 @@
1
+ import { SessionOptions } from '../types';
1
2
  import { Session } from './Session';
2
- interface CreateSessionParams {
3
- /**
4
- * Should save to sessionStorage?
5
- */
6
- stickySession: boolean;
7
- /**
8
- * The sampling rate of the Session. See integration configuration comments
9
- * for `replaysSamplingRate`.
10
- */
11
- samplingRate?: number;
12
- }
13
3
  /**
14
4
  * Create a new session, which in its current implementation is a Sentry event
15
5
  * that all replays will be saved to as attachments. Currently, we only expect
16
6
  * one of these Sentry events per "replay session".
17
7
  */
18
- export declare function createSession({ stickySession, samplingRate, }: CreateSessionParams): Session;
19
- export {};
8
+ export declare function createSession({ sessionSampleRate, errorSampleRate, stickySession, }: SessionOptions): Session;
@@ -1,5 +1,6 @@
1
+ import { SampleRates } from '../types';
1
2
  import { Session } from './Session';
2
3
  /**
3
4
  * Fetches a session from storage
4
5
  */
5
- export declare function fetchSession(): Session | null;
6
+ export declare function fetchSession({ sessionSampleRate, errorSampleRate, }: SampleRates): Session | null;
@@ -1,27 +1,19 @@
1
+ import { SessionOptions } from '../types';
1
2
  import { Session } from './Session';
2
- interface GetSessionParams {
3
+ interface GetSessionParams extends SessionOptions {
3
4
  /**
4
5
  * The length of time (in ms) which we will consider the session to be expired.
5
6
  */
6
7
  expiry: number;
7
- /**
8
- * Should save session to sessionStorage?
9
- */
10
- stickySession: boolean;
11
8
  /**
12
9
  * The current session (e.g. if stickySession is off)
13
10
  */
14
11
  currentSession?: Session;
15
- /**
16
- * The sampling rate of the Session. See integration configuration comments
17
- * for `replaysSamplingRate`.
18
- */
19
- samplingRate?: number;
20
12
  }
21
13
  /**
22
14
  * Get or create a session
23
15
  */
24
- export declare function getSession({ expiry, currentSession, stickySession, samplingRate, }: GetSessionParams): {
16
+ export declare function getSession({ expiry, currentSession, stickySession, sessionSampleRate, errorSampleRate, }: GetSessionParams): {
25
17
  type: string;
26
18
  session: Session;
27
19
  };
@@ -33,47 +33,72 @@ export interface WorkerResponse {
33
33
  success: boolean;
34
34
  response: string | Uint8Array;
35
35
  }
36
- export interface ReplayPluginOptions {
36
+ export interface SampleRates {
37
+ /**
38
+ * The sample rate for session-long replays. 1.0 will record all sessions and
39
+ * 0 will record none.
40
+ */
41
+ sessionSampleRate: number;
42
+ /**
43
+ * The sample rate for sessions that has had an error occur. This is
44
+ * independent of `sessionSampleRate`.
45
+ */
46
+ errorSampleRate: number;
47
+ }
48
+ /**
49
+ * Session options that are configurable by the integration configuration
50
+ */
51
+ export interface SessionOptions extends SampleRates {
52
+ /**
53
+ * If false, will create a new session per pageload. Otherwise, saves session
54
+ * to Session Storage.
55
+ */
56
+ stickySession: boolean;
57
+ }
58
+ export interface ReplayPluginOptions extends SessionOptions {
37
59
  /**
38
60
  * The amount of time to wait before sending a replay
39
61
  */
40
- flushMinDelay?: number;
62
+ flushMinDelay: number;
41
63
  /**
42
64
  * The max amount of time to wait before sending a replay
43
65
  */
44
- flushMaxDelay?: number;
66
+ flushMaxDelay: number;
45
67
  /**
46
68
  * The amount of time to buffer the initial snapshot
47
69
  */
48
- initialFlushDelay?: number;
49
- /**
50
- * If false, will create a new session per pageload
51
- */
52
- stickySession?: boolean;
70
+ initialFlushDelay: number;
53
71
  /**
54
72
  * Attempt to use compression when web workers are available
55
73
  *
56
74
  * (default is true)
57
75
  */
58
- useCompression?: boolean;
76
+ useCompression: boolean;
59
77
  /**
60
78
  * Only capture replays when an error happens
79
+ *
80
+ * @deprecated
81
+ * @see errorSampleRate
61
82
  */
62
83
  captureOnlyOnError?: boolean;
63
84
  /**
64
- * The sampling rate for replays. 1.0 will record all replays, 0 will record none.
85
+ * The sample rate for replays. 1.0 will record all replays, 0 will record none.
86
+ *
87
+ * @deprecated
88
+ * @see sessionSampleRate
65
89
  */
66
90
  replaysSamplingRate?: number;
67
91
  /**
68
92
  * Mask all text in recordings. All text will be replaced with asterisks by default.
69
93
  */
70
- maskAllText?: boolean;
94
+ maskAllText: boolean;
71
95
  /**
72
96
  * Block all media (e.g. images, svg, video) in recordings.
73
97
  */
74
- blockAllMedia?: boolean;
98
+ blockAllMedia: boolean;
75
99
  }
76
- export interface ReplayConfiguration extends ReplayPluginOptions, RecordingOptions {
100
+ declare type OptionalReplayPluginOptions = Partial<ReplayPluginOptions>;
101
+ export interface ReplayConfiguration extends OptionalReplayPluginOptions, RecordingOptions {
77
102
  }
78
103
  /**
79
104
  * Some initial state captured before creating a root replay event
@@ -103,3 +128,4 @@ export interface ReplayEventContext {
103
128
  */
104
129
  earliestEvent: number | null;
105
130
  }
131
+ export {};
@@ -4,4 +4,4 @@
4
4
  * 1.0 = 100% sampling
5
5
  * 0.0 = 0% sampling
6
6
  */
7
- export declare function isSampled(sampleRate: number): boolean;
7
+ export declare function isSampled(sampleRate?: number): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/replay",
3
- "version": "0.6.10-0",
3
+ "version": "0.6.11-0",
4
4
  "description": "User replays for Sentry",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",