@sentry/replay 0.6.14-2 → 0.6.14-4

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 (70) hide show
  1. package/LICENSE +11 -198
  2. package/README.md +1 -1
  3. package/dist/index.es.js +46 -43
  4. package/dist/index.js +46 -43
  5. package/dist/index.js.map +1 -1
  6. package/dist/types/src/index.d.ts +17 -23
  7. package/dist/types/src/types.d.ts +25 -11
  8. package/package.json +3 -3
  9. package/dist/config/types/jest.config.d.ts +0 -3
  10. package/dist/config/types/jest.setup.d.ts +0 -32
  11. package/dist/config/types/src/blockAllMedia.test.d.ts +0 -1
  12. package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
  13. package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +0 -5
  14. package/dist/config/types/src/coreHandlers/handleDom.d.ts +0 -1
  15. package/dist/config/types/src/coreHandlers/handleFetch.d.ts +0 -19
  16. package/dist/config/types/src/coreHandlers/handleFetch.test.d.ts +0 -1
  17. package/dist/config/types/src/coreHandlers/handleHistory.d.ts +0 -7
  18. package/dist/config/types/src/coreHandlers/handleScope-unit.test.d.ts +0 -1
  19. package/dist/config/types/src/coreHandlers/handleScope.d.ts +0 -2
  20. package/dist/config/types/src/coreHandlers/handleScope.test.d.ts +0 -1
  21. package/dist/config/types/src/coreHandlers/handleXhr.d.ts +0 -21
  22. package/dist/config/types/src/createPerformanceEntry.d.ts +0 -43
  23. package/dist/config/types/src/createPerformanceEntry.test.d.ts +0 -1
  24. package/dist/config/types/src/eventBuffer.d.ts +0 -45
  25. package/dist/config/types/src/eventBuffer.test.d.ts +0 -1
  26. package/dist/config/types/src/flags.d.ts +0 -2
  27. package/dist/config/types/src/flush.test.d.ts +0 -1
  28. package/dist/config/types/src/index-errorSampleRate.test.d.ts +0 -1
  29. package/dist/config/types/src/index-noSticky.test.d.ts +0 -1
  30. package/dist/config/types/src/index-sampling.test.d.ts +0 -1
  31. package/dist/config/types/src/index.d.ts +0 -288
  32. package/dist/config/types/src/index.test.d.ts +0 -1
  33. package/dist/config/types/src/multiple-instances.test.d.ts +0 -1
  34. package/dist/config/types/src/session/Session.d.ts +0 -63
  35. package/dist/config/types/src/session/Session.test.d.ts +0 -1
  36. package/dist/config/types/src/session/constants.d.ts +0 -11
  37. package/dist/config/types/src/session/createSession.d.ts +0 -8
  38. package/dist/config/types/src/session/createSession.test.d.ts +0 -1
  39. package/dist/config/types/src/session/deleteSession.d.ts +0 -4
  40. package/dist/config/types/src/session/deleteSession.test.d.ts +0 -1
  41. package/dist/config/types/src/session/fetchSession.d.ts +0 -6
  42. package/dist/config/types/src/session/fetchSession.test.d.ts +0 -1
  43. package/dist/config/types/src/session/getSession.d.ts +0 -20
  44. package/dist/config/types/src/session/getSession.test.d.ts +0 -1
  45. package/dist/config/types/src/session/index.d.ts +0 -1
  46. package/dist/config/types/src/session/saveSession.d.ts +0 -2
  47. package/dist/config/types/src/session/saveSession.test.d.ts +0 -1
  48. package/dist/config/types/src/stop.test.d.ts +0 -1
  49. package/dist/config/types/src/types.d.ts +0 -130
  50. package/dist/config/types/src/util/addInternalBreadcrumb.d.ts +0 -5
  51. package/dist/config/types/src/util/captureInternalException.d.ts +0 -4
  52. package/dist/config/types/src/util/createBreadcrumb.d.ts +0 -4
  53. package/dist/config/types/src/util/createPayload.d.ts +0 -5
  54. package/dist/config/types/src/util/dedupePerformanceEntries.d.ts +0 -10
  55. package/dist/config/types/src/util/dedupePerformanceEntries.test.d.ts +0 -1
  56. package/dist/config/types/src/util/isExpired.d.ts +0 -5
  57. package/dist/config/types/src/util/isExpired.test.d.ts +0 -1
  58. package/dist/config/types/src/util/isIngestHost.d.ts +0 -4
  59. package/dist/config/types/src/util/isInternal.d.ts +0 -5
  60. package/dist/config/types/src/util/isSampled.d.ts +0 -7
  61. package/dist/config/types/src/util/isSampled.test.d.ts +0 -1
  62. package/dist/config/types/src/util/isSessionExpired.d.ts +0 -5
  63. package/dist/config/types/src/util/isSessionExpired.test.d.ts +0 -1
  64. package/dist/config/types/src/util/logger.d.ts +0 -12
  65. package/dist/config/types/test/fixtures/performanceEntry/lcp.d.ts +0 -1
  66. package/dist/config/types/test/fixtures/performanceEntry/navigation.d.ts +0 -1
  67. package/dist/config/types/test/fixtures/performanceEntry/resource.d.ts +0 -1
  68. package/dist/config/types/test/index.d.ts +0 -3
  69. package/dist/config/types/test/mocks/mockRrweb.d.ts +0 -15
  70. package/dist/config/types/test/mocks/mockSdk.d.ts +0 -10
@@ -2,7 +2,7 @@ import { Breadcrumb, Event, Integration } from '@sentry/types';
2
2
  import { Session } from './session/Session';
3
3
  import { ReplayPerformanceEntry } from './createPerformanceEntry';
4
4
  import { IEventBuffer } from './eventBuffer';
5
- import type { AllPerformanceEntry, InitialState, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordingEvent, RecordingOptions, ReplayConfiguration, ReplayPluginOptions, SendReplay } from './types';
5
+ import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, PopEventContext, RecordingEvent, RecordingOptions, ReplayConfiguration, ReplayPluginOptions, SendReplay } from './types';
6
6
  /**
7
7
  * Returns true to return control to calling function, otherwise continue with normal batching
8
8
  */
@@ -59,27 +59,25 @@ export declare class Replay implements Integration {
59
59
  * Function to stop recording
60
60
  */
61
61
  private stopRecording;
62
- /**
63
- * Captured state when integration is first initialized
64
- */
65
- private initialState;
66
62
  private context;
67
63
  session: Session | undefined;
68
64
  constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, sessionSampleRate, errorSampleRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, replaysSamplingRate, captureOnlyOnError, ...recordingOptions }?: ReplayConfiguration);
69
65
  /**
70
- * Because we create a transaction in `setupOnce`, we can potentially create a
71
- * transaction before some native SDK integrations have run and applied their
72
- * own global event processor. An example is:
66
+ * We previously used to create a transaction in `setupOnce` and it would
67
+ * potentially create a transaction before some native SDK integrations have run
68
+ * and applied their own global event processor. An example is:
73
69
  * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
74
70
  *
75
- * So we call `this.setup` in next event loop as a workaround to wait for
76
- * other global event processors to finish
71
+ * So we call `this.setup` in next event loop as a workaround to wait for other
72
+ * global event processors to finish. This is no longer needed, but keeping it
73
+ * here to avoid any future issues.
77
74
  */
78
75
  setupOnce(): void;
79
76
  /**
80
77
  * Initializes the plugin.
81
78
  *
82
- * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
79
+ * Creates or loads a session, attaches listeners to varying events (DOM,
80
+ * PerformanceObserver, Recording, Sentry SDK, etc)
83
81
  */
84
82
  start(): void;
85
83
  /**
@@ -89,7 +87,8 @@ export declare class Replay implements Integration {
89
87
  */
90
88
  startRecording(): void;
91
89
  /**
92
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
90
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
91
+ * does not support a teardown
93
92
  */
94
93
  stop(): void;
95
94
  /**
@@ -166,7 +165,6 @@ export declare class Replay implements Integration {
166
165
  * Handler for Sentry Core SDK events.
167
166
  *
168
167
  * These specific events will create span-like objects in the recording.
169
- *
170
168
  */
171
169
  handleCoreSpanListener: (type: InstrumentationTypeSpan) => (handlerData: any) => void;
172
170
  /**
@@ -205,8 +203,9 @@ export declare class Replay implements Integration {
205
203
  */
206
204
  updateSessionActivity(lastActivity?: number): void;
207
205
  /**
208
- * Updates the user activity timestamp and resumes recording. This should be called in an event handler for a user action that we consider as the user being "active" (e.g. a mouse click).
209
- *
206
+ * Updates the user activity timestamp and resumes recording. This should be
207
+ * called in an event handler for a user action that we consider as the user
208
+ * being "active" (e.g. a mouse click).
210
209
  */
211
210
  triggerUserActivity(): Promise<void>;
212
211
  /**
@@ -248,12 +247,7 @@ export declare class Replay implements Integration {
248
247
  /**
249
248
  * Return and clear context
250
249
  */
251
- popEventContext(): {
252
- initialState: InitialState;
253
- errorIds: string[];
254
- traceIds: string[];
255
- urls: string[];
256
- };
250
+ popEventContext(): PopEventContext;
257
251
  /**
258
252
  * Flushes replay event buffer to Sentry.
259
253
  *
@@ -278,11 +272,11 @@ export declare class Replay implements Integration {
278
272
  /**
279
273
  * Send replay attachment using `fetch()`
280
274
  */
281
- sendReplayRequest({ events, replayId: event_id, segmentId: segment_id, includeReplayStartTimestamp, }: SendReplay): Promise<void | undefined>;
275
+ sendReplayRequest({ events, replayId: event_id, segmentId: segment_id, includeReplayStartTimestamp, eventContext, }: SendReplay): Promise<void | undefined>;
282
276
  resetRetries(): void;
283
277
  /**
284
278
  * Finalize and send the current replay event to Sentry
285
279
  */
286
- sendReplay({ replayId, events, segmentId, includeReplayStartTimestamp, }: SendReplay): Promise<unknown>;
280
+ sendReplay({ replayId, events, segmentId, includeReplayStartTimestamp, eventContext, }: SendReplay): Promise<unknown>;
287
281
  }
288
282
  export {};
@@ -8,6 +8,7 @@ export interface SendReplay {
8
8
  replayId: string;
9
9
  segmentId: number;
10
10
  includeReplayStartTimestamp: boolean;
11
+ eventContext: PopEventContext;
11
12
  }
12
13
  export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
13
14
  export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
@@ -99,17 +100,34 @@ export interface ReplayPluginOptions extends SessionOptions {
99
100
  declare type OptionalReplayPluginOptions = Partial<ReplayPluginOptions>;
100
101
  export interface ReplayConfiguration extends OptionalReplayPluginOptions, RecordingOptions {
101
102
  }
102
- /**
103
- * Some initial state captured before creating a root replay event
104
- */
105
- export interface InitialState {
106
- timestamp: number;
107
- url: string;
103
+ interface CommonEventContext {
104
+ /**
105
+ * The initial URL of the session
106
+ */
107
+ initialUrl: string;
108
+ /**
109
+ * The initial starting timestamp of the session
110
+ */
111
+ initialTimestamp: number;
112
+ /**
113
+ * Ordered list of URLs that have been visited during a replay segment
114
+ */
115
+ urls: string[];
116
+ }
117
+ export interface PopEventContext extends CommonEventContext {
118
+ /**
119
+ * List of Sentry error ids that have occurred during a replay segment
120
+ */
121
+ errorIds: Array<string>;
122
+ /**
123
+ * List of Sentry trace ids that have occurred during a replay segment
124
+ */
125
+ traceIds: Array<string>;
108
126
  }
109
127
  /**
110
128
  * Additional context that will be sent w/ `replay_event`
111
129
  */
112
- export interface ReplayEventContext {
130
+ export interface InternalEventContext extends CommonEventContext {
113
131
  /**
114
132
  * Set of Sentry error ids that have occurred during a replay segment
115
133
  */
@@ -118,10 +136,6 @@ export interface ReplayEventContext {
118
136
  * Set of Sentry trace ids that have occurred during a replay segment
119
137
  */
120
138
  traceIds: Set<string>;
121
- /**
122
- * Ordered list of URLs that have been visited during a replay segment
123
- */
124
- urls: string[];
125
139
  /**
126
140
  * The timestamp of the earliest event that has been added to event buffer. This can happen due to the Performance Observer which buffers events.
127
141
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/replay",
3
- "version": "0.6.14-2",
3
+ "version": "0.6.14-4",
4
4
  "description": "User replays for Sentry",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -30,7 +30,7 @@
30
30
  "url": "git+https://github.com/getsentry/sentry-replay.git"
31
31
  },
32
32
  "author": "Sentry",
33
- "license": "Apache-2.0",
33
+ "license": "MIT",
34
34
  "bugs": {
35
35
  "url": "https://github.com/getsentry/sentry-replay/issues"
36
36
  },
@@ -90,7 +90,7 @@
90
90
  }
91
91
  ],
92
92
  "volta": {
93
- "node": "18.11.0",
93
+ "node": "14.21.1",
94
94
  "yarn": "1.22.19"
95
95
  }
96
96
  }
@@ -1,3 +0,0 @@
1
- import type { Config } from '@jest/types';
2
- declare const _default: () => Promise<Config.InitialOptions>;
3
- export default _default;
@@ -1,32 +0,0 @@
1
- import { Session } from './src/session/Session';
2
- declare type SentReplayExpected = {
3
- envelopeHeader?: {
4
- event_id: string;
5
- sent_at: string;
6
- sdk: {
7
- name: string;
8
- version?: string;
9
- };
10
- };
11
- replayEventHeader?: {
12
- type: 'replay_event';
13
- };
14
- replayEventPayload?: Record<string, any>;
15
- recordingHeader?: {
16
- type: 'replay_recording';
17
- length: number;
18
- };
19
- recordingPayloadHeader?: Record<string, any>;
20
- events?: string | Uint8Array;
21
- };
22
- declare module 'expect' {
23
- interface AsymmetricMatchers {
24
- toHaveSentReplay(expected?: SentReplayExpected): void;
25
- toHaveSameSession(expected: undefined | Session): void;
26
- }
27
- interface Matchers<R> {
28
- toHaveSentReplay(expected?: SentReplayExpected): R;
29
- toHaveSameSession(expected: undefined | Session): R;
30
- }
31
- }
32
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { InstrumentationTypeBreadcrumb } from '../types';
2
- import { handleScope } from './handleScope';
3
- export declare function getBreadcrumbHandler(type: InstrumentationTypeBreadcrumb): typeof handleScope;
@@ -1,5 +0,0 @@
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 +0,0 @@
1
- export declare function handleDom(handlerData: any): import("@sentry/types").Breadcrumb | null;
@@ -1,19 +0,0 @@
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 {};
@@ -1,7 +0,0 @@
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 +0,0 @@
1
- import { Breadcrumb, Scope } from '@sentry/types';
2
- export declare function handleScope(scope: Scope): Breadcrumb | null;
@@ -1,21 +0,0 @@
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 {};
@@ -1,43 +0,0 @@
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 {};
@@ -1,45 +0,0 @@
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 {};
@@ -1 +0,0 @@
1
- import 'jsdom-worker';
@@ -1,2 +0,0 @@
1
- /** Flag that is true for debug builds, false otherwise. */
2
- export declare const IS_DEBUG_BUILD: boolean;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};