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

airbrake-mini-client

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airbrake-mini-client - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "airbrake-mini-client",
"version": "0.0.3",
"version": "0.0.4",
"description": "A lightweight alternative to airbrake-js.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -70,2 +70,3 @@ # airbrake-mini-client

}
return notice
})

@@ -72,0 +73,0 @@ ```

var objectAssign = require('object-assign')
var Reporter = require('./reporter')
var stacktrace = require('./stacktrace')
var packageJSON = require('../package.json')
var NOTIFIER = {
name: packageJSON.name,
version: packageJSON.version,
url: 'https://github.com/tes/airbrake-mini-client'
}
var DEFAULT_ENVIRONMENT = 'local'
function AirbrakeMini (config) {

@@ -9,2 +18,3 @@ if (!(this instanceof AirbrakeMini)) {

}
this.environment = config.environment || DEFAULT_ENVIRONMENT
this.reporter = config.reporter || new Reporter(config)

@@ -14,6 +24,12 @@ this.filters = []

AirbrakeMini.prototype.notify = function airbrakeMiniNotify (err) {
var payload = {
AirbrakeMini.prototype.createInitialPayload = function airbrakeCreateInitialPayload () {
return {
id: '',
context: {
notifier: NOTIFIER,
userAgent: window.navigator.userAgent,
url: window.location.href,
rootDirectory: window.location.protocol + '//' + window.location.host,
language: 'JavaScript',
environment: this.environment,
severity: 'error',

@@ -27,3 +43,7 @@ windowError: false,

}
}
AirbrakeMini.prototype.notify = function airbrakeMiniNotify (err) {
var payload = this.createInitialPayload()
if (err instanceof Error) {

@@ -30,0 +50,0 @@ payload.errors = [stacktrace(err)]

/* eslint-env browser */
var packageJSON = require('../package.json')
var objectAssign = require('object-assign')
var DEFAULT_HOST = 'https://api.airbrake.io'
var DEFAULT_TIMEOUT = 10000
var DEFAULT_ENVIRONMENT = 'local'

@@ -16,8 +12,2 @@ var errors = {

var NOTIFIER = {
name: packageJSON.name,
version: packageJSON.version,
url: 'https://github.com/tes/airbrake-mini-client'
}
function Reporter (config) {

@@ -31,21 +21,5 @@ if (!config.projectId || !config.projectKey) {

this.timeout = config.timeout || DEFAULT_TIMEOUT
this.environment = config.environment || DEFAULT_ENVIRONMENT
}
Reporter.prototype.enrichPayload = function reporterEnrichPayload (payload) {
var ctx = objectAssign({}, {
notifier: NOTIFIER,
userAgent: window.navigator.userAgent,
url: window.location.href,
rootDirectory: window.location.protocol + '//' + window.location.host,
language: 'JavaScript',
environment: this.environment
}, payload.context || {})
return objectAssign({}, payload, { context: ctx })
}
Reporter.prototype.notify = function reporterNotify (payload) {
var enrichedPayload = this.enrichPayload(payload)
let utime = Date.now() / 1000

@@ -107,5 +81,5 @@ if (utime < rateLimitReset) {

req.send(JSON.stringify(enrichedPayload))
req.send(JSON.stringify(payload))
}
module.exports = Reporter

@@ -29,3 +29,3 @@ /* eslint-env browser, mocha */

assert.equal(payload.id, '')
assert.deepEqual(payload.context, { severity: 'error', windowError: false, history: [] })
assert.equal(payload.context.severity, 'error')
})

@@ -38,3 +38,3 @@

assert.equal(payload.id, '')
assert.deepEqual(payload.context, { severity: 'warning', windowError: false, history: [] })
assert.equal(payload.context.severity, 'warning')
})

@@ -63,4 +63,11 @@

assert.equal(payload.id, 1)
assert.deepEqual(payload.context, { severity: 'warning', windowError: false, history: [] })
assert.equal(payload.context.severity, 'warning')
})
it('generate initial payload', () => {
var enrichedObject = airbrake.createInitialPayload()
assert.equal(enrichedObject.context.environment, 'local')
assert.equal(enrichedObject.context.notifier.name, 'airbrake-mini-client')
assert.typeOf(enrichedObject.context.userAgent, 'string')
})
})

@@ -33,11 +33,2 @@ /* eslint-env browser, mocha */

it('enriches a the payload', () => {
var enrichedObject = reporter.enrichPayload({ test1: 1, context: { test2: 2 } })
assert.equal(enrichedObject.test1, 1)
assert.equal(enrichedObject.context.test2, 2)
assert.equal(enrichedObject.context.environment, 'local')
assert.equal(enrichedObject.context.notifier.name, 'airbrake-mini-client')
assert.typeOf(enrichedObject.context.userAgent, 'string')
})
it('notifies', () => {

@@ -44,0 +35,0 @@ reporter.notify({ test: 1 })

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