I am working on a Nuxt.js project and I have integrated Bugsnag for error monitoring and reporting. However, I want to exclude logging HTTP 401 errors in Bugsnag. To achieve this, I have implemented the @bugsnag/plugin-vue and made modifications to the Bugsnag configuration file as shown below:
import Vue from 'vue';
import Bugsnag from '@bugsnag/js';
import BugsnagVue from '@bugsnag/plugin-vue';
const bugsnagClient = Bugsnag.start({
apiKey: process.env.BUGSNAG_KEY,
plugins: [new BugsnagVue()],
onError: function (event) {
// Don't log failed authorization errors.
return event.errors[0].status !== 401 || event.errors[0].errorMessage?.includes('401');
}
});
const bugsnagVue = Bugsnag.getPlugin('vue');
bugsnagVue.installVueErrorHandler(Vue);
export default (ctx, inject) => {
inject('bugsnag', bugsnagClient);
};
Unfortunately, this solution is not working as expected. The HTTP 401 errors are still being logged in Bugsnag. Could someone please guide me on how to properly prevent logging HTTP 401 errors in Bugsnag using the @bugsnag/plugin-vue in a Nuxt.js project?
Thank you in advance for your help!
