nuxt-testevia
Advanced tools
Comparing version 1.0.1 to 1.0.3
{ | ||
"name": "nuxt-testevia", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Nuxt - Testevia Logger", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
const path = require('path') | ||
const errorHandler = require('./error-handler.js').default | ||
@@ -7,4 +8,9 @@ module.exports = function(options) { | ||
src: path.resolve(__dirname, 'plugin.js'), | ||
options | ||
}) | ||
options: { | ||
...options, | ||
errorHandler: path.resolve(__dirname, './error-handler.js') | ||
} | ||
}); | ||
this.nuxt.hook('render:errorMiddleware', app => app.use(errorHandler.errorHandler(options))) | ||
} | ||
@@ -11,0 +17,0 @@ |
import Vue from 'vue' | ||
import axios from 'axios' | ||
import errorHandler from <%= serialize(options.errorHandler) %>; | ||
class Testevia{ | ||
constructor({settings, context}){ | ||
this.project = settings.project; | ||
this.sendingEnabled = !context.isDev || settings.dev; | ||
this.context = context; | ||
this.config = { | ||
headers: {'Authorization': settings.apiKey} | ||
}; | ||
this.init() | ||
} | ||
init(){ | ||
Vue.config.errorHandler = (err) => { | ||
if(this.sendingEnabled) this.sendError(err) | ||
export default (context, inject) =>{ | ||
let options = <%= serialize(options) %>; | ||
Vue.config.errorHandler = (err) => { | ||
if(!context.isDev || options.dev){ | ||
errorHandler.sendError(process.server ? context.route.fullPath : window.location.href, err, options); | ||
} | ||
} | ||
sendError(err){ | ||
let context = { | ||
project: this.project, | ||
source: 'frontend', | ||
data: { | ||
url: process.server ? this.context.route.fullPath : window.location.href | ||
}, | ||
} | ||
if(err.message) context.data['error_message'] = err.message; | ||
if(err.stack) context.data['stacktrace'] = err.stack; | ||
axios.post('https://testevia.broj42.com/api/log-errors/', context, this.config) | ||
.catch(e =>{ | ||
// console.dir(e) | ||
}); | ||
} | ||
} | ||
export default (context, inject) =>{ | ||
let testevia = new Testevia({ | ||
settings: { | ||
...<%= serialize(options) %> | ||
}, | ||
context | ||
}); | ||
inject('sendError', (err) => testevia.sendError(err)) | ||
inject('sendError', (err, options) => errorHandler.sendError(err, options)) | ||
} |
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
2351
4
51