@sentry/replay 0.6.5 → 0.6.7-0
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.
- package/dist/config/types/jest.config.d.ts +3 -0
- package/dist/config/types/jest.setup.d.ts +32 -0
- package/dist/config/types/src/blockAllMedia.test.d.ts +1 -0
- package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +3 -0
- package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +5 -0
- package/dist/config/types/src/coreHandlers/handleDom.d.ts +1 -0
- package/dist/config/types/src/coreHandlers/handleFetch.d.ts +19 -0
- package/dist/config/types/src/coreHandlers/handleFetch.test.d.ts +1 -0
- package/dist/config/types/src/coreHandlers/handleHistory.d.ts +7 -0
- package/dist/config/types/src/coreHandlers/handleScope-unit.test.d.ts +1 -0
- package/dist/config/types/src/coreHandlers/handleScope.d.ts +2 -0
- package/dist/config/types/src/coreHandlers/handleScope.test.d.ts +1 -0
- package/dist/config/types/src/coreHandlers/handleXhr.d.ts +21 -0
- package/dist/config/types/src/createPerformanceEntry.d.ts +43 -0
- package/dist/config/types/src/createPerformanceEntry.test.d.ts +1 -0
- package/dist/config/types/src/eventBuffer.d.ts +45 -0
- package/dist/config/types/src/eventBuffer.test.d.ts +1 -0
- package/dist/config/types/src/flags.d.ts +2 -0
- package/dist/config/types/src/flush.test.d.ts +1 -0
- package/dist/config/types/src/index-captureOnlyOnError.test.d.ts +1 -0
- package/dist/config/types/src/index-noSticky.test.d.ts +1 -0
- package/dist/config/types/src/index-sampling.test.d.ts +1 -0
- package/dist/config/types/src/index.d.ts +245 -0
- package/dist/config/types/src/index.test.d.ts +1 -0
- package/dist/config/types/src/multiple-instances.test.d.ts +1 -0
- package/dist/config/types/src/session/Session.d.ts +63 -0
- package/dist/config/types/src/session/Session.test.d.ts +1 -0
- package/dist/config/types/src/session/constants.d.ts +6 -0
- package/dist/config/types/src/session/createSession.d.ts +19 -0
- package/dist/config/types/src/session/createSession.test.d.ts +1 -0
- package/dist/config/types/src/session/deleteSession.d.ts +4 -0
- package/dist/config/types/src/session/deleteSession.test.d.ts +1 -0
- package/dist/config/types/src/session/fetchSession.d.ts +5 -0
- package/dist/config/types/src/session/fetchSession.test.d.ts +1 -0
- package/dist/config/types/src/session/getSession.d.ts +28 -0
- package/dist/config/types/src/session/getSession.test.d.ts +1 -0
- package/dist/config/types/src/session/index.d.ts +1 -0
- package/dist/config/types/src/session/saveSession.d.ts +2 -0
- package/dist/config/types/src/session/saveSession.test.d.ts +1 -0
- package/dist/config/types/src/stop.test.d.ts +1 -0
- package/dist/config/types/src/types.d.ts +105 -0
- package/dist/config/types/src/util/addInternalBreadcrumb.d.ts +5 -0
- package/dist/config/types/src/util/captureInternalException.d.ts +4 -0
- package/dist/config/types/src/util/createBreadcrumb.d.ts +4 -0
- package/dist/config/types/src/util/createPayload.d.ts +5 -0
- package/dist/config/types/src/util/dedupePerformanceEntries.d.ts +10 -0
- package/dist/config/types/src/util/dedupePerformanceEntries.test.d.ts +1 -0
- package/dist/config/types/src/util/isExpired.d.ts +5 -0
- package/dist/config/types/src/util/isExpired.test.d.ts +1 -0
- package/dist/config/types/src/util/isIngestHost.d.ts +4 -0
- package/dist/config/types/src/util/isInternal.d.ts +5 -0
- package/dist/config/types/src/util/isSampled.d.ts +7 -0
- package/dist/config/types/src/util/isSampled.test.d.ts +1 -0
- package/dist/config/types/src/util/isSessionExpired.d.ts +5 -0
- package/dist/config/types/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/config/types/src/util/logger.d.ts +12 -0
- package/dist/config/types/test/fixtures/performanceEntry/lcp.d.ts +1 -0
- package/dist/config/types/test/fixtures/performanceEntry/navigation.d.ts +1 -0
- package/dist/config/types/test/fixtures/performanceEntry/resource.d.ts +1 -0
- package/dist/config/types/test/index.d.ts +3 -0
- package/dist/config/types/test/mocks/mockRrweb.d.ts +15 -0
- package/dist/config/types/test/mocks/mockSdk.d.ts +10 -0
- package/dist/index.es.js +20 -5
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/types/src/session/constants.d.ts +1 -0
- package/dist/types/src/util/isSessionExpired.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
|
|
2
|
+
export declare type RecordingEvent = eventWithTime;
|
|
3
|
+
export declare type RecordingOptions = recordOptions<eventWithTime>;
|
|
4
|
+
export declare type RecordedEvents = Uint8Array | string;
|
|
5
|
+
export declare type AllPerformanceEntry = PerformancePaintTiming | PerformanceResourceTiming | PerformanceNavigationTiming;
|
|
6
|
+
export interface SendReplayRequest {
|
|
7
|
+
endpoint: string;
|
|
8
|
+
events: RecordedEvents;
|
|
9
|
+
replayId: string;
|
|
10
|
+
segmentId: number;
|
|
11
|
+
includeReplayStartTimestamp: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
|
|
14
|
+
export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
|
|
15
|
+
export declare type InstrumentationType = InstrumentationTypeBreadcrumb | InstrumentationTypeSpan | 'console' | 'error' | 'unhandledrejection';
|
|
16
|
+
/**
|
|
17
|
+
* The request payload to worker
|
|
18
|
+
*/
|
|
19
|
+
export interface WorkerRequest {
|
|
20
|
+
id: number;
|
|
21
|
+
method: string;
|
|
22
|
+
args: any[];
|
|
23
|
+
}
|
|
24
|
+
declare global {
|
|
25
|
+
const __SENTRY_REPLAY_VERSION__: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The response from the worker
|
|
29
|
+
*/
|
|
30
|
+
export interface WorkerResponse {
|
|
31
|
+
id: number;
|
|
32
|
+
method: string;
|
|
33
|
+
success: boolean;
|
|
34
|
+
response: string | Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
export interface ReplayPluginOptions {
|
|
37
|
+
/**
|
|
38
|
+
* The amount of time to wait before sending a replay
|
|
39
|
+
*/
|
|
40
|
+
flushMinDelay?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The max amount of time to wait before sending a replay
|
|
43
|
+
*/
|
|
44
|
+
flushMaxDelay?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The amount of time to buffer the initial snapshot
|
|
47
|
+
*/
|
|
48
|
+
initialFlushDelay?: number;
|
|
49
|
+
/**
|
|
50
|
+
* If false, will create a new session per pageload
|
|
51
|
+
*/
|
|
52
|
+
stickySession?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Attempt to use compression when web workers are available
|
|
55
|
+
*
|
|
56
|
+
* (default is true)
|
|
57
|
+
*/
|
|
58
|
+
useCompression?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Only capture replays when an error happens
|
|
61
|
+
*/
|
|
62
|
+
captureOnlyOnError?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The sampling rate for replays. 1.0 will record all replays, 0 will record none.
|
|
65
|
+
*/
|
|
66
|
+
replaysSamplingRate?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Mask all text in recordings. All text will be replaced with asterisks by default.
|
|
69
|
+
*/
|
|
70
|
+
maskAllText?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Block all media (e.g. images, svg, video) in recordings.
|
|
73
|
+
*/
|
|
74
|
+
blockAllMedia?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface ReplayConfiguration extends ReplayPluginOptions, RecordingOptions {
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Some initial state captured before creating a root replay event
|
|
80
|
+
*/
|
|
81
|
+
export interface InitialState {
|
|
82
|
+
timestamp: number;
|
|
83
|
+
url: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Additional context that will be sent w/ `replay_event`
|
|
87
|
+
*/
|
|
88
|
+
export interface ReplayEventContext {
|
|
89
|
+
/**
|
|
90
|
+
* Set of Sentry error ids that have occurred during a replay segment
|
|
91
|
+
*/
|
|
92
|
+
errorIds: Set<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Set of Sentry trace ids that have occurred during a replay segment
|
|
95
|
+
*/
|
|
96
|
+
traceIds: Set<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Ordered list of URLs that have been visited during a replay segment
|
|
99
|
+
*/
|
|
100
|
+
urls: string[];
|
|
101
|
+
/**
|
|
102
|
+
* The timestamp of the earliest event that has been added to event buffer. This can happen due to the Performance Observer which buffers events.
|
|
103
|
+
*/
|
|
104
|
+
earliestEvent: number | null;
|
|
105
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Breadcrumb } from '@sentry/types';
|
|
2
|
+
declare type RequiredProperties = 'category' | 'message';
|
|
3
|
+
export default function createBreadcrumb(breadcrumb: Pick<Breadcrumb, RequiredProperties> & Partial<Omit<Breadcrumb, RequiredProperties>>): Breadcrumb;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* There are some difficulties diagnosing why there are duplicate navigation
|
|
3
|
+
* entries. We've witnessed several intermittent results:
|
|
4
|
+
* - duplicate entries have duration = 0
|
|
5
|
+
* - duplicate entries are the same object reference
|
|
6
|
+
* - none of the above
|
|
7
|
+
*
|
|
8
|
+
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
9
|
+
*/
|
|
10
|
+
export declare function dedupePerformanceEntries(currentList: PerformanceEntryList, newList: PerformanceEntryList): PerformancePaintTiming[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
trace: (...args: unknown[]) => void;
|
|
11
|
+
};
|
|
12
|
+
export { logger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PerformanceEntryLcp(obj?: Partial<PerformancePaintTiming>): PerformancePaintTiming;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PerformanceEntryNavigation(obj?: Partial<PerformanceNavigationTiming>): PerformanceNavigationTiming;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PerformanceEntryResource(obj?: Partial<PerformanceResourceTiming>): PerformanceResourceTiming;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { RecordingEvent } from '../../src/types';
|
|
3
|
+
declare type RecordAdditionalProperties = {
|
|
4
|
+
takeFullSnapshot: jest.Mock;
|
|
5
|
+
addCustomEvent: () => void;
|
|
6
|
+
freezePage: () => void;
|
|
7
|
+
mirror: unknown;
|
|
8
|
+
_emitter: (event: RecordingEvent, ...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,10 @@
|
|
|
1
|
+
import { BrowserOptions } from '@sentry/browser';
|
|
2
|
+
import { ReplayConfiguration } from '../../src/types';
|
|
3
|
+
interface MockSdkParams {
|
|
4
|
+
replayOptions?: ReplayConfiguration;
|
|
5
|
+
sentryOptions?: BrowserOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare function mockSdk({ replayOptions, sentryOptions, }?: MockSdkParams): Promise<{
|
|
8
|
+
replay: import("../../src").Replay;
|
|
9
|
+
}>;
|
|
10
|
+
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -142,12 +142,14 @@ function getBreadcrumbHandler(type) {
|
|
|
142
142
|
return handleDom;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
var isBrowser$1 = typeof window !== 'undefined';
|
|
145
146
|
/**
|
|
146
147
|
* Returns true if we are currently recording an internal to Sentry replay
|
|
147
148
|
* (e.g. on https://sentry.io )
|
|
148
149
|
*/
|
|
149
150
|
function isInternal() {
|
|
150
|
-
return
|
|
151
|
+
return (isBrowser$1 &&
|
|
152
|
+
['sentry.io', 'dev.getsentry.net'].includes(window.location.host));
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
/**
|
|
@@ -248,6 +250,8 @@ var REPLAY_EVENT_NAME = 'replay_event';
|
|
|
248
250
|
var SESSION_IDLE_DURATION = 300000; // 5 minutes in ms
|
|
249
251
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
250
252
|
var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
253
|
+
// The maximum length of a session
|
|
254
|
+
var MAX_SESSION_LIFE = 1800000; // 30 minutes
|
|
251
255
|
|
|
252
256
|
/**
|
|
253
257
|
* Deletes a session from storage
|
|
@@ -285,9 +289,14 @@ function isExpired(initialTime, expiry, targetTime) {
|
|
|
285
289
|
/**
|
|
286
290
|
* Checks to see if session is expired
|
|
287
291
|
*/
|
|
288
|
-
function isSessionExpired(session,
|
|
292
|
+
function isSessionExpired(session, idleTimeout, targetTime) {
|
|
289
293
|
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
290
|
-
return
|
|
294
|
+
return (
|
|
295
|
+
// First, check that maximum session length has not been exceeded
|
|
296
|
+
isExpired(session.started, MAX_SESSION_LIFE, targetTime) ||
|
|
297
|
+
// check that the idle timeout has not been exceeded (i.e. user has
|
|
298
|
+
// performed an action within the last `idleTimeout` ms)
|
|
299
|
+
isExpired(session === null || session === void 0 ? void 0 : session.lastActivity, idleTimeout, targetTime));
|
|
291
300
|
}
|
|
292
301
|
|
|
293
302
|
function wrapLogger(logFn) {
|
|
@@ -1471,6 +1480,13 @@ var Replay = /** @class */ (function () {
|
|
|
1471
1480
|
// requires coordination with frontend
|
|
1472
1481
|
var isMs = event.timestamp > 9999999999;
|
|
1473
1482
|
var timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
1483
|
+
// Throw out events that happen more than 5 minutes ago. This can happen if
|
|
1484
|
+
// page has been left open and idle for a long period of time and user
|
|
1485
|
+
// comes back to trigger a new session. The performance entries rely on
|
|
1486
|
+
// `performance.timeOrigin`, which is when the page first opened.
|
|
1487
|
+
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1474
1490
|
// Only record earliest event if a new session was created, otherwise it
|
|
1475
1491
|
// shouldn't be relevant
|
|
1476
1492
|
if (this.newSessionCreated &&
|
|
@@ -1699,7 +1715,7 @@ var Replay = /** @class */ (function () {
|
|
|
1699
1715
|
timestamp = new Date().getTime();
|
|
1700
1716
|
sdkInfo = {
|
|
1701
1717
|
name: 'sentry.javascript.integration.replay',
|
|
1702
|
-
version: "0.6.
|
|
1718
|
+
version: "0.6.7-0",
|
|
1703
1719
|
};
|
|
1704
1720
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1705
1721
|
var _a;
|
|
@@ -1805,7 +1821,6 @@ var Replay = /** @class */ (function () {
|
|
|
1805
1821
|
ex_1 = _b.sent();
|
|
1806
1822
|
console.error(ex_1);
|
|
1807
1823
|
// Capture error for every failed replay
|
|
1808
|
-
// TODO: Remove this before GA as this will create an error on customer's project
|
|
1809
1824
|
setContext('Replays', {
|
|
1810
1825
|
retryCount: this.retryCount,
|
|
1811
1826
|
});
|
package/dist/index.js
CHANGED
|
@@ -150,12 +150,14 @@ function getBreadcrumbHandler(type) {
|
|
|
150
150
|
return handleDom;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
var isBrowser$1 = typeof window !== 'undefined';
|
|
153
154
|
/**
|
|
154
155
|
* Returns true if we are currently recording an internal to Sentry replay
|
|
155
156
|
* (e.g. on https://sentry.io )
|
|
156
157
|
*/
|
|
157
158
|
function isInternal() {
|
|
158
|
-
return
|
|
159
|
+
return (isBrowser$1 &&
|
|
160
|
+
['sentry.io', 'dev.getsentry.net'].includes(window.location.host));
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
/**
|
|
@@ -256,6 +258,8 @@ var REPLAY_EVENT_NAME = 'replay_event';
|
|
|
256
258
|
var SESSION_IDLE_DURATION = 300000; // 5 minutes in ms
|
|
257
259
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
258
260
|
var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
261
|
+
// The maximum length of a session
|
|
262
|
+
var MAX_SESSION_LIFE = 1800000; // 30 minutes
|
|
259
263
|
|
|
260
264
|
/**
|
|
261
265
|
* Deletes a session from storage
|
|
@@ -293,9 +297,14 @@ function isExpired(initialTime, expiry, targetTime) {
|
|
|
293
297
|
/**
|
|
294
298
|
* Checks to see if session is expired
|
|
295
299
|
*/
|
|
296
|
-
function isSessionExpired(session,
|
|
300
|
+
function isSessionExpired(session, idleTimeout, targetTime) {
|
|
297
301
|
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
298
|
-
return
|
|
302
|
+
return (
|
|
303
|
+
// First, check that maximum session length has not been exceeded
|
|
304
|
+
isExpired(session.started, MAX_SESSION_LIFE, targetTime) ||
|
|
305
|
+
// check that the idle timeout has not been exceeded (i.e. user has
|
|
306
|
+
// performed an action within the last `idleTimeout` ms)
|
|
307
|
+
isExpired(session === null || session === void 0 ? void 0 : session.lastActivity, idleTimeout, targetTime));
|
|
299
308
|
}
|
|
300
309
|
|
|
301
310
|
function wrapLogger(logFn) {
|
|
@@ -1479,6 +1488,13 @@ var Replay = /** @class */ (function () {
|
|
|
1479
1488
|
// requires coordination with frontend
|
|
1480
1489
|
var isMs = event.timestamp > 9999999999;
|
|
1481
1490
|
var timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
1491
|
+
// Throw out events that happen more than 5 minutes ago. This can happen if
|
|
1492
|
+
// page has been left open and idle for a long period of time and user
|
|
1493
|
+
// comes back to trigger a new session. The performance entries rely on
|
|
1494
|
+
// `performance.timeOrigin`, which is when the page first opened.
|
|
1495
|
+
if (timestampInMs + SESSION_IDLE_DURATION < new Date().getTime()) {
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1482
1498
|
// Only record earliest event if a new session was created, otherwise it
|
|
1483
1499
|
// shouldn't be relevant
|
|
1484
1500
|
if (this.newSessionCreated &&
|
|
@@ -1707,7 +1723,7 @@ var Replay = /** @class */ (function () {
|
|
|
1707
1723
|
timestamp = new Date().getTime();
|
|
1708
1724
|
sdkInfo = {
|
|
1709
1725
|
name: 'sentry.javascript.integration.replay',
|
|
1710
|
-
version: "0.6.
|
|
1726
|
+
version: "0.6.7-0",
|
|
1711
1727
|
};
|
|
1712
1728
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1713
1729
|
var _a;
|
|
@@ -1813,7 +1829,6 @@ var Replay = /** @class */ (function () {
|
|
|
1813
1829
|
ex_1 = _b.sent();
|
|
1814
1830
|
console.error(ex_1);
|
|
1815
1831
|
// Capture error for every failed replay
|
|
1816
|
-
// TODO: Remove this before GA as this will create an error on customer's project
|
|
1817
1832
|
core.setContext('Replays', {
|
|
1818
1833
|
retryCount: this.retryCount,
|
|
1819
1834
|
});
|