Hi, I installed the package sentry-cordova in one cordova project, it works well reporting errors in global functions on browser, but errors thrown into vue app.
I am not interested on the additional info collected by sentry/vue integration, is there a way to track errors at both levels? vanilla javascript, and vue js
I added these undefined functions to trigger errors:
On main index.html of project:
function onLoad() {
document.addEventListener("backbutton", onBackKeyDown, false);
document.addEventListener("deviceready", onDeviceReady, false);
}
function onBackKeyDown() {
myUndefinedFunction();
// navigator.app.exitApp();
}
function onDeviceReady() {
window.Sentry = cordova.require('sentry-cordova.Sentry');
window.Sentry.init({ dsn: '---my-dns---' });
}
On a Vuex action function:
updateCounter(context, params) {
myUndefinedFunction();
axios.post(’—my-api-url—’, postData)
.then(response => {
context.commit(‘UPDATE_COUNTER’, response.data)
context.commit(‘ASSIGN_CHARTS_DATA’)
})
},
When I move into app to trigger the errors, if I check the call stack both calls are wrapped by sentryWrapped() , I past this sentry function here:
var sentryWrapped = function () {
// tslint:disable-next-line:strict-type-predicates
if (before && typeof before === 'function') {
before.apply(this, arguments);
}
var args = Array.prototype.slice.call(arguments);
// tslint:disable:no-unsafe-any
try {
var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
if (fn.handleEvent) {
// Attempt to invoke user-land function
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it
// means the sentry.javascript SDK caught an error invoking your application code. This
// is expected behavior and NOT indicative of a bug with sentry.javascript.
return fn.handleEvent.apply(this, wrappedArguments);
}
// Attempt to invoke user-land function
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it
// means the sentry.javascript SDK caught an error invoking your application code. This
// is expected behavior and NOT indicative of a bug with sentry.javascript.
return fn.apply(this, wrappedArguments);
// tslint:enable:no-unsafe-any
}
catch (ex) {
ignoreNextOnError();
withScope(function (scope) {
scope.addEventProcessor(function (event) {
var processedEvent = __assign({}, event);
if (options.mechanism) {
addExceptionTypeValue(processedEvent, undefined, undefined, options.mechanism);
}
processedEvent.extra = __assign({}, processedEvent.extra, { arguments: normalize(args, 3) });
return processedEvent;
});
captureException(ex);
});
throw ex;
}
};
Doing a debugging I found that the undefined function error on index.html is catched on the catch
block of sentryWrapped , but the undefined function error on Vuex action is not
I see these backtrace on console:
Error on index.html:
Uncaught ReferenceError: myUndefinedFunction is not defined
at Channel.onBackKeyDown (index.html:18)
at Channel.fire (cordova.js:868)
at cordova.js:225
at sentryWrapped (sentry-cordova.bundle.js:4748)
onBackKeyDown @ index.html:18
Channel.fire @ cordova.js:868
(anonymous) @ cordova.js:225
sentryWrapped @ sentry-cordova.bundle.js:4748
setTimeout (async)
(anonymous) @ sentry-cordova.bundle.js:5122
fireDocumentEvent @ cordova.js:220
onMessageFromNative @ cordova.js:1519
callbackFromNative @ cordova.js:287
(anonymous) @ VM27:1
Error on Vuex action:
sentry-cordova.bundle.js:5308 ReferenceError: myUndefinedFunction is not defined
at f.updateCounter (app.05cc97cd95b1a69ba935.js:1)
at Array. (vendor.e0276726a18851e1cc28.js:57)
at f.NYxO.f.dispatch (vendor.e0276726a18851e1cc28.js:63)
at f.dispatch (vendor.e0276726a18851e1cc28.js:57)
at click (0.192ae2fdf69cf4879444.js:1)
at Wt (vendor.e0276726a18851e1cc28.js:19)
at HTMLButtonElement.n (vendor.e0276726a18851e1cc28.js:19)
at HTMLButtonElement.o._wrapper (vendor.e0276726a18851e1cc28.js:19)
at HTMLButtonElement.sentryWrapped (sentry-cordova.bundle.js:4748)
(anonymous) @ sentry-cordova.bundle.js:5308
Vt @ vendor.e0276726a18851e1cc28.js:19
Ut @ vendor.e0276726a18851e1cc28.js:19
qt @ vendor.e0276726a18851e1cc28.js:19
Wt @ vendor.e0276726a18851e1cc28.js:19
n @ vendor.e0276726a18851e1cc28.js:19
o._wrapper @ vendor.e0276726a18851e1cc28.js:19
sentryWrapped @ sentry-cordova.bundle.js:4748
This is my stack:
cordova-android: 8.1.0
sentry-cordova: 0.17.0
Android API: 27