@sentry/replay 0.5.21 → 0.5.23
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/index.es.js +148 -56
- package/dist/index.js +147 -56
- package/dist/index.js.map +1 -1
- package/dist/{config/types/jest.config.d.ts → jest.config.d.ts} +0 -0
- package/dist/{config/types/jest.setup.d.ts → jest.setup.d.ts} +0 -0
- package/dist/{config/types/src → src}/api/captureReplayEvent.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/getBreadcrumbHandler.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/getSpanHandler.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleDom.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleFetch.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleFetch.test.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleHistory.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleScope-unit.test.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleScope.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleScope.test.d.ts +0 -0
- package/dist/{config/types/src → src}/coreHandlers/handleXhr.d.ts +0 -0
- package/dist/{config/types/src → src}/createPerformanceEntry.d.ts +0 -0
- package/dist/{config/types/src → src}/createPerformanceEntry.test.d.ts +0 -0
- package/dist/{config/types/src → src}/eventBuffer.d.ts +0 -0
- package/dist/{config/types/src → src}/eventBuffer.test.d.ts +0 -0
- package/dist/{config/types/src → src}/flags.d.ts +0 -0
- package/dist/{config/types/src → src}/flush.test.d.ts +0 -0
- package/dist/{config/types/src → src}/index-captureOnlyOnError.test.d.ts +0 -0
- package/dist/{config/types/src → src}/index-noSticky.test.d.ts +0 -0
- package/dist/{config/types/src → src}/index-sampling.test.d.ts +0 -0
- package/dist/{config/types/src → src}/index.d.ts +2 -14
- package/dist/{config/types/src → src}/index.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/Session.d.ts +0 -0
- package/dist/{config/types/src → src}/session/Session.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/constants.d.ts +0 -0
- package/dist/{config/types/src → src}/session/createSession.d.ts +0 -0
- package/dist/{config/types/src → src}/session/createSession.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/deleteSession.d.ts +0 -0
- package/dist/{config/types/src → src}/session/deleteSession.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/fetchSession.d.ts +0 -0
- package/dist/{config/types/src → src}/session/fetchSession.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/getSession.d.ts +0 -0
- package/dist/{config/types/src → src}/session/getSession.test.d.ts +0 -0
- package/dist/{config/types/src → src}/session/index.d.ts +0 -0
- package/dist/{config/types/src → src}/session/saveSession.d.ts +0 -0
- package/dist/{config/types/src → src}/session/saveSession.test.d.ts +0 -0
- package/dist/{config/types/src → src}/stop.test.d.ts +0 -0
- package/dist/{config/types/src → src}/types.d.ts +3 -0
- package/dist/src/util/addInternalBreadcrumb.d.ts +5 -0
- package/dist/{config/types/src → src}/util/createBreadcrumb.d.ts +0 -0
- package/dist/{config/types/src → src}/util/createPayload.d.ts +0 -0
- package/dist/{config/types/src/util/dedupeNavigationEntries.d.ts → src/util/dedupePerformanceEntries.d.ts} +1 -1
- package/dist/{config/types/src/util/isExpired.test.d.ts → src/util/dedupePerformanceEntries.test.d.ts} +0 -0
- package/dist/{config/types/src → src}/util/isExpired.d.ts +0 -0
- package/dist/{config/types/src/util/isSampled.test.d.ts → src/util/isExpired.test.d.ts} +0 -0
- package/dist/{config/types/src → src}/util/isIngestHost.d.ts +0 -0
- package/dist/src/util/isInternal.d.ts +5 -0
- package/dist/{config/types/src → src}/util/isSampled.d.ts +0 -0
- package/dist/{config/types/src/util/isSessionExpired.test.d.ts → src/util/isSampled.test.d.ts} +0 -0
- package/dist/{config/types/src → src}/util/isSessionExpired.d.ts +0 -0
- package/dist/src/util/isSessionExpired.test.d.ts +1 -0
- package/dist/{config/types/src → src}/util/logger.d.ts +0 -0
- package/dist/test/fixtures/performanceEntry/lcp.d.ts +1 -0
- package/dist/test/fixtures/performanceEntry/navigation.d.ts +1 -0
- package/dist/test/fixtures/performanceEntry/resource.d.ts +1 -0
- package/dist/{config/types/test → test}/index.d.ts +0 -0
- package/dist/{config/types/test → test}/mocks/mockRrweb.d.ts +0 -0
- package/dist/{config/types/test → test}/mocks/mockSdk.d.ts +0 -0
- package/dist/types/src/index.d.ts +2 -14
- package/dist/types/src/types.d.ts +3 -0
- package/dist/types/src/util/addInternalBreadcrumb.d.ts +5 -0
- package/dist/types/src/util/dedupePerformanceEntries.d.ts +10 -0
- package/dist/types/src/util/isInternal.d.ts +5 -0
- package/package.json +1 -2
- package/dist/config/types/src/coreHandlers/handleConsole.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, setContext, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
|
|
1
|
+
import { addBreadcrumb, withScope, 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
3
|
import debounce from 'lodash.debounce';
|
|
4
|
-
import throttle from 'lodash.throttle';
|
|
5
4
|
import { record, EventType } from 'rrweb';
|
|
6
5
|
|
|
7
6
|
/******************************************************************************
|
|
@@ -97,13 +96,40 @@ var SESSION_IDLE_DURATION = 300000; // 5 minutes in ms
|
|
|
97
96
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
98
97
|
var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
99
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if we are currently recording an internal to Sentry replay
|
|
101
|
+
* (e.g. on https://sentry.io )
|
|
102
|
+
*/
|
|
103
|
+
function isInternal() {
|
|
104
|
+
return ['sentry.io', 'dev.getsentry.net'].includes(window.location.host);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Wrapper for core SDK's `addBreadcrumb` only when used on `sentry.io`
|
|
109
|
+
*/
|
|
110
|
+
function addInternalBreadcrumb(arg) {
|
|
111
|
+
if (!isInternal()) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
var category = arg.category, level = arg.level, message = arg.message, rest = __rest(arg, ["category", "level", "message"]);
|
|
115
|
+
addBreadcrumb(__assign({ category: category || 'console', level: level || 'debug', message: "[debug]: ".concat(message) }, rest));
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
function captureReplayEvent(_a) {
|
|
101
119
|
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;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
if (segment_id !== 0 && includeReplayStartTimestamp) {
|
|
121
|
+
addInternalBreadcrumb({
|
|
122
|
+
message: "Including replay_start_timestamp on non-initial segment (id: ".concat(segment_id, ")"),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
withScope(function (scope) {
|
|
126
|
+
scope.setTag('replay_sdk_version', "0.5.23");
|
|
127
|
+
captureEvent(__assign(__assign({
|
|
128
|
+
// @ts-expect-error replay_event is a new event type
|
|
129
|
+
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
130
|
+
? { replay_start_timestamp: initialState.timestamp / 1000 }
|
|
131
|
+
: {})), { timestamp: timestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls: urls, replay_id: replay_id, segment_id: segment_id }), { event_id: replay_id });
|
|
132
|
+
});
|
|
107
133
|
}
|
|
108
134
|
|
|
109
135
|
function createBreadcrumb(breadcrumb) {
|
|
@@ -167,7 +193,7 @@ function isIngestHost(targetHost) {
|
|
|
167
193
|
var _b = ((_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
|
|
168
194
|
// XXX: Special case when this integration is used by Sentry on `sentry.io`
|
|
169
195
|
// We would like to capture network requests made to our ingest endpoints for debugging
|
|
170
|
-
if (
|
|
196
|
+
if (isInternal()) {
|
|
171
197
|
return false;
|
|
172
198
|
}
|
|
173
199
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
@@ -493,6 +519,75 @@ function createPayload(_a) {
|
|
|
493
519
|
return payloadWithSequence;
|
|
494
520
|
}
|
|
495
521
|
|
|
522
|
+
var NAVIGATION_ENTRY_KEYS = [
|
|
523
|
+
'name',
|
|
524
|
+
'type',
|
|
525
|
+
'startTime',
|
|
526
|
+
'transferSize',
|
|
527
|
+
'duration',
|
|
528
|
+
];
|
|
529
|
+
function isNavigationEntryEqual(a) {
|
|
530
|
+
return function (b) {
|
|
531
|
+
return NAVIGATION_ENTRY_KEYS.every(function (key) { return a[key] === b[key]; });
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* There are some difficulties diagnosing why there are duplicate navigation
|
|
536
|
+
* entries. We've witnessed several intermittent results:
|
|
537
|
+
* - duplicate entries have duration = 0
|
|
538
|
+
* - duplicate entries are the same object reference
|
|
539
|
+
* - none of the above
|
|
540
|
+
*
|
|
541
|
+
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
542
|
+
*/
|
|
543
|
+
function dedupePerformanceEntries(currentList, newList) {
|
|
544
|
+
// Partition `currentList` into 3 different lists based on entryType
|
|
545
|
+
var _a = currentList.reduce(function (acc, entry) {
|
|
546
|
+
if (entry.entryType === 'navigation') {
|
|
547
|
+
acc[0].push(entry);
|
|
548
|
+
}
|
|
549
|
+
else if (entry.entryType === 'largest-contentful-paint') {
|
|
550
|
+
acc[1].push(entry);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
acc[2].push(entry);
|
|
554
|
+
}
|
|
555
|
+
return acc;
|
|
556
|
+
}, [[], [], []]), existingNavigationEntries = _a[0], existingLcpEntries = _a[1], existingEntries = _a[2];
|
|
557
|
+
var newEntries = [];
|
|
558
|
+
var newNavigationEntries = [];
|
|
559
|
+
var newLcpEntry = existingLcpEntries.length
|
|
560
|
+
? existingLcpEntries[existingLcpEntries.length - 1] // Take the last element as list is sorted
|
|
561
|
+
: undefined;
|
|
562
|
+
newList.forEach(function (entry) {
|
|
563
|
+
if (entry.entryType === 'largest-contentful-paint') {
|
|
564
|
+
// We want the latest LCP event only
|
|
565
|
+
if (!newLcpEntry || newLcpEntry.startTime < entry.startTime) {
|
|
566
|
+
newLcpEntry = entry;
|
|
567
|
+
}
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (entry.entryType === 'navigation') {
|
|
571
|
+
var navigationEntry = entry;
|
|
572
|
+
// Check if the navigation entry is contained in currentList or newList
|
|
573
|
+
if (
|
|
574
|
+
// Ignore any navigation entries with duration 0, as they are likely duplicates
|
|
575
|
+
entry.duration > 0 &&
|
|
576
|
+
// Ensure new entry does not already exist in existing entries
|
|
577
|
+
!existingNavigationEntries.find(isNavigationEntryEqual(navigationEntry)) &&
|
|
578
|
+
// Ensure new entry does not already exist in new list of navigation entries
|
|
579
|
+
!newNavigationEntries.find(isNavigationEntryEqual(navigationEntry))) {
|
|
580
|
+
newNavigationEntries.push(navigationEntry);
|
|
581
|
+
}
|
|
582
|
+
// Otherwise this navigation entry is considered a duplicate and is thrown away
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
newEntries.push(entry);
|
|
586
|
+
});
|
|
587
|
+
// Re-combine and sort by startTime
|
|
588
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (newLcpEntry ? [newLcpEntry] : []), true), existingNavigationEntries, true), existingEntries, true), newEntries, true), newNavigationEntries, true).sort(function (a, b) { return a.startTime - b.startTime; });
|
|
589
|
+
}
|
|
590
|
+
|
|
496
591
|
var _a;
|
|
497
592
|
// Map entryType -> function to normalize data for event
|
|
498
593
|
var ENTRY_TYPES = (_a = {
|
|
@@ -807,12 +902,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
807
902
|
* List of PerformanceEntry from PerformanceObserver
|
|
808
903
|
*/
|
|
809
904
|
this.performanceEvents = [];
|
|
810
|
-
/**
|
|
811
|
-
* The timestamp of the first event since the last flush. This is used to
|
|
812
|
-
* determine if the maximum allowed time has passed before events should be
|
|
813
|
-
* flushed again.
|
|
814
|
-
*/
|
|
815
|
-
this.initialEventTimestampSinceFlush = null;
|
|
816
905
|
this.performanceObserver = null;
|
|
817
906
|
this.retryCount = 0;
|
|
818
907
|
this.retryInterval = BASE_RETRY_INTERVAL;
|
|
@@ -847,7 +936,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
847
936
|
* when an error occurs.
|
|
848
937
|
**/
|
|
849
938
|
this.handleGlobalEvent = function (event) {
|
|
850
|
-
var _a, _b;
|
|
939
|
+
var _a, _b, _c, _d;
|
|
851
940
|
// Do not apply replayId to the root event
|
|
852
941
|
if (
|
|
853
942
|
// @ts-expect-error new event type
|
|
@@ -865,6 +954,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
865
954
|
// XXX: Is it safe to assume that all other events are error events?
|
|
866
955
|
// @ts-expect-error: Type 'undefined' is not assignable to type 'string'.ts(2345)
|
|
867
956
|
_this.context.errorIds.add(event.event_id);
|
|
957
|
+
if (event.exception) {
|
|
958
|
+
var exc = (_d = (_c = event.exception) === null || _c === void 0 ? void 0 : _c.values) === null || _d === void 0 ? void 0 : _d[0];
|
|
959
|
+
addInternalBreadcrumb({
|
|
960
|
+
message: "Tagging event (".concat(event.event_id, ") - ").concat((exc === null || exc === void 0 ? void 0 : exc.type) || 'Unknown', ": ").concat((exc === null || exc === void 0 ? void 0 : exc.value) || 'n/a'),
|
|
961
|
+
});
|
|
962
|
+
}
|
|
868
963
|
// Need to be very careful that this does not cause an infinite loop
|
|
869
964
|
if (_this.options.captureOnlyOnError &&
|
|
870
965
|
event.exception &&
|
|
@@ -888,7 +983,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
888
983
|
return;
|
|
889
984
|
}
|
|
890
985
|
_this.addUpdate(function () {
|
|
891
|
-
var _a;
|
|
986
|
+
var _a, _b;
|
|
892
987
|
// We need to clear existing events on a checkout, otherwise they are
|
|
893
988
|
// incremental event updates and should be appended
|
|
894
989
|
_this.addEvent(event, isCheckout);
|
|
@@ -911,6 +1006,15 @@ var SentryReplay = /** @class */ (function () {
|
|
|
911
1006
|
// for a set amount of time before flushing. This can help avoid
|
|
912
1007
|
// capturing replays of users that immediately close the window.
|
|
913
1008
|
setTimeout(function () { return _this.conditionalFlush(); }, _this.options.initialFlushDelay);
|
|
1009
|
+
// Cancel any previously debounced flushes to ensure there are no [near]
|
|
1010
|
+
// simultaneous flushes happening. The latter request should be
|
|
1011
|
+
// insignificant in this case, so wait for additional user interaction to
|
|
1012
|
+
// trigger a new flush.
|
|
1013
|
+
//
|
|
1014
|
+
// This can happen because there's no guarantee that a recording event
|
|
1015
|
+
// happens first. e.g. a mouse click can happen and trigger a debounced
|
|
1016
|
+
// flush before the checkout.
|
|
1017
|
+
(_b = _this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
914
1018
|
return true;
|
|
915
1019
|
});
|
|
916
1020
|
};
|
|
@@ -1019,8 +1123,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1019
1123
|
this.handlePerformanceObserver = function (list) {
|
|
1020
1124
|
// For whatever reason the observer was returning duplicate navigation
|
|
1021
1125
|
// entries (the other entry types were not duplicated).
|
|
1022
|
-
var
|
|
1023
|
-
_this.performanceEvents =
|
|
1126
|
+
var newPerformanceEntries = dedupePerformanceEntries(_this.performanceEvents, list.getEntries());
|
|
1127
|
+
_this.performanceEvents = newPerformanceEntries;
|
|
1024
1128
|
};
|
|
1025
1129
|
/**
|
|
1026
1130
|
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
@@ -1045,9 +1149,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1045
1149
|
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1046
1150
|
return [2 /*return*/];
|
|
1047
1151
|
}
|
|
1048
|
-
//
|
|
1049
|
-
// We do this regardless of having a queued flush since the event updates
|
|
1050
|
-
// will be handled by queued flush
|
|
1152
|
+
// A flush is about to happen, cancel any queued flushes
|
|
1051
1153
|
(_b = this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
1052
1154
|
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1053
1155
|
this.flushLock = this.runFlush();
|
|
@@ -1067,22 +1169,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1067
1169
|
console.error(err_1);
|
|
1068
1170
|
return [3 /*break*/, 6];
|
|
1069
1171
|
case 5:
|
|
1070
|
-
this.
|
|
1172
|
+
this.debouncedFlush();
|
|
1071
1173
|
return [7 /*endfinally*/];
|
|
1072
1174
|
case 6: return [2 /*return*/];
|
|
1073
1175
|
}
|
|
1074
1176
|
});
|
|
1075
1177
|
}); };
|
|
1076
|
-
/**
|
|
1077
|
-
* A throttled `flush()` that is called after a flush is completed and there
|
|
1078
|
-
* are other queued flushes.
|
|
1079
|
-
*
|
|
1080
|
-
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
1081
|
-
*/
|
|
1082
|
-
this.throttledFlush = throttle(this.flush, 1000, {
|
|
1083
|
-
leading: false,
|
|
1084
|
-
trailing: true,
|
|
1085
|
-
});
|
|
1086
1178
|
this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
|
|
1087
1179
|
this.options = {
|
|
1088
1180
|
flushMinDelay: flushMinDelay,
|
|
@@ -1160,13 +1252,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1160
1252
|
* processing and hand back control to caller.
|
|
1161
1253
|
*/
|
|
1162
1254
|
SentryReplay.prototype.addUpdate = function (cb) {
|
|
1163
|
-
var now = new Date().getTime();
|
|
1164
|
-
// Timestamp of the first replay event since the last flush, this gets
|
|
1165
|
-
// reset when we finish the replay event
|
|
1166
|
-
if (!this.initialEventTimestampSinceFlush &&
|
|
1167
|
-
!this.options.captureOnlyOnError) {
|
|
1168
|
-
this.initialEventTimestampSinceFlush = now;
|
|
1169
|
-
}
|
|
1170
1255
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1171
1256
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1172
1257
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1179,6 +1264,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1179
1264
|
if (cbResult === true) {
|
|
1180
1265
|
return;
|
|
1181
1266
|
}
|
|
1267
|
+
// addUpdate is called quite frequently - use debouncedFlush so that it
|
|
1268
|
+
// respects the flush delays and does not flush immediately
|
|
1182
1269
|
this.debouncedFlush();
|
|
1183
1270
|
};
|
|
1184
1271
|
/**
|
|
@@ -1230,7 +1317,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1230
1317
|
var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
|
|
1231
1318
|
var url = "".concat(window.location.origin).concat(urlPath);
|
|
1232
1319
|
this.performanceEvents = [];
|
|
1233
|
-
this.initialEventTimestampSinceFlush = null;
|
|
1234
1320
|
// Reset context as well
|
|
1235
1321
|
this.clearContext();
|
|
1236
1322
|
this.initialState = {
|
|
@@ -1512,50 +1598,53 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1512
1598
|
*
|
|
1513
1599
|
* Performance events are only added right before flushing - this is
|
|
1514
1600
|
* due to the buffered performance observer events.
|
|
1601
|
+
*
|
|
1602
|
+
* Should never be called directly, only by `flush`
|
|
1515
1603
|
*/
|
|
1516
1604
|
SentryReplay.prototype.runFlush = function () {
|
|
1517
|
-
var _a;
|
|
1605
|
+
var _a, _b, _c;
|
|
1518
1606
|
return __awaiter(this, void 0, void 0, function () {
|
|
1519
|
-
var replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1520
|
-
return __generator(this, function (
|
|
1521
|
-
switch (
|
|
1607
|
+
var stack, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1608
|
+
return __generator(this, function (_d) {
|
|
1609
|
+
switch (_d.label) {
|
|
1522
1610
|
case 0:
|
|
1611
|
+
stack = ((_a = new Error('trace').stack) === null || _a === void 0 ? void 0 : _a.split('\n')) || [];
|
|
1612
|
+
addInternalBreadcrumb({
|
|
1613
|
+
message: "runFlush (".concat((_b = this.session) === null || _b === void 0 ? void 0 : _b.segmentId, ")\n\n").concat(stack.slice(1).join('\n')),
|
|
1614
|
+
});
|
|
1523
1615
|
if (!this.session) {
|
|
1524
1616
|
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1525
1617
|
return [2 /*return*/];
|
|
1526
1618
|
}
|
|
1527
1619
|
return [4 /*yield*/, this.addPerformanceEntries()];
|
|
1528
1620
|
case 1:
|
|
1529
|
-
|
|
1530
|
-
if (!((
|
|
1621
|
+
_d.sent();
|
|
1622
|
+
if (!((_c = this.eventBuffer) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
1531
1623
|
return [2 /*return*/];
|
|
1532
1624
|
}
|
|
1533
1625
|
// Only attach memory event if eventBuffer is not empty
|
|
1534
1626
|
return [4 /*yield*/, this.addMemoryEntry()];
|
|
1535
1627
|
case 2:
|
|
1536
1628
|
// Only attach memory event if eventBuffer is not empty
|
|
1537
|
-
|
|
1629
|
+
_d.sent();
|
|
1538
1630
|
replayId = this.session.id;
|
|
1539
1631
|
newSessionCreated = this.newSessionCreated;
|
|
1540
1632
|
segmentId = this.session.segmentId++;
|
|
1541
|
-
|
|
1542
|
-
// events will get flushed properly
|
|
1543
|
-
this.initialEventTimestampSinceFlush = null;
|
|
1544
|
-
_b.label = 3;
|
|
1633
|
+
_d.label = 3;
|
|
1545
1634
|
case 3:
|
|
1546
|
-
|
|
1635
|
+
_d.trys.push([3, 6, , 7]);
|
|
1547
1636
|
return [4 /*yield*/, this.eventBuffer.finish()];
|
|
1548
1637
|
case 4:
|
|
1549
|
-
recordingData =
|
|
1638
|
+
recordingData = _d.sent();
|
|
1550
1639
|
return [4 /*yield*/, this.sendReplay(replayId, recordingData, segmentId)];
|
|
1551
1640
|
case 5:
|
|
1552
|
-
|
|
1641
|
+
_d.sent();
|
|
1553
1642
|
// The below will only happen after successfully sending replay //
|
|
1554
1643
|
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: new Date().getTime() })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1555
1644
|
this.newSessionCreated = false;
|
|
1556
1645
|
return [3 /*break*/, 7];
|
|
1557
1646
|
case 6:
|
|
1558
|
-
err_2 =
|
|
1647
|
+
err_2 = _d.sent();
|
|
1559
1648
|
captureException(err_2);
|
|
1560
1649
|
console.error(err_2);
|
|
1561
1650
|
return [3 /*break*/, 7];
|
|
@@ -1584,7 +1673,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1584
1673
|
envelope = createEnvelope({
|
|
1585
1674
|
event_id: event_id,
|
|
1586
1675
|
sent_at: new Date().toISOString(),
|
|
1587
|
-
sdk: {
|
|
1676
|
+
sdk: {
|
|
1677
|
+
name: 'sentry.javascript.integration.replay',
|
|
1678
|
+
version: "0.5.23",
|
|
1679
|
+
},
|
|
1588
1680
|
}, [
|
|
1589
1681
|
[
|
|
1590
1682
|
{
|