@sentry/replay 7.83.0 → 7.85.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/index.js +78 -21
- package/cjs/index.js.map +1 -1
- package/esm/index.js +79 -22
- package/esm/index.js.map +1 -1
- package/package.json +6 -6
- package/types/coreHandlers/handleGlobalEvent.d.ts +1 -1
- package/types/coreHandlers/util/networkUtils.d.ts.map +1 -1
- package/types/coreHandlers/util/xhrUtils.d.ts +13 -1
- package/types/coreHandlers/util/xhrUtils.d.ts.map +1 -1
- package/types/replay.d.ts.map +1 -1
- package/types/types/request.d.ts +1 -1
- package/types/types/request.d.ts.map +1 -1
- package/types-ts3.8/coreHandlers/handleGlobalEvent.d.ts +1 -1
- package/types-ts3.8/coreHandlers/util/xhrUtils.d.ts +16 -1
- package/types-ts3.8/types/request.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentHub, getClient, isSentryRequestUrl,
|
|
1
|
+
import { getCurrentHub, getClient, isSentryRequestUrl, addEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
|
|
2
2
|
import { GLOBAL_OBJ, normalize, fill, htmlTreeAsString, browserPerformanceTimeOrigin, logger, uuid4, SENTRY_XHR_DATA_KEY, dropUndefinedKeys, stringMatchesSomePattern, addFetchInstrumentationHandler, addXhrInstrumentationHandler, addClickKeypressInstrumentationHandler, addHistoryInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, consoleSandbox, isBrowser } from '@sentry/utils';
|
|
3
3
|
import { addPerformanceInstrumentationHandler, addLcpInstrumentationHandler } from '@sentry-internal/tracing';
|
|
4
4
|
|
|
@@ -5221,21 +5221,6 @@ function isSampled(sampleRate) {
|
|
|
5221
5221
|
return Math.random() < sampleRate;
|
|
5222
5222
|
}
|
|
5223
5223
|
|
|
5224
|
-
/**
|
|
5225
|
-
* Save a session to session storage.
|
|
5226
|
-
*/
|
|
5227
|
-
function saveSession(session) {
|
|
5228
|
-
if (!hasSessionStorage()) {
|
|
5229
|
-
return;
|
|
5230
|
-
}
|
|
5231
|
-
|
|
5232
|
-
try {
|
|
5233
|
-
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
5234
|
-
} catch (e) {
|
|
5235
|
-
// Ignore potential SecurityError exceptions
|
|
5236
|
-
}
|
|
5237
|
-
}
|
|
5238
|
-
|
|
5239
5224
|
/**
|
|
5240
5225
|
* Get a session with defaults & applied sampling.
|
|
5241
5226
|
*/
|
|
@@ -5259,6 +5244,21 @@ function makeSession(session) {
|
|
|
5259
5244
|
};
|
|
5260
5245
|
}
|
|
5261
5246
|
|
|
5247
|
+
/**
|
|
5248
|
+
* Save a session to session storage.
|
|
5249
|
+
*/
|
|
5250
|
+
function saveSession(session) {
|
|
5251
|
+
if (!hasSessionStorage()) {
|
|
5252
|
+
return;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5255
|
+
try {
|
|
5256
|
+
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
5257
|
+
} catch (e) {
|
|
5258
|
+
// Ignore potential SecurityError exceptions
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
|
|
5262
5262
|
/**
|
|
5263
5263
|
* Get the sampled status for a session based on sample rates & current sampled status.
|
|
5264
5264
|
*/
|
|
@@ -5711,7 +5711,7 @@ function shouldSampleForBufferEvent(replay, event) {
|
|
|
5711
5711
|
}
|
|
5712
5712
|
|
|
5713
5713
|
/**
|
|
5714
|
-
* Returns a listener to be added to `
|
|
5714
|
+
* Returns a listener to be added to `addEventProcessor(listener)`.
|
|
5715
5715
|
*/
|
|
5716
5716
|
function handleGlobalEventListener(
|
|
5717
5717
|
replay,
|
|
@@ -6040,6 +6040,10 @@ function getBodyString(body) {
|
|
|
6040
6040
|
if (body instanceof FormData) {
|
|
6041
6041
|
return [_serializeFormData(body)];
|
|
6042
6042
|
}
|
|
6043
|
+
|
|
6044
|
+
if (!body) {
|
|
6045
|
+
return [undefined];
|
|
6046
|
+
}
|
|
6043
6047
|
} catch (e2) {
|
|
6044
6048
|
DEBUG_BUILD && logger.warn('[Replay] Failed to serialize body', body);
|
|
6045
6049
|
return [undefined, 'BODY_PARSE_ERROR'];
|
|
@@ -6047,7 +6051,7 @@ function getBodyString(body) {
|
|
|
6047
6051
|
|
|
6048
6052
|
DEBUG_BUILD && logger.info('[Replay] Skipping network body because of body type', body);
|
|
6049
6053
|
|
|
6050
|
-
return [undefined];
|
|
6054
|
+
return [undefined, 'UNPARSEABLE_BODY_TYPE'];
|
|
6051
6055
|
}
|
|
6052
6056
|
|
|
6053
6057
|
/** Merge a warning into an existing network request/response. */
|
|
@@ -6579,7 +6583,7 @@ function enrichXhrBreadcrumb(
|
|
|
6579
6583
|
const reqSize = getBodySize(input, options.textEncoder);
|
|
6580
6584
|
const resSize = xhr.getResponseHeader('content-length')
|
|
6581
6585
|
? parseContentLengthHeader(xhr.getResponseHeader('content-length'))
|
|
6582
|
-
:
|
|
6586
|
+
: _getBodySize(xhr.response, xhr.responseType, options.textEncoder);
|
|
6583
6587
|
|
|
6584
6588
|
if (reqSize !== undefined) {
|
|
6585
6589
|
breadcrumb.data.request_body_size = reqSize;
|
|
@@ -6672,8 +6676,7 @@ function _getXhrResponseBody(xhr) {
|
|
|
6672
6676
|
|
|
6673
6677
|
// Try to manually parse the response body, if responseText fails
|
|
6674
6678
|
try {
|
|
6675
|
-
|
|
6676
|
-
return getBodyString(response);
|
|
6679
|
+
return _parseXhrResponse(xhr.response, xhr.responseType);
|
|
6677
6680
|
} catch (e) {
|
|
6678
6681
|
errors.push(e);
|
|
6679
6682
|
}
|
|
@@ -6683,6 +6686,60 @@ function _getXhrResponseBody(xhr) {
|
|
|
6683
6686
|
return [undefined];
|
|
6684
6687
|
}
|
|
6685
6688
|
|
|
6689
|
+
/**
|
|
6690
|
+
* Get the string representation of the XHR response.
|
|
6691
|
+
* Based on MDN, these are the possible types of the response:
|
|
6692
|
+
* string
|
|
6693
|
+
* ArrayBuffer
|
|
6694
|
+
* Blob
|
|
6695
|
+
* Document
|
|
6696
|
+
* POJO
|
|
6697
|
+
*
|
|
6698
|
+
* Exported only for tests.
|
|
6699
|
+
*/
|
|
6700
|
+
function _parseXhrResponse(
|
|
6701
|
+
body,
|
|
6702
|
+
responseType,
|
|
6703
|
+
) {
|
|
6704
|
+
try {
|
|
6705
|
+
if (typeof body === 'string') {
|
|
6706
|
+
return [body];
|
|
6707
|
+
}
|
|
6708
|
+
|
|
6709
|
+
if (body instanceof Document) {
|
|
6710
|
+
return [body.body.outerHTML];
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
if (responseType === 'json' && body && typeof body === 'object') {
|
|
6714
|
+
return [JSON.stringify(body)];
|
|
6715
|
+
}
|
|
6716
|
+
|
|
6717
|
+
if (!body) {
|
|
6718
|
+
return [undefined];
|
|
6719
|
+
}
|
|
6720
|
+
} catch (e2) {
|
|
6721
|
+
DEBUG_BUILD && logger.warn('[Replay] Failed to serialize body', body);
|
|
6722
|
+
return [undefined, 'BODY_PARSE_ERROR'];
|
|
6723
|
+
}
|
|
6724
|
+
|
|
6725
|
+
DEBUG_BUILD && logger.info('[Replay] Skipping network body because of body type', body);
|
|
6726
|
+
|
|
6727
|
+
return [undefined, 'UNPARSEABLE_BODY_TYPE'];
|
|
6728
|
+
}
|
|
6729
|
+
|
|
6730
|
+
function _getBodySize(
|
|
6731
|
+
body,
|
|
6732
|
+
responseType,
|
|
6733
|
+
textEncoder,
|
|
6734
|
+
) {
|
|
6735
|
+
try {
|
|
6736
|
+
const bodyStr = responseType === 'json' && body && typeof body === 'object' ? JSON.stringify(body) : body;
|
|
6737
|
+
return getBodySize(bodyStr, textEncoder);
|
|
6738
|
+
} catch (e3) {
|
|
6739
|
+
return undefined;
|
|
6740
|
+
}
|
|
6741
|
+
}
|
|
6742
|
+
|
|
6686
6743
|
/**
|
|
6687
6744
|
* This method does two things:
|
|
6688
6745
|
* - It enriches the regular XHR/fetch breadcrumbs with request/response size data
|
|
@@ -6901,7 +6958,7 @@ function addGlobalListeners(replay) {
|
|
|
6901
6958
|
if (client && client.addEventProcessor) {
|
|
6902
6959
|
client.addEventProcessor(eventProcessor);
|
|
6903
6960
|
} else {
|
|
6904
|
-
|
|
6961
|
+
addEventProcessor(eventProcessor);
|
|
6905
6962
|
}
|
|
6906
6963
|
|
|
6907
6964
|
// If a custom client has no hooks yet, we continue to use the "old" implementation
|