@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/cjs/index.js
CHANGED
|
@@ -5223,21 +5223,6 @@ function isSampled(sampleRate) {
|
|
|
5223
5223
|
return Math.random() < sampleRate;
|
|
5224
5224
|
}
|
|
5225
5225
|
|
|
5226
|
-
/**
|
|
5227
|
-
* Save a session to session storage.
|
|
5228
|
-
*/
|
|
5229
|
-
function saveSession(session) {
|
|
5230
|
-
if (!hasSessionStorage()) {
|
|
5231
|
-
return;
|
|
5232
|
-
}
|
|
5233
|
-
|
|
5234
|
-
try {
|
|
5235
|
-
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
5236
|
-
} catch (e) {
|
|
5237
|
-
// Ignore potential SecurityError exceptions
|
|
5238
|
-
}
|
|
5239
|
-
}
|
|
5240
|
-
|
|
5241
5226
|
/**
|
|
5242
5227
|
* Get a session with defaults & applied sampling.
|
|
5243
5228
|
*/
|
|
@@ -5261,6 +5246,21 @@ function makeSession(session) {
|
|
|
5261
5246
|
};
|
|
5262
5247
|
}
|
|
5263
5248
|
|
|
5249
|
+
/**
|
|
5250
|
+
* Save a session to session storage.
|
|
5251
|
+
*/
|
|
5252
|
+
function saveSession(session) {
|
|
5253
|
+
if (!hasSessionStorage()) {
|
|
5254
|
+
return;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
try {
|
|
5258
|
+
WINDOW.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
5259
|
+
} catch (e) {
|
|
5260
|
+
// Ignore potential SecurityError exceptions
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
|
|
5264
5264
|
/**
|
|
5265
5265
|
* Get the sampled status for a session based on sample rates & current sampled status.
|
|
5266
5266
|
*/
|
|
@@ -5713,7 +5713,7 @@ function shouldSampleForBufferEvent(replay, event) {
|
|
|
5713
5713
|
}
|
|
5714
5714
|
|
|
5715
5715
|
/**
|
|
5716
|
-
* Returns a listener to be added to `
|
|
5716
|
+
* Returns a listener to be added to `addEventProcessor(listener)`.
|
|
5717
5717
|
*/
|
|
5718
5718
|
function handleGlobalEventListener(
|
|
5719
5719
|
replay,
|
|
@@ -6042,6 +6042,10 @@ function getBodyString(body) {
|
|
|
6042
6042
|
if (body instanceof FormData) {
|
|
6043
6043
|
return [_serializeFormData(body)];
|
|
6044
6044
|
}
|
|
6045
|
+
|
|
6046
|
+
if (!body) {
|
|
6047
|
+
return [undefined];
|
|
6048
|
+
}
|
|
6045
6049
|
} catch (e2) {
|
|
6046
6050
|
DEBUG_BUILD && utils.logger.warn('[Replay] Failed to serialize body', body);
|
|
6047
6051
|
return [undefined, 'BODY_PARSE_ERROR'];
|
|
@@ -6049,7 +6053,7 @@ function getBodyString(body) {
|
|
|
6049
6053
|
|
|
6050
6054
|
DEBUG_BUILD && utils.logger.info('[Replay] Skipping network body because of body type', body);
|
|
6051
6055
|
|
|
6052
|
-
return [undefined];
|
|
6056
|
+
return [undefined, 'UNPARSEABLE_BODY_TYPE'];
|
|
6053
6057
|
}
|
|
6054
6058
|
|
|
6055
6059
|
/** Merge a warning into an existing network request/response. */
|
|
@@ -6581,7 +6585,7 @@ function enrichXhrBreadcrumb(
|
|
|
6581
6585
|
const reqSize = getBodySize(input, options.textEncoder);
|
|
6582
6586
|
const resSize = xhr.getResponseHeader('content-length')
|
|
6583
6587
|
? parseContentLengthHeader(xhr.getResponseHeader('content-length'))
|
|
6584
|
-
:
|
|
6588
|
+
: _getBodySize(xhr.response, xhr.responseType, options.textEncoder);
|
|
6585
6589
|
|
|
6586
6590
|
if (reqSize !== undefined) {
|
|
6587
6591
|
breadcrumb.data.request_body_size = reqSize;
|
|
@@ -6674,8 +6678,7 @@ function _getXhrResponseBody(xhr) {
|
|
|
6674
6678
|
|
|
6675
6679
|
// Try to manually parse the response body, if responseText fails
|
|
6676
6680
|
try {
|
|
6677
|
-
|
|
6678
|
-
return getBodyString(response);
|
|
6681
|
+
return _parseXhrResponse(xhr.response, xhr.responseType);
|
|
6679
6682
|
} catch (e) {
|
|
6680
6683
|
errors.push(e);
|
|
6681
6684
|
}
|
|
@@ -6685,6 +6688,60 @@ function _getXhrResponseBody(xhr) {
|
|
|
6685
6688
|
return [undefined];
|
|
6686
6689
|
}
|
|
6687
6690
|
|
|
6691
|
+
/**
|
|
6692
|
+
* Get the string representation of the XHR response.
|
|
6693
|
+
* Based on MDN, these are the possible types of the response:
|
|
6694
|
+
* string
|
|
6695
|
+
* ArrayBuffer
|
|
6696
|
+
* Blob
|
|
6697
|
+
* Document
|
|
6698
|
+
* POJO
|
|
6699
|
+
*
|
|
6700
|
+
* Exported only for tests.
|
|
6701
|
+
*/
|
|
6702
|
+
function _parseXhrResponse(
|
|
6703
|
+
body,
|
|
6704
|
+
responseType,
|
|
6705
|
+
) {
|
|
6706
|
+
try {
|
|
6707
|
+
if (typeof body === 'string') {
|
|
6708
|
+
return [body];
|
|
6709
|
+
}
|
|
6710
|
+
|
|
6711
|
+
if (body instanceof Document) {
|
|
6712
|
+
return [body.body.outerHTML];
|
|
6713
|
+
}
|
|
6714
|
+
|
|
6715
|
+
if (responseType === 'json' && body && typeof body === 'object') {
|
|
6716
|
+
return [JSON.stringify(body)];
|
|
6717
|
+
}
|
|
6718
|
+
|
|
6719
|
+
if (!body) {
|
|
6720
|
+
return [undefined];
|
|
6721
|
+
}
|
|
6722
|
+
} catch (e2) {
|
|
6723
|
+
DEBUG_BUILD && utils.logger.warn('[Replay] Failed to serialize body', body);
|
|
6724
|
+
return [undefined, 'BODY_PARSE_ERROR'];
|
|
6725
|
+
}
|
|
6726
|
+
|
|
6727
|
+
DEBUG_BUILD && utils.logger.info('[Replay] Skipping network body because of body type', body);
|
|
6728
|
+
|
|
6729
|
+
return [undefined, 'UNPARSEABLE_BODY_TYPE'];
|
|
6730
|
+
}
|
|
6731
|
+
|
|
6732
|
+
function _getBodySize(
|
|
6733
|
+
body,
|
|
6734
|
+
responseType,
|
|
6735
|
+
textEncoder,
|
|
6736
|
+
) {
|
|
6737
|
+
try {
|
|
6738
|
+
const bodyStr = responseType === 'json' && body && typeof body === 'object' ? JSON.stringify(body) : body;
|
|
6739
|
+
return getBodySize(bodyStr, textEncoder);
|
|
6740
|
+
} catch (e3) {
|
|
6741
|
+
return undefined;
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
|
|
6688
6745
|
/**
|
|
6689
6746
|
* This method does two things:
|
|
6690
6747
|
* - It enriches the regular XHR/fetch breadcrumbs with request/response size data
|
|
@@ -6903,7 +6960,7 @@ function addGlobalListeners(replay) {
|
|
|
6903
6960
|
if (client && client.addEventProcessor) {
|
|
6904
6961
|
client.addEventProcessor(eventProcessor);
|
|
6905
6962
|
} else {
|
|
6906
|
-
core.
|
|
6963
|
+
core.addEventProcessor(eventProcessor);
|
|
6907
6964
|
}
|
|
6908
6965
|
|
|
6909
6966
|
// If a custom client has no hooks yet, we continue to use the "old" implementation
|