Skip to content

Suggestion: Sentry [error tracking] #207

Closed as not planned
Closed as not planned
@alexcroox

Description

@alexcroox

Docs: https://docs.sentry.io/platforms/javascript/

For reference this is how I currently instrument it:

import { Capacitor } from '@capacitor/core'
import * as Sentry from '@sentry/vue'

import { appVersion } from '~/shared/version'

export default defineNuxtPlugin({
  name: 'sentry',
  setup(nuxtApp) {
    if (import.meta.env.TEST) {
      return
    }

    const {
      public: { errorReportingEnabled, sentry }
    } = useRuntimeConfig()

    if (!sentry.client.dsn) {
      console.error('Sentry DSN not found in environment')
      return
    }

    Sentry.init({
      enabled: errorReportingEnabled,
      app: nuxtApp.vueApp,
      release: appVersion,
      dsn: sentry.client.dsn,
      // debug: true,
      environment: sentry.environment,
      ignoreErrors: [/Network Error/i, /Fetch Error/i]
    })

    Sentry.setTag('app-platform', Capacitor.getPlatform())
    Sentry.setTag('app-native', Capacitor.isNativePlatform())

    return {
      provide: {
        sentry: Sentry
      }
    }
  }
})

and after the user has logged in or we detect they are already logged in on page load:

this.sentry.setUser({
  id,
  email,
  username,
  roles
})

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions