@sentry/replay 7.28.1 → 7.30.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/cjs/constants.js +9 -1
- package/cjs/constants.js.map +1 -1
- package/cjs/coreHandlers/breadcrumbHandler.js +3 -0
- package/cjs/coreHandlers/breadcrumbHandler.js.map +1 -1
- package/cjs/coreHandlers/handleDom.js +3 -0
- package/cjs/coreHandlers/handleDom.js.map +1 -1
- package/cjs/coreHandlers/handleFetch.js.map +1 -1
- package/cjs/coreHandlers/handleGlobalEvent.js +2 -5
- package/cjs/coreHandlers/handleGlobalEvent.js.map +1 -1
- package/cjs/coreHandlers/handleHistory.js.map +1 -1
- package/cjs/coreHandlers/handleScope.js +3 -0
- package/cjs/coreHandlers/handleScope.js.map +1 -1
- package/cjs/coreHandlers/handleXhr.js.map +1 -1
- package/cjs/createPerformanceEntry.js +7 -31
- package/cjs/createPerformanceEntry.js.map +1 -1
- package/cjs/eventBuffer.js +33 -11
- package/cjs/eventBuffer.js.map +1 -1
- package/cjs/integration.js +22 -14
- package/cjs/integration.js.map +1 -1
- package/cjs/replay.js +25 -18
- package/cjs/replay.js.map +1 -1
- package/cjs/session/saveSession.js +3 -0
- package/cjs/session/saveSession.js.map +1 -1
- package/cjs/util/addMemoryEntry.js +20 -0
- package/cjs/util/addMemoryEntry.js.map +1 -1
- package/cjs/util/createBreadcrumb.js +3 -0
- package/cjs/util/createBreadcrumb.js.map +1 -1
- package/cjs/util/createPerformanceSpans.js.map +1 -1
- package/cjs/util/{createPayload.js → createRecordingData.js} +6 -3
- package/cjs/util/createRecordingData.js.map +1 -0
- package/cjs/util/createReplayEnvelope.js +7 -6
- package/cjs/util/createReplayEnvelope.js.map +1 -1
- package/cjs/util/debounce.js +67 -0
- package/cjs/util/debounce.js.map +1 -0
- package/cjs/util/isBrowser.js +9 -1
- package/cjs/util/isBrowser.js.map +1 -1
- package/cjs/util/isRrwebError.js +3 -0
- package/cjs/util/isRrwebError.js.map +1 -1
- package/cjs/util/monkeyPatchRecordDroppedEvent.js +7 -1
- package/cjs/util/monkeyPatchRecordDroppedEvent.js.map +1 -1
- package/cjs/util/prepareReplayEvent.js +42 -0
- package/cjs/util/prepareReplayEvent.js.map +1 -0
- package/esm/constants.js +7 -2
- package/esm/constants.js.map +1 -1
- package/esm/coreHandlers/breadcrumbHandler.js +3 -0
- package/esm/coreHandlers/breadcrumbHandler.js.map +1 -1
- package/esm/coreHandlers/handleDom.js +3 -0
- package/esm/coreHandlers/handleDom.js.map +1 -1
- package/esm/coreHandlers/handleFetch.js.map +1 -1
- package/esm/coreHandlers/handleGlobalEvent.js +2 -5
- package/esm/coreHandlers/handleGlobalEvent.js.map +1 -1
- package/esm/coreHandlers/handleHistory.js.map +1 -1
- package/esm/coreHandlers/handleScope.js +3 -0
- package/esm/coreHandlers/handleScope.js.map +1 -1
- package/esm/coreHandlers/handleXhr.js.map +1 -1
- package/esm/createPerformanceEntry.js +8 -31
- package/esm/createPerformanceEntry.js.map +1 -1
- package/esm/eventBuffer.js +33 -11
- package/esm/eventBuffer.js.map +1 -1
- package/esm/integration.js +23 -15
- package/esm/integration.js.map +1 -1
- package/esm/replay.js +22 -15
- package/esm/replay.js.map +1 -1
- package/esm/session/saveSession.js +3 -0
- package/esm/session/saveSession.js.map +1 -1
- package/esm/util/addMemoryEntry.js +20 -0
- package/esm/util/addMemoryEntry.js.map +1 -1
- package/esm/util/createBreadcrumb.js +3 -0
- package/esm/util/createBreadcrumb.js.map +1 -1
- package/esm/util/createPerformanceSpans.js.map +1 -1
- package/esm/util/{createPayload.js → createRecordingData.js} +6 -3
- package/esm/util/createRecordingData.js.map +1 -0
- package/esm/util/createReplayEnvelope.js +7 -6
- package/esm/util/createReplayEnvelope.js.map +1 -1
- package/esm/util/debounce.js +65 -0
- package/esm/util/debounce.js.map +1 -0
- package/esm/util/isBrowser.js +9 -1
- package/esm/util/isBrowser.js.map +1 -1
- package/esm/util/isRrwebError.js +3 -0
- package/esm/util/isRrwebError.js.map +1 -1
- package/esm/util/monkeyPatchRecordDroppedEvent.js +7 -1
- package/esm/util/monkeyPatchRecordDroppedEvent.js.map +1 -1
- package/esm/util/prepareReplayEvent.js +40 -0
- package/esm/util/prepareReplayEvent.js.map +1 -0
- package/package.json +4 -6
- package/types/constants.d.ts +5 -1
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/breadcrumbHandler.d.ts +3 -0
- package/types/coreHandlers/breadcrumbHandler.d.ts.map +1 -1
- package/types/coreHandlers/handleDom.d.ts +3 -0
- package/types/coreHandlers/handleDom.d.ts.map +1 -1
- package/types/coreHandlers/handleFetch.d.ts +1 -2
- package/types/coreHandlers/handleFetch.d.ts.map +1 -1
- package/types/coreHandlers/handleGlobalEvent.d.ts.map +1 -1
- package/types/coreHandlers/handleHistory.d.ts.map +1 -1
- package/types/coreHandlers/handleScope.d.ts +3 -0
- package/types/coreHandlers/handleScope.d.ts.map +1 -1
- package/types/coreHandlers/handleXhr.d.ts.map +1 -1
- package/types/createPerformanceEntry.d.ts +4 -35
- package/types/createPerformanceEntry.d.ts.map +1 -1
- package/types/eventBuffer.d.ts +26 -2
- package/types/eventBuffer.d.ts.map +1 -1
- package/types/integration.d.ts +8 -2
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts +9 -3
- package/types/replay.d.ts.map +1 -1
- package/types/session/saveSession.d.ts +3 -0
- package/types/session/saveSession.d.ts.map +1 -1
- package/types/types.d.ts +25 -3
- package/types/types.d.ts.map +1 -1
- package/types/util/addMemoryEntry.d.ts.map +1 -1
- package/types/util/createBreadcrumb.d.ts +3 -0
- package/types/util/createBreadcrumb.d.ts.map +1 -1
- package/types/util/createPerformanceSpans.d.ts +1 -2
- package/types/util/createPerformanceSpans.d.ts.map +1 -1
- package/types/util/createRecordingData.d.ts +10 -0
- package/types/util/createRecordingData.d.ts.map +1 -0
- package/types/util/createReplayEnvelope.d.ts +6 -2
- package/types/util/createReplayEnvelope.d.ts.map +1 -1
- package/types/util/debounce.d.ts +30 -0
- package/types/util/debounce.d.ts.map +1 -0
- package/types/util/isBrowser.d.ts +3 -0
- package/types/util/isBrowser.d.ts.map +1 -1
- package/types/util/isRrwebError.d.ts +3 -0
- package/types/util/isRrwebError.d.ts.map +1 -1
- package/types/util/monkeyPatchRecordDroppedEvent.d.ts +6 -0
- package/types/util/monkeyPatchRecordDroppedEvent.d.ts.map +1 -1
- package/types/util/prepareReplayEvent.d.ts +12 -0
- package/types/util/prepareReplayEvent.d.ts.map +1 -0
- package/cjs/_virtual/_commonjsHelpers.js +0 -42
- package/cjs/_virtual/_commonjsHelpers.js.map +0 -1
- package/cjs/node_modules/lodash.debounce/index.js +0 -384
- package/cjs/node_modules/lodash.debounce/index.js.map +0 -1
- package/cjs/util/createPayload.js.map +0 -1
- package/cjs/util/getReplayEvent.js +0 -31
- package/cjs/util/getReplayEvent.js.map +0 -1
- package/esm/_virtual/_commonjsHelpers.js +0 -35
- package/esm/_virtual/_commonjsHelpers.js.map +0 -1
- package/esm/node_modules/lodash.debounce/index.js +0 -382
- package/esm/node_modules/lodash.debounce/index.js.map +0 -1
- package/esm/util/createPayload.js.map +0 -1
- package/esm/util/getReplayEvent.js +0 -29
- package/esm/util/getReplayEvent.js.map +0 -1
- package/types/util/createPayload.d.ts +0 -6
- package/types/util/createPayload.d.ts.map +0 -1
- package/types/util/getReplayEvent.d.ts +0 -9
- package/types/util/getReplayEvent.d.ts.map +0 -1
package/esm/replay.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _optionalChain } from '@sentry/utils/esm/buildPolyfills';
|
|
2
2
|
import { captureException, getCurrentHub, addGlobalEventProcessor, setContext } from '@sentry/core';
|
|
3
3
|
import { logger, addInstrumentationHandler } from '@sentry/utils';
|
|
4
|
-
import lodash_debounce from './node_modules/lodash.debounce/index.js';
|
|
5
4
|
import './node_modules/rrweb/es/rrweb/packages/rrweb/src/entries/all.js';
|
|
6
5
|
import { SESSION_IDLE_DURATION, WINDOW, VISIBILITY_CHANGE_TIMEOUT, MAX_SESSION_LIFE, REPLAY_EVENT_NAME, UNABLE_TO_SEND_REPLAY } from './constants.js';
|
|
7
6
|
import { breadcrumbHandler } from './coreHandlers/breadcrumbHandler.js';
|
|
@@ -18,13 +17,14 @@ import { saveSession } from './session/saveSession.js';
|
|
|
18
17
|
import { addEvent } from './util/addEvent.js';
|
|
19
18
|
import { addMemoryEntry } from './util/addMemoryEntry.js';
|
|
20
19
|
import { createBreadcrumb } from './util/createBreadcrumb.js';
|
|
21
|
-
import { createPayload } from './util/createPayload.js';
|
|
22
20
|
import { createPerformanceSpans } from './util/createPerformanceSpans.js';
|
|
21
|
+
import { createRecordingData } from './util/createRecordingData.js';
|
|
23
22
|
import { createReplayEnvelope } from './util/createReplayEnvelope.js';
|
|
24
|
-
import {
|
|
23
|
+
import { debounce } from './util/debounce.js';
|
|
25
24
|
import { isExpired } from './util/isExpired.js';
|
|
26
25
|
import { isSessionExpired } from './util/isSessionExpired.js';
|
|
27
26
|
import { overwriteRecordDroppedEvent, restoreRecordDroppedEvent } from './util/monkeyPatchRecordDroppedEvent.js';
|
|
27
|
+
import { prepareReplayEvent } from './util/prepareReplayEvent.js';
|
|
28
28
|
import record from './node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js';
|
|
29
29
|
import { EventType } from './node_modules/rrweb/es/rrweb/packages/rrweb/src/types.js';
|
|
30
30
|
|
|
@@ -37,6 +37,9 @@ import { EventType } from './node_modules/rrweb/es/rrweb/packages/rrweb/src/type
|
|
|
37
37
|
const BASE_RETRY_INTERVAL = 5000;
|
|
38
38
|
const MAX_RETRY_COUNT = 3;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The main replay container class, which holds all the state and methods for recording and sending replays.
|
|
42
|
+
*/
|
|
40
43
|
class ReplayContainer {
|
|
41
44
|
__init() {this.eventBuffer = null;}
|
|
42
45
|
|
|
@@ -104,7 +107,7 @@ class ReplayContainer {
|
|
|
104
107
|
this._recordingOptions = recordingOptions;
|
|
105
108
|
this._options = options;
|
|
106
109
|
|
|
107
|
-
this._debouncedFlush =
|
|
110
|
+
this._debouncedFlush = debounce(() => this.flush(), this._options.flushMinDelay, {
|
|
108
111
|
maxWait: this._options.flushMaxDelay,
|
|
109
112
|
});
|
|
110
113
|
}
|
|
@@ -833,7 +836,6 @@ class ReplayContainer {
|
|
|
833
836
|
// A flush is about to happen, cancel any queued flushes
|
|
834
837
|
_optionalChain([this, 'access', _30 => _30._debouncedFlush, 'optionalAccess', _31 => _31.cancel, 'call', _32 => _32()]);
|
|
835
838
|
|
|
836
|
-
// No existing flush in progress, proceed with flushing.
|
|
837
839
|
// this._flushLock acts as a lock so that future calls to `flush()`
|
|
838
840
|
// will be blocked until this promise resolves
|
|
839
841
|
if (!this._flushLock) {
|
|
@@ -866,8 +868,8 @@ class ReplayContainer {
|
|
|
866
868
|
*/
|
|
867
869
|
flushImmediate() {
|
|
868
870
|
this._debouncedFlush();
|
|
869
|
-
// `.flush` is provided by lodash.debounce
|
|
870
|
-
return this._debouncedFlush.flush();
|
|
871
|
+
// `.flush` is provided by the debounced function, analogously to lodash.debounce
|
|
872
|
+
return this._debouncedFlush.flush() ;
|
|
871
873
|
}
|
|
872
874
|
|
|
873
875
|
/**
|
|
@@ -880,7 +882,7 @@ class ReplayContainer {
|
|
|
880
882
|
includeReplayStartTimestamp,
|
|
881
883
|
eventContext,
|
|
882
884
|
}) {
|
|
883
|
-
const
|
|
885
|
+
const recordingData = createRecordingData({
|
|
884
886
|
events,
|
|
885
887
|
headers: {
|
|
886
888
|
segment_id,
|
|
@@ -897,7 +899,7 @@ class ReplayContainer {
|
|
|
897
899
|
const transport = client && client.getTransport();
|
|
898
900
|
const dsn = _optionalChain([client, 'optionalAccess', _33 => _33.getDsn, 'call', _34 => _34()]);
|
|
899
901
|
|
|
900
|
-
if (!client || !scope || !transport || !dsn) {
|
|
902
|
+
if (!client || !scope || !transport || !dsn || !this.session || !this.session.sampled) {
|
|
901
903
|
return;
|
|
902
904
|
}
|
|
903
905
|
|
|
@@ -911,12 +913,15 @@ class ReplayContainer {
|
|
|
911
913
|
urls,
|
|
912
914
|
replay_id: replayId,
|
|
913
915
|
segment_id,
|
|
916
|
+
replay_type: this.session.sampled,
|
|
914
917
|
};
|
|
915
918
|
|
|
916
|
-
const replayEvent = await
|
|
919
|
+
const replayEvent = await prepareReplayEvent({ scope, client, replayId, event: baseEvent });
|
|
917
920
|
|
|
918
921
|
if (!replayEvent) {
|
|
919
|
-
|
|
922
|
+
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions
|
|
923
|
+
client.recordDroppedEvent('event_processor', 'replay_event', baseEvent);
|
|
924
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('An event processor returned `null`, will not send event.');
|
|
920
925
|
return;
|
|
921
926
|
}
|
|
922
927
|
|
|
@@ -924,7 +929,6 @@ class ReplayContainer {
|
|
|
924
929
|
...replayEvent.tags,
|
|
925
930
|
sessionSampleRate: this._options.sessionSampleRate,
|
|
926
931
|
errorSampleRate: this._options.errorSampleRate,
|
|
927
|
-
replayType: _optionalChain([this, 'access', _35 => _35.session, 'optionalAccess', _36 => _36.sampled]),
|
|
928
932
|
};
|
|
929
933
|
|
|
930
934
|
/*
|
|
@@ -943,6 +947,7 @@ class ReplayContainer {
|
|
|
943
947
|
],
|
|
944
948
|
"replay_id": "eventId",
|
|
945
949
|
"segment_id": 3,
|
|
950
|
+
"replay_type": "error",
|
|
946
951
|
"platform": "javascript",
|
|
947
952
|
"event_id": "eventId",
|
|
948
953
|
"environment": "production",
|
|
@@ -958,20 +963,22 @@ class ReplayContainer {
|
|
|
958
963
|
"tags": {
|
|
959
964
|
"sessionSampleRate": 1,
|
|
960
965
|
"errorSampleRate": 0,
|
|
961
|
-
"replayType": "error"
|
|
962
966
|
}
|
|
963
967
|
}
|
|
964
968
|
*/
|
|
965
969
|
|
|
966
|
-
const envelope = createReplayEnvelope(replayEvent,
|
|
970
|
+
const envelope = createReplayEnvelope(replayEvent, recordingData, dsn, client.getOptions().tunnel);
|
|
967
971
|
|
|
968
972
|
try {
|
|
969
|
-
return transport.send(envelope);
|
|
973
|
+
return await transport.send(envelope);
|
|
970
974
|
} catch (e) {
|
|
971
975
|
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
972
976
|
}
|
|
973
977
|
}
|
|
974
978
|
|
|
979
|
+
/**
|
|
980
|
+
* Reset the counter of retries for sending replays.
|
|
981
|
+
*/
|
|
975
982
|
resetRetries() {
|
|
976
983
|
this._retryCount = 0;
|
|
977
984
|
this._retryInterval = BASE_RETRY_INTERVAL;
|