Skip to content

Sentry

For client and server logs we have configured Sentry. For that we use @sentry/nuxt module.

Configuration

Configuration is pretty straight forward:

  1. Configure sentry in nuxt.config.ts
ts
sentry: {
    sourceMapsUploadOptions: {
      url: process.env.NUXT_SENTRY_URL,
      authToken: process.env.NUXT_SENTRY_AUTH_TOKEN,
      org: "ORGANIZATION_NAME",
      project: "PROJECT_NAME",
    },
  },
  1. Configure sentry for client

To configure sentry for client, create sentry.client.config.ts in the root of the project:

ts
import { useRuntimeConfig } from "#imports";
import * as Sentry from "@sentry/nuxt";

const config = useRuntimeConfig();

Sentry.init({
  dsn: config.public.sentry.dsn,
  environment: config.public.environment,
  replaysSessionSampleRate: config.public.environment !== "prod" ? 1.0 : 0.1,
  replaysOnErrorSampleRate: 1.0,
  integrations: [
    Sentry.replayIntegration({
      maskAllInputs: true,
      maskAllText: false,
    }),
  ],
});
  1. Configure sentry for server

To configure sentry for server, create sentry.server.config.ts in the root of the project:

ts
import * as Sentry from "@sentry/nuxt";

if (process.env.NUXT_PUBLIC_SENTRY_DSN) {
  Sentry.init({
    dsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
    environment: process.env.NUXT_PUBLIC_ENVIRONMENT,
  });
}

For more details about the configuration options refer to Sentry docs

Made with ♥️ by Riešenia