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

[🐛 Bug]: Sentry integration #421

Closed
1 task done
martwozniak opened this issue Aug 8, 2023 · 1 comment
Closed
1 task done

[🐛 Bug]: Sentry integration #421

martwozniak opened this issue Aug 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@martwozniak
Copy link

next-on-pages environment related information

System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
Memory: 32 GB
Shell: C:\Program Files\Git\usr\bin\bash.exe
Binaries:
Node: 20.5.0
Bun: N/A
pnpm: N/A
Yarn: 1.22.19
npm: 9.8.0
Package Manager Used: yarn (classic)
Relevant Packages:
@cloudflare/next-on-pages: 1.5.0
vercel: N/A
next: N/A

Description

Sentry does not work when published on Cloudflare Pages.

functions/_middleware.ts

import sentryPlugin from '@cloudflare/pages-plugin-sentry';
import { PagesFunction } from '@cloudflare/workers-types';

export const onRequest: PagesFunction = sentryPlugin({
  dsn: 'dsn_here',
});

Reproduction

  1. Create nextjs project
  2. npx @sentry/wizard@latest -i nextjs
  3. Publish to cloudflare pages
  4. Sentry not logging any errors
  5. Add middleware
import sentryPlugin from '@cloudflare/pages-plugin-sentry';
import { PagesFunction } from '@cloudflare/workers-types';

export const onRequest: PagesFunction = sentryPlugin({
  dsn: 'dsn_here',
});
  1. Sentry not logging any errors

Pages Deployment Method

Direct Upload (wrangler pages publish or the @cloudflare/pages-action GitHub Action)

Pages Deployment ID

71596039

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
@martwozniak martwozniak added the bug Something isn't working label Aug 8, 2023
@dario-piotrowicz
Copy link
Member

Thanks for the issue @martwozniak 🙂

The issue here is that @cloudflare/next-on-pages generates a Pages project in advanced mode, this mode is incompatible with the functions/ directory implementation and the latter gets ignored, as you can see in the docs:
Screenshot 2023-08-25 at 21 23 27

So it is expected for your implementation not to work, you'll need to change it so that you integrate sentry directly in your Next.js application.

I haven't used sentry before so unfortunately I cannot help you much in that regard, but the sentry docs seem to include clear instructions on how to do so 🙂

Also note that people have had a few issues with sentry (like #178 and #420), so I can't guarantee that it'll work for your specific use case (but I'll be here to help if I can 🙂)

I hope this is helpful 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants