Skip to content

Commit e8d3102

Browse files
author
Luca Forstner
committed
fix(browser): Don't stomp xhr function names
1 parent 3ea5373 commit e8d3102

File tree

1 file changed

+4
-4
lines changed
  • packages/browser-utils/src/instrument

1 file changed

+4
-4
lines changed

packages/browser-utils/src/instrument/xhr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function instrumentXHR(): void {
3030
const xhrproto = XMLHttpRequest.prototype;
3131

3232
fill(xhrproto, 'open', function (originalOpen: () => void): () => void {
33-
return function (this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: unknown[]): void {
33+
return function open(this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: unknown[]): void {
3434
const startTimestamp = timestampInSeconds() * 1000;
3535

3636
// open() should always be called with two or more arguments
@@ -81,7 +81,7 @@ export function instrumentXHR(): void {
8181

8282
if ('onreadystatechange' in this && typeof this.onreadystatechange === 'function') {
8383
fill(this, 'onreadystatechange', function (original: WrappedFunction) {
84-
return function (this: SentryWrappedXMLHttpRequest, ...readyStateArgs: unknown[]): void {
84+
return function onreadystatechange(this: SentryWrappedXMLHttpRequest, ...readyStateArgs: unknown[]): void {
8585
onreadystatechangeHandler();
8686
return original.apply(this, readyStateArgs);
8787
};
@@ -94,7 +94,7 @@ export function instrumentXHR(): void {
9494
// This will only work for user/library defined headers, not for the default/browser-assigned headers.
9595
// Request cookies are also unavailable for XHR, as `Cookie` header can't be defined by `setRequestHeader`.
9696
fill(this, 'setRequestHeader', function (original: WrappedFunction) {
97-
return function (this: SentryWrappedXMLHttpRequest, ...setRequestHeaderArgs: unknown[]): void {
97+
return function setRequestHeader(this: SentryWrappedXMLHttpRequest, ...setRequestHeaderArgs: unknown[]): void {
9898
const [header, value] = setRequestHeaderArgs;
9999

100100
const xhrInfo = this[SENTRY_XHR_DATA_KEY];
@@ -112,7 +112,7 @@ export function instrumentXHR(): void {
112112
});
113113

114114
fill(xhrproto, 'send', function (originalSend: () => void): () => void {
115-
return function (this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: unknown[]): void {
115+
return function send(this: XMLHttpRequest & SentryWrappedXMLHttpRequest, ...args: unknown[]): void {
116116
const sentryXhrData = this[SENTRY_XHR_DATA_KEY];
117117

118118
if (!sentryXhrData) {

0 commit comments

Comments
 (0)