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

@appsignal/javascript

Package Overview
Dependencies
Maintainers
2
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-alpha.0 to 1.0.0-alpha.1

dist/cjs/error.js

52

dist/cjs/api.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,8 +60,17 @@ var environment_1 = require("./environment");

*
* @param {Transaction} txn A single API transaction object
* @param {Span} span A single API `Span`
*
* @return {Promise<any>} An API response
* @return {Promise<Span>} A single API `Span`
*/
PushApi.prototype.push = function (txn) {
return this._transport.send(txn.toJSON());
PushApi.prototype.push = function (span) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._transport.send(span.toJSON())];
case 1:
_a.sent();
return [2 /*return*/, span];
}
});
});
};

@@ -33,0 +77,0 @@ /**

89

dist/cjs/index.js

@@ -9,3 +9,3 @@ "use strict";

var environment_1 = require("./environment");
var transaction_1 = require("./transaction");
var span_1 = require("./span");
var Appsignal = /** @class */ (function () {

@@ -17,7 +17,6 @@ /**

*
* @param {AppsignalOptions} options An object of options to configure the AppSignal client
* @param {AppsignalOptions} options An object of options to configure the AppSignal client
*/
function Appsignal(options) {
this.VERSION = "1.0.0";
this._action = "";
this._env = environment_1.Environment.serialize();

@@ -32,28 +31,24 @@ var key = options.key, uri = options.uri;

}
Appsignal.prototype.setAction = function (name) {
this._action = name;
};
/**
* Records and sends an exception to AppSignal.
*
* @param {Error} error A JavaScript Error object
* @param {Error | Span} data A JavaScript Error or Appsignal Span object
* @param {object} tags An key, value object of tags
* @param {string} namespace An optional namespace name
*
* @return {Promise<any>} An API response
* @return {Promise<Span> | void} An API response, or `void` if `Promise` is unsupported.
*/
Appsignal.prototype.sendError = function (error, tags, namespace) {
Appsignal.prototype.send = function (data, tags, namespace) {
if (tags === void 0) { tags = {}; }
var txn = new transaction_1.Transaction({
action: this._action,
environment: this._env
});
if (!(error instanceof Error)) {
throw new Error("Can't send error, given error is not a valid Error object");
if (!(data instanceof Error) && !(data instanceof span_1.Span)) {
throw new Error("Can't send error, given error is not a valid type");
}
txn.setError(error);
// "events" refer to a fixed point in time, as opposed to
// a range or length in time
var span = data instanceof span_1.Span ? data : this._createSpanFromError(data);
if (tags)
txn.setTags(tags);
span.setTags(tags);
if (namespace)
txn.setNamespace(namespace);
span.setNamespace(namespace);
if (environment_1.Environment.supportsPromises()) {
return this._api.push(txn);
return this._api.push(span);
}

@@ -67,6 +62,45 @@ else {

/**
* Records and sends a browser `Error` to AppSignal. An alias to `#send()`
* to maintain compatibility.
*
* @param {Error} error A JavaScript Error object
* @param {object} tags An key, value object of tags
* @param {string} namespace An optional namespace name
*
* @return {Promise<Span> | void} An API response, or `void` if `Promise` is unsupported.
*/
Appsignal.prototype.sendError = function (error, tags, namespace) {
return this.send(error, tags, namespace);
};
/**
* Registers and installs a valid plugin.
*
* A plugin is typically a function that can be used to provide a
* reference to the `Appsignal` instance via returning a function
* that can be bound to `this`.
*
* @param {Plugin} plugin A JavaScript Error object
*
* @return {void}
*/
Appsignal.prototype.use = function (plugin) {
plugin.call(this);
};
/**
* Creates a new `Span`, augmented with the current environment.
*
* @return {Span} An AppSignal `Span` object
*/
Appsignal.prototype.createSpan = function () {
var _a = this._options.revision, revision = _a === void 0 ? "" : _a;
return new span_1.Span({
environment: this._env,
revision: revision
});
};
/**
* Returns an object that includes useful diagnostic information.
* Can be used to debug the installation.
*
* @return {object} A diagnostic report
* @return {object} A diagnostic report
*/

@@ -80,4 +114,17 @@ Appsignal.prototype.diagnose = function () {

};
/**
* Creates a valid AppSignal `Span` from a JavaScript `Error`
* object.
*
* @param {Error} error A JavaScript error
*
* @return {Span} An AppSignal event
*/
Appsignal.prototype._createSpanFromError = function (error) {
var event = this.createSpan();
event.setError(error);
return event;
};
return Appsignal;
}());
exports.default = Appsignal;

@@ -0,1 +1,36 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { Environment } from "./environment";

@@ -23,8 +58,17 @@ import { urlEncode } from "./utils/url";

*
* @param {Transaction} txn A single API transaction object
* @param {Span} span A single API `Span`
*
* @return {Promise<any>} An API response
* @return {Promise<Span>} A single API `Span`
*/
PushApi.prototype.push = function (txn) {
return this._transport.send(txn.toJSON());
PushApi.prototype.push = function (span) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._transport.send(span.toJSON())];
case 1:
_a.sent();
return [2 /*return*/, span];
}
});
});
};

@@ -31,0 +75,0 @@ /**

@@ -7,3 +7,3 @@ /**

import { Environment } from "./environment";
import { Transaction } from "./transaction";
import { Span } from "./span";
var Appsignal = /** @class */ (function () {

@@ -15,7 +15,6 @@ /**

*
* @param {AppsignalOptions} options An object of options to configure the AppSignal client
* @param {AppsignalOptions} options An object of options to configure the AppSignal client
*/
function Appsignal(options) {
this.VERSION = "1.0.0";
this._action = "";
this._env = Environment.serialize();

@@ -30,28 +29,24 @@ var key = options.key, uri = options.uri;

}
Appsignal.prototype.setAction = function (name) {
this._action = name;
};
/**
* Records and sends an exception to AppSignal.
*
* @param {Error} error A JavaScript Error object
* @param {Error | Span} data A JavaScript Error or Appsignal Span object
* @param {object} tags An key, value object of tags
* @param {string} namespace An optional namespace name
*
* @return {Promise<any>} An API response
* @return {Promise<Span> | void} An API response, or `void` if `Promise` is unsupported.
*/
Appsignal.prototype.sendError = function (error, tags, namespace) {
Appsignal.prototype.send = function (data, tags, namespace) {
if (tags === void 0) { tags = {}; }
var txn = new Transaction({
action: this._action,
environment: this._env
});
if (!(error instanceof Error)) {
throw new Error("Can't send error, given error is not a valid Error object");
if (!(data instanceof Error) && !(data instanceof Span)) {
throw new Error("Can't send error, given error is not a valid type");
}
txn.setError(error);
// "events" refer to a fixed point in time, as opposed to
// a range or length in time
var span = data instanceof Span ? data : this._createSpanFromError(data);
if (tags)
txn.setTags(tags);
span.setTags(tags);
if (namespace)
txn.setNamespace(namespace);
span.setNamespace(namespace);
if (Environment.supportsPromises()) {
return this._api.push(txn);
return this._api.push(span);
}

@@ -65,6 +60,45 @@ else {

/**
* Records and sends a browser `Error` to AppSignal. An alias to `#send()`
* to maintain compatibility.
*
* @param {Error} error A JavaScript Error object
* @param {object} tags An key, value object of tags
* @param {string} namespace An optional namespace name
*
* @return {Promise<Span> | void} An API response, or `void` if `Promise` is unsupported.
*/
Appsignal.prototype.sendError = function (error, tags, namespace) {
return this.send(error, tags, namespace);
};
/**
* Registers and installs a valid plugin.
*
* A plugin is typically a function that can be used to provide a
* reference to the `Appsignal` instance via returning a function
* that can be bound to `this`.
*
* @param {Plugin} plugin A JavaScript Error object
*
* @return {void}
*/
Appsignal.prototype.use = function (plugin) {
plugin.call(this);
};
/**
* Creates a new `Span`, augmented with the current environment.
*
* @return {Span} An AppSignal `Span` object
*/
Appsignal.prototype.createSpan = function () {
var _a = this._options.revision, revision = _a === void 0 ? "" : _a;
return new Span({
environment: this._env,
revision: revision
});
};
/**
* Returns an object that includes useful diagnostic information.
* Can be used to debug the installation.
*
* @return {object} A diagnostic report
* @return {object} A diagnostic report
*/

@@ -78,4 +112,17 @@ Appsignal.prototype.diagnose = function () {

};
/**
* Creates a valid AppSignal `Span` from a JavaScript `Error`
* object.
*
* @param {Error} error A JavaScript error
*
* @return {Span} An AppSignal event
*/
Appsignal.prototype._createSpanFromError = function (error) {
var event = this.createSpan();
event.setError(error);
return event;
};
return Appsignal;
}());
export default Appsignal;
{
"name": "@appsignal/javascript",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"main": "dist/cjs/index.js",

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

},
"gitHead": "a1512779320e251098ef8fe89c7af3b4c327a79f"
"dependencies": {
"error-stack-parser": "^2.0.2"
},
"gitHead": "5fe0af306d57d794d34796316f4f10696c1e1e8f"
}
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