@sentry/replay 0.4.8-2 → 0.4.9

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 (67) hide show
  1. package/README.md +15 -15
  2. package/dist/config/dist/jest.config.d.ts +3 -0
  3. package/dist/config/dist/jest.setup.d.ts +10 -0
  4. package/dist/config/dist/src/api/captureReplay.d.ts +10 -0
  5. package/dist/config/dist/src/api/captureReplayUpdate.d.ts +12 -0
  6. package/dist/config/dist/src/coreHandlers/getBreadcrumbHandler.d.ts +3 -0
  7. package/dist/config/dist/src/coreHandlers/getSpanHandler.d.ts +5 -0
  8. package/dist/config/dist/src/coreHandlers/handleDom.d.ts +1 -0
  9. package/dist/config/dist/src/coreHandlers/handleFetch.d.ts +19 -0
  10. package/dist/config/dist/src/coreHandlers/handleFetch.test.d.ts +1 -0
  11. package/dist/config/dist/src/coreHandlers/handleHistory.d.ts +7 -0
  12. package/dist/config/dist/src/coreHandlers/handleScope-unit.test.d.ts +1 -0
  13. package/dist/config/dist/src/coreHandlers/handleScope.d.ts +2 -0
  14. package/dist/config/dist/src/coreHandlers/handleScope.test.d.ts +1 -0
  15. package/dist/config/dist/src/coreHandlers/handleXhr.d.ts +21 -0
  16. package/dist/{dist → config/dist/src}/coreHandlers/index.d.ts +0 -0
  17. package/dist/config/dist/src/createPerformanceEntry.d.ts +42 -0
  18. package/dist/config/dist/src/createPerformanceEntry.test.d.ts +1 -0
  19. package/dist/config/dist/src/eventBuffer.d.ts +45 -0
  20. package/dist/config/dist/src/eventBuffer.test.d.ts +1 -0
  21. package/dist/config/dist/src/flags.d.ts +2 -0
  22. package/dist/config/dist/src/index-captureOnlyOnError.test.d.ts +1 -0
  23. package/dist/config/dist/src/index-noSticky.test.d.ts +1 -0
  24. package/dist/config/dist/src/index-sampling.test.d.ts +1 -0
  25. package/dist/config/dist/src/index.d.ts +225 -0
  26. package/dist/config/dist/src/index.test.d.ts +1 -0
  27. package/dist/config/dist/src/session/Session.d.ts +63 -0
  28. package/dist/config/dist/src/session/Session.test.d.ts +1 -0
  29. package/dist/config/dist/src/session/constants.d.ts +5 -0
  30. package/dist/config/dist/src/session/createSession.d.ts +19 -0
  31. package/dist/config/dist/src/session/createSession.test.d.ts +1 -0
  32. package/dist/config/dist/src/session/fetchSession.d.ts +5 -0
  33. package/dist/config/dist/src/session/fetchSession.test.d.ts +1 -0
  34. package/dist/config/dist/src/session/getSession.d.ts +28 -0
  35. package/dist/config/dist/src/session/getSession.test.d.ts +1 -0
  36. package/dist/config/dist/src/session/index.d.ts +1 -0
  37. package/dist/config/dist/src/session/saveSession.d.ts +2 -0
  38. package/dist/config/dist/src/session/saveSession.test.d.ts +1 -0
  39. package/dist/config/dist/src/types.d.ts +90 -0
  40. package/dist/config/dist/src/util/createBreadcrumb.d.ts +4 -0
  41. package/dist/config/dist/src/util/createPayload.d.ts +5 -0
  42. package/dist/config/dist/src/util/isExpired.d.ts +5 -0
  43. package/dist/config/dist/src/util/isExpired.test.d.ts +1 -0
  44. package/dist/config/dist/src/util/isIngestHost.d.ts +4 -0
  45. package/dist/config/dist/src/util/isSampled.d.ts +7 -0
  46. package/dist/config/dist/src/util/isSampled.test.d.ts +1 -0
  47. package/dist/config/dist/src/util/isSessionExpired.d.ts +5 -0
  48. package/dist/config/dist/src/util/isSessionExpired.test.d.ts +1 -0
  49. package/dist/config/dist/src/util/logger.d.ts +12 -0
  50. package/dist/config/dist/src/util/supportsSendBeacon.d.ts +4 -0
  51. package/dist/config/dist/test/index.d.ts +3 -0
  52. package/dist/config/dist/test/mocks/mockRrweb.d.ts +15 -0
  53. package/dist/config/dist/test/mocks/mockSdk.d.ts +11 -0
  54. package/dist/dist/api/captureReplay.d.ts +5 -3
  55. package/dist/dist/api/captureReplayUpdate.d.ts +5 -3
  56. package/dist/dist/coreHandlers/getBreadcrumbHandler.d.ts +3 -0
  57. package/dist/dist/coreHandlers/getSpanHandler.d.ts +5 -0
  58. package/dist/dist/coreHandlers/handleFetch.d.ts +19 -2
  59. package/dist/dist/coreHandlers/handleHistory.d.ts +7 -0
  60. package/dist/dist/coreHandlers/handleXhr.d.ts +21 -2
  61. package/dist/dist/eventBuffer.d.ts +11 -4
  62. package/dist/dist/index.d.ts +26 -10
  63. package/dist/dist/types.d.ts +20 -8
  64. package/dist/index.es.js +329 -199
  65. package/dist/index.js +328 -198
  66. package/dist/index.js.map +1 -1
  67. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ This integration is a WIP.
4
4
 
5
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) and the [rrweb package](https://www.npmjs.com/package/rrweb) installed.
7
+ For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) installed.
8
8
 
9
9
  ## Installation
10
10
 
@@ -19,13 +19,13 @@ npm install --save @sentry/browser @sentry/replay
19
19
  with yarn:
20
20
 
21
21
  ```shell
22
- yarn add @sentry/replay @sentry/browser @sentry/replay
22
+ yarn add @sentry/browser @sentry/replay
23
23
  ```
24
24
 
25
25
  ## Setup
26
26
 
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 rrweb documentation for advice on configuring these values.
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 rrweb documentation for advice on configuring these values.
29
29
 
30
30
 
31
31
  ```javascript
@@ -51,14 +51,14 @@ Sentry.init({
51
51
 
52
52
  | key | type | default | description |
53
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` |
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
+ | `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
62
+ | `recordingConfig.blockClass` | `string` | `'sr-block'` | Redact all elements with the class name `sr-block` |
63
+ | `recordingConfig.ignoreClass` | `string` | `'sr-ignore'` | Ignores all elements with the class name `sr-ignore` |
64
+ | `recordingConfig.maskTextClass` | `string` | `'sr-mask'` | Mask 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: Session): CustomMatcherResult;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { Session } from '@/session/Session';
2
+ import { InitialState } from '@/types';
3
+ export interface CaptureReplayParams {
4
+ session: Session;
5
+ initialState: InitialState;
6
+ errorIds: string[];
7
+ traceIds: string[];
8
+ urls: string[];
9
+ }
10
+ export declare function captureReplay({ session, initialState, errorIds, traceIds, urls, }: CaptureReplayParams): void;
@@ -0,0 +1,12 @@
1
+ import type { Session } from '@/session/Session';
2
+ export interface CaptureReplayUpdateParams {
3
+ session: Session;
4
+ /**
5
+ * Timestamp of the event in milliseconds
6
+ */
7
+ timestamp: number;
8
+ errorIds: string[];
9
+ traceIds: string[];
10
+ urls: string[];
11
+ }
12
+ export declare function captureReplayUpdate({ session, timestamp, errorIds, traceIds, urls, }: CaptureReplayUpdateParams): 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;
@@ -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): 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;
@@ -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]: any;
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;
21
+ export {};
@@ -0,0 +1,42 @@
1
+ export interface ReplayPerformanceEntry {
2
+ /**
3
+ * One of these types https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType
4
+ */
5
+ type: string;
6
+ /**
7
+ * A more specific description of the performance entry
8
+ */
9
+ name: string;
10
+ /**
11
+ * The start timestamp in seconds
12
+ */
13
+ start: number;
14
+ /**
15
+ * The end timestamp in seconds
16
+ */
17
+ end: number;
18
+ /**
19
+ * Additional unstructured data to be included
20
+ */
21
+ data?: Record<string, unknown>;
22
+ }
23
+ interface MemoryInfo {
24
+ jsHeapSizeLimit: number;
25
+ totalJSHeapSize: number;
26
+ usedJSHeapSize: number;
27
+ }
28
+ export declare function createPerformanceEntries(entries: PerformanceEntry[]): ReplayPerformanceEntry[];
29
+ export declare function createMemoryEntry(memoryEntry: MemoryInfo): {
30
+ type: string;
31
+ name: string;
32
+ start: number;
33
+ end: number;
34
+ data: {
35
+ memory: {
36
+ jsHeapSizeLimit: number;
37
+ totalJSHeapSize: number;
38
+ usedJSHeapSize: number;
39
+ };
40
+ };
41
+ };
42
+ 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,225 @@
1
+ import { Breadcrumb, DsnComponents, Event, Integration } from '@sentry/types';
2
+ import { CaptureReplayParams } from './api/captureReplay';
3
+ import { CaptureReplayUpdateParams } from './api/captureReplayUpdate';
4
+ import { Session } from './session/Session';
5
+ import { ReplayPerformanceEntry } from './createPerformanceEntry';
6
+ import { IEventBuffer } from './eventBuffer';
7
+ import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, 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;
22
+ /**
23
+ * Buffer of breadcrumbs to be uploaded
24
+ */
25
+ breadcrumbs: Breadcrumb[];
26
+ /**
27
+ * List of PerformanceEntry from PerformanceObserver
28
+ */
29
+ performanceEvents: PerformanceEntry[];
30
+ /**
31
+ * Options to pass to `rrweb.record()`
32
+ */
33
+ readonly recordingOptions: RecordingConfig;
34
+ readonly options: SentryReplayPluginOptions;
35
+ /**
36
+ * setTimeout id used for debouncing sending rrweb attachments
37
+ */
38
+ private timeout;
39
+ /**
40
+ * The timestamp of the first event since the last flush. This is used to
41
+ * determine if the maximum allowed time has passed before events should be
42
+ * flushed again.
43
+ */
44
+ private initialEventTimestampSinceFlush;
45
+ private performanceObserver;
46
+ private retryCount;
47
+ private retryInterval;
48
+ /**
49
+ * Flag to make sure we only create a replay event when
50
+ * necessary (i.e. we only want to have a single replay
51
+ * event per session and it should only be created
52
+ * immediately before sending recording)
53
+ */
54
+ private needsCaptureReplay;
55
+ /**
56
+ * Captured state when integration is first initialized
57
+ */
58
+ private initialState;
59
+ private context;
60
+ session: Session | undefined;
61
+ static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
62
+ constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
63
+ useCompression, captureOnlyOnError, replaysSamplingRate, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
64
+ /**
65
+ * Because we create a transaction in `setupOnce`, we can potentially create a
66
+ * transaction before some native SDK integrations have run and applied their
67
+ * own global event processor. An example is:
68
+ * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
69
+ *
70
+ * So we call `this.setup` in next event loop as a workaround to wait for
71
+ * other global event processors to finish
72
+ */
73
+ setupOnce(): void;
74
+ /**
75
+ * Initializes the plugin.
76
+ *
77
+ * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
78
+ */
79
+ setup(): void;
80
+ /**
81
+ * We want to batch uploads of replay events. Save events only if
82
+ * `<flushMinDelay>` milliseconds have elapsed since the last event
83
+ * *OR* if `<flushMaxDelay>` milliseconds have elapsed.
84
+ *
85
+ * Accepts a callback to perform side-effects and returns true to stop batch
86
+ * processing and hand back control to caller.
87
+ */
88
+ addUpdate(cb?: AddUpdateCallback): void;
89
+ /**
90
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
91
+ */
92
+ destroy(): void;
93
+ clearSession(): void;
94
+ /**
95
+ * Loads a session from storage, or creates a new one if it does not exist or
96
+ * is expired.
97
+ */
98
+ loadSession({ expiry }: {
99
+ expiry: number;
100
+ }): void;
101
+ /**
102
+ * Adds listeners to record events for the replay
103
+ */
104
+ addListeners(): void;
105
+ /**
106
+ * Cleans up listeners that were created in `addListeners`
107
+ */
108
+ removeListeners(): void;
109
+ /**
110
+ * Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
111
+ * events as a tag. Also handles the case where we only want to capture a reply
112
+ * when an error occurs.
113
+ **/
114
+ handleGlobalEvent: (event: Event) => Event;
115
+ /**
116
+ * Handler for recording events.
117
+ *
118
+ * Adds to event buffer, and has varying flushing behaviors if the event was a checkout.
119
+ */
120
+ handleRecordingEmit: (event: RecordingEvent, isCheckout?: boolean) => void;
121
+ /**
122
+ * Handle when visibility of the page content changes. Opening a new tab will
123
+ * cause the state to change to hidden because of content of current page will
124
+ * be hidden. Likewise, moving a different window to cover the contents of the
125
+ * page will also trigger a change to a hidden state.
126
+ */
127
+ handleVisibilityChange: () => void;
128
+ /**
129
+ * Handle when page is blurred
130
+ */
131
+ handleWindowBlur: () => void;
132
+ /**
133
+ * Handle when page is focused
134
+ */
135
+ handleWindowFocus: () => void;
136
+ /**
137
+ * Handle when page is closed
138
+ */
139
+ handleWindowUnload: () => void;
140
+ /**
141
+ * Handler for Sentry Core SDK events.
142
+ *
143
+ * These specific events will create span-like objects in the recording.
144
+ *
145
+ */
146
+ handleCoreSpanListener: (type: InstrumentationTypeSpan) => (handlerData: any) => void;
147
+ /**
148
+ * Handler for Sentry Core SDK events.
149
+ *
150
+ * These events will create breadcrumb-like objects in the recording.
151
+ */
152
+ handleCoreBreadcrumbListener: (type: InstrumentationTypeBreadcrumb) => (handlerData: any) => void;
153
+ /**
154
+ * Keep a list of performance entries that will be sent with a replay
155
+ */
156
+ handlePerformanceObserver: (list: PerformanceObserverEntryList) => void;
157
+ /**
158
+ * Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
159
+ */
160
+ doChangeToBackgroundTasks(breadcrumb?: Breadcrumb): void;
161
+ /**
162
+ * Tasks to run when we consider a page to be visible (via focus and/or visibility)
163
+ */
164
+ doChangeToForegroundTasks(breadcrumb?: Breadcrumb): void;
165
+ /**
166
+ * Trigger rrweb to take a full snapshot which will cause this plugin to
167
+ * create a new Replay event.
168
+ */
169
+ triggerFullSnapshot(): void;
170
+ /**
171
+ * Updates the session's last activity timestamp
172
+ */
173
+ updateLastActivity(lastActivity?: number): void;
174
+ /**
175
+ * Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
176
+ */
177
+ createCustomBreadcrumb(breadcrumb: Breadcrumb): void;
178
+ /**
179
+ * Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
180
+ */
181
+ createPerformanceSpans(entries: ReplayPerformanceEntry[]): Promise<void[]>;
182
+ /**
183
+ * Observed performance events are added to `this.performanceEvents`. These
184
+ * are included in the replay event before it is finished and sent to Sentry.
185
+ */
186
+ addPerformanceEntries(): Promise<void[]>;
187
+ /**
188
+ * Create a "span" for the total amount of memory being used by JS objects
189
+ * (including v8 internal objects).
190
+ */
191
+ addMemoryEntry(): Promise<void[]>;
192
+ /**
193
+ *
194
+ *
195
+ * Returns true if session is not expired, false otherwise.
196
+ */
197
+ checkAndHandleExpiredSession(expiry?: number): boolean;
198
+ /**
199
+ * Only flush if `captureOnlyOnError` is false.
200
+ */
201
+ conditionalFlush(lastActivity?: number): Promise<void>;
202
+ /**
203
+ * Return and clear context
204
+ */
205
+ popEventContext({ timestamp, }: {
206
+ timestamp: number;
207
+ }): CaptureReplayParams & CaptureReplayUpdateParams;
208
+ /**
209
+ * Flushes replay event buffer to Sentry.
210
+ *
211
+ * Performance events are only added right before flushing - this is probably
212
+ * due to the buffered performance observer events.
213
+ */
214
+ flushUpdate(lastActivity?: number): Promise<void>;
215
+ /**
216
+ * Send replay attachment using either `sendBeacon()` or `fetch()`
217
+ */
218
+ sendReplayRequest({ endpoint, events }: ReplayRequest): Promise<void>;
219
+ resetRetries(): void;
220
+ /**
221
+ * Finalize and send the current replay event to Sentry
222
+ */
223
+ sendReplay(eventId: string, events: Uint8Array | string): Promise<boolean>;
224
+ }
225
+ 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;
58
+ set previousSessionId(id: string);
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 ROOT_REPLAY_NAME = "sentry-replay";
3
+ export declare const REPLAY_EVENT_NAME = "sentry-replay-event";
4
+ export declare const SESSION_IDLE_DURATION = 900000;
5
+ export declare const VISIBILITY_CHANGE_TIMEOUT = 900000;
@@ -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,5 @@
1
+ import { Session } from './Session';
2
+ /**
3
+ * Fetches a session from storage
4
+ */
5
+ export declare function fetchSession(): Session | null;
@@ -0,0 +1,28 @@
1
+ import { Session } from './Session';
2
+ interface GetSessionParams {
3
+ /**
4
+ * The length of time (in ms) which we will consider the session to be expired.
5
+ */
6
+ expiry: number;
7
+ /**
8
+ * Should save session to sessionStorage?
9
+ */
10
+ stickySession: boolean;
11
+ /**
12
+ * The current session (e.g. if stickySession is off)
13
+ */
14
+ currentSession?: Session;
15
+ /**
16
+ * The sampling rate of the Session. See integration configuration comments
17
+ * for `replaysSamplingRate`.
18
+ */
19
+ samplingRate?: number;
20
+ }
21
+ /**
22
+ * Get or create a session
23
+ */
24
+ export declare function getSession({ expiry, currentSession, stickySession, samplingRate, }: GetSessionParams): {
25
+ type: string;
26
+ session: Session;
27
+ };
28
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './createSession';