@sentry/replay 0.4.8-1 → 0.4.8

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 (128) hide show
  1. package/README.md +15 -15
  2. package/dist/{jest.config.d.ts → config/dist/jest.config.d.ts} +0 -0
  3. package/dist/{jest.setup.d.ts → config/dist/jest.setup.d.ts} +0 -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/{src → config/dist/src}/coreHandlers/handleDom.d.ts +0 -0
  9. package/dist/config/dist/src/coreHandlers/handleFetch.d.ts +19 -0
  10. package/dist/{src → config/dist/src}/coreHandlers/handleFetch.test.d.ts +0 -0
  11. package/dist/config/dist/src/coreHandlers/handleHistory.d.ts +7 -0
  12. package/dist/{src → config/dist/src}/coreHandlers/handleScope-unit.test.d.ts +0 -0
  13. package/dist/{src → config/dist/src}/coreHandlers/handleScope.d.ts +0 -0
  14. package/dist/{src → config/dist/src}/coreHandlers/handleScope.test.d.ts +0 -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/{src → config/dist/src}/createPerformanceEntry.d.ts +0 -0
  18. package/dist/{src → config/dist/src}/createPerformanceEntry.test.d.ts +0 -0
  19. package/dist/{src → config/dist/src}/eventBuffer.d.ts +9 -2
  20. package/dist/config/dist/src/eventBuffer.test.d.ts +1 -0
  21. package/dist/{src → config/dist/src}/flags.d.ts +0 -0
  22. package/dist/{src → config/dist/src}/index-captureOnlyOnError.test.d.ts +0 -0
  23. package/dist/{src → config/dist/src}/index-noSticky.test.d.ts +0 -0
  24. package/dist/{src → config/dist/src}/index-sampling.test.d.ts +0 -0
  25. package/dist/{src → config/dist/src}/index.d.ts +18 -11
  26. package/dist/{src → config/dist/src}/index.test.d.ts +0 -0
  27. package/dist/{src → config/dist/src}/session/Session.d.ts +0 -0
  28. package/dist/{src → config/dist/src}/session/Session.test.d.ts +0 -0
  29. package/dist/{src → config/dist/src}/session/constants.d.ts +0 -0
  30. package/dist/{src → config/dist/src}/session/createSession.d.ts +0 -0
  31. package/dist/{src → config/dist/src}/session/createSession.test.d.ts +0 -0
  32. package/dist/{src → config/dist/src}/session/fetchSession.d.ts +0 -0
  33. package/dist/{src → config/dist/src}/session/fetchSession.test.d.ts +0 -0
  34. package/dist/{src → config/dist/src}/session/getSession.d.ts +0 -0
  35. package/dist/{src → config/dist/src}/session/getSession.test.d.ts +0 -0
  36. package/dist/{src → config/dist/src}/session/index.d.ts +0 -0
  37. package/dist/{src → config/dist/src}/session/saveSession.d.ts +0 -0
  38. package/dist/{src → config/dist/src}/session/saveSession.test.d.ts +0 -0
  39. package/dist/{src → config/dist/src}/types.d.ts +22 -8
  40. package/dist/{src → config/dist/src}/util/createBreadcrumb.d.ts +0 -0
  41. package/dist/config/dist/src/util/createPayload.d.ts +5 -0
  42. package/dist/{src → config/dist/src}/util/isExpired.d.ts +0 -0
  43. package/dist/{src → config/dist/src}/util/isExpired.test.d.ts +0 -0
  44. package/dist/{src → config/dist/src}/util/isIngestHost.d.ts +0 -0
  45. package/dist/{src → config/dist/src}/util/isSampled.d.ts +0 -0
  46. package/dist/{src → config/dist/src}/util/isSampled.test.d.ts +0 -0
  47. package/dist/{src → config/dist/src}/util/isSessionExpired.d.ts +0 -0
  48. package/dist/{src → config/dist/src}/util/isSessionExpired.test.d.ts +0 -0
  49. package/dist/{src → config/dist/src}/util/logger.d.ts +0 -0
  50. package/dist/{src → config/dist/src}/util/supportsSendBeacon.d.ts +0 -0
  51. package/dist/{test → config/dist/test}/index.d.ts +0 -0
  52. package/dist/{test → config/dist/test}/mocks/mockRrweb.d.ts +0 -0
  53. package/dist/{test → config/dist/test}/mocks/mockSdk.d.ts +0 -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/index.d.ts +18 -7
  62. package/dist/dist/types.d.ts +20 -8
  63. package/dist/index.es.js +223 -126
  64. package/dist/index.js +222 -125
  65. package/dist/index.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/esm/index.js +0 -1454
  68. package/dist/esm/worker-aa3eb59a.js +0 -4
  69. package/dist/src/api/captureReplay.d.ts +0 -3
  70. package/dist/src/api/captureReplayUpdate.d.ts +0 -2
  71. package/dist/src/coreHandlers/handleFetch.d.ts +0 -2
  72. package/dist/src/coreHandlers/handleXhr.d.ts +0 -2
  73. package/dist/src/coreHandlers/index.d.ts +0 -4
  74. package/dist/src/eventBuffer.test.d.ts +0 -1
  75. package/dist/types/jest.config.d.ts +0 -3
  76. package/dist/types/jest.setup.d.ts +0 -10
  77. package/dist/types/src/api/captureReplay.d.ts +0 -3
  78. package/dist/types/src/api/captureReplayUpdate.d.ts +0 -2
  79. package/dist/types/src/coreHandlers/handleDom.d.ts +0 -1
  80. package/dist/types/src/coreHandlers/handleFetch.d.ts +0 -2
  81. package/dist/types/src/coreHandlers/handleFetch.test.d.ts +0 -1
  82. package/dist/types/src/coreHandlers/handleScope-unit.test.d.ts +0 -1
  83. package/dist/types/src/coreHandlers/handleScope.d.ts +0 -2
  84. package/dist/types/src/coreHandlers/handleScope.test.d.ts +0 -1
  85. package/dist/types/src/coreHandlers/handleXhr.d.ts +0 -2
  86. package/dist/types/src/coreHandlers/index.d.ts +0 -4
  87. package/dist/types/src/createPerformanceEntry.d.ts +0 -42
  88. package/dist/types/src/createPerformanceEntry.test.d.ts +0 -1
  89. package/dist/types/src/eventBuffer.d.ts +0 -31
  90. package/dist/types/src/eventBuffer.test.d.ts +0 -1
  91. package/dist/types/src/flags.d.ts +0 -2
  92. package/dist/types/src/index-captureOnlyOnError.test.d.ts +0 -1
  93. package/dist/types/src/index-noSticky.test.d.ts +0 -1
  94. package/dist/types/src/index-sampling.test.d.ts +0 -1
  95. package/dist/types/src/index.d.ts +0 -209
  96. package/dist/types/src/index.test.d.ts +0 -1
  97. package/dist/types/src/session/Session.d.ts +0 -63
  98. package/dist/types/src/session/Session.test.d.ts +0 -1
  99. package/dist/types/src/session/constants.d.ts +0 -5
  100. package/dist/types/src/session/createSession.d.ts +0 -19
  101. package/dist/types/src/session/createSession.test.d.ts +0 -1
  102. package/dist/types/src/session/fetchSession.d.ts +0 -5
  103. package/dist/types/src/session/fetchSession.test.d.ts +0 -1
  104. package/dist/types/src/session/getSession.d.ts +0 -28
  105. package/dist/types/src/session/getSession.test.d.ts +0 -1
  106. package/dist/types/src/session/index.d.ts +0 -1
  107. package/dist/types/src/session/saveSession.d.ts +0 -2
  108. package/dist/types/src/session/saveSession.test.d.ts +0 -1
  109. package/dist/types/src/session/types.d.ts +0 -0
  110. package/dist/types/src/types.d.ts +0 -76
  111. package/dist/types/src/util/createBreadcrumb.d.ts +0 -4
  112. package/dist/types/src/util/isExpired.d.ts +0 -5
  113. package/dist/types/src/util/isExpired.test.d.ts +0 -1
  114. package/dist/types/src/util/isIngestHost.d.ts +0 -4
  115. package/dist/types/src/util/isSampled.d.ts +0 -7
  116. package/dist/types/src/util/isSampled.test.d.ts +0 -1
  117. package/dist/types/src/util/isSessionExpired.d.ts +0 -5
  118. package/dist/types/src/util/isSessionExpired.test.d.ts +0 -1
  119. package/dist/types/src/util/logger.d.ts +0 -12
  120. package/dist/types/src/util/supportsSendBeacon.d.ts +0 -4
  121. package/dist/types/test/index.d.ts +0 -3
  122. package/dist/types/test/mocks/mockRrweb.d.ts +0 -15
  123. package/dist/types/test/mocks/mockSdk.d.ts +0 -11
  124. package/dist/types/worker/src/Compressor.d.ts +0 -15
  125. package/dist/types/worker/src/handleMessage.d.ts +0 -2
  126. package/dist/worker-aa3eb59a.js +0 -4
  127. package/dist/worker-f4750cfb.js +0 -7
  128. package/dist/worker-f4750cfb.js.map +0 -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,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,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,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 {};
@@ -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
- sendEventToWorker(event: RecordingEvent): void;
34
+ sendEventToWorker: (event: RecordingEvent) => void;
35
+ finishRequest: (id: number) => Promise<Uint8Array>;
29
36
  finish(): Promise<Uint8Array>;
30
37
  }
31
38
  export {};
@@ -0,0 +1 @@
1
+ import 'jsdom-worker';
File without changes
@@ -1,8 +1,10 @@
1
1
  import { Breadcrumb, DsnComponents, Event, Integration } from '@sentry/types';
2
+ import { CaptureReplayParams } from './api/captureReplay';
3
+ import { CaptureReplayUpdateParams } from './api/captureReplayUpdate';
2
4
  import { Session } from './session/Session';
3
5
  import { ReplayPerformanceEntry } from './createPerformanceEntry';
4
6
  import { IEventBuffer } from './eventBuffer';
5
- import type { InstrumentationType, RecordingConfig, RecordingEvent, ReplayRequest, ReplaySpan, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
7
+ import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
6
8
  /**
7
9
  * Returns true to return control to calling function, otherwise continue with normal batching
8
10
  */
@@ -21,10 +23,6 @@ export declare class SentryReplay implements Integration {
21
23
  * Buffer of breadcrumbs to be uploaded
22
24
  */
23
25
  breadcrumbs: Breadcrumb[];
24
- /**
25
- * Buffer of replay spans to be uploaded
26
- */
27
- replaySpans: ReplaySpan[];
28
26
  /**
29
27
  * List of PerformanceEntry from PerformanceObserver
30
28
  */
@@ -58,10 +56,7 @@ export declare class SentryReplay implements Integration {
58
56
  * Captured state when integration is first initialized
59
57
  */
60
58
  private initialState;
61
- /**
62
- * List of error events that should be associated with the replay
63
- */
64
- errorIds: number[];
59
+ private context;
65
60
  session: Session | undefined;
66
61
  static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
67
62
  constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
@@ -145,10 +140,16 @@ export declare class SentryReplay implements Integration {
145
140
  /**
146
141
  * Handler for Sentry Core SDK events.
147
142
  *
148
- * Transforms core SDK events into replay events.
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
149
  *
150
+ * These events will create breadcrumb-like objects in the recording.
150
151
  */
151
- handleCoreListener: (type: InstrumentationType) => (handlerData: any) => void;
152
+ handleCoreBreadcrumbListener: (type: InstrumentationTypeBreadcrumb) => (handlerData: any) => void;
152
153
  /**
153
154
  * Keep a list of performance entries that will be sent with a replay
154
155
  */
@@ -193,6 +194,12 @@ export declare class SentryReplay implements Integration {
193
194
  * Only flush if `captureOnlyOnError` is false.
194
195
  */
195
196
  conditionalFlush(lastActivity?: number): Promise<void>;
197
+ /**
198
+ * Return and clear context
199
+ */
200
+ popEventContext({ timestamp, }: {
201
+ timestamp: number;
202
+ }): CaptureReplayParams & CaptureReplayUpdateParams;
196
203
  /**
197
204
  * Flushes replay event buffer to Sentry.
198
205
  *
File without changes
File without changes
@@ -2,22 +2,18 @@ import { record } from 'rrweb';
2
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
- export interface ReplaySpan {
6
- description: string;
7
- op: string;
8
- startTimestamp: number;
9
- endTimestamp: number;
10
- data?: Record<string, unknown>;
11
- }
12
5
  export interface ReplayRequest {
13
6
  endpoint: string;
14
7
  events: Uint8Array | string;
15
8
  }
16
- export declare type InstrumentationType = 'scope' | 'dom' | 'fetch' | 'xhr';
9
+ export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
10
+ export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
11
+ export declare type InstrumentationType = InstrumentationTypeBreadcrumb | InstrumentationTypeSpan | 'console' | 'error' | 'unhandledrejection';
17
12
  /**
18
13
  * The request payload to worker
19
14
  */
20
15
  export interface WorkerRequest {
16
+ id: number;
21
17
  method: string;
22
18
  args: any[];
23
19
  }
@@ -25,6 +21,7 @@ export interface WorkerRequest {
25
21
  * The response from the worker
26
22
  */
27
23
  export interface WorkerResponse {
24
+ id: number;
28
25
  method: string;
29
26
  success: boolean;
30
27
  response: string | Uint8Array;
@@ -74,3 +71,20 @@ export interface InitialState {
74
71
  timestamp: number;
75
72
  url: string;
76
73
  }
74
+ /**
75
+ * Additional context that will be sent w/ `replay_event`
76
+ */
77
+ export interface ReplayEventContext {
78
+ /**
79
+ * Set of Sentry error ids that have occurred during a replay segment
80
+ */
81
+ errorIds: Set<string>;
82
+ /**
83
+ * Set of Sentry trace ids that have occurred during a replay segment
84
+ */
85
+ traceIds: Set<string>;
86
+ /**
87
+ * Ordered list of URLs that have been visited during a replay segment
88
+ */
89
+ urls: string[];
90
+ }
@@ -0,0 +1,5 @@
1
+ import { RecordedEvents } from '@/types';
2
+ export declare function createPayload({ events, headers, }: {
3
+ events: RecordedEvents;
4
+ headers: Record<string, any>;
5
+ }): string | Uint8Array;
File without changes
File without changes
@@ -1,8 +1,10 @@
1
1
  import type { Session } from '@/session/Session';
2
2
  import { InitialState } from '@/types';
3
- interface CaptureReplayParams {
3
+ export interface CaptureReplayParams {
4
4
  session: Session;
5
5
  initialState: InitialState;
6
+ errorIds: string[];
7
+ traceIds: string[];
8
+ urls: string[];
6
9
  }
7
- export declare function captureReplay({ session, initialState }: CaptureReplayParams): void;
8
- export {};
10
+ export declare function captureReplay({ session, initialState, errorIds, traceIds, urls, }: CaptureReplayParams): void;
@@ -1,10 +1,12 @@
1
1
  import type { Session } from '@/session/Session';
2
- interface CaptureReplayUpdateParams {
2
+ export interface CaptureReplayUpdateParams {
3
3
  session: Session;
4
4
  /**
5
5
  * Timestamp of the event in milliseconds
6
6
  */
7
7
  timestamp: number;
8
+ errorIds: string[];
9
+ traceIds: string[];
10
+ urls: string[];
8
11
  }
9
- export declare function captureReplayUpdate({ session, timestamp, }: CaptureReplayUpdateParams): void;
10
- export {};
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;
@@ -1,2 +1,19 @@
1
- import { ReplaySpan } from '@/types';
2
- export declare function handleFetch(handlerData: any): ReplaySpan;
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 {};
@@ -1,2 +1,21 @@
1
- import { ReplaySpan } from '@/types';
2
- export declare function handleXhr(handlerData: any): ReplaySpan;
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 {};
@@ -1,8 +1,10 @@
1
1
  import { Breadcrumb, DsnComponents, Event, Integration } from '@sentry/types';
2
+ import { CaptureReplayParams } from './api/captureReplay';
3
+ import { CaptureReplayUpdateParams } from './api/captureReplayUpdate';
2
4
  import { Session } from './session/Session';
3
5
  import { ReplayPerformanceEntry } from './createPerformanceEntry';
4
6
  import { IEventBuffer } from './eventBuffer';
5
- import type { InstrumentationType, RecordingConfig, RecordingEvent, ReplayRequest, ReplaySpan, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
7
+ import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
6
8
  /**
7
9
  * Returns true to return control to calling function, otherwise continue with normal batching
8
10
  */
@@ -21,10 +23,6 @@ export declare class SentryReplay implements Integration {
21
23
  * Buffer of breadcrumbs to be uploaded
22
24
  */
23
25
  breadcrumbs: Breadcrumb[];
24
- /**
25
- * Buffer of replay spans to be uploaded
26
- */
27
- replaySpans: ReplaySpan[];
28
26
  /**
29
27
  * List of PerformanceEntry from PerformanceObserver
30
28
  */
@@ -58,6 +56,7 @@ export declare class SentryReplay implements Integration {
58
56
  * Captured state when integration is first initialized
59
57
  */
60
58
  private initialState;
59
+ private context;
61
60
  session: Session | undefined;
62
61
  static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
63
62
  constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
@@ -141,10 +140,16 @@ export declare class SentryReplay implements Integration {
141
140
  /**
142
141
  * Handler for Sentry Core SDK events.
143
142
  *
144
- * Transforms core SDK events into replay events.
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.
145
149
  *
150
+ * These events will create breadcrumb-like objects in the recording.
146
151
  */
147
- handleCoreListener: (type: InstrumentationType) => (handlerData: any) => void;
152
+ handleCoreBreadcrumbListener: (type: InstrumentationTypeBreadcrumb) => (handlerData: any) => void;
148
153
  /**
149
154
  * Keep a list of performance entries that will be sent with a replay
150
155
  */
@@ -189,6 +194,12 @@ export declare class SentryReplay implements Integration {
189
194
  * Only flush if `captureOnlyOnError` is false.
190
195
  */
191
196
  conditionalFlush(lastActivity?: number): Promise<void>;
197
+ /**
198
+ * Return and clear context
199
+ */
200
+ popEventContext({ timestamp, }: {
201
+ timestamp: number;
202
+ }): CaptureReplayParams & CaptureReplayUpdateParams;
192
203
  /**
193
204
  * Flushes replay event buffer to Sentry.
194
205
  *
@@ -2,18 +2,13 @@ import { record } from 'rrweb';
2
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
- export interface ReplaySpan {
6
- description: string;
7
- op: string;
8
- startTimestamp: number;
9
- endTimestamp: number;
10
- data?: Record<string, unknown>;
11
- }
12
5
  export interface ReplayRequest {
13
6
  endpoint: string;
14
7
  events: Uint8Array | string;
15
8
  }
16
- export declare type InstrumentationType = 'scope' | 'dom' | 'fetch' | 'xhr';
9
+ export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
10
+ export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
11
+ export declare type InstrumentationType = InstrumentationTypeBreadcrumb | InstrumentationTypeSpan | 'console' | 'error' | 'unhandledrejection';
17
12
  /**
18
13
  * The request payload to worker
19
14
  */
@@ -76,3 +71,20 @@ export interface InitialState {
76
71
  timestamp: number;
77
72
  url: string;
78
73
  }
74
+ /**
75
+ * Additional context that will be sent w/ `replay_event`
76
+ */
77
+ export interface ReplayEventContext {
78
+ /**
79
+ * Set of Sentry error ids that have occurred during a replay segment
80
+ */
81
+ errorIds: Set<string>;
82
+ /**
83
+ * Set of Sentry trace ids that have occurred during a replay segment
84
+ */
85
+ traceIds: Set<string>;
86
+ /**
87
+ * Ordered list of URLs that have been visited during a replay segment
88
+ */
89
+ urls: string[];
90
+ }