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

@appsignal/javascript

Package Overview
Dependencies
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appsignal/javascript - npm Package Compare versions

Comparing version 1.0.0-beta.6 to 1.0.0-beta.7

dist/cjs/utils/hashmap.d.ts

5

dist/cjs/environment.d.ts

@@ -1,4 +0,5 @@

import { BrowserEnvironment } from "./types/environment";
export declare class Environment {
static serialize(): BrowserEnvironment;
static serialize(): {
[key: string]: string;
};
static origin(): string;

@@ -5,0 +6,0 @@ static transport(): string;

7

dist/cjs/index.d.ts
import { Span } from "./span";
import { compose } from "./utils/functional";
import { IHook } from "./interfaces/IHook";
import { AppsignalOptions } from "./types/options";
import { Breadcrumb } from "@appsignal/types";
export default class Appsignal {

@@ -10,2 +10,3 @@ VERSION: string;

private _api;
private _breadcrumbs;
private _hooks;

@@ -23,6 +24,6 @@ private _env;

addOverride<T extends IHook>(override: T): void;
diagnose(): object;
demo(): void;
addBreadcrumb(breadcrumb: Omit<Breadcrumb, "timestamp">): void;
private _createSpanFromError;
}
export { Span, compose };
//# sourceMappingURL=index.d.ts.map

@@ -8,7 +8,6 @@ "use strict";

var span_1 = require("./span");
exports.Span = span_1.Span;
var functional_1 = require("./utils/functional");
exports.compose = functional_1.compose;
var queue_1 = require("./queue");
var dispatcher_1 = require("./dispatcher");
var hashmap_1 = require("./utils/hashmap");
var Appsignal = (function () {

@@ -32,2 +31,3 @@ function Appsignal(options) {

});
this._breadcrumbs = [];
this._dispatcher = new dispatcher_1.Dispatcher(this._queue, this._api);

@@ -40,3 +40,4 @@ this._options = options;

if (!(data instanceof Error) && !(data instanceof span_1.Span)) {
throw new Error("Can't send error, given error is not a valid type");
console.error("[APPSIGNAL]: Can't send error, given error is not a valid type");
return;
}

@@ -51,2 +52,4 @@ var span = data instanceof span_1.Span ? data : this._createSpanFromError(data);

span.setNamespace(namespace);
if (this._breadcrumbs.length > 0)
span.setBreadcrumbs(this._breadcrumbs);
if (this._hooks.overrides.length > 0) {

@@ -107,9 +110,30 @@ functional_1.compose.apply(void 0, tslib_1.__spread(this._hooks.overrides))(span);

};
Appsignal.prototype.diagnose = function () {
return {
version: this.VERSION,
config: this._options,
environment: this._env
};
Appsignal.prototype.demo = function () {
var span = this._createSpanFromError(new Error("Hello world! This is an error used for demonstration purposes."));
span
.setAction("TestAction")
.setParams({
path: "/hello",
method: "GET"
})
.setTags({
demo_sample: "true"
});
this.send(span);
};
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) });
if (!crumb.category) {
console.warn("[APPSIGNAL]: Breadcrumb not added. `category` is missing.");
return;
}
if (!crumb.action) {
console.warn("[APPSIGNAL]: Breadcrumb not added. `action` is missing.");
return;
}
if (this._breadcrumbs.length === 20) {
this._breadcrumbs.pop();
}
this._breadcrumbs.unshift(crumb);
};
Appsignal.prototype._createSpanFromError = function (error) {

@@ -116,0 +140,0 @@ var event = this.createSpan();

@@ -8,4 +8,4 @@ import { Span } from "./span";

push(item: Span | Span[]): void;
drain(): IterableIterator<Span | undefined>;
drain(): Generator<Span | undefined, void, unknown>;
}
//# sourceMappingURL=queue.d.ts.map
import { Serializable } from "./serializable";
import { Span as AppsignalSpan } from "./types/span";
export declare class Span extends Serializable<AppsignalSpan> {
constructor(span?: Partial<AppsignalSpan>);
import { SpanData, Breadcrumb, HashMap, HashMapValue } from "@appsignal/types";
export declare class Span extends Serializable<SpanData> {
constructor(span?: Partial<SpanData>);
setAction(name: string): this;
setNamespace(name: string): this;
setError<T extends Error>(error: Error | T): this;
setTags(tags: object): this;
setParams(params: object): this;
setTags(tags: HashMap<string>): this;
setParams(params: HashMap<HashMapValue>): this;
setBreadcrumbs(breadcrumbs: Breadcrumb[]): this;
}
//# sourceMappingURL=span.d.ts.map

@@ -6,12 +6,16 @@ "use strict";

var stacktrace_1 = require("./utils/stacktrace");
var hashmap_1 = require("./utils/hashmap");
var Span = (function (_super) {
tslib_1.__extends(Span, _super);
function Span(span) {
return _super.call(this, tslib_1.__assign({ timestamp: Math.round(new Date().getTime() / 1000), namespace: "frontend", revision: "", error: {
name: "",
message: "",
return _super.call(this, tslib_1.__assign({ timestamp: Math.round(new Date().getTime() / 1000), namespace: "frontend", error: {
name: "NullError",
message: "No error has been set",
backtrace: []
}, environment: {}, tags: {}, params: {} }, span)) || this;
} }, span)) || this;
}
Span.prototype.setAction = function (name) {
if (!name || typeof name !== "string") {
return this;
}
this._data.action = name;

@@ -21,2 +25,5 @@ return this;

Span.prototype.setNamespace = function (name) {
if (!name || typeof name !== "string") {
return this;
}
this._data.namespace = name;

@@ -36,9 +43,13 @@ return this;

Span.prototype.setTags = function (tags) {
this._data.tags = tslib_1.__assign({}, this._data.tags, tags);
this._data.tags = tslib_1.__assign(tslib_1.__assign({}, this._data.tags), hashmap_1.toHashMapString(tags));
return this;
};
Span.prototype.setParams = function (params) {
this._data.params = tslib_1.__assign({}, this._data.params, params);
this._data.params = tslib_1.__assign(tslib_1.__assign({}, this._data.params), params);
return this;
};
Span.prototype.setBreadcrumbs = function (breadcrumbs) {
this._data.breadcrumbs = breadcrumbs;
return this;
};
return Span;

@@ -45,0 +56,0 @@ }(serializable_1.Serializable));

@@ -1,2 +0,2 @@

export declare const VERSION = "1.0.0-beta.6";
export declare const VERSION = "1.0.0-beta.7";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = "1.0.0-beta.6";
exports.VERSION = "1.0.0-beta.7";
//# sourceMappingURL=version.js.map

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __awaiter, __generator } from "tslib";
import { Environment } from "./environment";

@@ -15,4 +15,4 @@ import { urlEncode } from "./utils/url";

PushApi.prototype.push = function (span) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {

@@ -19,0 +19,0 @@ case 0: return [4, this._transport.send(span.toJSON())];

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __assign, __awaiter, __generator, __values } from "tslib";
var Dispatcher = (function () {

@@ -9,3 +9,3 @@ function Dispatcher(queue, api, options) {

this._queue = queue;
this.options = tslib_1.__assign({ limit: 5, initialDuration: 1000 }, options);
this.options = __assign({ limit: 5, initialDuration: 1000 }, options);
this.reset();

@@ -17,10 +17,10 @@ }

var BACKOFF_FACTOR = 1.3;
var cb = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var cb = function () { return __awaiter(_this, void 0, void 0, function () {
var _a, _b, span, e_1, expDuration, e_2_1;
var e_2, _c;
return tslib_1.__generator(this, function (_d) {
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_d.trys.push([0, 7, 8, 9]);
_a = tslib_1.__values(this._queue.drain()), _b = _a.next();
_a = __values(this._queue.drain()), _b = _a.next();
_d.label = 1;

@@ -27,0 +27,0 @@ case 1:

@@ -1,4 +0,5 @@

import { BrowserEnvironment } from "./types/environment";
export declare class Environment {
static serialize(): BrowserEnvironment;
static serialize(): {
[key: string]: string;
};
static origin(): string;

@@ -5,0 +6,0 @@ static transport(): string;

import { Span } from "./span";
import { compose } from "./utils/functional";
import { IHook } from "./interfaces/IHook";
import { AppsignalOptions } from "./types/options";
import { Breadcrumb } from "@appsignal/types";
export default class Appsignal {

@@ -10,2 +10,3 @@ VERSION: string;

private _api;
private _breadcrumbs;
private _hooks;

@@ -23,6 +24,6 @@ private _env;

addOverride<T extends IHook>(override: T): void;
diagnose(): object;
demo(): void;
addBreadcrumb(breadcrumb: Omit<Breadcrumb, "timestamp">): void;
private _createSpanFromError;
}
export { Span, compose };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __assign, __awaiter, __generator, __read, __spread } from "tslib";
import { VERSION } from "./version";

@@ -9,2 +9,3 @@ import { PushApi } from "./api";

import { Dispatcher } from "./dispatcher";
import { toHashMap } from "./utils/hashmap";
var Appsignal = (function () {

@@ -28,2 +29,3 @@ function Appsignal(options) {

});
this._breadcrumbs = [];
this._dispatcher = new Dispatcher(this._queue, this._api);

@@ -36,7 +38,8 @@ this._options = options;

if (!(data instanceof Error) && !(data instanceof Span)) {
throw new Error("Can't send error, given error is not a valid type");
console.error("[APPSIGNAL]: Can't send error, given error is not a valid type");
return;
}
var span = data instanceof Span ? data : this._createSpanFromError(data);
if (this._hooks.decorators.length > 0) {
compose.apply(void 0, tslib_1.__spread(this._hooks.decorators))(span);
compose.apply(void 0, __spread(this._hooks.decorators))(span);
}

@@ -47,4 +50,6 @@ if (tags)

span.setNamespace(namespace);
if (this._breadcrumbs.length > 0)
span.setBreadcrumbs(this._breadcrumbs);
if (this._hooks.overrides.length > 0) {
compose.apply(void 0, tslib_1.__spread(this._hooks.overrides))(span);
compose.apply(void 0, __spread(this._hooks.overrides))(span);
}

@@ -79,5 +84,5 @@ if (Environment.supportsPromises()) {

Appsignal.prototype.wrap = function (fn) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return __awaiter(this, void 0, void 0, function () {
var e_1;
return tslib_1.__generator(this, function (_a) {
return __generator(this, function (_a) {
switch (_a.label) {

@@ -104,9 +109,30 @@ case 0:

};
Appsignal.prototype.diagnose = function () {
return {
version: this.VERSION,
config: this._options,
environment: this._env
};
Appsignal.prototype.demo = function () {
var span = this._createSpanFromError(new Error("Hello world! This is an error used for demonstration purposes."));
span
.setAction("TestAction")
.setParams({
path: "/hello",
method: "GET"
})
.setTags({
demo_sample: "true"
});
this.send(span);
};
Appsignal.prototype.addBreadcrumb = function (breadcrumb) {
var crumb = __assign(__assign({ timestamp: Math.round(new Date().getTime() / 1000) }, breadcrumb), { metadata: toHashMap(breadcrumb.metadata) });
if (!crumb.category) {
console.warn("[APPSIGNAL]: Breadcrumb not added. `category` is missing.");
return;
}
if (!crumb.action) {
console.warn("[APPSIGNAL]: Breadcrumb not added. `action` is missing.");
return;
}
if (this._breadcrumbs.length === 20) {
this._breadcrumbs.pop();
}
this._breadcrumbs.unshift(crumb);
};
Appsignal.prototype._createSpanFromError = function (error) {

@@ -120,3 +146,2 @@ var event = this.createSpan();

export default Appsignal;
export { Span, compose };
//# sourceMappingURL=index.js.map

@@ -8,4 +8,4 @@ import { Span } from "./span";

push(item: Span | Span[]): void;
drain(): IterableIterator<Span | undefined>;
drain(): Generator<Span | undefined, void, unknown>;
}
//# sourceMappingURL=queue.d.ts.map

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __generator, __read, __spread } from "tslib";
var Queue = (function () {

@@ -14,6 +14,6 @@ function Queue(data) {

var _a;
(_a = this._data).push.apply(_a, tslib_1.__spread(item));
(_a = this._data).push.apply(_a, __spread(item));
};
Queue.prototype.drain = function () {
return tslib_1.__generator(this, function (_a) {
return __generator(this, function (_a) {
switch (_a.label) {

@@ -20,0 +20,0 @@ case 0:

import { Serializable } from "./serializable";
import { Span as AppsignalSpan } from "./types/span";
export declare class Span extends Serializable<AppsignalSpan> {
constructor(span?: Partial<AppsignalSpan>);
import { SpanData, Breadcrumb, HashMap, HashMapValue } from "@appsignal/types";
export declare class Span extends Serializable<SpanData> {
constructor(span?: Partial<SpanData>);
setAction(name: string): this;
setNamespace(name: string): this;
setError<T extends Error>(error: Error | T): this;
setTags(tags: object): this;
setParams(params: object): this;
setTags(tags: HashMap<string>): this;
setParams(params: HashMap<HashMapValue>): this;
setBreadcrumbs(breadcrumbs: Breadcrumb[]): this;
}
//# sourceMappingURL=span.d.ts.map

@@ -1,14 +0,18 @@

import * as tslib_1 from "tslib";
import { __assign, __extends } from "tslib";
import { Serializable } from "./serializable";
import { getStacktrace } from "./utils/stacktrace";
import { toHashMapString } from "./utils/hashmap";
var Span = (function (_super) {
tslib_1.__extends(Span, _super);
__extends(Span, _super);
function Span(span) {
return _super.call(this, tslib_1.__assign({ timestamp: Math.round(new Date().getTime() / 1000), namespace: "frontend", revision: "", error: {
name: "",
message: "",
return _super.call(this, __assign({ timestamp: Math.round(new Date().getTime() / 1000), namespace: "frontend", error: {
name: "NullError",
message: "No error has been set",
backtrace: []
}, environment: {}, tags: {}, params: {} }, span)) || this;
} }, span)) || this;
}
Span.prototype.setAction = function (name) {
if (!name || typeof name !== "string") {
return this;
}
this._data.action = name;

@@ -18,2 +22,5 @@ return this;

Span.prototype.setNamespace = function (name) {
if (!name || typeof name !== "string") {
return this;
}
this._data.namespace = name;

@@ -33,9 +40,13 @@ return this;

Span.prototype.setTags = function (tags) {
this._data.tags = tslib_1.__assign({}, this._data.tags, tags);
this._data.tags = __assign(__assign({}, this._data.tags), toHashMapString(tags));
return this;
};
Span.prototype.setParams = function (params) {
this._data.params = tslib_1.__assign({}, this._data.params, params);
this._data.params = __assign(__assign({}, this._data.params), params);
return this;
};
Span.prototype.setBreadcrumbs = function (breadcrumbs) {
this._data.breadcrumbs = breadcrumbs;
return this;
};
return Span;

@@ -42,0 +53,0 @@ }(Serializable));

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __awaiter, __generator } from "tslib";
var FetchTransport = (function () {

@@ -7,5 +7,5 @@ function FetchTransport(url, headers) {

FetchTransport.prototype.send = function (data) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return __awaiter(this, void 0, void 0, function () {
var res, statusText, ok;
return tslib_1.__generator(this, function (_a) {
return __generator(this, function (_a) {
switch (_a.label) {

@@ -12,0 +12,0 @@ case 0: return [4, fetch(this.url, {

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __read, __spread } from "tslib";
export function compose() {

@@ -15,5 +15,5 @@ var funcs = [];

}
return a(b.apply(void 0, tslib_1.__spread(args)));
return a(b.apply(void 0, __spread(args)));
}; });
}
//# sourceMappingURL=functional.js.map

@@ -1,2 +0,2 @@

export declare const VERSION = "1.0.0-beta.6";
export declare const VERSION = "1.0.0-beta.7";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

export var VERSION = "1.0.0-beta.6";
export var VERSION = "1.0.0-beta.7";
//# sourceMappingURL=version.js.map
{
"name": "@appsignal/javascript",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"main": "dist/cjs/index.js",

@@ -10,3 +10,3 @@ "module": "dist/esm/index.js",

"scripts": {
"build": "run-s versionfile build:cjs build:esm",
"build": "run-s build:cjs build:esm",
"build:esm": "tsc -p tsconfig.esm.json",

@@ -16,9 +16,9 @@ "build:esm:watch": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",

"build:cjs:watch": "tsc -p tsconfig.cjs.json -w --preserveWatchOutput",
"build:watch": "run-p build:cjs:watch build:esm:watch",
"clean": "rimraf dist coverage src/version.ts",
"build:watch": "yarn versionfile && run-p build:cjs:watch build:esm:watch",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"test": "jest",
"test:watch": "jest --watch",
"prepublish": "run-s clean build",
"versionfile": "node scripts/create-versionfile.js"
"versionfile": "node scripts/create-versionfile.js",
"postversion": "yarn versionfile"
},

@@ -29,6 +29,7 @@ "publishConfig": {

"dependencies": {
"@appsignal/types": "^1.0.0-beta.0",
"error-stack-parser": "^2.0.2",
"tslib": "^1.10.0"
},
"gitHead": "59dc875708a7e6138cfd60960e5f9036e885e64c"
"gitHead": "cbfc8f73b18884a2dae0d55b7c7fe775c754335b"
}

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

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