diff --git a/lib/sentry.js b/lib/sentry.js index c444e01c..9d576866 100644 --- a/lib/sentry.js +++ b/lib/sentry.js @@ -42,8 +42,7 @@ module.exports = function sentry (moduleOptions) { }) } - // Hook in to Nuxt renderer - this.nuxt.plugin('renderer', (renderer) => { + const hook = (renderer) => { renderer.app.use(Raven.requestHandler()) // Grab Nuxt's original error middleware and overwrite it with our own @@ -55,5 +54,8 @@ module.exports = function sentry (moduleOptions) { // Call Nuxt's original error middleware nuxtErrorMiddleware.call(renderer, err, req, res, next) } - }) + } + + // Hook in to Nuxt renderer + this.nuxt.hook ? this.nuxt.hook('render:before', hook) : this.nuxt.plugin('renderer', hook) }