@sentry/replay 0.5.17 → 0.5.18

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.
Files changed (60) hide show
  1. package/README.md +3 -2
  2. package/dist/config/types/jest.config.d.ts +3 -0
  3. package/dist/config/types/jest.setup.d.ts +10 -0
  4. package/dist/config/types/src/api/captureReplayEvent.d.ts +37 -0
  5. package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +3 -0
  6. package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +5 -0
  7. package/dist/config/types/src/coreHandlers/handleDom.d.ts +1 -0
  8. package/dist/config/types/src/coreHandlers/handleFetch.d.ts +19 -0
  9. package/dist/config/types/src/coreHandlers/handleFetch.test.d.ts +1 -0
  10. package/dist/config/types/src/coreHandlers/handleHistory.d.ts +7 -0
  11. package/dist/config/types/src/coreHandlers/handleScope-unit.test.d.ts +1 -0
  12. package/dist/config/types/src/coreHandlers/handleScope.d.ts +2 -0
  13. package/dist/config/types/src/coreHandlers/handleScope.test.d.ts +1 -0
  14. package/dist/config/types/src/coreHandlers/handleXhr.d.ts +21 -0
  15. package/dist/config/types/src/createPerformanceEntry.d.ts +43 -0
  16. package/dist/config/types/src/createPerformanceEntry.test.d.ts +1 -0
  17. package/dist/config/types/src/eventBuffer.d.ts +45 -0
  18. package/dist/config/types/src/eventBuffer.test.d.ts +1 -0
  19. package/dist/config/types/src/flags.d.ts +2 -0
  20. package/dist/config/types/src/flush.test.d.ts +1 -0
  21. package/dist/config/types/src/index-captureOnlyOnError.test.d.ts +1 -0
  22. package/dist/config/types/src/index-noSticky.test.d.ts +1 -0
  23. package/dist/config/types/src/index-sampling.test.d.ts +1 -0
  24. package/dist/config/types/src/index.d.ts +253 -0
  25. package/dist/config/types/src/index.test.d.ts +1 -0
  26. package/dist/config/types/src/session/Session.d.ts +63 -0
  27. package/dist/config/types/src/session/Session.test.d.ts +1 -0
  28. package/dist/config/types/src/session/constants.d.ts +5 -0
  29. package/dist/config/types/src/session/createSession.d.ts +19 -0
  30. package/dist/config/types/src/session/createSession.test.d.ts +1 -0
  31. package/dist/config/types/src/session/deleteSession.d.ts +4 -0
  32. package/dist/config/types/src/session/deleteSession.test.d.ts +1 -0
  33. package/dist/config/types/src/session/fetchSession.d.ts +5 -0
  34. package/dist/config/types/src/session/fetchSession.test.d.ts +1 -0
  35. package/dist/config/types/src/session/getSession.d.ts +28 -0
  36. package/dist/config/types/src/session/getSession.test.d.ts +1 -0
  37. package/dist/config/types/src/session/index.d.ts +1 -0
  38. package/dist/config/types/src/session/saveSession.d.ts +2 -0
  39. package/dist/config/types/src/session/saveSession.test.d.ts +1 -0
  40. package/dist/config/types/src/stop.test.d.ts +1 -0
  41. package/dist/config/types/src/types.d.ts +102 -0
  42. package/dist/config/types/src/util/createBreadcrumb.d.ts +4 -0
  43. package/dist/config/types/src/util/createPayload.d.ts +5 -0
  44. package/dist/config/types/src/util/isExpired.d.ts +5 -0
  45. package/dist/config/types/src/util/isExpired.test.d.ts +1 -0
  46. package/dist/config/types/src/util/isIngestHost.d.ts +4 -0
  47. package/dist/config/types/src/util/isSampled.d.ts +7 -0
  48. package/dist/config/types/src/util/isSampled.test.d.ts +1 -0
  49. package/dist/config/types/src/util/isSessionExpired.d.ts +5 -0
  50. package/dist/config/types/src/util/isSessionExpired.test.d.ts +1 -0
  51. package/dist/config/types/src/util/logger.d.ts +12 -0
  52. package/dist/config/types/test/index.d.ts +3 -0
  53. package/dist/config/types/test/mocks/mockRrweb.d.ts +15 -0
  54. package/dist/config/types/test/mocks/mockSdk.d.ts +11 -0
  55. package/dist/index.es.js +8 -1
  56. package/dist/index.js +8 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/types/src/index.d.ts +1 -1
  59. package/dist/types/src/types.d.ts +4 -0
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -36,7 +36,7 @@ Sentry.init({
36
36
  dsn: '__DSN__',
37
37
  integrations: [
38
38
  new SentryReplay({
39
- stickySession: false, // Default is true
39
+ maskAllText: true, // Will mask all text strings
40
40
  recordingConfig: {
41
41
  maskAllInputs: false, // Default is true
42
42
  },
@@ -66,10 +66,11 @@ replay.setup(); // Start recording again
66
66
  | `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. |
67
67
  | `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. |
68
68
  | `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. |
69
+ | `maskAllText` | `boolean` | `false` | Mask *all* text strings with `*`. |
70
+ | `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
69
71
  | `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. |
70
72
  | `useCompression` | `boolean` | `true` | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
71
73
  | `captureOnlyOnError` | `boolean` | `false` | Only capture the recording when an error happens. |
72
- | `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
73
74
  | `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
74
75
  | `recordingConfig.blockClass` | `string` | `'sr-block'` | Redact all elements with the class name `sr-block` |
75
76
  | `recordingConfig.ignoreClass` | `string` | `'sr-ignore'` | Ignores all elements with the class name `sr-ignore` |
@@ -0,0 +1,3 @@
1
+ import type { Config } from '@jest/types';
2
+ declare const _default: () => Promise<Config.InitialOptions>;
3
+ export default _default;
@@ -0,0 +1,10 @@
1
+ /// <reference types="jest" />
2
+ import { Session } from '@/session/Session';
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R> {
6
+ toHaveSentReplay(expected?: string | Uint8Array): CustomMatcherResult;
7
+ toHaveSameSession(expected: undefined | Session): CustomMatcherResult;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,37 @@
1
+ import { InitialState } from '@/types';
2
+ export interface CaptureReplayEventParams {
3
+ /**
4
+ * Initial state of the replay
5
+ */
6
+ initialState: InitialState;
7
+ /**
8
+ * Include a timestamp that should be deemed as the "starting" timestamp of the
9
+ * replay. This usually comes from a `window.performance` entry.
10
+ */
11
+ includeReplayStartTimestamp: boolean;
12
+ /**
13
+ * List of error ids contained in current recording segment
14
+ */
15
+ errorIds: string[];
16
+ /**
17
+ * The current replay id
18
+ */
19
+ replayId: string;
20
+ /**
21
+ * The current recording segment id
22
+ */
23
+ segmentId: number;
24
+ /**
25
+ * Timestamp of the event in milliseconds
26
+ */
27
+ timestamp: number;
28
+ /**
29
+ * List of trace ids contained in current recording segment
30
+ */
31
+ traceIds: string[];
32
+ /**
33
+ * List of URLs visisted in current recording segment
34
+ */
35
+ urls: string[];
36
+ }
37
+ export declare function captureReplayEvent({ initialState, includeReplayStartTimestamp, errorIds, replayId: replay_id, segmentId: segment_id, timestamp, traceIds, urls, }: CaptureReplayEventParams): void;
@@ -0,0 +1,3 @@
1
+ import { InstrumentationTypeBreadcrumb } from '@/types';
2
+ import { handleScope } from './handleScope';
3
+ export declare function getBreadcrumbHandler(type: InstrumentationTypeBreadcrumb): typeof handleScope;
@@ -0,0 +1,5 @@
1
+ import { InstrumentationTypeSpan } from '@/types';
2
+ import { handleFetch } from './handleFetch';
3
+ import { handleHistory } from './handleHistory';
4
+ import { handleXhr } from './handleXhr';
5
+ export declare function getSpanHandler(type: InstrumentationTypeSpan): typeof handleFetch | typeof handleXhr | typeof handleHistory;
@@ -0,0 +1 @@
1
+ export declare function handleDom(handlerData: any): import("@sentry/types").Breadcrumb | null;
@@ -0,0 +1,19 @@
1
+ import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
2
+ interface FetchHandlerData {
3
+ args: Parameters<typeof fetch>;
4
+ fetchData: {
5
+ method: string;
6
+ url: string;
7
+ };
8
+ response: {
9
+ type: string;
10
+ url: string;
11
+ redirected: boolean;
12
+ status: number;
13
+ ok: boolean;
14
+ };
15
+ startTimestamp: number;
16
+ endTimestamp?: number;
17
+ }
18
+ export declare function handleFetch(handlerData: FetchHandlerData): null | ReplayPerformanceEntry;
19
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
2
+ interface HistoryHandlerData {
3
+ from: string;
4
+ to: string;
5
+ }
6
+ export declare function handleHistory(handlerData: HistoryHandlerData): ReplayPerformanceEntry;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Breadcrumb, Scope } from '@sentry/types';
2
+ export declare function handleScope(scope: Scope): Breadcrumb | null;
@@ -0,0 +1,21 @@
1
+ import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
2
+ declare type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
3
+ interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
4
+ [key: string]: unknown;
5
+ __sentry_xhr__?: {
6
+ method?: string;
7
+ url?: string;
8
+ status_code?: number;
9
+ body?: XHRSendInput;
10
+ startTimestamp?: number;
11
+ };
12
+ __sentry_own_request__?: boolean;
13
+ }
14
+ interface XhrHandlerData {
15
+ args: [method: string, url: string];
16
+ xhr: SentryWrappedXMLHttpRequest;
17
+ startTimestamp: number;
18
+ endTimestamp?: number;
19
+ }
20
+ export declare function handleXhr(handlerData: XhrHandlerData): ReplayPerformanceEntry | null;
21
+ export {};
@@ -0,0 +1,43 @@
1
+ import { AllPerformanceEntry } from './types';
2
+ export interface ReplayPerformanceEntry {
3
+ /**
4
+ * One of these types https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType
5
+ */
6
+ type: string;
7
+ /**
8
+ * A more specific description of the performance entry
9
+ */
10
+ name: string;
11
+ /**
12
+ * The start timestamp in seconds
13
+ */
14
+ start: number;
15
+ /**
16
+ * The end timestamp in seconds
17
+ */
18
+ end: number;
19
+ /**
20
+ * Additional unstructured data to be included
21
+ */
22
+ data?: Record<string, unknown>;
23
+ }
24
+ interface MemoryInfo {
25
+ jsHeapSizeLimit: number;
26
+ totalJSHeapSize: number;
27
+ usedJSHeapSize: number;
28
+ }
29
+ export declare function createPerformanceEntries(entries: AllPerformanceEntry[]): ReplayPerformanceEntry[];
30
+ export declare function createMemoryEntry(memoryEntry: MemoryInfo): {
31
+ type: string;
32
+ name: string;
33
+ start: number;
34
+ end: number;
35
+ data: {
36
+ memory: {
37
+ jsHeapSizeLimit: number;
38
+ totalJSHeapSize: number;
39
+ usedJSHeapSize: number;
40
+ };
41
+ };
42
+ };
43
+ export {};
@@ -0,0 +1,45 @@
1
+ import { RecordingEvent, WorkerRequest, WorkerResponse } from './types';
2
+ interface CreateEventBufferParams {
3
+ useCompression: boolean;
4
+ }
5
+ export declare function createEventBuffer({ useCompression }: CreateEventBufferParams): EventBufferCompressionWorker | EventBufferArray;
6
+ export interface IEventBuffer {
7
+ get length(): number;
8
+ destroy(): void;
9
+ addEvent(event: RecordingEvent, isCheckout?: boolean): void;
10
+ finish(): Promise<string | Uint8Array>;
11
+ }
12
+ declare class EventBufferArray implements IEventBuffer {
13
+ events: RecordingEvent[];
14
+ constructor();
15
+ destroy(): void;
16
+ get length(): number;
17
+ addEvent(event: RecordingEvent, isCheckout?: boolean): void;
18
+ finish(): Promise<string>;
19
+ }
20
+ export declare class EventBufferCompressionWorker implements IEventBuffer {
21
+ private worker;
22
+ private eventBufferItemLength;
23
+ private _id;
24
+ constructor(worker: Worker);
25
+ /**
26
+ * Read-only incrementing counter
27
+ */
28
+ get id(): number;
29
+ /**
30
+ * Post message to worker and wait for response before resolving promise.
31
+ */
32
+ postMessage({ id, method, args, }: WorkerRequest): Promise<WorkerResponse['response']>;
33
+ init(): void;
34
+ destroy(): void;
35
+ /**
36
+ * Note that this may not reflect what is actually in the event buffer. This
37
+ * is only a local count of the buffer size since `addEvent` is async.
38
+ */
39
+ get length(): number;
40
+ addEvent(event: RecordingEvent, isCheckout?: boolean): Promise<string | Uint8Array>;
41
+ sendEventToWorker: (event: RecordingEvent) => Promise<string | Uint8Array>;
42
+ finishRequest: (id: number) => Promise<Uint8Array>;
43
+ finish(): Promise<Uint8Array>;
44
+ }
45
+ export {};
@@ -0,0 +1 @@
1
+ import 'jsdom-worker';
@@ -0,0 +1,2 @@
1
+ /** Flag that is true for debug builds, false otherwise. */
2
+ export declare const IS_DEBUG_BUILD: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,253 @@
1
+ /// <reference types="lodash" />
2
+ import { Breadcrumb, Event, Integration } from '@sentry/types';
3
+ import { CaptureReplayEventParams } from './api/captureReplayEvent';
4
+ import { Session } from './session/Session';
5
+ import { ReplayPerformanceEntry } from './createPerformanceEntry';
6
+ import { IEventBuffer } from './eventBuffer';
7
+ import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
8
+ /**
9
+ * Returns true to return control to calling function, otherwise continue with normal batching
10
+ */
11
+ declare type AddUpdateCallback = () => boolean | void;
12
+ export declare class SentryReplay implements Integration {
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ static id: string;
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ name: string;
21
+ eventBuffer: IEventBuffer | null;
22
+ /**
23
+ * List of PerformanceEntry from PerformanceObserver
24
+ */
25
+ performanceEvents: AllPerformanceEntry[];
26
+ /**
27
+ * Options to pass to `rrweb.record()`
28
+ */
29
+ readonly recordingOptions: RecordingConfig;
30
+ readonly options: SentryReplayPluginOptions;
31
+ /**
32
+ * setTimeout id used for debouncing sending rrweb attachments
33
+ */
34
+ private timeout;
35
+ /**
36
+ * The timestamp of the first event since the last flush. This is used to
37
+ * determine if the maximum allowed time has passed before events should be
38
+ * flushed again.
39
+ */
40
+ private initialEventTimestampSinceFlush;
41
+ private performanceObserver;
42
+ private retryCount;
43
+ private retryInterval;
44
+ /**
45
+ * Flag when a new session has been created. Captured replay events behave
46
+ * slightly differently in this case: `replay_start_timestamp` is included.
47
+ */
48
+ private newSessionCreated;
49
+ private flushLock;
50
+ /**
51
+ * Is the integration currently active?
52
+ */
53
+ private isEnabled;
54
+ /**
55
+ * Have we attached listeners to the core SDK?
56
+ * Note we have to track this as there is no way to remove instrumentation handlers.
57
+ */
58
+ private hasInitializedCoreListeners;
59
+ /**
60
+ * Function to stop recording
61
+ */
62
+ private stopRecording;
63
+ /**
64
+ * Captured state when integration is first initialized
65
+ */
66
+ private initialState;
67
+ private context;
68
+ session: Session | undefined;
69
+ constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
70
+ /**
71
+ * Because we create a transaction in `setupOnce`, we can potentially create a
72
+ * transaction before some native SDK integrations have run and applied their
73
+ * own global event processor. An example is:
74
+ * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
75
+ *
76
+ * So we call `this.setup` in next event loop as a workaround to wait for
77
+ * other global event processors to finish
78
+ */
79
+ setupOnce(): void;
80
+ /**
81
+ * Initializes the plugin.
82
+ *
83
+ * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
84
+ */
85
+ setup(): void;
86
+ /**
87
+ * We want to batch uploads of replay events. Save events only if
88
+ * `<flushMinDelay>` milliseconds have elapsed since the last event
89
+ * *OR* if `<flushMaxDelay>` milliseconds have elapsed.
90
+ *
91
+ * Accepts a callback to perform side-effects and returns true to stop batch
92
+ * processing and hand back control to caller.
93
+ */
94
+ addUpdate(cb?: AddUpdateCallback): void;
95
+ /**
96
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
97
+ */
98
+ destroy(): void;
99
+ clearSession(): void;
100
+ /**
101
+ * Loads a session from storage, or creates a new one if it does not exist or
102
+ * is expired.
103
+ */
104
+ loadSession({ expiry }: {
105
+ expiry: number;
106
+ }): void;
107
+ /**
108
+ * Capture some initial state that can change throughout the lifespan of the
109
+ * replay. This is required because otherwise they would be captured at the
110
+ * first flush.
111
+ */
112
+ setInitialState(): void;
113
+ /**
114
+ * Adds listeners to record events for the replay
115
+ */
116
+ addListeners(): void;
117
+ /**
118
+ * Cleans up listeners that were created in `addListeners`
119
+ */
120
+ removeListeners(): void;
121
+ /**
122
+ * Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
123
+ * events as a tag. Also handles the case where we only want to capture a reply
124
+ * when an error occurs.
125
+ **/
126
+ handleGlobalEvent: (event: Event) => Event;
127
+ /**
128
+ * Handler for recording events.
129
+ *
130
+ * Adds to event buffer, and has varying flushing behaviors if the event was a checkout.
131
+ */
132
+ handleRecordingEmit: (event: RecordingEvent, isCheckout?: boolean) => void;
133
+ /**
134
+ * Handle when visibility of the page content changes. Opening a new tab will
135
+ * cause the state to change to hidden because of content of current page will
136
+ * be hidden. Likewise, moving a different window to cover the contents of the
137
+ * page will also trigger a change to a hidden state.
138
+ */
139
+ handleVisibilityChange: () => void;
140
+ /**
141
+ * Handle when page is blurred
142
+ */
143
+ handleWindowBlur: () => void;
144
+ /**
145
+ * Handle when page is focused
146
+ */
147
+ handleWindowFocus: () => void;
148
+ /**
149
+ * Handler for Sentry Core SDK events.
150
+ *
151
+ * These specific events will create span-like objects in the recording.
152
+ *
153
+ */
154
+ handleCoreSpanListener: (type: InstrumentationTypeSpan) => (handlerData: any) => void;
155
+ /**
156
+ * Handler for Sentry Core SDK events.
157
+ *
158
+ * These events will create breadcrumb-like objects in the recording.
159
+ */
160
+ handleCoreBreadcrumbListener: (type: InstrumentationTypeBreadcrumb) => (handlerData: any) => void;
161
+ /**
162
+ * Keep a list of performance entries that will be sent with a replay
163
+ */
164
+ handlePerformanceObserver: (list: PerformanceObserverEntryList) => void;
165
+ /**
166
+ * Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
167
+ */
168
+ doChangeToBackgroundTasks(breadcrumb?: Breadcrumb): void;
169
+ /**
170
+ * Tasks to run when we consider a page to be visible (via focus and/or visibility)
171
+ */
172
+ doChangeToForegroundTasks(breadcrumb?: Breadcrumb): void;
173
+ /**
174
+ * Trigger rrweb to take a full snapshot which will cause this plugin to
175
+ * create a new Replay event.
176
+ */
177
+ triggerFullSnapshot(): void;
178
+ /**
179
+ * Add an event to the event buffer
180
+ */
181
+ addEvent(event: RecordingEvent, isCheckout?: boolean): void;
182
+ /**
183
+ * Updates the session's last activity timestamp
184
+ */
185
+ updateLastActivity(lastActivity?: number): void;
186
+ /**
187
+ * Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
188
+ */
189
+ createCustomBreadcrumb(breadcrumb: Breadcrumb): void;
190
+ /**
191
+ * Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
192
+ */
193
+ createPerformanceSpans(entries: ReplayPerformanceEntry[]): Promise<void[]>;
194
+ /**
195
+ * Observed performance events are added to `this.performanceEvents`. These
196
+ * are included in the replay event before it is finished and sent to Sentry.
197
+ */
198
+ addPerformanceEntries(): Promise<void[]>;
199
+ /**
200
+ * Create a "span" for the total amount of memory being used by JS objects
201
+ * (including v8 internal objects).
202
+ */
203
+ addMemoryEntry(): Promise<void[]> | undefined;
204
+ /**
205
+ *
206
+ *
207
+ * Returns true if session is not expired, false otherwise.
208
+ */
209
+ checkAndHandleExpiredSession(expiry?: number): boolean;
210
+ /**
211
+ * Only flush if `captureOnlyOnError` is false.
212
+ */
213
+ conditionalFlush(): Promise<void> | undefined;
214
+ /**
215
+ * Clear context
216
+ */
217
+ clearContext(): void;
218
+ /**
219
+ * Return and clear context
220
+ */
221
+ popEventContext({ timestamp, }: {
222
+ timestamp: number;
223
+ }): Omit<CaptureReplayEventParams, 'includeReplayStartTimestamp' | 'segmentId' | 'replayId'>;
224
+ /**
225
+ * Flushes replay event buffer to Sentry.
226
+ *
227
+ * Performance events are only added right before flushing - this is
228
+ * due to the buffered performance observer events.
229
+ */
230
+ runFlush(): Promise<void>;
231
+ /**
232
+ * Flush recording data to Sentry. Creates a lock so that only a single flush
233
+ * can be active at a time.
234
+ */
235
+ flush: () => Promise<void>;
236
+ /**
237
+ * A throttled `flush()` that is called after a flush is completed and there
238
+ * are other queued flushes.
239
+ *
240
+ * Instead of calling a flush for every <n> queued flush, condense it to a single call
241
+ */
242
+ throttledFlush: import("lodash").DebouncedFunc<() => Promise<void>>;
243
+ /**
244
+ * Send replay attachment using `fetch()`
245
+ */
246
+ sendReplayRequest({ endpoint, events, replayId: event_id, segmentId: segment_id, }: ReplayRequest): Promise<void>;
247
+ resetRetries(): void;
248
+ /**
249
+ * Finalize and send the current replay event to Sentry
250
+ */
251
+ sendReplay(replayId: string, events: RecordedEvents, segmentId: number): Promise<unknown>;
252
+ }
253
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,63 @@
1
+ interface SessionObject {
2
+ id: string;
3
+ /**
4
+ * Start time of current session
5
+ */
6
+ started: number;
7
+ /**
8
+ * Last known activity of the session
9
+ */
10
+ lastActivity: number;
11
+ /**
12
+ * Segment ID for replay events
13
+ */
14
+ segmentId: number;
15
+ /**
16
+ * Is the session sampled?
17
+ */
18
+ sampled: boolean;
19
+ }
20
+ interface SessionOptions {
21
+ stickySession?: boolean;
22
+ samplingRate?: number;
23
+ }
24
+ export declare class Session {
25
+ /**
26
+ * Session ID
27
+ */
28
+ private _id;
29
+ /**
30
+ * Start time of current session
31
+ */
32
+ private _started;
33
+ /**
34
+ * Last known activity of the session
35
+ */
36
+ private _lastActivity;
37
+ /**
38
+ * Sequence ID specific to replay updates
39
+ */
40
+ private _segmentId;
41
+ /**
42
+ * Previous session ID
43
+ */
44
+ private _previousSessionId;
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);
51
+ get id(): string;
52
+ get started(): number;
53
+ get lastActivity(): number;
54
+ set lastActivity(newDate: number);
55
+ get segmentId(): number;
56
+ set segmentId(id: number);
57
+ get previousSessionId(): string | undefined;
58
+ set previousSessionId(id: string | undefined);
59
+ get sampled(): boolean;
60
+ set sampled(_isSampled: boolean);
61
+ toJSON(): SessionObject;
62
+ }
63
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const REPLAY_SESSION_KEY = "sentryReplaySession";
2
+ export declare const REPLAY_EVENT_NAME = "replay_event";
3
+ export declare const RECORDING_EVENT_NAME = "replay_recording";
4
+ export declare const SESSION_IDLE_DURATION = 300000;
5
+ export declare const VISIBILITY_CHANGE_TIMEOUT = 300000;
@@ -0,0 +1,19 @@
1
+ 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
+ /**
14
+ * Create a new session, which in its current implementation is a Sentry event
15
+ * that all replays will be saved to as attachments. Currently, we only expect
16
+ * one of these Sentry events per "replay session".
17
+ */
18
+ export declare function createSession({ stickySession, samplingRate, }: CreateSessionParams): Session;
19
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Deletes a session from storage
3
+ */
4
+ export declare function deleteSession(): void;
@@ -0,0 +1,5 @@
1
+ import { Session } from './Session';
2
+ /**
3
+ * Fetches a session from storage
4
+ */
5
+ export declare function fetchSession(): Session | null;