-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(nextjs): Clarify user integration functions #3599
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
Conversation
Adds front-end performance monitoring in the Next.js SDK, by providing a router instrumentation.
…request data (#3577) This PR does two things: 1) It wraps two more methods on `next`'s `Server` class, one of which is called on every API request, and the other of which is called on every page request. Both methods are passed a parameterized version of the path, which our wrappers grab and use to modify the name of the currently active transaction. 2) It adds an event processor which pulls data off of the request and adds it to the event. This runs whether or not tracing is enabled, in order to add data to both error and transaction events. The only other thing of minor interest is that the type for `Event.request.query_string` is expanded to include objects, which is okay according to the dev docs: https://develop.sentry.dev/sdk/event-payloads/request/#attribute).
Just a bunch of random housekeeping. - No longer return project root directory from `instrumentServer` since it's not yet defined at that point. - No longer store transaction on `res`, since our new use of domains means that `getActiveTransaction` is safe. As a result, change `NextResponse` from an interface to a type which is purely an alias. - Store a pointer to the live `Server` instance directly on the top scope rather than in an object, and get rid of the other stuff being stored in that object (`closure`) since it can all be gotten off of the aforementioned `Server` instance. - Fix/expand/tweak various docstrings and comments. - Improve log message when tracing an outgoing HTTP request.
1) Fix a bug which prevented the "don't overwrite these keys" warning from working correctly. 2) Restrict the warning to appearing when overwriting keys which actually have values.
Automatically enable `BrowserTracing` if a traceSampler or tracesSample Rate is set. Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
size-limit report
|
| BrowserTracing: { keyPath: 'options.routingInstrumentation', value: nextRouterInstrumentation }, | ||
| }); | ||
| return addIntegration(defaultBrowserTracingIntegration, integrations, [ | ||
| ['options.routingInstrumentation', nextRouterInstrumentation], |
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.
Why not pass in the integration name here? I think that would simplify the logic when trying the find the integration to update.
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.
Yeah, I thought of that, but I was trying not to completely redo everything, LOL. Happy to do it, though.
Damn, didn't read closely enough. You mean instead of passing in a fully-formed instance? I'm not sure how that makes things simpler.
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.
Something like this (like the logic I had above), so we know exactly what integration to update.
| ['options.routingInstrumentation', nextRouterInstrumentation], | |
| ['BrowserTracing', 'options.routingInstrumentation', nextRouterInstrumentation], |
then we can just
for (const integration of allIntegrations) {
if integration.name === options[0] {
update(integration, options[1], options[2]);
}
}|
Closing this as stale, as I think some of these changes have been made in the meantime. I'll come back to the others at some point, but I think it'll be easiest to do that in a new PR. |
With @AbhiPrasad's blessing, a bunch of edits which originated as suggestions to #3586. That got merged before they could be made, so this adds them in a different form.
Included changes:
addIntegrationToArray, to make the conditionals and flow clearerOptionstype, to enforce that only options for the given integration can be passed and to allow multiple options to be passed