-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(nextjs): Add option to automatically tunnel events #6425
Conversation
acea201
to
7c9b129
Compare
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get some tests? In particular I would like to see shouldTraceRequest
and the options.tunnel = tunnelPath
logic tested.
We can prob extract the options.tunnel = tunnelPath
into a util function and export it just to be unit tested.
packages/nextjs/src/index.client.ts
Outdated
__DEBUG_BUILD__ && logger.info(`Tunneling events to "${tunnelPath}"`); | ||
options.tunnel = tunnelPath; | ||
} else { | ||
__DEBUG_BUILD__ && logger.warn('Provided DSN is not a Sentry SaaS DSN. Will not tunnel events.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: This should work with self-hosted as well right? Why indicate SaaS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to tunnel if you're already on self-hosted? Requests to self-hosted instances are probably not being blocked by ad blockers.
Another reason we limit this is because of next.js rewrite restrictions. For example, the protocol needs to be static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to ask the same thing. It's for sure less likely for someone's self-hosted instance to land on a block-list, but not impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to tunnel if you're already on self-hosted
Good point, not sure actually, don't know enough to comment on this. @kamilogorek is tunneling a thing for self-hosted users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for sure less likely for someone's self-hosted instance to land on a block-list, but not impossible.
I believe if somebody's self-hosted instance is landing on a block-list, they're probably high-profile enough that their proxy route (via this option) will also land on a block list - rendering the option useless anyhow.
I personally would ship this without directly supporting self-hosted. And if we see demand for proxying to other hosts we can pretty easily add something like a tunnelTarget
option that would allow for that. It should be perfectly compatible with this change.
I am not gonna go into detail here but there are a few things to consider when letting users choose the host. For example, we would need some special logic to tunnel requests to ingest.sentry.io
because you cannot put that string into a tunnel request, since it would be blocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can also implement this logic themselves if they need to for the self-hosted case. Yeah that sounds reasonable enough for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if somebody's self-hosted instance is landing on a block-list, they're probably high-profile enough that their proxy route (via this option) will also land on a block list - rendering the option useless anyhow.
I personally would ship this without directly supporting self-hosted. And if we see demand for proxying to other hosts we can pretty easily add something like a
tunnelTarget
option that would allow for that. It should be perfectly compatible with this change.
Yup, that's fair. Let's leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice addition!
packages/nextjs/src/index.client.ts
Outdated
__DEBUG_BUILD__ && logger.info(`Tunneling events to "${tunnelPath}"`); | ||
options.tunnel = tunnelPath; | ||
} else { | ||
__DEBUG_BUILD__ && logger.warn('Provided DSN is not a Sentry SaaS DSN. Will not tunnel events.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to ask the same thing. It's for sure less likely for someone's self-hosted instance to land on a block-list, but not impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice addition!
(Got the mad rainbow unicorn, and now this comment is here twice. But I'm paranoid and don't want to delete it in case it's just a display bug and I end up deleting the original. Let's see if this edit shows up on both...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! All of my remaining suggestions are just about comments, so all L.
Co-authored-by: Katie Byers <katie.byers@sentry.io>
Adds the option
tunnelRoute
to thewithSentryConfig()
wrapper to automatically tunnel Sentry requests through the Next.js server via a configured route. This is a mechanism to prevent ad-blockers from blocking requests to Sentry.We are leveraging Next.js
rewrites
option for tunneling which is essentially just a proxy configuration. It has the upside that when deployed on Vercel it is quite fast.One thing we needed to take care of was that we're not creating spans/transactions for these proxied requests because they were extremely spammy.
Resolves: #5571