@sentry/replay 0.6.14-3 → 0.6.14-5

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 (69) hide show
  1. package/LICENSE +11 -198
  2. package/dist/index.es.js +100 -59
  3. package/dist/index.js +100 -59
  4. package/dist/index.js.map +1 -1
  5. package/dist/types/src/index.d.ts +6 -14
  6. package/dist/types/src/types.d.ts +25 -11
  7. package/package.json +4 -10
  8. package/dist/config/types/jest.config.d.ts +0 -3
  9. package/dist/config/types/jest.setup.d.ts +0 -32
  10. package/dist/config/types/src/blockAllMedia.test.d.ts +0 -1
  11. package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
  12. package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +0 -5
  13. package/dist/config/types/src/coreHandlers/handleDom.d.ts +0 -1
  14. package/dist/config/types/src/coreHandlers/handleFetch.d.ts +0 -19
  15. package/dist/config/types/src/coreHandlers/handleFetch.test.d.ts +0 -1
  16. package/dist/config/types/src/coreHandlers/handleHistory.d.ts +0 -7
  17. package/dist/config/types/src/coreHandlers/handleScope-unit.test.d.ts +0 -1
  18. package/dist/config/types/src/coreHandlers/handleScope.d.ts +0 -2
  19. package/dist/config/types/src/coreHandlers/handleScope.test.d.ts +0 -1
  20. package/dist/config/types/src/coreHandlers/handleXhr.d.ts +0 -21
  21. package/dist/config/types/src/createPerformanceEntry.d.ts +0 -43
  22. package/dist/config/types/src/createPerformanceEntry.test.d.ts +0 -1
  23. package/dist/config/types/src/eventBuffer.d.ts +0 -45
  24. package/dist/config/types/src/eventBuffer.test.d.ts +0 -1
  25. package/dist/config/types/src/flags.d.ts +0 -2
  26. package/dist/config/types/src/flush.test.d.ts +0 -1
  27. package/dist/config/types/src/index-errorSampleRate.test.d.ts +0 -1
  28. package/dist/config/types/src/index-noSticky.test.d.ts +0 -1
  29. package/dist/config/types/src/index-sampling.test.d.ts +0 -1
  30. package/dist/config/types/src/index.d.ts +0 -291
  31. package/dist/config/types/src/index.test.d.ts +0 -1
  32. package/dist/config/types/src/multiple-instances.test.d.ts +0 -1
  33. package/dist/config/types/src/session/Session.d.ts +0 -63
  34. package/dist/config/types/src/session/Session.test.d.ts +0 -1
  35. package/dist/config/types/src/session/constants.d.ts +0 -11
  36. package/dist/config/types/src/session/createSession.d.ts +0 -8
  37. package/dist/config/types/src/session/createSession.test.d.ts +0 -1
  38. package/dist/config/types/src/session/deleteSession.d.ts +0 -4
  39. package/dist/config/types/src/session/deleteSession.test.d.ts +0 -1
  40. package/dist/config/types/src/session/fetchSession.d.ts +0 -6
  41. package/dist/config/types/src/session/fetchSession.test.d.ts +0 -1
  42. package/dist/config/types/src/session/getSession.d.ts +0 -20
  43. package/dist/config/types/src/session/getSession.test.d.ts +0 -1
  44. package/dist/config/types/src/session/index.d.ts +0 -1
  45. package/dist/config/types/src/session/saveSession.d.ts +0 -2
  46. package/dist/config/types/src/session/saveSession.test.d.ts +0 -1
  47. package/dist/config/types/src/stop.test.d.ts +0 -1
  48. package/dist/config/types/src/types.d.ts +0 -130
  49. package/dist/config/types/src/util/addInternalBreadcrumb.d.ts +0 -5
  50. package/dist/config/types/src/util/captureInternalException.d.ts +0 -4
  51. package/dist/config/types/src/util/createBreadcrumb.d.ts +0 -4
  52. package/dist/config/types/src/util/createPayload.d.ts +0 -5
  53. package/dist/config/types/src/util/dedupePerformanceEntries.d.ts +0 -10
  54. package/dist/config/types/src/util/dedupePerformanceEntries.test.d.ts +0 -1
  55. package/dist/config/types/src/util/isExpired.d.ts +0 -5
  56. package/dist/config/types/src/util/isExpired.test.d.ts +0 -1
  57. package/dist/config/types/src/util/isIngestHost.d.ts +0 -4
  58. package/dist/config/types/src/util/isInternal.d.ts +0 -5
  59. package/dist/config/types/src/util/isSampled.d.ts +0 -7
  60. package/dist/config/types/src/util/isSampled.test.d.ts +0 -1
  61. package/dist/config/types/src/util/isSessionExpired.d.ts +0 -5
  62. package/dist/config/types/src/util/isSessionExpired.test.d.ts +0 -1
  63. package/dist/config/types/src/util/logger.d.ts +0 -12
  64. package/dist/config/types/test/fixtures/performanceEntry/lcp.d.ts +0 -1
  65. package/dist/config/types/test/fixtures/performanceEntry/navigation.d.ts +0 -1
  66. package/dist/config/types/test/fixtures/performanceEntry/resource.d.ts +0 -1
  67. package/dist/config/types/test/index.d.ts +0 -3
  68. package/dist/config/types/test/mocks/mockRrweb.d.ts +0 -15
  69. 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,10 +59,6 @@ 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);
@@ -98,7 +94,8 @@ export declare class Replay implements Integration {
98
94
  /**
99
95
  * Pause some replay functionality. See comments for `isPaused`.
100
96
  * This differs from stop as this only stops DOM recording, it is
101
- * not as thorough of a shutdown as `stop()`. */
97
+ * not as thorough of a shutdown as `stop()`.
98
+ */
102
99
  pause(): void;
103
100
  /**
104
101
  * Resumes recording, see notes for `pause().
@@ -251,12 +248,7 @@ export declare class Replay implements Integration {
251
248
  /**
252
249
  * Return and clear context
253
250
  */
254
- popEventContext(): {
255
- initialState: InitialState;
256
- errorIds: string[];
257
- traceIds: string[];
258
- urls: string[];
259
- };
251
+ popEventContext(): PopEventContext;
260
252
  /**
261
253
  * Flushes replay event buffer to Sentry.
262
254
  *
@@ -281,11 +273,11 @@ export declare class Replay implements Integration {
281
273
  /**
282
274
  * Send replay attachment using `fetch()`
283
275
  */
284
- sendReplayRequest({ events, replayId: event_id, segmentId: segment_id, includeReplayStartTimestamp, }: SendReplay): Promise<void | undefined>;
276
+ sendReplayRequest({ events, replayId: event_id, segmentId: segment_id, includeReplayStartTimestamp, eventContext, }: SendReplay): Promise<void | undefined>;
285
277
  resetRetries(): void;
286
278
  /**
287
279
  * Finalize and send the current replay event to Sentry
288
280
  */
289
- sendReplay({ replayId, events, segmentId, includeReplayStartTimestamp, }: SendReplay): Promise<unknown>;
281
+ sendReplay({ replayId, events, segmentId, includeReplayStartTimestamp, eventContext, }: SendReplay): Promise<unknown>;
290
282
  }
291
283
  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-3",
3
+ "version": "0.6.14-5",
4
4
  "description": "User replays for Sentry",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -17,7 +17,6 @@
17
17
  "clean": "yarn rimraf dist",
18
18
  "dev": "yarn build:dev --watch",
19
19
  "lint": "yarn eslint . --ext .js,.jsx,.ts,.tsx",
20
- "prepare": "husky install",
21
20
  "prepack": "yarn build:prod",
22
21
  "start:demo": "yarn build:dev && cd demo && yarn start",
23
22
  "test": "yarn jest"
@@ -30,7 +29,7 @@
30
29
  "url": "git+https://github.com/getsentry/sentry-replay.git"
31
30
  },
32
31
  "author": "Sentry",
33
- "license": "Apache-2.0",
32
+ "license": "MIT",
34
33
  "bugs": {
35
34
  "url": "https://github.com/getsentry/sentry-replay/issues"
36
35
  },
@@ -54,11 +53,10 @@
54
53
  "eslint-config-prettier": "^8.5.0",
55
54
  "eslint-plugin-prettier": "^4.0.0",
56
55
  "eslint-plugin-simple-import-sort": "^7.0.0",
57
- "husky": ">=6",
58
56
  "jest": "^29.2.1",
59
57
  "jest-environment-jsdom": "^29.2.1",
60
58
  "jsdom-worker": "^0.2.1",
61
- "lint-staged": ">=10",
59
+ "pako": "^2.0.4",
62
60
  "prettier": "^2.5.1",
63
61
  "rimraf": "^3.0.2",
64
62
  "rollup": "^2.70.0",
@@ -74,15 +72,11 @@
74
72
  "@sentry/types": "^7.7.0",
75
73
  "@sentry/utils": "^7.7.0",
76
74
  "lodash.debounce": "^4.0.8",
77
- "pako": "^2.0.4",
78
75
  "rrweb": "^1.1.3"
79
76
  },
80
77
  "prettier": {
81
78
  "singleQuote": true
82
79
  },
83
- "lint-staged": {
84
- "*.{js,jsx,ts,tsx}": "yarn eslint --cache --fix"
85
- },
86
80
  "size-limit": [
87
81
  {
88
82
  "path": "dist/index.js",
@@ -90,7 +84,7 @@
90
84
  }
91
85
  ],
92
86
  "volta": {
93
- "node": "18.12.1",
87
+ "node": "14.21.1",
94
88
  "yarn": "1.22.19"
95
89
  }
96
90
  }
@@ -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 {};