@sentry/replay 0.2.0-17 → 0.2.0-18

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 (79) hide show
  1. package/dist/{jest.config.d.ts → config/dist/jest.config.d.ts} +0 -0
  2. package/dist/{jest.setup.d.ts → config/dist/jest.setup.d.ts} +2 -2
  3. package/dist/config/dist/src/api/captureReplay.d.ts +2 -0
  4. package/dist/config/dist/src/api/captureReplayUpdate.d.ts +2 -0
  5. package/dist/{src → config/dist/src}/coreHandlers/handleDom.d.ts +0 -0
  6. package/dist/{src → config/dist/src}/coreHandlers/handleFetch.d.ts +0 -0
  7. package/dist/{src/eventBuffer.test.d.ts → config/dist/src/coreHandlers/handleScope-unit.test.d.ts} +0 -0
  8. package/dist/config/dist/src/coreHandlers/handleScope.d.ts +3 -0
  9. package/dist/{src/index.test.d.ts → config/dist/src/coreHandlers/handleScope.test.d.ts} +0 -0
  10. package/dist/{src → config/dist/src}/coreHandlers/handleXhr.d.ts +0 -0
  11. package/dist/{src → config/dist/src}/coreHandlers/index.d.ts +0 -0
  12. package/dist/{src → config/dist/src}/createPerformanceEntry.d.ts +0 -0
  13. package/dist/{src → config/dist/src}/eventBuffer.d.ts +1 -6
  14. package/dist/{src/session/createSession.test.d.ts → config/dist/src/eventBuffer.test.d.ts} +0 -0
  15. package/dist/{src → config/dist/src}/flags.d.ts +0 -0
  16. package/dist/{src/session/fetchSession.test.d.ts → config/dist/src/index-noSticky.test.d.ts} +0 -0
  17. package/dist/{src → config/dist/src}/index.d.ts +5 -32
  18. package/dist/{src/session/getSession.test.d.ts → config/dist/src/index.test.d.ts} +0 -0
  19. package/dist/config/dist/src/session/Session.d.ts +46 -0
  20. package/dist/{src/session/saveSession.test.d.ts → config/dist/src/session/Session.test.d.ts} +0 -0
  21. package/dist/{src → config/dist/src}/session/constants.d.ts +1 -1
  22. package/dist/{src → config/dist/src}/session/createSession.d.ts +2 -2
  23. package/dist/{src/session/updateSessionActivity.test.d.ts → config/dist/src/session/createSession.test.d.ts} +0 -0
  24. package/dist/config/dist/src/session/fetchSession.d.ts +2 -0
  25. package/dist/{src/util/isExpired.test.d.ts → config/dist/src/session/fetchSession.test.d.ts} +0 -0
  26. package/dist/{src → config/dist/src}/session/getSession.d.ts +3 -3
  27. package/dist/{src/util/isSessionExpired.test.d.ts → config/dist/src/session/getSession.test.d.ts} +0 -0
  28. package/dist/{src → config/dist/src}/session/index.d.ts +0 -1
  29. package/dist/config/dist/src/session/saveSession.d.ts +2 -0
  30. package/dist/config/dist/src/session/saveSession.test.d.ts +1 -0
  31. package/dist/{src → config/dist/src}/types.d.ts +26 -0
  32. package/dist/{src → config/dist/src}/util/createBreadcrumb.d.ts +0 -0
  33. package/dist/{src → config/dist/src}/util/isExpired.d.ts +0 -0
  34. package/dist/config/dist/src/util/isExpired.test.d.ts +1 -0
  35. package/dist/config/dist/src/util/isIngestHost.d.ts +4 -0
  36. package/dist/config/dist/src/util/isSessionExpired.d.ts +5 -0
  37. package/dist/config/dist/src/util/isSessionExpired.test.d.ts +1 -0
  38. package/dist/config/dist/src/util/logger.d.ts +11 -0
  39. package/dist/config/dist/test/index.d.ts +3 -0
  40. package/dist/config/dist/test/mocks/mockRrweb.d.ts +15 -0
  41. package/dist/config/dist/test/mocks/mockSdk.d.ts +11 -0
  42. package/dist/dist/coreHandlers/handleDom.d.ts +1 -0
  43. package/dist/dist/coreHandlers/handleFetch.d.ts +2 -0
  44. package/dist/dist/coreHandlers/handleScope.d.ts +3 -0
  45. package/dist/dist/coreHandlers/handleXhr.d.ts +2 -0
  46. package/dist/dist/coreHandlers/index.d.ts +4 -0
  47. package/dist/dist/createPerformanceEntry.d.ts +42 -0
  48. package/dist/dist/eventBuffer.d.ts +31 -0
  49. package/dist/dist/flags.d.ts +2 -0
  50. package/dist/dist/index.d.ts +122 -0
  51. package/dist/dist/session/Session.d.ts +46 -0
  52. package/dist/dist/session/constants.d.ts +5 -0
  53. package/dist/dist/session/createSession.d.ts +14 -0
  54. package/dist/dist/session/fetchSession.d.ts +2 -0
  55. package/dist/dist/session/getSession.d.ts +20 -0
  56. package/dist/dist/session/index.d.ts +1 -0
  57. package/dist/dist/session/saveSession.d.ts +2 -0
  58. package/dist/dist/types.d.ts +57 -0
  59. package/dist/dist/util/createBreadcrumb.d.ts +4 -0
  60. package/dist/dist/util/isExpired.d.ts +5 -0
  61. package/dist/dist/util/isIngestHost.d.ts +4 -0
  62. package/dist/dist/util/isSessionExpired.d.ts +5 -0
  63. package/dist/{src → dist}/util/logger.d.ts +0 -0
  64. package/dist/index.es.js +85 -39
  65. package/dist/index.js +85 -39
  66. package/dist/index.js.map +1 -1
  67. package/package.json +12 -9
  68. package/dist/rollup.config.d.ts +0 -3
  69. package/dist/src/coreHandlers/handleScope.d.ts +0 -2
  70. package/dist/src/createMemoryEntry.d.ts +0 -19
  71. package/dist/src/session/fetchSession.d.ts +0 -2
  72. package/dist/src/session/saveSession.d.ts +0 -2
  73. package/dist/src/session/types.d.ts +0 -6
  74. package/dist/src/session/updateSessionActivity.d.ts +0 -3
  75. package/dist/src/util/isSessionExpired.d.ts +0 -5
  76. package/dist/test/index.d.ts +0 -1
  77. package/dist/worker-9d2d4d71.js +0 -7
  78. package/dist/worker-9d2d4d71.js.map +0 -1
  79. package/dist/worker-c801dc28.js +0 -4
@@ -1,10 +1,10 @@
1
1
  /// <reference types="jest" />
2
- import { ReplaySession } from '@/session';
2
+ import { Session } from '@/session/Session';
3
3
  declare global {
4
4
  namespace jest {
5
5
  interface Matchers<R> {
6
6
  toHaveSentReplay(expected?: string | Uint8Array): CustomMatcherResult;
7
- toHaveSameSession(expected: ReplaySession): CustomMatcherResult;
7
+ toHaveSameSession(expected: Session): CustomMatcherResult;
8
8
  }
9
9
  }
10
10
  }
@@ -0,0 +1,2 @@
1
+ import type { Session } from '@/session/Session';
2
+ export declare function captureReplay(session: Session): void;
@@ -0,0 +1,2 @@
1
+ import type { Session } from '@/session/Session';
2
+ export declare function captureReplayUpdate(session: Session): void;
@@ -0,0 +1,3 @@
1
+ import { Scope } from '@sentry/hub';
2
+ import { Breadcrumb } from '@sentry/types';
3
+ export declare function handleScope(scope: Scope): Breadcrumb;
@@ -1,13 +1,8 @@
1
1
  import { RRWebEvent } from './types';
2
- declare global {
3
- interface Window {
4
- __SENTRY_USE_ARRAY_BUFFER: boolean;
5
- }
6
- }
7
2
  interface CreateEventBufferParams {
8
3
  useCompression: boolean;
9
4
  }
10
- export declare function createEventBuffer({ useCompression, }: CreateEventBufferParams): Promise<EventBufferCompressionWorker | EventBufferArray>;
5
+ export declare function createEventBuffer({ useCompression }: CreateEventBufferParams): EventBufferCompressionWorker | EventBufferArray;
11
6
  export interface IEventBuffer {
12
7
  get length(): number;
13
8
  destroy(): void;
File without changes
@@ -1,38 +1,12 @@
1
1
  import { DsnComponents, Integration, Breadcrumb } from '@sentry/types';
2
2
  import { ReplayPerformanceEntry } from './createPerformanceEntry';
3
3
  import { IEventBuffer } from './eventBuffer';
4
- import { ReplaySession } from './session';
5
- import type { RRWebOptions, ReplaySpan, ReplayRequest, InstrumentationType } from './types';
4
+ import type { RRWebOptions, ReplaySpan, ReplayRequest, InstrumentationType, SentryReplayPluginOptions, SentryReplayConfiguration } from './types';
5
+ import { Session } from './session/Session';
6
6
  /**
7
7
  * Returns true if we want to flush immediately, otherwise continue with normal batching
8
8
  */
9
9
  declare type AddUpdateCallback = () => boolean | void;
10
- interface PluginOptions {
11
- /**
12
- * The amount of time to wait before sending a replay
13
- */
14
- uploadMinDelay?: number;
15
- /**
16
- * The max amount of time to wait before sending a replay
17
- */
18
- uploadMaxDelay?: number;
19
- /**
20
- * If false, will create a new session per pageload
21
- */
22
- stickySession?: boolean;
23
- /**
24
- * Attempt to use compression when web workers are available
25
- *
26
- * (default is true)
27
- */
28
- useCompression?: boolean;
29
- }
30
- interface SentryReplayConfiguration extends PluginOptions {
31
- /**
32
- * Options for `rrweb.recordsetup
33
- */
34
- rrwebConfig?: RRWebOptions;
35
- }
36
10
  export declare class SentryReplay implements Integration {
37
11
  /**
38
12
  * @inheritDoc
@@ -59,7 +33,7 @@ export declare class SentryReplay implements Integration {
59
33
  * Options to pass to `rrweb.record()`
60
34
  */
61
35
  readonly rrwebRecordOptions: RRWebOptions;
62
- readonly options: PluginOptions;
36
+ readonly options: SentryReplayPluginOptions;
63
37
  /**
64
38
  * setTimeout id used for debouncing sending rrweb attachments
65
39
  */
@@ -72,12 +46,12 @@ export declare class SentryReplay implements Integration {
72
46
  private performanceObserver;
73
47
  private retryCount;
74
48
  private retryInterval;
75
- session: ReplaySession | undefined;
49
+ session: Session | undefined;
76
50
  static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
77
51
  constructor({ uploadMinDelay, uploadMaxDelay, stickySession, // TBD: Making this opt-in for now
78
52
  useCompression, rrwebConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...rrwebRecordOptions }, }?: SentryReplayConfiguration);
79
53
  setupOnce(): void;
80
- setup(): Promise<void>;
54
+ setup(): void;
81
55
  /**
82
56
  * We want to batch uploads of replay events. Save events only if
83
57
  * `<uploadMinDelay>` milliseconds have elapsed since the last event
@@ -98,7 +72,6 @@ export declare class SentryReplay implements Integration {
98
72
  loadSession({ expiry }: {
99
73
  expiry: number;
100
74
  }): void;
101
- updateSession(session: Partial<ReplaySession>): void;
102
75
  addListeners(): void;
103
76
  removeListeners(): void;
104
77
  /**
@@ -0,0 +1,46 @@
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
+ * Sequence ID specific to replay updates
13
+ */
14
+ sequenceId: number;
15
+ }
16
+ interface SessionOptions {
17
+ stickySession?: boolean;
18
+ }
19
+ export declare class Session {
20
+ /**
21
+ * Session ID
22
+ */
23
+ private _id;
24
+ /**
25
+ * Start time of current session
26
+ */
27
+ private _started;
28
+ /**
29
+ * Last known activity of the session
30
+ */
31
+ private _lastActivity;
32
+ /**
33
+ * Sequence ID specific to replay updates
34
+ */
35
+ private _sequenceId;
36
+ private options;
37
+ constructor(session?: Partial<SessionObject>, { stickySession }?: SessionOptions);
38
+ get id(): string;
39
+ get started(): number;
40
+ get lastActivity(): number;
41
+ set lastActivity(newDate: number);
42
+ get sequenceId(): number;
43
+ set sequenceId(id: number);
44
+ toJSON(): SessionObject;
45
+ }
46
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare const REPLAY_SESSION_KEY = "sentryReplaySession";
2
2
  export declare const ROOT_REPLAY_NAME = "sentry-replay";
3
3
  export declare const REPLAY_EVENT_NAME = "sentry-replay-event";
4
- export declare const VISIBILITY_CHANGE_TIMEOUT = 60000;
5
4
  export declare const SESSION_IDLE_DURATION = 900000;
5
+ export declare const VISIBILITY_CHANGE_TIMEOUT = 900000;
@@ -1,4 +1,4 @@
1
- import type { ReplaySession } from './types';
1
+ import { Session } from './Session';
2
2
  interface CreateSessionParams {
3
3
  /**
4
4
  * Should save to sessionStorage?
@@ -10,5 +10,5 @@ interface CreateSessionParams {
10
10
  * that all replays will be saved to as attachments. Currently, we only expect
11
11
  * one of these Sentry events per "replay session".
12
12
  */
13
- export declare function createSession({ stickySession, }: CreateSessionParams): ReplaySession;
13
+ export declare function createSession({ stickySession, }: CreateSessionParams): Session;
14
14
  export {};
@@ -0,0 +1,2 @@
1
+ import { Session } from './Session';
2
+ export declare function fetchSession(): Session | null;
@@ -1,4 +1,4 @@
1
- import { ReplaySession } from './types';
1
+ import { Session } from './Session';
2
2
  interface GetSessionParams {
3
3
  /**
4
4
  * The length of time (in ms) which we will consider the session to be expired.
@@ -11,10 +11,10 @@ interface GetSessionParams {
11
11
  /**
12
12
  * The current session (e.g. if stickySession is off)
13
13
  */
14
- currentSession?: ReplaySession;
14
+ currentSession?: Session;
15
15
  }
16
16
  /**
17
17
  * Get or create a session
18
18
  */
19
- export declare function getSession({ expiry, currentSession, stickySession, }: GetSessionParams): ReplaySession;
19
+ export declare function getSession({ expiry, currentSession, stickySession, }: GetSessionParams): Session;
20
20
  export {};
@@ -1,2 +1 @@
1
- export * from './types';
2
1
  export * from './createSession';
@@ -0,0 +1,2 @@
1
+ import { Session } from './Session';
2
+ export declare function saveSession(session: Session): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -29,3 +29,29 @@ export interface WorkerResponse {
29
29
  success: boolean;
30
30
  response: string | Uint8Array;
31
31
  }
32
+ export interface SentryReplayPluginOptions {
33
+ /**
34
+ * The amount of time to wait before sending a replay
35
+ */
36
+ uploadMinDelay?: number;
37
+ /**
38
+ * The max amount of time to wait before sending a replay
39
+ */
40
+ uploadMaxDelay?: number;
41
+ /**
42
+ * If false, will create a new session per pageload
43
+ */
44
+ stickySession?: boolean;
45
+ /**
46
+ * Attempt to use compression when web workers are available
47
+ *
48
+ * (default is true)
49
+ */
50
+ useCompression?: boolean;
51
+ }
52
+ export interface SentryReplayConfiguration extends SentryReplayPluginOptions {
53
+ /**
54
+ * Options for `rrweb.recordsetup
55
+ */
56
+ rrwebConfig?: RRWebOptions;
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks is `targetHost` is a Sentry ingestion host
3
+ */
4
+ export declare function isIngestHost(targetHost: string): boolean;
@@ -0,0 +1,5 @@
1
+ import { Session } from '@/session/Session';
2
+ /**
3
+ * Checks to see if session is expired
4
+ */
5
+ export declare function isSessionExpired(session: Session, expiry: number, targetTime?: number): boolean;
@@ -0,0 +1,11 @@
1
+ declare const logger: {
2
+ error: (...args: any[]) => any;
3
+ warn: (...args: any[]) => any;
4
+ log: (...args: any[]) => any;
5
+ disable(): void;
6
+ enable(): void;
7
+ info: (...args: unknown[]) => void;
8
+ debug: (...args: unknown[]) => void;
9
+ assert: (...args: unknown[]) => void;
10
+ };
11
+ export { logger };
@@ -0,0 +1,3 @@
1
+ export * from './mocks/mockRrweb';
2
+ export * from './mocks/mockSdk';
3
+ export declare const BASE_TIMESTAMP: number;
@@ -0,0 +1,15 @@
1
+ /// <reference types="jest" />
2
+ import { RRWebEvent } from '@/types';
3
+ declare type RecordAdditionalProperties = {
4
+ takeFullSnapshot: jest.Mock;
5
+ addCustomEvent: () => void;
6
+ freezePage: () => void;
7
+ mirror: unknown;
8
+ _emitter: (event: RRWebEvent, ...args: any[]) => void;
9
+ };
10
+ export declare type RecordMock = jest.MockedFunction<typeof rrweb.record> & RecordAdditionalProperties;
11
+ import * as rrweb from 'rrweb';
12
+ export declare function mockRrweb(): {
13
+ record: RecordMock;
14
+ };
15
+ export {};
@@ -0,0 +1,11 @@
1
+ import { BrowserOptions } from '@sentry/browser';
2
+ import { SentryReplayConfiguration } from '@/types';
3
+ import { SentryReplay } from '@';
4
+ interface MockSdkParams {
5
+ replayOptions?: SentryReplayConfiguration;
6
+ sentryOptions?: BrowserOptions;
7
+ }
8
+ export declare function mockSdk({ replayOptions, sentryOptions, }?: MockSdkParams): {
9
+ replay: SentryReplay;
10
+ };
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare function handleDom(handlerData: any): import("@sentry/types").Breadcrumb;
@@ -0,0 +1,2 @@
1
+ import { ReplaySpan } from '@/types';
2
+ export declare function handleFetch(handlerData: any): ReplaySpan;
@@ -0,0 +1,3 @@
1
+ import { Scope } from '@sentry/hub';
2
+ import { Breadcrumb } from '@sentry/types';
3
+ export declare function handleScope(scope: Scope): Breadcrumb;
@@ -0,0 +1,2 @@
1
+ import { ReplaySpan } from '@/types';
2
+ export declare function handleXhr(handlerData: any): ReplaySpan;
@@ -0,0 +1,4 @@
1
+ export * from './handleDom';
2
+ export * from './handleFetch';
3
+ export * from './handleScope';
4
+ export * from './handleXhr';
@@ -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,31 @@
1
+ import { RRWebEvent } 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: RRWebEvent, isCheckout?: boolean): void;
10
+ finish(): Promise<string | Uint8Array>;
11
+ }
12
+ declare class EventBufferArray implements IEventBuffer {
13
+ events: RRWebEvent[];
14
+ constructor();
15
+ destroy(): void;
16
+ get length(): number;
17
+ addEvent(event: RRWebEvent, isCheckout?: boolean): void;
18
+ finish(): Promise<string>;
19
+ }
20
+ export declare class EventBufferCompressionWorker implements IEventBuffer {
21
+ private worker;
22
+ private eventBufferItemLength;
23
+ constructor(worker: Worker);
24
+ init(): void;
25
+ destroy(): void;
26
+ get length(): number;
27
+ addEvent(event: RRWebEvent, isCheckout?: boolean): void;
28
+ sendEventToWorker(event: RRWebEvent): void;
29
+ finish(): Promise<Uint8Array>;
30
+ }
31
+ export {};
@@ -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,122 @@
1
+ import { DsnComponents, Integration, Breadcrumb } from '@sentry/types';
2
+ import { ReplayPerformanceEntry } from './createPerformanceEntry';
3
+ import { IEventBuffer } from './eventBuffer';
4
+ import type { RRWebOptions, ReplaySpan, ReplayRequest, InstrumentationType, SentryReplayPluginOptions, SentryReplayConfiguration } from './types';
5
+ import { Session } from './session/Session';
6
+ /**
7
+ * Returns true if we want to flush immediately, otherwise continue with normal batching
8
+ */
9
+ declare type AddUpdateCallback = () => boolean | void;
10
+ export declare class SentryReplay implements Integration {
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ static id: string;
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ name: string;
19
+ eventBuffer: IEventBuffer;
20
+ /**
21
+ * Buffer of breadcrumbs to be uploaded
22
+ */
23
+ breadcrumbs: Breadcrumb[];
24
+ /**
25
+ * Buffer of replay spans to be uploaded
26
+ */
27
+ replaySpans: ReplaySpan[];
28
+ /**
29
+ * List of PerformanceEntry from PerformanceObserver
30
+ */
31
+ performanceEvents: PerformanceEntry[];
32
+ /**
33
+ * Options to pass to `rrweb.record()`
34
+ */
35
+ readonly rrwebRecordOptions: RRWebOptions;
36
+ readonly options: SentryReplayPluginOptions;
37
+ /**
38
+ * setTimeout id used for debouncing sending rrweb attachments
39
+ */
40
+ private timeout;
41
+ /**
42
+ * The timestamp of the first event since the last flush.
43
+ * This is used to determine if the maximum allowed time has passed before we should flush events again.
44
+ */
45
+ private initialEventTimestampSinceFlush;
46
+ private performanceObserver;
47
+ private retryCount;
48
+ private retryInterval;
49
+ session: Session | undefined;
50
+ static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
51
+ constructor({ uploadMinDelay, uploadMaxDelay, stickySession, // TBD: Making this opt-in for now
52
+ useCompression, rrwebConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...rrwebRecordOptions }, }?: SentryReplayConfiguration);
53
+ setupOnce(): void;
54
+ setup(): void;
55
+ /**
56
+ * We want to batch uploads of replay events. Save events only if
57
+ * `<uploadMinDelay>` milliseconds have elapsed since the last event
58
+ * *OR* if `<uploadMaxDelay>` milliseconds have elapsed.
59
+ *
60
+ * Accepts a callback to perform side-effects and returns a boolean value if we
61
+ * should flush events immediately
62
+ */
63
+ addUpdate(cb?: AddUpdateCallback): void;
64
+ /**
65
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
66
+ */
67
+ destroy(): void;
68
+ clearSession(): void;
69
+ /**
70
+ * Loads a session from storage, or creates a new one
71
+ */
72
+ loadSession({ expiry }: {
73
+ expiry: number;
74
+ }): void;
75
+ addListeners(): void;
76
+ removeListeners(): void;
77
+ /**
78
+ * Handle when visibility of the page changes. (e.g. new tab is opened)
79
+ */
80
+ handleVisibilityChange: () => void;
81
+ handleWindowUnload: () => void;
82
+ handleCoreListener: (type: InstrumentationType) => (handlerData: any) => void;
83
+ /**
84
+ * Keep a list of performance entries that will be sent with a replay
85
+ */
86
+ handlePerformanceObserver: (list: PerformanceObserverEntryList) => void;
87
+ /**
88
+ * Trigger rrweb to take a full snapshot which will cause this plugin to
89
+ * create a new Replay event.
90
+ */
91
+ triggerFullSnapshot(): void;
92
+ /**
93
+ * Create a span for each performance entry. The parent transaction is `this.replayEvent`.
94
+ */
95
+ createPerformanceSpans(entries: ReplayPerformanceEntry[]): void;
96
+ /**
97
+ * Observed performance events are added to `this.performanceEvents`. These
98
+ * are included in the replay event before it is finished and sent to Sentry.
99
+ */
100
+ addPerformanceEntries(): void;
101
+ /**
102
+ *
103
+ *
104
+ * Returns true if session is not expired, false otherwise.
105
+ */
106
+ checkAndHandleExpiredSession(expiry?: number): boolean;
107
+ flushUpdate(lastActivity?: number): Promise<void>;
108
+ /**
109
+ * Determine if there is browser support for `navigator.sendBeacon`
110
+ */
111
+ hasSendBeacon(): boolean;
112
+ /**
113
+ * Send replay attachment using either `sendBeacon()` or `fetch()`
114
+ */
115
+ sendReplayRequest({ endpoint, events }: ReplayRequest): Promise<void>;
116
+ resetRetries(): void;
117
+ /**
118
+ * Finalize and send the current replay event to Sentry
119
+ */
120
+ sendReplay(eventId: string, events: Uint8Array | string): Promise<boolean>;
121
+ }
122
+ export {};
@@ -0,0 +1,46 @@
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
+ * Sequence ID specific to replay updates
13
+ */
14
+ sequenceId: number;
15
+ }
16
+ interface SessionOptions {
17
+ stickySession?: boolean;
18
+ }
19
+ export declare class Session {
20
+ /**
21
+ * Session ID
22
+ */
23
+ private _id;
24
+ /**
25
+ * Start time of current session
26
+ */
27
+ private _started;
28
+ /**
29
+ * Last known activity of the session
30
+ */
31
+ private _lastActivity;
32
+ /**
33
+ * Sequence ID specific to replay updates
34
+ */
35
+ private _sequenceId;
36
+ private options;
37
+ constructor(session?: Partial<SessionObject>, { stickySession }?: SessionOptions);
38
+ get id(): string;
39
+ get started(): number;
40
+ get lastActivity(): number;
41
+ set lastActivity(newDate: number);
42
+ get sequenceId(): number;
43
+ set sequenceId(id: number);
44
+ toJSON(): SessionObject;
45
+ }
46
+ 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,14 @@
1
+ import { Session } from './Session';
2
+ interface CreateSessionParams {
3
+ /**
4
+ * Should save to sessionStorage?
5
+ */
6
+ stickySession: boolean;
7
+ }
8
+ /**
9
+ * Create a new session, which in its current implementation is a Sentry event
10
+ * that all replays will be saved to as attachments. Currently, we only expect
11
+ * one of these Sentry events per "replay session".
12
+ */
13
+ export declare function createSession({ stickySession, }: CreateSessionParams): Session;
14
+ export {};