@sentry/replay 0.5.14 → 0.5.16
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/src/api/captureReplayEvent.d.ts +22 -0
- package/dist/config/types/src/createPerformanceEntry.d.ts +2 -1
- package/dist/config/types/src/index.d.ts +14 -6
- package/dist/config/types/src/session/constants.d.ts +2 -2
- package/dist/config/types/src/session/deleteSession.test.d.ts +1 -0
- package/dist/config/types/src/stop.test.d.ts +1 -0
- package/dist/config/types/src/types.d.ts +1 -0
- package/dist/index.es.js +116 -53
- package/dist/index.js +120 -53
- package/dist/index.js.map +1 -1
- package/dist/types/src/api/captureReplayEvent.d.ts +22 -0
- package/dist/types/src/createPerformanceEntry.d.ts +2 -1
- package/dist/types/src/index.d.ts +14 -6
- package/dist/types/src/session/constants.d.ts +2 -2
- package/dist/types/src/types.d.ts +1 -0
- package/package.json +3 -1
- package/dist/config/types/src/api/captureReplay.d.ts +0 -10
- package/dist/config/types/src/api/captureReplayUpdate.d.ts +0 -12
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import { InitialState } from '@/types';
|
|
2
2
|
export interface CaptureReplayEventParams {
|
|
3
|
+
/**
|
|
4
|
+
* Initial state of the replay
|
|
5
|
+
*/
|
|
3
6
|
initialState: InitialState;
|
|
7
|
+
/**
|
|
8
|
+
* Include a timestamp that should be deemed as the "starting" timestamp of the
|
|
9
|
+
* replay. This usually comes from a `window.performance` entry.
|
|
10
|
+
*/
|
|
4
11
|
includeReplayStartTimestamp: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* List of error ids contained in current recording segment
|
|
14
|
+
*/
|
|
5
15
|
errorIds: string[];
|
|
16
|
+
/**
|
|
17
|
+
* The current replay id
|
|
18
|
+
*/
|
|
6
19
|
replayId: string;
|
|
20
|
+
/**
|
|
21
|
+
* The current recording segment id
|
|
22
|
+
*/
|
|
7
23
|
segmentId: number;
|
|
8
24
|
/**
|
|
9
25
|
* Timestamp of the event in milliseconds
|
|
10
26
|
*/
|
|
11
27
|
timestamp: number;
|
|
28
|
+
/**
|
|
29
|
+
* List of trace ids contained in current recording segment
|
|
30
|
+
*/
|
|
12
31
|
traceIds: string[];
|
|
32
|
+
/**
|
|
33
|
+
* List of URLs visisted in current recording segment
|
|
34
|
+
*/
|
|
13
35
|
urls: string[];
|
|
14
36
|
}
|
|
15
37
|
export declare function captureReplayEvent({ initialState, includeReplayStartTimestamp, errorIds, replayId: replay_id, segmentId: segment_id, timestamp, traceIds, urls, }: CaptureReplayEventParams): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AllPerformanceEntry } from './types';
|
|
1
2
|
export interface ReplayPerformanceEntry {
|
|
2
3
|
/**
|
|
3
4
|
* One of these types https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType
|
|
@@ -25,7 +26,7 @@ interface MemoryInfo {
|
|
|
25
26
|
totalJSHeapSize: number;
|
|
26
27
|
usedJSHeapSize: number;
|
|
27
28
|
}
|
|
28
|
-
export declare function createPerformanceEntries(entries:
|
|
29
|
+
export declare function createPerformanceEntries(entries: AllPerformanceEntry[]): ReplayPerformanceEntry[];
|
|
29
30
|
export declare function createMemoryEntry(memoryEntry: MemoryInfo): {
|
|
30
31
|
type: string;
|
|
31
32
|
name: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import { Breadcrumb, Event, Integration } from '@sentry/types';
|
|
2
3
|
import { CaptureReplayEventParams } from './api/captureReplayEvent';
|
|
3
4
|
import { Session } from './session/Session';
|
|
4
5
|
import { ReplayPerformanceEntry } from './createPerformanceEntry';
|
|
5
6
|
import { IEventBuffer } from './eventBuffer';
|
|
6
|
-
import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
7
|
+
import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
7
8
|
/**
|
|
8
9
|
* Returns true to return control to calling function, otherwise continue with normal batching
|
|
9
10
|
*/
|
|
@@ -21,7 +22,7 @@ export declare class SentryReplay implements Integration {
|
|
|
21
22
|
/**
|
|
22
23
|
* List of PerformanceEntry from PerformanceObserver
|
|
23
24
|
*/
|
|
24
|
-
performanceEvents:
|
|
25
|
+
performanceEvents: AllPerformanceEntry[];
|
|
25
26
|
/**
|
|
26
27
|
* Options to pass to `rrweb.record()`
|
|
27
28
|
*/
|
|
@@ -45,6 +46,7 @@ export declare class SentryReplay implements Integration {
|
|
|
45
46
|
* slightly differently in this case: `replay_start_timestamp` is included.
|
|
46
47
|
*/
|
|
47
48
|
private newSessionCreated;
|
|
49
|
+
private flushLock;
|
|
48
50
|
/**
|
|
49
51
|
* Is the integration currently active?
|
|
50
52
|
*/
|
|
@@ -209,19 +211,25 @@ export declare class SentryReplay implements Integration {
|
|
|
209
211
|
* Only flush if `captureOnlyOnError` is false.
|
|
210
212
|
*/
|
|
211
213
|
conditionalFlush(): Promise<void> | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Clear context
|
|
216
|
+
*/
|
|
217
|
+
clearContext(): void;
|
|
212
218
|
/**
|
|
213
219
|
* Return and clear context
|
|
214
220
|
*/
|
|
215
|
-
popEventContext({ timestamp, }
|
|
216
|
-
timestamp
|
|
217
|
-
}): CaptureReplayEventParams
|
|
221
|
+
popEventContext({ timestamp, }: {
|
|
222
|
+
timestamp: number;
|
|
223
|
+
}): Omit<CaptureReplayEventParams, 'includeReplayStartTimestamp' | 'segmentId' | 'replayId'>;
|
|
224
|
+
runFlush(): Promise<void>;
|
|
218
225
|
/**
|
|
219
226
|
* Flushes replay event buffer to Sentry.
|
|
220
227
|
*
|
|
221
228
|
* Performance events are only added right before flushing - this is probably
|
|
222
229
|
* due to the buffered performance observer events.
|
|
223
230
|
*/
|
|
224
|
-
flushUpdate()
|
|
231
|
+
flushUpdate: () => Promise<void>;
|
|
232
|
+
throttledFlushUpdate: import("lodash").DebouncedFunc<() => Promise<void>>;
|
|
225
233
|
/**
|
|
226
234
|
* Send replay attachment using `fetch()`
|
|
227
235
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const REPLAY_SESSION_KEY = "sentryReplaySession";
|
|
2
2
|
export declare const REPLAY_EVENT_NAME = "replay_event";
|
|
3
3
|
export declare const RECORDING_EVENT_NAME = "replay_recording";
|
|
4
|
-
export declare const SESSION_IDLE_DURATION =
|
|
5
|
-
export declare const VISIBILITY_CHANGE_TIMEOUT =
|
|
4
|
+
export declare const SESSION_IDLE_DURATION = 300000;
|
|
5
|
+
export declare const VISIBILITY_CHANGE_TIMEOUT = 300000;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import type { eventWithTime } from 'rrweb/typings/types';
|
|
|
3
3
|
export declare type RecordingEvent = eventWithTime;
|
|
4
4
|
export declare type RecordingConfig = Parameters<typeof record>[0];
|
|
5
5
|
export declare type RecordedEvents = Uint8Array | string;
|
|
6
|
+
export declare type AllPerformanceEntry = PerformancePaintTiming | PerformanceResourceTiming | PerformanceNavigationTiming;
|
|
6
7
|
export interface ReplayRequest {
|
|
7
8
|
endpoint: string;
|
|
8
9
|
events: RecordedEvents;
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, setContext, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
|
|
2
2
|
import { htmlTreeAsString, logger as logger$1, uuid4, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
3
4
|
import { record, EventType } from 'rrweb';
|
|
4
5
|
|
|
5
6
|
/******************************************************************************
|
|
@@ -91,17 +92,17 @@ function __spreadArray(to, from, pack) {
|
|
|
91
92
|
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
92
93
|
var REPLAY_EVENT_NAME = 'replay_event';
|
|
93
94
|
// The idle limit for a session
|
|
94
|
-
var SESSION_IDLE_DURATION =
|
|
95
|
+
var SESSION_IDLE_DURATION = 300000; // 5 minutes in ms
|
|
95
96
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
96
97
|
var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
97
98
|
|
|
98
99
|
function captureReplayEvent(_a) {
|
|
99
100
|
var initialState = _a.initialState, includeReplayStartTimestamp = _a.includeReplayStartTimestamp, errorIds = _a.errorIds, replay_id = _a.replayId, segment_id = _a.segmentId, timestamp = _a.timestamp, traceIds = _a.traceIds, urls = _a.urls;
|
|
100
|
-
captureEvent(__assign(__assign(
|
|
101
|
+
captureEvent(__assign(__assign({
|
|
101
102
|
// @ts-expect-error replay_event is a new event type
|
|
102
103
|
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
103
104
|
? { replay_start_timestamp: initialState.timestamp / 1000 }
|
|
104
|
-
: {})),
|
|
105
|
+
: {})), { timestamp: timestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls: urls, replay_id: replay_id, segment_id: segment_id }), { event_id: replay_id });
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
function createBreadcrumb(breadcrumb) {
|
|
@@ -521,7 +522,11 @@ function createPaintEntry(entry) {
|
|
|
521
522
|
}
|
|
522
523
|
function createNavigationEntry(entry) {
|
|
523
524
|
// TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
|
|
524
|
-
var entryType = entry.entryType, name = entry.name, domComplete = entry.domComplete, startTime = entry.startTime, transferSize = entry.transferSize, type = entry.type;
|
|
525
|
+
var entryType = entry.entryType, name = entry.name, duration = entry.duration, domComplete = entry.domComplete, startTime = entry.startTime, transferSize = entry.transferSize, type = entry.type;
|
|
526
|
+
// Ignore entries with no duration, they do not seem to be useful and cause dupes
|
|
527
|
+
if (duration === 0) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
525
530
|
return {
|
|
526
531
|
type: "".concat(entryType, ".").concat(type),
|
|
527
532
|
start: getAbsoluteTime(startTime),
|
|
@@ -529,11 +534,12 @@ function createNavigationEntry(entry) {
|
|
|
529
534
|
name: name,
|
|
530
535
|
data: {
|
|
531
536
|
size: transferSize,
|
|
537
|
+
duration: duration,
|
|
532
538
|
},
|
|
533
539
|
};
|
|
534
540
|
}
|
|
535
541
|
function createResourceEntry(entry) {
|
|
536
|
-
var entryType = entry.entryType, initiatorType = entry.initiatorType, name = entry.name, responseEnd = entry.responseEnd, startTime = entry.startTime, transferSize = entry.transferSize;
|
|
542
|
+
var entryType = entry.entryType, initiatorType = entry.initiatorType, name = entry.name, responseEnd = entry.responseEnd, startTime = entry.startTime, encodedBodySize = entry.encodedBodySize, transferSize = entry.transferSize;
|
|
537
543
|
// Do not capture fetches to Sentry ingestion endpoint
|
|
538
544
|
if (isIngestHost(name)) {
|
|
539
545
|
return null;
|
|
@@ -549,6 +555,7 @@ function createResourceEntry(entry) {
|
|
|
549
555
|
name: name,
|
|
550
556
|
data: {
|
|
551
557
|
size: transferSize,
|
|
558
|
+
encodedBodySize: encodedBodySize,
|
|
552
559
|
},
|
|
553
560
|
};
|
|
554
561
|
}
|
|
@@ -561,6 +568,7 @@ function createLargestContentfulPaint(entry) {
|
|
|
561
568
|
start: start,
|
|
562
569
|
end: start + duration,
|
|
563
570
|
data: {
|
|
571
|
+
duration: duration,
|
|
564
572
|
size: size,
|
|
565
573
|
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
566
574
|
nodeId: record.mirror.getId(entry.element),
|
|
@@ -659,7 +667,6 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
659
667
|
method: 'addEvent',
|
|
660
668
|
args: [event],
|
|
661
669
|
});
|
|
662
|
-
logger.log('Message posted to worker');
|
|
663
670
|
// XXX: See note in `get length()`
|
|
664
671
|
_this.eventBufferItemLength++;
|
|
665
672
|
return promise;
|
|
@@ -808,6 +815,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
808
815
|
* slightly differently in this case: `replay_start_timestamp` is included.
|
|
809
816
|
*/
|
|
810
817
|
this.newSessionCreated = false;
|
|
818
|
+
this.flushLock = null;
|
|
811
819
|
/**
|
|
812
820
|
* Is the integration currently active?
|
|
813
821
|
*/
|
|
@@ -921,6 +929,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
921
929
|
var breadcrumb = createBreadcrumb({
|
|
922
930
|
category: 'ui.blur',
|
|
923
931
|
});
|
|
932
|
+
// Do not count blur as a user action -- it's part of the process of them
|
|
933
|
+
// leaving the page
|
|
924
934
|
_this.doChangeToBackgroundTasks(breadcrumb);
|
|
925
935
|
};
|
|
926
936
|
/**
|
|
@@ -930,6 +940,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
930
940
|
var breadcrumb = createBreadcrumb({
|
|
931
941
|
category: 'ui.focus',
|
|
932
942
|
});
|
|
943
|
+
// Do not count focus as a user action -- instead wait until they focus and
|
|
944
|
+
// interactive with page
|
|
933
945
|
_this.doChangeToForegroundTasks(breadcrumb);
|
|
934
946
|
};
|
|
935
947
|
/**
|
|
@@ -950,6 +962,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
950
962
|
if (type === 'history') {
|
|
951
963
|
// Need to collect visited URLs
|
|
952
964
|
_this.context.urls.push(result.name);
|
|
965
|
+
_this.updateLastActivity();
|
|
953
966
|
}
|
|
954
967
|
_this.addUpdate(function () {
|
|
955
968
|
_this.createPerformanceSpans([result]);
|
|
@@ -976,6 +989,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
976
989
|
if (result.category === 'sentry.transaction') {
|
|
977
990
|
return;
|
|
978
991
|
}
|
|
992
|
+
if (result.category === 'ui.click') {
|
|
993
|
+
_this.updateLastActivity();
|
|
994
|
+
}
|
|
979
995
|
_this.addUpdate(function () {
|
|
980
996
|
_this.addEvent({
|
|
981
997
|
type: EventType.Custom,
|
|
@@ -998,6 +1014,63 @@ var SentryReplay = /** @class */ (function () {
|
|
|
998
1014
|
var newEntries = new Set(list.getEntries());
|
|
999
1015
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1000
1016
|
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Flushes replay event buffer to Sentry.
|
|
1019
|
+
*
|
|
1020
|
+
* Performance events are only added right before flushing - this is probably
|
|
1021
|
+
* due to the buffered performance observer events.
|
|
1022
|
+
*/
|
|
1023
|
+
this.flushUpdate = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1024
|
+
var err_1;
|
|
1025
|
+
var _a;
|
|
1026
|
+
return __generator(this, function (_b) {
|
|
1027
|
+
switch (_b.label) {
|
|
1028
|
+
case 0:
|
|
1029
|
+
if (!this.isEnabled) {
|
|
1030
|
+
// This is just a precaution, there should be no listeners that would
|
|
1031
|
+
// cause a flush.
|
|
1032
|
+
return [2 /*return*/];
|
|
1033
|
+
}
|
|
1034
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
1035
|
+
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1036
|
+
return [2 /*return*/];
|
|
1037
|
+
}
|
|
1038
|
+
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1039
|
+
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1040
|
+
return [2 /*return*/];
|
|
1041
|
+
}
|
|
1042
|
+
// Since flushing, ensure other queued flushes are cancelled
|
|
1043
|
+
// We do this regardless of having a queued flush since the event updates
|
|
1044
|
+
// will be handled by queued flush
|
|
1045
|
+
clearTimeout(this.timeout);
|
|
1046
|
+
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1047
|
+
this.flushLock = this.runFlush();
|
|
1048
|
+
return [4 /*yield*/, this.flushLock];
|
|
1049
|
+
case 1:
|
|
1050
|
+
_b.sent();
|
|
1051
|
+
this.flushLock = null;
|
|
1052
|
+
return [2 /*return*/];
|
|
1053
|
+
case 2:
|
|
1054
|
+
_b.trys.push([2, 4, 5, 6]);
|
|
1055
|
+
return [4 /*yield*/, this.flushLock];
|
|
1056
|
+
case 3:
|
|
1057
|
+
_b.sent();
|
|
1058
|
+
return [3 /*break*/, 6];
|
|
1059
|
+
case 4:
|
|
1060
|
+
err_1 = _b.sent();
|
|
1061
|
+
console.error(err_1);
|
|
1062
|
+
return [3 /*break*/, 6];
|
|
1063
|
+
case 5:
|
|
1064
|
+
this.throttledFlushUpdate();
|
|
1065
|
+
return [7 /*endfinally*/];
|
|
1066
|
+
case 6: return [2 /*return*/];
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}); };
|
|
1070
|
+
this.throttledFlushUpdate = throttle(this.flushUpdate, 1000, {
|
|
1071
|
+
leading: false,
|
|
1072
|
+
trailing: true,
|
|
1073
|
+
});
|
|
1001
1074
|
this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
|
|
1002
1075
|
this.options = {
|
|
1003
1076
|
flushMinDelay: flushMinDelay,
|
|
@@ -1043,6 +1116,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1043
1116
|
// If session was not sampled, then we do not initialize the integration at all.
|
|
1044
1117
|
return;
|
|
1045
1118
|
}
|
|
1119
|
+
// setup() is generally called on page load or manually - in both cases we
|
|
1120
|
+
// should treat it as an activity
|
|
1121
|
+
this.updateLastActivity();
|
|
1046
1122
|
this.eventBuffer = createEventBuffer({
|
|
1047
1123
|
useCompression: Boolean(this.options.useCompression),
|
|
1048
1124
|
});
|
|
@@ -1151,8 +1227,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1151
1227
|
var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
|
|
1152
1228
|
var url = "".concat(window.location.origin).concat(urlPath);
|
|
1153
1229
|
this.performanceEvents = [];
|
|
1230
|
+
this.initialEventTimestampSinceFlush = null;
|
|
1154
1231
|
// Reset context as well
|
|
1155
|
-
this.
|
|
1232
|
+
this.clearContext();
|
|
1156
1233
|
this.initialState = {
|
|
1157
1234
|
timestamp: new Date().getTime(),
|
|
1158
1235
|
url: url,
|
|
@@ -1282,8 +1359,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1282
1359
|
// requires coordination with frontend
|
|
1283
1360
|
var isMs = event.timestamp > 9999999999;
|
|
1284
1361
|
var timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
1285
|
-
if
|
|
1286
|
-
|
|
1362
|
+
// Only record earliest event if a new session was created, otherwise it
|
|
1363
|
+
// shouldn't be relevant
|
|
1364
|
+
if (this.newSessionCreated &&
|
|
1365
|
+
(!this.context.earliestEvent ||
|
|
1366
|
+
timestampInMs < this.context.earliestEvent)) {
|
|
1287
1367
|
this.context.earliestEvent = timestampInMs;
|
|
1288
1368
|
}
|
|
1289
1369
|
this.eventBuffer.addEvent(event, isCheckout);
|
|
@@ -1394,11 +1474,20 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1394
1474
|
}
|
|
1395
1475
|
return this.flushUpdate();
|
|
1396
1476
|
};
|
|
1477
|
+
/**
|
|
1478
|
+
* Clear context
|
|
1479
|
+
*/
|
|
1480
|
+
SentryReplay.prototype.clearContext = function () {
|
|
1481
|
+
this.context.errorIds.clear();
|
|
1482
|
+
this.context.traceIds.clear();
|
|
1483
|
+
this.context.urls = [];
|
|
1484
|
+
this.context.earliestEvent = null;
|
|
1485
|
+
};
|
|
1397
1486
|
/**
|
|
1398
1487
|
* Return and clear context
|
|
1399
1488
|
*/
|
|
1400
1489
|
SentryReplay.prototype.popEventContext = function (_a) {
|
|
1401
|
-
var
|
|
1490
|
+
var timestamp = _a.timestamp;
|
|
1402
1491
|
var initialState = this.initialState;
|
|
1403
1492
|
if (this.initialState &&
|
|
1404
1493
|
this.context.earliestEvent &&
|
|
@@ -1412,52 +1501,31 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1412
1501
|
traceIds: Array.from(this.context.traceIds).filter(Boolean),
|
|
1413
1502
|
urls: this.context.urls,
|
|
1414
1503
|
};
|
|
1415
|
-
this.
|
|
1416
|
-
this.context.traceIds.clear();
|
|
1417
|
-
this.context.urls = [];
|
|
1418
|
-
this.context.earliestEvent = null;
|
|
1419
|
-
// @ts-expect-error: Type 'undefined' is not assignable to type 'Session'.ts(2322)
|
|
1504
|
+
this.clearContext();
|
|
1420
1505
|
return context;
|
|
1421
1506
|
};
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
*
|
|
1425
|
-
* Performance events are only added right before flushing - this is probably
|
|
1426
|
-
* due to the buffered performance observer events.
|
|
1427
|
-
*/
|
|
1428
|
-
SentryReplay.prototype.flushUpdate = function () {
|
|
1429
|
-
var _a, _b;
|
|
1507
|
+
SentryReplay.prototype.runFlush = function () {
|
|
1508
|
+
var _a;
|
|
1430
1509
|
return __awaiter(this, void 0, void 0, function () {
|
|
1431
|
-
var timestamp, replayId, newSessionCreated, segmentId, recordingData,
|
|
1432
|
-
return __generator(this, function (
|
|
1433
|
-
switch (
|
|
1510
|
+
var timestamp, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1511
|
+
return __generator(this, function (_b) {
|
|
1512
|
+
switch (_b.label) {
|
|
1434
1513
|
case 0:
|
|
1435
|
-
if (!this.
|
|
1436
|
-
// This is just a precaution, there should be no listeners that would
|
|
1437
|
-
// cause a flush.
|
|
1438
|
-
return [2 /*return*/];
|
|
1439
|
-
}
|
|
1440
|
-
if (!this.checkAndHandleExpiredSession()) {
|
|
1441
|
-
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1442
|
-
return [2 /*return*/];
|
|
1443
|
-
}
|
|
1444
|
-
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1514
|
+
if (!this.session) {
|
|
1445
1515
|
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1446
1516
|
return [2 /*return*/];
|
|
1447
1517
|
}
|
|
1448
|
-
// Since already flushing, ensure other queued flushes are cancelled
|
|
1449
|
-
clearTimeout(this.timeout);
|
|
1450
1518
|
return [4 /*yield*/, this.addPerformanceEntries()];
|
|
1451
1519
|
case 1:
|
|
1452
|
-
|
|
1453
|
-
if (!((
|
|
1520
|
+
_b.sent();
|
|
1521
|
+
if (!((_a = this.eventBuffer) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1454
1522
|
return [2 /*return*/];
|
|
1455
1523
|
}
|
|
1456
1524
|
// Only attach memory event if eventBuffer is not empty
|
|
1457
1525
|
return [4 /*yield*/, this.addMemoryEntry()];
|
|
1458
1526
|
case 2:
|
|
1459
1527
|
// Only attach memory event if eventBuffer is not empty
|
|
1460
|
-
|
|
1528
|
+
_b.sent();
|
|
1461
1529
|
timestamp = new Date().getTime();
|
|
1462
1530
|
replayId = this.session.id;
|
|
1463
1531
|
newSessionCreated = this.newSessionCreated;
|
|
@@ -1465,28 +1533,23 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1465
1533
|
// Reset this to null regardless of `sendReplay` result so that future
|
|
1466
1534
|
// events will get flushed properly
|
|
1467
1535
|
this.initialEventTimestampSinceFlush = null;
|
|
1468
|
-
|
|
1536
|
+
_b.label = 3;
|
|
1469
1537
|
case 3:
|
|
1470
|
-
|
|
1538
|
+
_b.trys.push([3, 6, , 7]);
|
|
1471
1539
|
return [4 /*yield*/, this.eventBuffer.finish()];
|
|
1472
1540
|
case 4:
|
|
1473
|
-
recordingData =
|
|
1541
|
+
recordingData = _b.sent();
|
|
1474
1542
|
return [4 /*yield*/, this.sendReplay(replayId, recordingData, segmentId)];
|
|
1475
1543
|
case 5:
|
|
1476
|
-
|
|
1544
|
+
_b.sent();
|
|
1477
1545
|
// The below will only happen after successfully sending replay //
|
|
1478
|
-
// TBD: Alternatively we could update this after every rrweb event
|
|
1479
|
-
// `timestamp` should reflect when the event happens. e.g. the timestamp
|
|
1480
|
-
// of the event is passed as an argument in the case where a timeout
|
|
1481
|
-
// occurs.
|
|
1482
|
-
this.updateLastActivity(timestamp);
|
|
1483
1546
|
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: timestamp })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1484
1547
|
this.newSessionCreated = false;
|
|
1485
1548
|
return [3 /*break*/, 7];
|
|
1486
1549
|
case 6:
|
|
1487
|
-
|
|
1488
|
-
captureException(
|
|
1489
|
-
console.error(
|
|
1550
|
+
err_2 = _b.sent();
|
|
1551
|
+
captureException(err_2);
|
|
1552
|
+
console.error(err_2);
|
|
1490
1553
|
return [3 /*break*/, 7];
|
|
1491
1554
|
case 7: return [2 /*return*/];
|
|
1492
1555
|
}
|