Skip to content

Commit

Permalink
full url instead of hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasini committed Nov 13, 2024
1 parent e627d42 commit aaf4963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/store/sagas/xmlHttpRequestOverride.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('overrideXMLHttpRequest', () => {
const xhr = new XMLHttpRequest();
xhr.onload = () => {
expect(mockTrace).toHaveBeenCalledWith({
name: 'api.example.com',
name: 'https://api.example.com/data',
op: trace.TraceOperation.NoBasicFunctionalityHttp,
});
done();
Expand All @@ -97,7 +97,7 @@ describe('createLoggingXHROverride', () => {
const xhr = new XMLHttpRequest();
xhr.onload = () => {
expect(mockTrace).toHaveBeenCalledWith({
name: 'api.example.com',
name: 'https://api.example.com/data',
op: trace.TraceOperation.Http,
});
done();
Expand Down
8 changes: 3 additions & 5 deletions app/store/sagas/xmlHttpRequestOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ function createXHROverride(options: XHROverrideOptions) {
password?: string | null,
) {
currentUrl = url?.toString();
const hostname = new URL(currentUrl).hostname;
trace({
name: hostname as TraceName,
name: currentUrl as TraceName,
op: options.operation,
});
return originalOpen.apply(this, [
Expand All @@ -61,13 +60,12 @@ function createXHROverride(options: XHROverrideOptions) {
};

global.XMLHttpRequest.prototype.send = function (...args: unknown[]) {
const hostname = new URL(currentUrl).hostname;
this.addEventListener('load', () => {
endTrace({ name: hostname as TraceName });
endTrace({ name: currentUrl as TraceName });
});

this.addEventListener('error', () => {
endTrace({ name: hostname as TraceName });
endTrace({ name: currentUrl as TraceName });
});

if (options.beforeSend && options.beforeSend(currentUrl)) {
Expand Down

0 comments on commit aaf4963

Please sign in to comment.