Although #https://github.com/zeit/next.js/issues/2334 is an issue on next.js, I'd like to know the best way to integrate Sentry.
I was using express + nuxt.js and was able to catch errors from client-side via raven-js
module, but when navigating a page component which uses asyncData(server-side), I can't send that error to sentry but only use error() to send error page to the user.
My best guess is the raven-js
module is for client-side use and we should use raven-node
in express side, I tried this but turned out that errors from asyncData() isn't passing to or handled by express.
plugins/raven.js
import Vue from 'vue';
import Raven from 'raven-js';
import RavenVue from 'raven-js/plugins/vue';
Raven
.config('https://<>@sentry.io/<>')
.addPlugin(RavenVue, Vue)
.install();
pages/test.vue
async asyncData ({ isServer, req, store, params, error }) {
try {
let { data } = await axios.post('http://10.20.100.100:15050/api/run ....
}
catch(e) {
console.log(Raven.isSetup()) // this will be false
Raven.captureException(e)
error({ statusCode: 404, message: 'Post not found' }) // 404 from nuxt
}
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1033">#c1033</a>)</em></sub></div>