Giter VIP home page Giter VIP logo

Comments (9)

ThomasKientz avatar ThomasKientz commented on July 20, 2024 3

@DiederikvandenB It's a simple nuxt plugin :

// plugins/axios.js
export default function({ $axios, store, error, app }) {
  $axios.onError(e => {
    if (process.client) {
      app.$sentry.configureScope(scope => {
        scope.setExtra("request", e);
        app.$sentry && app.$sentry.captureException(e.response.data);
      });
    }
    return Promise.reject(e);
  });
}
// nuxt.config.js
module.exports = {
  modules: [
    "@nuxtjs/axios",
  ],
  plugins: [
    "@/plugins/axios",
  ],
}

from sentry-module.

ThomasKientz avatar ThomasKientz commented on July 20, 2024 3

@seandelaney solution for me was (as you can see in the thread)

using

app.$sentry

with module updated to v2.

from sentry-module.

ThomasKientz avatar ThomasKientz commented on July 20, 2024 3

Ok I think I finally get it ! My guess :

Sentry is working in client side only, but the plugin is not registered for client side only cause I need it to be initiated in server side (as I need for axios)

But I am calling $sentry only in $axios.onError(e => { ... app.$sentry }) through app and its working cause by the time $sentry had time to be injected !

from sentry-module.

 avatar commented on July 20, 2024

This issue as been imported as question since it does not respect sentry-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/sentry-module/issues/c34.

from sentry-module.

aldarund avatar aldarund commented on July 20, 2024
  1. there no $raven in latest version of nuxt sentry, its $sentry
  2. export default function({ $axios, store, error, {app: { $sentry } }) {

from sentry-module.

ThomasKientz avatar ThomasKientz commented on July 20, 2024

@aldarund Thanks !

I was using v1 of sentry module using $raven.

So I have updated module to v2.

Some details

I don't know why, It doesn't work with destructured assignement :

export default function({ $axios, store, error, app: { $sentry } }) {

=> $sentry is still undefined.

It works though with :

export default function({ $axios, store, error, app }) {

and then accessing $sentry : app.$sentry

from sentry-module.

DiederikvandenB avatar DiederikvandenB commented on July 20, 2024

Could you maybe share some more code? In which file are you calling this code, what are you importing, etc.

from sentry-module.

seandelaney avatar seandelaney commented on July 20, 2024

What was the solution?

I have a similar issue where $sentry is undefined within my plugin: https://cmty.app/nuxt/sentry-module/issues/c36

from sentry-module.

DiederikvandenB avatar DiederikvandenB commented on July 20, 2024

Sorry for not responding! Completely forgot. Very glad you were able to resolve it yourself.

from sentry-module.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.