@appsignal/plugin-breadcrumbs-network
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,6 +0,10 @@ | ||
declare function networkBreadcrumbsPlugin(options?: { | ||
[key: string]: any; | ||
}): (this: any) => void; | ||
import Appsignal from "@appsignal/javascript"; | ||
declare type PluginOptions = { | ||
xhrEnabled: true; | ||
fetchEnabled: true; | ||
ignoreUrls: RegExp[]; | ||
}; | ||
declare function networkBreadcrumbsPlugin({ xhrEnabled, fetchEnabled, ignoreUrls }: Partial<PluginOptions>): (this: Appsignal) => void; | ||
export declare const plugin: typeof networkBreadcrumbsPlugin; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function networkBreadcrumbsPlugin(options) { | ||
var opts = __assign({ xhrEnabled: true, fetchEnabled: true }, options); | ||
opts.xhrEnabled = opts.xhrEnabled ? "XMLHttpRequest" in window : false; | ||
opts.fetchEnabled = opts.xhrEnabled ? "fetch" in window : false; | ||
function networkBreadcrumbsPlugin(_a) { | ||
var _b = _a.xhrEnabled, xhrEnabled = _b === void 0 ? true : _b, _c = _a.fetchEnabled, fetchEnabled = _c === void 0 ? true : _c, _d = _a.ignoreUrls, ignoreUrls = _d === void 0 ? [] : _d; | ||
var isXhrEnabled = xhrEnabled ? "XMLHttpRequest" in window : false; | ||
var isFetchEnabled = fetchEnabled ? "fetch" in window : false; | ||
return function () { | ||
var _this = this; | ||
var appsignal = this; | ||
var xhrPatch = function () { | ||
var appsignal = _this; | ||
var prevOpen = XMLHttpRequest.prototype.open; | ||
@@ -26,16 +14,20 @@ function open(method, url) { | ||
function onXhrLoad() { | ||
appsignal.addBreadcrumb({ | ||
action: this.status >= 400 | ||
? "Request failed with code " + this.status | ||
: "Recieved a response with code " + this.status, | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
if (!ignoreUrls.some(function (el) { return el.test(url); })) { | ||
appsignal.addBreadcrumb({ | ||
action: this.status >= 400 | ||
? "Request failed with code " + this.status | ||
: "Recieved a response with code " + this.status, | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
} | ||
} | ||
function onXhrError() { | ||
appsignal.addBreadcrumb({ | ||
action: "Request failed", | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
if (!ignoreUrls.some(function (el) { return el.test(url); })) { | ||
appsignal.addBreadcrumb({ | ||
action: "Request failed", | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
} | ||
} | ||
@@ -49,3 +41,2 @@ this.addEventListener("load", onXhrLoad); | ||
var fetchPatch = function () { | ||
var appsignal = _this; | ||
var originalFetch = window.fetch; | ||
@@ -61,2 +52,5 @@ function fetch(input, init) { | ||
}; | ||
if (ignoreUrls.some(function (el) { return el.test(url); })) { | ||
return originalFetch.apply(window, arguments); | ||
} | ||
return originalFetch | ||
@@ -84,5 +78,5 @@ .apply(window, arguments) | ||
}; | ||
if (opts.xhrEnabled) | ||
if (isXhrEnabled) | ||
xhrPatch(); | ||
if (opts.fetchEnabled) | ||
if (isFetchEnabled) | ||
fetchPatch(); | ||
@@ -89,0 +83,0 @@ }; |
@@ -1,6 +0,10 @@ | ||
declare function networkBreadcrumbsPlugin(options?: { | ||
[key: string]: any; | ||
}): (this: any) => void; | ||
import Appsignal from "@appsignal/javascript"; | ||
declare type PluginOptions = { | ||
xhrEnabled: true; | ||
fetchEnabled: true; | ||
ignoreUrls: RegExp[]; | ||
}; | ||
declare function networkBreadcrumbsPlugin({ xhrEnabled, fetchEnabled, ignoreUrls }: Partial<PluginOptions>): (this: Appsignal) => void; | ||
export declare const plugin: typeof networkBreadcrumbsPlugin; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,20 +0,8 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function networkBreadcrumbsPlugin(options) { | ||
var opts = __assign({ xhrEnabled: true, fetchEnabled: true }, options); | ||
opts.xhrEnabled = opts.xhrEnabled ? "XMLHttpRequest" in window : false; | ||
opts.fetchEnabled = opts.xhrEnabled ? "fetch" in window : false; | ||
function networkBreadcrumbsPlugin(_a) { | ||
var _b = _a.xhrEnabled, xhrEnabled = _b === void 0 ? true : _b, _c = _a.fetchEnabled, fetchEnabled = _c === void 0 ? true : _c, _d = _a.ignoreUrls, ignoreUrls = _d === void 0 ? [] : _d; | ||
var isXhrEnabled = xhrEnabled ? "XMLHttpRequest" in window : false; | ||
var isFetchEnabled = fetchEnabled ? "fetch" in window : false; | ||
return function () { | ||
var _this = this; | ||
var appsignal = this; | ||
var xhrPatch = function () { | ||
var appsignal = _this; | ||
var prevOpen = XMLHttpRequest.prototype.open; | ||
@@ -24,16 +12,20 @@ function open(method, url) { | ||
function onXhrLoad() { | ||
appsignal.addBreadcrumb({ | ||
action: this.status >= 400 | ||
? "Request failed with code " + this.status | ||
: "Recieved a response with code " + this.status, | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
if (!ignoreUrls.some(function (el) { return el.test(url); })) { | ||
appsignal.addBreadcrumb({ | ||
action: this.status >= 400 | ||
? "Request failed with code " + this.status | ||
: "Recieved a response with code " + this.status, | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
} | ||
} | ||
function onXhrError() { | ||
appsignal.addBreadcrumb({ | ||
action: "Request failed", | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
if (!ignoreUrls.some(function (el) { return el.test(url); })) { | ||
appsignal.addBreadcrumb({ | ||
action: "Request failed", | ||
category: "XMLHttpRequest", | ||
metadata: metadata | ||
}); | ||
} | ||
} | ||
@@ -47,3 +39,2 @@ this.addEventListener("load", onXhrLoad); | ||
var fetchPatch = function () { | ||
var appsignal = _this; | ||
var originalFetch = window.fetch; | ||
@@ -59,2 +50,5 @@ function fetch(input, init) { | ||
}; | ||
if (ignoreUrls.some(function (el) { return el.test(url); })) { | ||
return originalFetch.apply(window, arguments); | ||
} | ||
return originalFetch | ||
@@ -82,5 +76,5 @@ .apply(window, arguments) | ||
}; | ||
if (opts.xhrEnabled) | ||
if (isXhrEnabled) | ||
xhrPatch(); | ||
if (opts.fetchEnabled) | ||
if (isFetchEnabled) | ||
fetchPatch(); | ||
@@ -87,0 +81,0 @@ }; |
{ | ||
"name": "@appsignal/plugin-breadcrumbs-network", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -21,6 +21,9 @@ "module": "dist/esm/index.js", | ||
}, | ||
"dependencies": { | ||
"@appsignal/javascript": "^1.3.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "804f605f616b747a6b5e0e66e187ee647d85b6d2" | ||
"gitHead": "014073816af166064c91bc96548f8fd508836820" | ||
} |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
19203
1
178
1
+ Added@appsignal/javascript@^1.3.0
+ Added@appsignal/javascript@1.5.0(transitive)
+ Addedtslib@2.8.1(transitive)