nuxt-community / sentry-module

Sentry module for Nuxt 2
https://sentry.nuxtjs.org
MIT License
500 stars 113 forks source link

Issues Implementing Session Replay with @nuxtjs/sentry: Transport Disabled Error #671

Closed weldar0616 closed 1 month ago

weldar0616 commented 7 months ago

Environment

Description

I am trying to implement Session Replay using @nuxtjs/sentry in my Nuxt application. Initially, my Sentry setup was working correctly, and logs were properly sent to Sentry with the following configuration:

Original package.json Configuration:

{
  "dependencies": {
    "@nuxtjs/sentry": "^5.1.7",
    ...
  }
}

Original nuxt.config.ts Configuration:

const config: NuxtConfig = {
  ssr: false,
  modules: ['@nuxtjs/sentry'],
  sentry: {
    dsn: process.env.SENTRY_DSN,
    publishRelease: true,
    sourceMapStyle: 'hidden-source-map',
    config: {
      environment: process.env.SENTRY_ENVIRONMENT,
      release: process.env.SENTRY_RELEASE_VERSION,
    },
    clientIntegrations: {
      CaptureConsole: { levels: ['error', 'warn', 'info'] },
    },
  },
  ...
}

Following the guide on Sentry Nuxt Session Replay, I updated my configuration:

Updated package.json:

- "@nuxtjs/sentry": "^5.1.7",
+ "@nuxtjs/sentry": "^7.5.0",
+ "@sentry/webpack-plugin": "^1.20.1",

Updated nuxt.config.ts: I added the Session Replay integration and updated CSP based on the Sentry guide for Vue.

head: {
  meta: [
    { httpEquiv: 'Content-Security-Policy', content: "worker-src 'self' blob:" },
    ...
  ],
},
sentry: {
  ... // other settings
  publishRelease: {
    authToken: process.env.SENTRY_AUTH_TOKEN,
    org: '<my-org>',
    project: '<my-project>',
    debug: true
  },
  config: {
    // ...
    debug: true
  },
  clientIntegrations: {
    CaptureConsole: { levels: ['error', 'warn', 'info'] },
    Replay: {},
  },
  clientConfig: {
    replaysSessionSampleRate: 0.1,
    replaysOnErrorSampleRate: 1.0
  },
}

However, after making these changes and running nuxt-ts build, I encounter the following error:

Sentry Logger [error]: Transport disabled

Due to this error, Session Replay does not seem to be functioning.

Expected Behavior

I expected Session Replay to be enabled without issues and for events and sessions to be sent to Sentry as configured.

Actual Behavior

The console logs Sentry Logger [error]: Transport disabled, and Session Replay is not working as expected.

Steps to Reproduce

  1. Update the Sentry configuration as described above.
  2. Run nuxt-ts build.
  3. Observe the error in the console.

Additional Context: Runtime Log Excerpt

Here is an excerpt from the runtime logs when the issue occurs. This might provide more insight into the problem:

> nuxt-ts build

 WARN  You're using Nuxt 2.15.8, which includes built-in TypeScript runtime support                                                                 12:27:54

 WARN  You can safely use nuxt instead of nuxt-ts and remove @nuxt/typescript-runtime package                                                       12:27:54

✔ Sentry reporting is enabled (client side: enabled, server side: enabled)                                                          nuxt:sentry 12:27:54 PM
ℹ Production build                                                                                                                                  12:27:55
ℹ Bundling only for client side                                                                                                                     12:27:55
ℹ Target: static                                                                                                                                    12:27:55
ℹ Using components loader to optimize imports                                                                                                       12:27:55
ℹ Discovered Components: .nuxt/components/readme.md                                                                                                 12:27:55
✔ Builder initialized                                                                                                                               12:27:55
✔ Nuxt files generated                                                                                                                              12:27:55
[Sentry Webpack Plugin] DEBUG: Injecting release code                                                                                               12:27:56
[Sentry Webpack Plugin] DEBUG: Loaders:                                                                                                             12:27:56
 [
...
]
[Sentry Webpack Plugin] DEBUG: Added loaders:                                                                                                       12:27:56
 [
...
]
[Sentry Webpack Plugin] DEBUG: Removed loaders:                                                                                                     12:27:56
 []
[Sentry Webpack Plugin] DEBUG: Entry:                                                                                                               12:27:56
 {
  app: [
...
  ]
}
[Sentry Webpack Plugin] DEBUG: Added entry:                                                                                                         12:27:56
 [
  {
    app: [
...
    ]
  }
]
[Sentry Webpack Plugin] DEBUG: Removed entry:                                                                                                       12:27:56
 [
  {
    app: [
...
    ]
  }
]
Sentry Logger [log]: Integration installed: InboundFilters                                                                                          12:27:56
Sentry Logger [log]: Integration installed: FunctionToString                                                                                        12:27:56
Sentry Logger [log]: Integration installed: LinkedErrors                                                                                            12:27:56
Sentry Logger [log]: Integration installed: RequestData                                                                                             12:27:56
Sentry Logger [log]: Integration installed: Console                                                                                                 12:27:56
Sentry Logger [log]: Integration installed: Http                                                                                                    12:27:56
Sentry Logger [log]: Integration installed: Undici                                                                                                  12:27:56
Sentry Logger [log]: Integration installed: OnUncaughtException                                                                                     12:27:56
Sentry Logger [log]: Integration installed: OnUnhandledRejection                                                                                    12:27:56
Sentry Logger [log]: Integration installed: ContextLines                                                                                            12:27:56
Sentry Logger [log]: Integration installed: LocalVariables                                                                                          12:27:56
Sentry Logger [log]: Integration installed: Context                                                                                                 12:27:56
Sentry Logger [log]: Integration installed: Modules                                                                                                 12:27:56
Sentry Logger [log]: Integration installed: Dedupe                                                                                                  12:27:56
Sentry Logger [log]: Integration installed: ExtraErrorData                                                                                          12:27:56
Sentry Logger [log]: Integration installed: RewriteFrames                                                                                           12:27:56
Sentry Logger [log]: Integration installed: Transaction                                                                                             12:27:56

● Client █████████████████████████ after emitting (98%)  

> Found 0 release files
> Rewriting sources
> Rewriting completed in 0s
> Adding source map references
> Found 1046 release files
> Analyzing 1046 sources
> ~/_nuxt/d062623.js
████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 450/1046
> ~/_nuxt/448af64.js
> ~/_nuxt/76876c6.js
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░ 957/1046
> Uploading completed in 0.273s
> Analyzing completed in 0.581s
> Rewriting sources
> ~/_nuxt/45c7f19.js.map
> Processing completed in 0.29s
> File upload complete (processing pending on server)
> Organization: <my-org>
> Project: <my-project>
> Release: local
> Dist: None
> Rewriting completed in 0.586s
> Adding source map references
> Bundling files for upload... ~/_nuxt/45c7f19.js
> Bundling completed in 1.245s
> Optimizing completed in 0.038s
> Uploading completed in 3.948s
> Uploaded release files to Sentry
> Processing completed in 0.301s
> File upload complete (processing pending on server)
> Organization: <my-org>
> Project: <my-project>
> Release: local
> Dist: None

Source Map Upload Report
...

✔ Client
  Compiled successfully in 2.14m

Hash: 3ea37ad0ed0f987402d7
Version: webpack 4.46.0
Time: 128489ms
Built at: 03/01/2024 12:30:04 PM
                                                                Asset       Size                                                                                                                                                                                                                                                               Chunks                                Chunk Names
                                       ../server/client.manifest.json    388 KiB                                                                                                                                                                                                                                                                       ...     
 + 524 hidden assets
Entrypoint app [big] = bf58487.js bf58487.js.map 5e98e2f.js 5e98e2f.js.map 45c7f19.js 45c7f19.js.map ae6cd29.js ae6cd29.js.map

*** clone ***                                                                                                                                       12:30:05
Sentry Logger [log]: [Tracing] Adding sentry-trace header xxx-yyy to outgoing request to "https://telemetry.nuxtjs.com/": 
ℹ Generating output directory: dist/                                                                                                                12:30:05
ℹ Generating pages                                                                                                                                  12:30:05
...
✔ Client-side fallback created: 200.html                                                                                                            12:30:06
Sentry Logger [log]: [Tracing] Adding sentry-trace header xxx-yyy to outgoing request to "https://telemetry.nuxtjs.com/": 

 ERROR  Sentry Logger [error]: Transport disabled                                                                                                   12:30:06

Please let me know if there's any more information I can provide to help diagnose this issue. Thank you for your support.

rchl commented 7 months ago

I haven't looked into the issue but as the warning says, you should probably stop using nuxt-ts since Nuxt supports TS natively now.

Also, it looks like Sentry is trying to send a trace event during build for the https://telemetry.nuxtjs.com/ request which is kinda pointless. Maybe Sentry should just be disabled during static generation.

As a workaround you can probably disable telemetry (telemetry: false in nuxt.config).

weldar0616 commented 7 months ago

Thank you for the prompt response!

I've changed nuxt-ts to nuxt and added telemetry: false, to nuxt-config.ts. This modification stopped the unnecessary telemetry events from being sent, however, I'm still encountering the following error:

ERROR Sentry Logger [error]: Transport disabled 17:07:37

I will continue to investigate this issue.

rchl commented 7 months ago

You might have to create a repo that reproduces the issue if you can't figure it out yourself.

rchl commented 1 month ago

Closing due to no way to reproduce.