Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the correct way to install Sentry on Nuxt? 😥 #14732

Closed
3 tasks done
svk-man opened this issue Dec 16, 2024 · 2 comments · Fixed by #14735 or #14737
Closed
3 tasks done

What is the correct way to install Sentry on Nuxt? 😥 #14732

svk-man opened this issue Dec 16, 2024 · 2 comments · Fixed by #14735 or #14737
Assignees
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@svk-man
Copy link

svk-man commented Dec 16, 2024

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nuxt

SDK Version

8.45.0

Framework Version

3.14.159

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
    dsn: import.meta.env.APP_SENTRY_INIT_DSN,
    integrations: [
      Sentry.browserTracingIntegration(),
      Sentry.replayIntegration(),
      Sentry.browserProfilingIntegration(),
      Sentry.captureConsoleIntegration({
        levels: ['error', 'warn'],
      }),
      Sentry.dedupeIntegration(),
      Sentry.httpClientIntegration({
        failedRequestStatusCodes: [400, 401, 403, 404, 405, 429, 444],
      }),
    ],
    sendDefaultPii: true,
    tracesSampleRate: 1.0,
    tracePropagationTargets: ['localhost'],
    replaysSessionSampleRate: 0.1,
    replaysOnErrorSampleRate: 1.0,
    profilesSampleRate: 1.0,
  })

Steps to Reproduce

I have followed the steps from the existing instructions:

  1. https://nuxt.com/modules/sentry
  2. https://docs.sentry.io/platforms/javascript/guides/nuxt/manual-setup/

Steps:

  1. Install the Sentry Nuxt SDK:
# Using npm
npm install @sentry/nuxt
  1. Add @sentry/nuxt/module to the modules section of nuxt.config.ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@sentry/nuxt/module'],
});
  1. Add a sentry.client.config.ts file to the root of your project:
import * as Sentry from '@sentry/nuxt'
import { useRuntimeConfig } from '#imports'

Sentry.init({
  dsn: useRuntimeConfig().public.sentry.dsn,
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration(),
    Sentry.browserProfilingIntegration(),
    Sentry.captureConsoleIntegration({
      levels: ['error', 'warn'],
    }),
    Sentry.dedupeIntegration(),
    Sentry.httpClientIntegration({
      failedRequestStatusCodes: [400, 401, 403, 404, 405, 429, 444],
    }),
  ],
  sendDefaultPii: true,
  tracesSampleRate: 1.0,
  tracePropagationTargets: ['localhost'],
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
  profilesSampleRate: 1.0,
})
  1. Add a sentry.server.config.ts file to the root of your project:
import * as Sentry from '@sentry/nuxt'

if (process.env.APP_SENTRY_INIT_DSN) {
  Sentry.init({
    dsn: import.meta.env.APP_SENTRY_INIT_DSN,
    integrations: [
      Sentry.browserTracingIntegration(),
      Sentry.replayIntegration(),
      Sentry.browserProfilingIntegration(),
      Sentry.captureConsoleIntegration({
        levels: ['error', 'warn'],
      }),
      Sentry.dedupeIntegration(),
      Sentry.httpClientIntegration({
        failedRequestStatusCodes: [400, 401, 403, 404, 405, 429, 444],
      }),
    ],
    sendDefaultPii: true,
    tracesSampleRate: 1.0,
    tracePropagationTargets: ['localhost'],
    replaysSessionSampleRate: 0.1,
    replaysOnErrorSampleRate: 1.0,
    profilesSampleRate: 1.0,
  })
}

5

"overrides": {
  "@vercel/nft": "^0.27.4"
}
  1. Add the command to package.json:
"start": "node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs",

Expected Result

I expect everything to work right out of the box.
Help me, please!

Actual Result

I get the following typing errors in the files (sentry.client.config.ts and sentry.server.config.ts):
Image

  • The ‘init’ property does not exist in the ‘typeof import(’project-name/node_modules/@sentry/nuxt/build/types/index.types‘)’ type.
  • The ‘browserTracingIntegration’ property does not exist in the ‘typeof import(’project-name/node_modules/@sentry/nuxt/build/types/index.types‘)’ type.
  • etc

When I go to import, I get:
Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 16, 2024
@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Dec 16, 2024
@s1gr1d
Copy link
Member

s1gr1d commented Dec 16, 2024

Thanks for reporting! Turns out adding an additional build config changed the build output of the types since 8.44.0.

I'm gonna fix this.

@s1gr1d s1gr1d self-assigned this Dec 16, 2024
@s1gr1d s1gr1d closed this as completed in 4873c6d Dec 16, 2024
s1gr1d added a commit that referenced this issue Dec 16, 2024
Because this config was added to the `includes`, the types were moved to
a subdirectory.
fixes #14732
s1gr1d added a commit that referenced this issue Dec 16, 2024
Copy link
Contributor

A PR closing this issue has just been released 🚀

This issue was referenced by PR #14737, which was included in the 8.46.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Archived in project
2 participants