@appsignal/javascript
Advanced tools
Comparing version 1.0.1 to 1.1.0-alpha.170
# Changelog | ||
## 1.2.0 | ||
- Dependency bumps | ||
- Add tags and namespace params to `appsignal.wrap()` method | ||
## 1.1.2 | ||
- Dependency bumps | ||
## 1.1.1 | ||
- Fix package dependency issue in `@appsignal/javascript` package | ||
## 1.1.0 | ||
- Dependency bumps | ||
- Split some reusable logic into `@appsignal/core` package | ||
- Fix errors when run with in React Native (#130) | ||
- Add ignored errors list (#134) | ||
(v.1.1.0 was marked as deprecated due to a bad release) | ||
## 1.0.1 | ||
- Dependency bumps, no new features |
@@ -5,3 +5,3 @@ "use strict"; | ||
var environment_1 = require("./environment"); | ||
var url_1 = require("./utils/url"); | ||
var core_1 = require("@appsignal/core"); | ||
var xdomain_1 = require("./transports/xdomain"); | ||
@@ -42,3 +42,3 @@ var xhr_1 = require("./transports/xhr"); | ||
var auth = this._authorization(); | ||
return this._uri + "?" + url_1.urlEncode(auth); | ||
return this._uri + "?" + core_1.urlEncode(auth); | ||
}; | ||
@@ -45,0 +45,0 @@ PushApi.prototype._authorization = function () { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core_1 = require("@appsignal/core"); | ||
var Dispatcher = (function () { | ||
@@ -17,2 +18,3 @@ function Dispatcher(queue, api, options) { | ||
if (time === void 0) { time = this._duration; } | ||
var globals = core_1.getGlobalObject(); | ||
var BACKOFF_FACTOR = 1.3; | ||
@@ -72,3 +74,3 @@ var cb = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
}); }; | ||
return window.setTimeout(cb, time); | ||
return globals.setTimeout(cb, time); | ||
}; | ||
@@ -75,0 +77,0 @@ Dispatcher.prototype.reset = function () { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@appsignal/core"); | ||
var Environment = (function () { | ||
@@ -13,10 +14,15 @@ function Environment() { | ||
Environment.origin = function () { | ||
return (window.location.origin || | ||
window.location.protocol + "//" + window.location.hostname); | ||
var globals = core_1.getGlobalObject(); | ||
if ((navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative" && !globals.location) { | ||
return ""; | ||
} | ||
return (globals.location.origin || | ||
globals.location.protocol + "//" + globals.location.hostname); | ||
}; | ||
Environment.transport = function () { | ||
if (window.XDomainRequest) { | ||
var globals = core_1.getGlobalObject(); | ||
if (globals.XDomainRequest) { | ||
return "XDomainRequest"; | ||
} | ||
else if (window.XMLHttpRequest && !window.fetch) { | ||
else if (globals.XMLHttpRequest && !globals.fetch) { | ||
return "XMLHttpRequest"; | ||
@@ -29,19 +35,15 @@ } | ||
Environment.supportsPromises = function () { | ||
var P = window.Promise; | ||
if (P) { | ||
var promiseToString = null; | ||
try { | ||
promiseToString = Object.prototype.toString.call(P.resolve()); | ||
} | ||
catch (e) { | ||
} | ||
if (promiseToString === "[object Promise]" && !P.cast) { | ||
return true; | ||
} | ||
if (promiseToString === "[object Object]" && | ||
Promise.prototype._guidKey) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
var globals = core_1.getGlobalObject(); | ||
return ("Promise" in globals && | ||
"resolve" in globals.Promise && | ||
"reject" in globals.Promise && | ||
"all" in globals.Promise && | ||
"race" in globals.Promise && | ||
(function () { | ||
var resolve; | ||
new globals.Promise(function (r) { | ||
resolve = r; | ||
}); | ||
return typeof resolve === "function"; | ||
})()); | ||
}; | ||
@@ -48,0 +50,0 @@ return Environment; |
@@ -7,2 +7,3 @@ import { Breadcrumb } from "@appsignal/types"; | ||
VERSION: string; | ||
ignored: RegExp[]; | ||
private _dispatcher; | ||
@@ -21,3 +22,3 @@ private _options; | ||
createSpan(fn?: Function): Span; | ||
wrap(fn: Function): Promise<any>; | ||
wrap(fn: Function, tags?: {}, namespace?: string): Promise<any>; | ||
addDecorator<T extends IHook>(decorator: T): void; | ||
@@ -24,0 +25,0 @@ addOverride<T extends IHook>(override: T): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core_1 = require("@appsignal/core"); | ||
var version_1 = require("./version"); | ||
@@ -10,4 +11,2 @@ var api_1 = require("./api"); | ||
var dispatcher_1 = require("./dispatcher"); | ||
var hashmap_1 = require("./utils/hashmap"); | ||
var functional_1 = require("./utils/functional"); | ||
var Appsignal = (function () { | ||
@@ -31,2 +30,3 @@ function Appsignal(options) { | ||
}); | ||
this.ignored = options.ignoreErrors || []; | ||
this._breadcrumbs = []; | ||
@@ -43,5 +43,19 @@ this._dispatcher = new dispatcher_1.Dispatcher(this._queue, this._api); | ||
} | ||
if (this.ignored.length !== 0) { | ||
if (data instanceof Error && | ||
this.ignored.some(function (el) { return el.test(data.message); })) { | ||
console.warn("[APPSIGNAL]: Ignored an error: " + data.message); | ||
return; | ||
} | ||
if (data instanceof span_1.Span) { | ||
var error_1 = data.serialize().error; | ||
if (error_1.message && this.ignored.some(function (el) { return el.test(error_1.message); })) { | ||
console.warn("[APPSIGNAL]: Ignored a span: " + error_1.message); | ||
return; | ||
} | ||
} | ||
} | ||
var span = data instanceof span_1.Span ? data : this._createSpanFromError(data); | ||
if (this._hooks.decorators.length > 0) { | ||
functional_1.compose.apply(void 0, tslib_1.__spread(this._hooks.decorators))(span); | ||
core_1.compose.apply(void 0, tslib_1.__spread(this._hooks.decorators))(span); | ||
} | ||
@@ -55,3 +69,3 @@ if (tags) | ||
if (this._hooks.overrides.length > 0) { | ||
functional_1.compose.apply(void 0, tslib_1.__spread(this._hooks.overrides))(span); | ||
core_1.compose.apply(void 0, tslib_1.__spread(this._hooks.overrides))(span); | ||
} | ||
@@ -88,3 +102,4 @@ if (environment_1.Environment.supportsPromises()) { | ||
}; | ||
Appsignal.prototype.wrap = function (fn) { | ||
Appsignal.prototype.wrap = function (fn, tags, namespace) { | ||
if (tags === void 0) { tags = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -95,11 +110,12 @@ var e_1; | ||
case 0: | ||
_a.trys.push([0, 1, , 3]); | ||
return [2, Promise.resolve(fn())]; | ||
case 1: | ||
_a.trys.push([0, 2, , 4]); | ||
return [4, fn()]; | ||
case 1: return [2, _a.sent()]; | ||
case 2: | ||
e_1 = _a.sent(); | ||
return [4, this.sendError(e_1)]; | ||
case 2: | ||
return [4, this.sendError(e_1, tags, namespace)]; | ||
case 3: | ||
_a.sent(); | ||
return [2, Promise.reject(e_1)]; | ||
case 3: return [2]; | ||
case 4: return [2]; | ||
} | ||
@@ -129,3 +145,3 @@ }); | ||
Appsignal.prototype.addBreadcrumb = function (breadcrumb) { | ||
var crumb = tslib_1.__assign(tslib_1.__assign({ timestamp: Math.round(new Date().getTime() / 1000) }, breadcrumb), { metadata: hashmap_1.toHashMap(breadcrumb.metadata) }); | ||
var crumb = tslib_1.__assign(tslib_1.__assign({ timestamp: Math.round(new Date().getTime() / 1000) }, breadcrumb), { metadata: core_1.toHashMap(breadcrumb.metadata) }); | ||
if (!crumb.category) { | ||
@@ -132,0 +148,0 @@ console.warn("[APPSIGNAL]: Breadcrumb not added. `category` is missing."); |
@@ -0,3 +1,3 @@ | ||
import { Serializable } from "@appsignal/core"; | ||
import { SpanData, Breadcrumb, HashMap, HashMapValue } from "@appsignal/types"; | ||
import { Serializable } from "./serializable"; | ||
export declare class Span extends Serializable<SpanData> { | ||
@@ -4,0 +4,0 @@ constructor(span?: Partial<SpanData>); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var serializable_1 = require("./serializable"); | ||
var stacktrace_1 = require("./utils/stacktrace"); | ||
var hashmap_1 = require("./utils/hashmap"); | ||
var core_1 = require("@appsignal/core"); | ||
var Span = (function (_super) { | ||
@@ -36,3 +34,3 @@ tslib_1.__extends(Span, _super); | ||
message: error.message || "No message given", | ||
backtrace: stacktrace_1.getStacktrace(error) | ||
backtrace: core_1.getStacktrace(error) | ||
}; | ||
@@ -42,3 +40,3 @@ return this; | ||
Span.prototype.setTags = function (tags) { | ||
this._data.tags = tslib_1.__assign(tslib_1.__assign({}, this._data.tags), hashmap_1.toHashMapString(tags)); | ||
this._data.tags = tslib_1.__assign(tslib_1.__assign({}, this._data.tags), core_1.toHashMapString(tags)); | ||
return this; | ||
@@ -55,4 +53,4 @@ }; | ||
return Span; | ||
}(serializable_1.Serializable)); | ||
}(core_1.Serializable)); | ||
exports.Span = Span; | ||
//# sourceMappingURL=span.js.map |
@@ -10,6 +10,7 @@ "use strict"; | ||
return new Promise(function (resolve, reject) { | ||
var _a; | ||
var req = new XDomainRequest(); | ||
var rx = new RegExp("^https?:"); | ||
req.onload = function () { return resolve({}); }; | ||
req.open("POST", _this.url.replace(rx, window.location.protocol)); | ||
req.open("POST", _this.url.replace(rx, (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.protocol)); | ||
setTimeout(function () { | ||
@@ -16,0 +17,0 @@ try { |
@@ -8,2 +8,3 @@ declare type BaseOptions = { | ||
revision?: string; | ||
ignoreErrors?: RegExp[]; | ||
}; | ||
@@ -10,0 +11,0 @@ export declare type PushApiOptions = BaseOptions & { |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.0.1"; | ||
export declare const VERSION = "1.2.1"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = "1.0.1"; | ||
exports.VERSION = "1.2.1"; | ||
//# sourceMappingURL=version.js.map |
import { __awaiter, __generator } from "tslib"; | ||
import { Environment } from "./environment"; | ||
import { urlEncode } from "./utils/url"; | ||
import { urlEncode } from "@appsignal/core"; | ||
import { XDomainTransport } from "./transports/xdomain"; | ||
@@ -5,0 +5,0 @@ import { XHRTransport } from "./transports/xhr"; |
import { __assign, __awaiter, __generator, __values } from "tslib"; | ||
import { getGlobalObject } from "@appsignal/core"; | ||
var Dispatcher = (function () { | ||
@@ -15,2 +16,3 @@ function Dispatcher(queue, api, options) { | ||
if (time === void 0) { time = this._duration; } | ||
var globals = getGlobalObject(); | ||
var BACKOFF_FACTOR = 1.3; | ||
@@ -70,3 +72,3 @@ var cb = function () { return __awaiter(_this, void 0, void 0, function () { | ||
}); }; | ||
return window.setTimeout(cb, time); | ||
return globals.setTimeout(cb, time); | ||
}; | ||
@@ -73,0 +75,0 @@ Dispatcher.prototype.reset = function () { |
@@ -0,1 +1,2 @@ | ||
import { getGlobalObject } from "@appsignal/core"; | ||
var Environment = (function () { | ||
@@ -11,10 +12,15 @@ function Environment() { | ||
Environment.origin = function () { | ||
return (window.location.origin || | ||
window.location.protocol + "//" + window.location.hostname); | ||
var globals = getGlobalObject(); | ||
if ((navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative" && !globals.location) { | ||
return ""; | ||
} | ||
return (globals.location.origin || | ||
globals.location.protocol + "//" + globals.location.hostname); | ||
}; | ||
Environment.transport = function () { | ||
if (window.XDomainRequest) { | ||
var globals = getGlobalObject(); | ||
if (globals.XDomainRequest) { | ||
return "XDomainRequest"; | ||
} | ||
else if (window.XMLHttpRequest && !window.fetch) { | ||
else if (globals.XMLHttpRequest && !globals.fetch) { | ||
return "XMLHttpRequest"; | ||
@@ -27,19 +33,15 @@ } | ||
Environment.supportsPromises = function () { | ||
var P = window.Promise; | ||
if (P) { | ||
var promiseToString = null; | ||
try { | ||
promiseToString = Object.prototype.toString.call(P.resolve()); | ||
} | ||
catch (e) { | ||
} | ||
if (promiseToString === "[object Promise]" && !P.cast) { | ||
return true; | ||
} | ||
if (promiseToString === "[object Object]" && | ||
Promise.prototype._guidKey) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
var globals = getGlobalObject(); | ||
return ("Promise" in globals && | ||
"resolve" in globals.Promise && | ||
"reject" in globals.Promise && | ||
"all" in globals.Promise && | ||
"race" in globals.Promise && | ||
(function () { | ||
var resolve; | ||
new globals.Promise(function (r) { | ||
resolve = r; | ||
}); | ||
return typeof resolve === "function"; | ||
})()); | ||
}; | ||
@@ -46,0 +48,0 @@ return Environment; |
@@ -7,2 +7,3 @@ import { Breadcrumb } from "@appsignal/types"; | ||
VERSION: string; | ||
ignored: RegExp[]; | ||
private _dispatcher; | ||
@@ -21,3 +22,3 @@ private _options; | ||
createSpan(fn?: Function): Span; | ||
wrap(fn: Function): Promise<any>; | ||
wrap(fn: Function, tags?: {}, namespace?: string): Promise<any>; | ||
addDecorator<T extends IHook>(decorator: T): void; | ||
@@ -24,0 +25,0 @@ addOverride<T extends IHook>(override: T): void; |
import { __assign, __awaiter, __generator, __read, __spread } from "tslib"; | ||
import { compose, toHashMap } from "@appsignal/core"; | ||
import { VERSION } from "./version"; | ||
@@ -8,4 +9,2 @@ import { PushApi } from "./api"; | ||
import { Dispatcher } from "./dispatcher"; | ||
import { toHashMap } from "./utils/hashmap"; | ||
import { compose } from "./utils/functional"; | ||
var Appsignal = (function () { | ||
@@ -29,2 +28,3 @@ function Appsignal(options) { | ||
}); | ||
this.ignored = options.ignoreErrors || []; | ||
this._breadcrumbs = []; | ||
@@ -41,2 +41,16 @@ this._dispatcher = new Dispatcher(this._queue, this._api); | ||
} | ||
if (this.ignored.length !== 0) { | ||
if (data instanceof Error && | ||
this.ignored.some(function (el) { return el.test(data.message); })) { | ||
console.warn("[APPSIGNAL]: Ignored an error: " + data.message); | ||
return; | ||
} | ||
if (data instanceof Span) { | ||
var error_1 = data.serialize().error; | ||
if (error_1.message && this.ignored.some(function (el) { return el.test(error_1.message); })) { | ||
console.warn("[APPSIGNAL]: Ignored a span: " + error_1.message); | ||
return; | ||
} | ||
} | ||
} | ||
var span = data instanceof Span ? data : this._createSpanFromError(data); | ||
@@ -85,3 +99,4 @@ if (this._hooks.decorators.length > 0) { | ||
}; | ||
Appsignal.prototype.wrap = function (fn) { | ||
Appsignal.prototype.wrap = function (fn, tags, namespace) { | ||
if (tags === void 0) { tags = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -92,11 +107,12 @@ var e_1; | ||
case 0: | ||
_a.trys.push([0, 1, , 3]); | ||
return [2, Promise.resolve(fn())]; | ||
case 1: | ||
_a.trys.push([0, 2, , 4]); | ||
return [4, fn()]; | ||
case 1: return [2, _a.sent()]; | ||
case 2: | ||
e_1 = _a.sent(); | ||
return [4, this.sendError(e_1)]; | ||
case 2: | ||
return [4, this.sendError(e_1, tags, namespace)]; | ||
case 3: | ||
_a.sent(); | ||
return [2, Promise.reject(e_1)]; | ||
case 3: return [2]; | ||
case 4: return [2]; | ||
} | ||
@@ -103,0 +119,0 @@ }); |
@@ -0,3 +1,3 @@ | ||
import { Serializable } from "@appsignal/core"; | ||
import { SpanData, Breadcrumb, HashMap, HashMapValue } from "@appsignal/types"; | ||
import { Serializable } from "./serializable"; | ||
export declare class Span extends Serializable<SpanData> { | ||
@@ -4,0 +4,0 @@ constructor(span?: Partial<SpanData>); |
import { __assign, __extends } from "tslib"; | ||
import { Serializable } from "./serializable"; | ||
import { getStacktrace } from "./utils/stacktrace"; | ||
import { toHashMapString } from "./utils/hashmap"; | ||
import { Serializable, getStacktrace, toHashMapString } from "@appsignal/core"; | ||
var Span = (function (_super) { | ||
@@ -6,0 +4,0 @@ __extends(Span, _super); |
@@ -8,6 +8,7 @@ var XDomainTransport = (function () { | ||
return new Promise(function (resolve, reject) { | ||
var _a; | ||
var req = new XDomainRequest(); | ||
var rx = new RegExp("^https?:"); | ||
req.onload = function () { return resolve({}); }; | ||
req.open("POST", _this.url.replace(rx, window.location.protocol)); | ||
req.open("POST", _this.url.replace(rx, (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.protocol)); | ||
setTimeout(function () { | ||
@@ -14,0 +15,0 @@ try { |
@@ -8,2 +8,3 @@ declare type BaseOptions = { | ||
revision?: string; | ||
ignoreErrors?: RegExp[]; | ||
}; | ||
@@ -10,0 +11,0 @@ export declare type PushApiOptions = BaseOptions & { |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.0.1"; | ||
export declare const VERSION = "1.2.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export var VERSION = "1.0.1"; | ||
export var VERSION = "1.2.1"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@appsignal/javascript", | ||
"version": "1.0.1", | ||
"version": "1.1.0-alpha.170+c098fe7", | ||
"main": "dist/cjs/index.js", | ||
@@ -21,3 +21,3 @@ "module": "dist/esm/index.js", | ||
"versionfile": "node scripts/create-versionfile.js", | ||
"postversion": "yarn versionfile" | ||
"version": "yarn versionfile" | ||
}, | ||
@@ -28,6 +28,9 @@ "publishConfig": { | ||
"dependencies": { | ||
"@appsignal/types": "^1.0.0", | ||
"tslib": "^1.10.0" | ||
"@appsignal/core": "^1.1.0-alpha.336+c098fe7", | ||
"tslib": "^1.11.1" | ||
}, | ||
"gitHead": "e5e14e5abf27c1e111bb63a5d82957b61050ffda" | ||
"devDependencies": { | ||
"@appsignal/types": "^1.0.0" | ||
}, | ||
"gitHead": "c098fe7601e86374dcc76e5b4474ec2f5405ca15" | ||
} |
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
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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86977
1
107
1266
2
3
+ Added@appsignal/core@1.1.22(transitive)
+ Addedtslib@2.7.0(transitive)
- Removed@appsignal/types@^1.0.0
- Removed@appsignal/types@1.0.0(transitive)
Updatedtslib@^1.11.1