airbrake-mini-client
Advanced tools
Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "airbrake-mini-client", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A lightweight alternative to airbrake-js.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -53,2 +53,3 @@ # airbrake-mini-client | ||
* reporter: an object providing a "notify" method | ||
* win: the window global object (default to the current window) | ||
@@ -55,0 +56,0 @@ ### Filters |
@@ -7,3 +7,3 @@ var objectAssign = require('object-assign') | ||
name: 'airbrake-mini-client', | ||
version: '0.0.6', | ||
version: '0.0.7', | ||
url: 'https://github.com/tes/airbrake-mini-client' | ||
@@ -21,2 +21,3 @@ } | ||
this.filters = [] | ||
this.win = config.win || window | ||
} | ||
@@ -29,5 +30,5 @@ | ||
notifier: NOTIFIER, | ||
userAgent: window.navigator.userAgent, | ||
url: window.location.href, | ||
rootDirectory: window.location.protocol + '//' + window.location.host, | ||
userAgent: this.win.navigator.userAgent, | ||
url: this.win.location.href, | ||
rootDirectory: this.win.location.protocol + '//' + this.win.location.host, | ||
language: 'JavaScript', | ||
@@ -34,0 +35,0 @@ environment: this.environment, |
@@ -20,2 +20,3 @@ /* eslint-env browser */ | ||
this.timeout = config.timeout || DEFAULT_TIMEOUT | ||
this.win = config.win || window | ||
} | ||
@@ -30,3 +31,3 @@ | ||
var url = this.host + '/api/v3/projects/' + this.projectId + '/notices?key=' + this.projectKey | ||
let req = new XMLHttpRequest() | ||
let req = new this.win.XMLHttpRequest() | ||
req.open('POST', url, true) | ||
@@ -33,0 +34,0 @@ req.timeout = this.timeout |
@@ -70,2 +70,21 @@ /* eslint-env browser, mocha */ | ||
}) | ||
it('allows override of window', () => { | ||
var userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' | ||
var href = 'https://github.com/tes/airbrake-mini-client' | ||
var protocol = 'https:' | ||
var host = 'github.com' | ||
var windowOverride = { navigator: { userAgent }, location: { href, protocol, host } } | ||
airbrake = new AirbrakeMini({ | ||
projectId: '123', | ||
projectKey: '456', | ||
reporter: reporter, | ||
win: windowOverride | ||
}) | ||
var enrichedObject = airbrake.createInitialPayload() | ||
assert.equal(enrichedObject.context.userAgent, userAgent) | ||
assert.equal(enrichedObject.context.url, href) | ||
assert.equal(enrichedObject.context.rootDirectory, `${protocol}//${host}`) | ||
}) | ||
}) |
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
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
14826
363
105