@sentry/replay 7.84.0 → 7.86.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 +63 -6
- package/cjs/index.js.map +1 -1
- package/esm/index.js +64 -7
- 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/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
|
|
|
@@ -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
|