Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions packages/utils/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ function instrumentXHR(): void {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const xhr = this;
const url = args[1];
xhr.__sentry_xhr__ = {
const xhrInfo: SentryWrappedXMLHttpRequest['__sentry_xhr__'] = (xhr.__sentry_xhr__ = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
method: isString(args[0]) ? args[0].toUpperCase() : args[0],
url: args[1],
};
});

// if Sentry key appears in URL, don't capture it as a request
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (isString(url) && xhr.__sentry_xhr__.method === 'POST' && url.match(/sentry_key/)) {
if (isString(url) && xhrInfo.method === 'POST' && url.match(/sentry_key/)) {
xhr.__sentry_own_request__ = true;
}

Expand All @@ -243,9 +243,7 @@ function instrumentXHR(): void {
try {
// touching statusCode in some platforms throws
// an exception
if (xhr.__sentry_xhr__) {
xhr.__sentry_xhr__.status_code = xhr.status;
}
xhrInfo.status_code = xhr.status;
} catch (e) {
/* do nothing */
}
Expand All @@ -256,8 +254,8 @@ function instrumentXHR(): void {
// Make sure to pop both key and value to keep it in sync.
requestKeys.splice(requestPos);
const args = requestValues.splice(requestPos)[0];
if (xhr.__sentry_xhr__ && args[0] !== undefined) {
xhr.__sentry_xhr__.body = args[0] as XHRSendInput;
if (args[0] !== undefined) {
xhrInfo.body = args[0] as XHRSendInput;
}
}
} catch (e) {
Expand Down