Nuxt.js: Best way to integrate Sentry

Created on 27 Jul 2017  路  7Comments  路  Source: nuxt/nuxt.js

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
    }
}
help-wanted

Most helpful comment

All 7 comments

I changed the service ip to a impossible target and was expecting catching the error and deal with it, not nodemon crash...

Any ideas ?
screenshot 2017-07-28 11 12 34

screenshot 2017-07-28 11 12 44

Did you end up figuring this out :)?

Why the thumbs down(s)? Is there an issue with https://github.com/nuxt-community/sentry-module ?

@DiederikvandenB is the module raport both server and client side errors?

@awronski Yes. It uses both raven-node and raven-js.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

mikekidder picture mikekidder  路  3Comments

gary149 picture gary149  路  3Comments