@sentry/replay 0.5.3 → 0.5.6

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 (85) hide show
  1. package/dist/index.es.js +123 -66
  2. package/dist/index.js +122 -65
  3. package/dist/index.js.map +1 -1
  4. package/dist/{config/types/jest.config.d.ts → jest.config.d.ts} +0 -0
  5. package/dist/{config/types/jest.setup.d.ts → jest.setup.d.ts} +1 -1
  6. package/dist/{config/types/src → src}/api/captureReplay.d.ts +0 -0
  7. package/dist/{config/types/src → src}/api/captureReplayUpdate.d.ts +0 -0
  8. package/dist/{config/types/src → src}/coreHandlers/getBreadcrumbHandler.d.ts +0 -0
  9. package/dist/{config/types/src → src}/coreHandlers/getSpanHandler.d.ts +0 -0
  10. package/dist/{config/types/src → src}/coreHandlers/handleDom.d.ts +0 -0
  11. package/dist/{config/types/src → src}/coreHandlers/handleFetch.d.ts +1 -1
  12. package/dist/{config/types/src → src}/coreHandlers/handleFetch.test.d.ts +0 -0
  13. package/dist/{config/types/src → src}/coreHandlers/handleHistory.d.ts +0 -0
  14. package/dist/{config/types/src → src}/coreHandlers/handleScope-unit.test.d.ts +0 -0
  15. package/dist/{config/types/src → src}/coreHandlers/handleScope.d.ts +0 -0
  16. package/dist/{config/types/src → src}/coreHandlers/handleScope.test.d.ts +0 -0
  17. package/dist/{config/types/src → src}/coreHandlers/handleXhr.d.ts +2 -2
  18. package/dist/{config/types/src → src}/createPerformanceEntry.d.ts +0 -0
  19. package/dist/{config/types/src → src}/createPerformanceEntry.test.d.ts +0 -0
  20. package/dist/{config/types/src → src}/eventBuffer.d.ts +0 -0
  21. package/dist/{config/types/src → src}/eventBuffer.test.d.ts +0 -0
  22. package/dist/{config/types/src → src}/flags.d.ts +0 -0
  23. package/dist/{config/types/src → src}/index-captureOnlyOnError.test.d.ts +0 -0
  24. package/dist/{config/types/src → src}/index-noSticky.test.d.ts +0 -0
  25. package/dist/{config/types/src → src}/index-sampling.test.d.ts +0 -0
  26. package/dist/{config/types/src → src}/index.d.ts +5 -1
  27. package/dist/{config/types/src → src}/index.test.d.ts +0 -0
  28. package/dist/{types/src → src}/session/Session.d.ts +2 -2
  29. package/dist/{config/types/src → src}/session/Session.test.d.ts +0 -0
  30. package/dist/{config/types/src → src}/session/constants.d.ts +0 -0
  31. package/dist/{config/types/src → src}/session/createSession.d.ts +0 -0
  32. package/dist/{config/types/src → src}/session/createSession.test.d.ts +0 -0
  33. package/dist/{config/types/src → src}/session/fetchSession.d.ts +0 -0
  34. package/dist/{config/types/src → src}/session/fetchSession.test.d.ts +0 -0
  35. package/dist/{config/types/src → src}/session/getSession.d.ts +0 -0
  36. package/dist/{config/types/src → src}/session/getSession.test.d.ts +0 -0
  37. package/dist/{config/types/src → src}/session/index.d.ts +0 -0
  38. package/dist/{config/types/src → src}/session/saveSession.d.ts +0 -0
  39. package/dist/{config/types/src → src}/session/saveSession.test.d.ts +0 -0
  40. package/dist/{config/types/src → src}/types.d.ts +4 -0
  41. package/dist/{config/types/src → src}/util/createBreadcrumb.d.ts +0 -0
  42. package/dist/{config/types/src → src}/util/createPayload.d.ts +0 -0
  43. package/dist/{types/src → src}/util/isExpired.d.ts +1 -1
  44. package/dist/{config/types/src → src}/util/isExpired.test.d.ts +0 -0
  45. package/dist/{config/types/src → src}/util/isIngestHost.d.ts +0 -0
  46. package/dist/{config/types/src → src}/util/isSampled.d.ts +0 -0
  47. package/dist/{config/types/src → src}/util/isSampled.test.d.ts +0 -0
  48. package/dist/{config/types/src → src}/util/isSessionExpired.d.ts +0 -0
  49. package/dist/{config/types/src → src}/util/isSessionExpired.test.d.ts +0 -0
  50. package/dist/{config/types/src → src}/util/logger.d.ts +0 -0
  51. package/dist/{config/types/test → test}/index.d.ts +0 -0
  52. package/dist/{config/types/test → test}/mocks/mockRrweb.d.ts +0 -0
  53. package/dist/{config/types/test → test}/mocks/mockSdk.d.ts +0 -0
  54. package/package.json +1 -1
  55. package/dist/config/types/src/session/Session.d.ts +0 -63
  56. package/dist/config/types/src/util/getAdditionalRequestData.d.ts +0 -2
  57. package/dist/config/types/src/util/isExpired.d.ts +0 -5
  58. package/dist/config/types/src/util/supportsSendBeacon.d.ts +0 -4
  59. package/dist/types/src/api/captureReplay.d.ts +0 -10
  60. package/dist/types/src/api/captureReplayUpdate.d.ts +0 -12
  61. package/dist/types/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
  62. package/dist/types/src/coreHandlers/getSpanHandler.d.ts +0 -5
  63. package/dist/types/src/coreHandlers/handleDom.d.ts +0 -1
  64. package/dist/types/src/coreHandlers/handleFetch.d.ts +0 -19
  65. package/dist/types/src/coreHandlers/handleHistory.d.ts +0 -7
  66. package/dist/types/src/coreHandlers/handleScope.d.ts +0 -2
  67. package/dist/types/src/coreHandlers/handleXhr.d.ts +0 -21
  68. package/dist/types/src/createPerformanceEntry.d.ts +0 -42
  69. package/dist/types/src/eventBuffer.d.ts +0 -45
  70. package/dist/types/src/flags.d.ts +0 -2
  71. package/dist/types/src/index.d.ts +0 -230
  72. package/dist/types/src/session/constants.d.ts +0 -5
  73. package/dist/types/src/session/createSession.d.ts +0 -19
  74. package/dist/types/src/session/fetchSession.d.ts +0 -5
  75. package/dist/types/src/session/getSession.d.ts +0 -28
  76. package/dist/types/src/session/index.d.ts +0 -1
  77. package/dist/types/src/session/saveSession.d.ts +0 -2
  78. package/dist/types/src/types.d.ts +0 -91
  79. package/dist/types/src/util/createBreadcrumb.d.ts +0 -4
  80. package/dist/types/src/util/createPayload.d.ts +0 -5
  81. package/dist/types/src/util/isIngestHost.d.ts +0 -4
  82. package/dist/types/src/util/isSampled.d.ts +0 -7
  83. package/dist/types/src/util/isSessionExpired.d.ts +0 -5
  84. package/dist/types/src/util/logger.d.ts +0 -12
  85. package/dist/types/src/util/supportsSendBeacon.d.ts +0 -4
@@ -4,7 +4,7 @@ declare global {
4
4
  namespace jest {
5
5
  interface Matchers<R> {
6
6
  toHaveSentReplay(expected?: string | Uint8Array): CustomMatcherResult;
7
- toHaveSameSession(expected: Session): CustomMatcherResult;
7
+ toHaveSameSession(expected: undefined | Session): CustomMatcherResult;
8
8
  }
9
9
  }
10
10
  }
@@ -15,5 +15,5 @@ interface FetchHandlerData {
15
15
  startTimestamp: number;
16
16
  endTimestamp?: number;
17
17
  }
18
- export declare function handleFetch(handlerData: FetchHandlerData): ReplayPerformanceEntry;
18
+ export declare function handleFetch(handlerData: FetchHandlerData): null | ReplayPerformanceEntry;
19
19
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
2
2
  declare type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
3
3
  interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
4
- [key: string]: any;
4
+ [key: string]: unknown;
5
5
  __sentry_xhr__?: {
6
6
  method?: string;
7
7
  url?: string;
@@ -17,5 +17,5 @@ interface XhrHandlerData {
17
17
  startTimestamp: number;
18
18
  endTimestamp?: number;
19
19
  }
20
- export declare function handleXhr(handlerData: XhrHandlerData): ReplayPerformanceEntry;
20
+ export declare function handleXhr(handlerData: XhrHandlerData): ReplayPerformanceEntry | null;
21
21
  export {};
File without changes
File without changes
@@ -172,6 +172,10 @@ export declare class SentryReplay implements Integration {
172
172
  * create a new Replay event.
173
173
  */
174
174
  triggerFullSnapshot(): void;
175
+ /**
176
+ * Add an event to the event buffer
177
+ */
178
+ addEvent(event: RecordingEvent, isCheckout?: boolean): void;
175
179
  /**
176
180
  * Updates the session's last activity timestamp
177
181
  */
@@ -218,7 +222,7 @@ export declare class SentryReplay implements Integration {
218
222
  */
219
223
  flushUpdate(lastActivity?: number): Promise<void>;
220
224
  /**
221
- * Send replay attachment using either `sendBeacon()` or `fetch()`
225
+ * Send replay attachment using `fetch()`
222
226
  */
223
227
  sendReplayRequest({ endpoint, events }: ReplayRequest): Promise<void>;
224
228
  resetRetries(): void;
File without changes
@@ -54,8 +54,8 @@ export declare class Session {
54
54
  set lastActivity(newDate: number);
55
55
  get segmentId(): number;
56
56
  set segmentId(id: number);
57
- get previousSessionId(): string;
58
- set previousSessionId(id: string);
57
+ get previousSessionId(): string | undefined;
58
+ set previousSessionId(id: string | undefined);
59
59
  get sampled(): boolean;
60
60
  set sampled(_isSampled: boolean);
61
61
  toJSON(): SessionObject;
@@ -88,4 +88,8 @@ export interface ReplayEventContext {
88
88
  * Ordered list of URLs that have been visited during a replay segment
89
89
  */
90
90
  urls: string[];
91
+ /**
92
+ * The timestamp of the earliest event that has been added to event buffer. This can happen due to the Performance Observer which buffers events.
93
+ */
94
+ earliestEvent: number | null;
91
95
  }
@@ -2,4 +2,4 @@
2
2
  * Given an initial timestamp and an expiry duration, checks to see if current
3
3
  * time should be considered as expired.
4
4
  */
5
- export declare function isExpired(initialTime: number, expiry: number, targetTime?: number): boolean;
5
+ export declare function isExpired(initialTime: null | number, expiry: undefined | number, targetTime?: number): boolean;
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/replay",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "description": "User replays for Sentry",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,63 +0,0 @@
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 {};
@@ -1,2 +0,0 @@
1
- import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
2
- export declare function getAdditionalRequestData(entries: ReplayPerformanceEntry[], coreRequests: ReplayPerformanceEntry[]): ReplayPerformanceEntry[];
@@ -1,5 +0,0 @@
1
- /**
2
- * Given an initial timestamp and an expiry duration, checks to see if current
3
- * time should be considered as expired.
4
- */
5
- export declare function isExpired(initialTime: number, expiry: number, targetTime?: number): boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine if there is browser support for `navigator.sendBeacon`
3
- */
4
- export declare function supportsSendBeacon(): boolean;
@@ -1,10 +0,0 @@
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;
@@ -1,12 +0,0 @@
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;
@@ -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;
@@ -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): 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;
@@ -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]: 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,42 +0,0 @@
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 {};
@@ -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,2 +0,0 @@
1
- /** Flag that is true for debug builds, false otherwise. */
2
- export declare const IS_DEBUG_BUILD: boolean;