-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Expanded Logging Customisation #1602
Comments
Thank you for opening. So adding a boolean to log invocations to be able differentiate between client and server logs are easy, but to set an option to don't send logs from the client at all is a bit harder. There might be an option to set it in the Merging #1473 would make this easier to implement, as the frontend code would be more tied to React. |
Thanks for responding @balazsorban44, would this move to Ideally not sending it at all would be great as redundant serverless invocations wouldn't be necessary. However, even providing some context as to where an error has originated from within the |
It would be nice to have @iaincollins's opinion on #1473 for this to be resolved properly (and potentially other issues while also optimizing performance), but adding a simple I got curious though, how does sentry's client logger catch the frontend errors created by next-auth? |
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks! |
There hasn't been much interest in this from the community. Adding a frontend flag is still on the table for me, but since these logs should only be sent when something is not working correctly, I don't think a high number of function invocations would occur. If you are interested in opening a PR addressing the frontend flag, please do. |
This will be closed by #2344 As mentioned, the log events will still happen, but you can filter them out in the This is an easy fix, and as I said, if you see a high number of invocations of that |
Similar to #2342, this aims to unify the user-facing API and provide an easier way to extend in the future. In addition, this PR also solves the problem when the `logger.error` method sometimes did not print results, because `Error` instances are not serializable and will be printed as empty objects `"{}"`. After this PR, we make any `Error` instances serializable as described here: https://iaincollins.medium.com/error-handling-in-javascript-a6172ccdf9af Closes #1602 Achieved by adding a `client: true` flag when logs are coming from the frontend. BREAKING CHANGE: The main change is that instead of an unknown number of parameters, the log events have at most two, where the second parameter is usually an object. In the case of the `error` event, it can also be an `Error` instance (that is serializable by `JSON.stringify`). If it is an object, an `Error` instance will be available on `metadata.error`, and `message` will default to `metadata.error.message`. This is done so that an error event always provides some kind of a stack to see where the error happened ```diff // [...nextauth.js] import log from "some-logger-service" ... logger: { - error(code, ...message) {}, + error(code, metadata) {}, - warn(code, ...message) {}, + warn(code) {} - debug(code, ...message) {} + debug(code, metadata) {} } ```
Similar to nextauthjs#2342, this aims to unify the user-facing API and provide an easier way to extend in the future. In addition, this PR also solves the problem when the `logger.error` method sometimes did not print results, because `Error` instances are not serializable and will be printed as empty objects `"{}"`. After this PR, we make any `Error` instances serializable as described here: https://iaincollins.medium.com/error-handling-in-javascript-a6172ccdf9af Closes nextauthjs#1602 Achieved by adding a `client: true` flag when logs are coming from the frontend. BREAKING CHANGE: The main change is that instead of an unknown number of parameters, the log events have at most two, where the second parameter is usually an object. In the case of the `error` event, it can also be an `Error` instance (that is serializable by `JSON.stringify`). If it is an object, an `Error` instance will be available on `metadata.error`, and `message` will default to `metadata.error.message`. This is done so that an error event always provides some kind of a stack to see where the error happened ```diff // [...nextauth.js] import log from "some-logger-service" ... logger: { - error(code, ...message) {}, + error(code, metadata) {}, - warn(code, ...message) {}, + warn(code) {} - debug(code, ...message) {} + debug(code, metadata) {} } ```
Summary of proposed feature
Additional boolean flags in options to be used in conjunction with logger object that allows for disables the sending of log events to the
_log
endpoint.Purpose of proposed feature
Serverless function invocation costs per request on Vercel. For customers that implement client and server-side exception tracking services (such as Sentry) already pay for these exceptions to be captured on said services. Having the exceptions also invoking the
_log
function is redundant in this scenario and would incur additional, unnecessary costs and double up on alerting.Detail about proposed feature
Offer the ability to set
_log endpoint
or similar tofalse
which disables it from being created in Vercel and disables the client and server parts of next-auth from attempting toPOST
data to the endpoint when an exception is caught. Customers are then encouraged to use the pre-existinglogger
object to capture and alert with their own logging platform.Potential problems
None that I can think of.
Describe any alternatives you've considered
Attempting to link Sentry to DataDog to capture
_log
events but this seems backward.Additional context
I can obviously try and help with this implementation.
The text was updated successfully, but these errors were encountered: