What is the best way to send user information together when an exception occurs?

usacoasts
0
usacoasts
commented 2 months ago

Hello ! Thank you for the nice module

I understood how to transmit user information with this question.
(https://cmty.app/nuxt/sentry-module/issues/c30)

But the way to write the user information in one point and send the user information together at the time of error occurrence isn't understood.

The way which thought of only one and put it into effect was a way using middleware, but this didn't go well by the following reason.
and nuxt is being used in SSR, not SPA.

serverMiddleware vs middleware!

(https://nuxtjs.org/api/configuration-servermiddleware/)

Don't confuse it with routes middleware which are being called before each route by Vue in Client Side or SSR. serverMiddleware are just running in server side before vue-server-renderer and can be used for server specific tasks like handling API requests or serving assets.

Even the way mentioned in ※code1 experimented on a project, but you didn't send one in case of the error which occurred by a different component to the user information.
Project/layouts/default.vue is a layout file, so it'll be a parent of all templates.

I'm sorry, could you inform me about the way to send the user information together at the time of error occurrence?

Thank You!


(※code1 ) (Project/layouts/default.vue)

export default {
head () {
const viewport = this.$device.isMobile
? 'width=device-width, initial-scale=1'
: 'width=1336'
return {
meta: [
{ hid: 'viewport', name: 'viewport', content: viewport },
{ hid: 'author', name: 'author', content: this.baseinfo.metaauthor },
{ hid: 'description', name: 'description', content: this.baseinfo.metadescription },
{ hid: 'keywords', name: 'keywords', content: this.baseinfo.metakeyword },
{ hid: 'options', name: 'options', content: this.baseinfo.metaoptions }
]
}
},
mixins: [HandleAfterLogin],
components: {
GeneralHeader,
GeneralFooter,
GeneralLoading,
MobileHeader
},
mounted () {
this.$sentry.configureScope(scope => {
scope.setUser({id: 1, username: 'test', email: '[email protected]'})
});
},
computed: {
…mapState('global', ['base_info'])
}

}

0
manniL
4.0k
manniL
commented 2 months ago

@usacoasts Please use CMTY and use code formatting for your issues.

1
usacoasts
0
usacoasts
commented 2 months ago

@manniL
I'm thankful for an answer.
A question was written once again in CMTY.

https://cmty.app/nuxt/sentry-module/issues/c32

0
Informations
QuestionResolved
#c31 - Created 2 months ago