Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bugsnag/request-tracker-performance

Package Overview
Dependencies
Maintainers
9
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bugsnag/request-tracker-performance - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0-alpha.0

17

dist/request-tracker-fetch.js

@@ -18,4 +18,6 @@ import { RequestTracker } from './request-tracker.js';

const startContext = createStartContext(clock.now(), input, init, global.document && global.document.baseURI);
const onRequestEnd = requestTracker.start(startContext);
return originalFetch.call(this, input, init).then(response => {
const { onRequestEnd, extraRequestHeaders } = requestTracker.start(startContext);
// Add the headers to the `init` received from the caller
const patchedInit = mergeRequestHeaders(init, extraRequestHeaders);
return originalFetch.call(this, input, patchedInit).then(response => {
onRequestEnd({ status: response.status, endTime: clock.now(), state: 'success' });

@@ -30,3 +32,14 @@ return response;

}
function mergeRequestHeaders(init, extraRequestHeaders) {
if (!extraRequestHeaders)
return init;
const extraHeaders = {};
for (const h of extraRequestHeaders) {
for (const [name, value] of Object.entries(h)) {
extraHeaders[name] = value;
}
}
return Object.assign(Object.assign({}, init), { headers: Object.assign(Object.assign({}, extraHeaders), init === null || init === void 0 ? void 0 : init.headers) });
}
export { createFetchRequestTracker as default };

@@ -23,3 +23,3 @@ import { RequestTracker } from './request-tracker.js';

this.removeEventListener('readystatechange', existingHandler);
const onRequestEnd = requestTracker.start({
const { onRequestEnd, extraRequestHeaders } = requestTracker.start({
type: 'xmlhttprequest',

@@ -30,2 +30,9 @@ method: requestData.method,

});
if (extraRequestHeaders) {
for (const extraHeaders of extraRequestHeaders) {
for (const [name, value] of Object.entries(extraHeaders)) {
this.setRequestHeader(name, value);
}
}
}
const onReadyStateChange = (evt) => {

@@ -32,0 +39,0 @@ if (this.readyState === xhr.DONE && onRequestEnd) {

23

dist/request-tracker.js

@@ -9,16 +9,23 @@ class RequestTracker {

start(context) {
const endCallbacks = [];
const results = [];
for (const startCallback of this.callbacks) {
const endCallback = startCallback(context);
if (endCallback)
endCallbacks.push(endCallback);
const result = startCallback(context);
if (result)
results.push(result);
}
return (endContext) => {
for (const endCallback of endCallbacks) {
endCallback(endContext);
}
return {
onRequestEnd: (endContext) => {
var _a;
for (const result of results) {
(_a = result === null || result === void 0 ? void 0 : result.onRequestEnd) === null || _a === void 0 ? void 0 : _a.call(result, endContext);
}
},
extraRequestHeaders: results.map(result => result === null || result === void 0 ? void 0 : result.extraRequestHeaders).filter(isDefined)
};
}
}
function isDefined(argument) {
return argument !== undefined;
}
export { RequestTracker };
export interface NetworkRequestInfo {
url: string;
url: string | null;
propagateTraceContext?: boolean;
}

@@ -4,0 +5,0 @@ export type NetworkRequestCallback<T extends NetworkRequestInfo> = (networkRequestInfo: T) => T | null;

@@ -18,3 +18,6 @@ export interface RequestStartContext {

export type RequestEndContext = RequestEndContextSuccess | RequestEndContextError;
export type RequestStartCallback = (context: RequestStartContext) => RequestEndCallback | undefined;
export type RequestStartCallback = (context: RequestStartContext) => {
onRequestEnd?: RequestEndCallback;
extraRequestHeaders?: Record<string, string>;
} | undefined;
export type RequestEndCallback = (context: RequestEndContext) => void;

@@ -24,4 +27,7 @@ export declare class RequestTracker {

onStart(startCallback: RequestStartCallback): void;
start(context: RequestStartContext): (endContext: RequestEndContext) => void;
start(context: RequestStartContext): {
onRequestEnd: (endContext: RequestEndContext) => void;
extraRequestHeaders: Record<string, string>[];
};
}
//# sourceMappingURL=request-tracker.d.ts.map
{
"name": "@bugsnag/request-tracker-performance",
"version": "2.2.0",
"version": "2.3.0-alpha.0",
"description": "BugSnag performance request tracker for monitoring XHR and fetch requests",

@@ -23,3 +23,3 @@ "homepage": "https://www.bugsnag.com/",

"dependencies": {
"@bugsnag/core-performance": "^2.2.0"
"@bugsnag/core-performance": "^2.3.0-alpha.0"
},

@@ -32,3 +32,3 @@ "type": "module",

],
"gitHead": "7b88c34595012a11948078bed7505a1ee0854e17"
"gitHead": "fde1316da0f448bedbdad6a22f9732d14c07ce61"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc