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

Using the Sentry Posthog integration on the server with NextJS in Vercel #1175

Open
osdiab opened this issue May 9, 2024 · 0 comments
Open

Comments

@osdiab
Copy link

osdiab commented May 9, 2024

I was wondering what is the right way to use the Sentry integration with Posthog in the Vercel environment. Basically:

  • Sentry has you initialize in a sentry.server.ts file that Sentry's NextJS bindings seem to call on its own.
  • In practice you would need to pass the Posthog client to the posthog sentry integration init function, which is fine
  • But where would I call posthog.shutdown() as recommended in the docs?
  • And how would it work regarding assigning the user distinct ID during actual requests? Would there be any risk of misattributing Sentry logs if I was setting the ID on the posthog client during requests?
  • Or maybe should I use the option in posthog-node to provide the tag like so:

https://posthog.com/docs/libraries/node#example-implementation

  Sentry.captureException(err, {
    tags: {
      [PostHogSentryIntegration.POSTHOG_ID_TAG]: request.user.id,
    },
  })

If I do this, still not sure how to handle the shutdown() function, should I be calling it perhaps by listening for events like SIGINT and calling it then or something?

Some guidance on the proper way to set this up so that server logs can also be tagged with Posthog would make tracking a user's journey across the backend and frontend much smoother, as it's clear how to set it up on the client side. Thanks!

@osdiab osdiab changed the title Using the Sentry Posthog integration with NextJS in Using the Sentry Posthog integration with NextJS in Vercel May 9, 2024
@osdiab osdiab changed the title Using the Sentry Posthog integration with NextJS in Vercel Using the Sentry Posthog integration on the server with NextJS in Vercel May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant