-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Update telemetry to use new errors information #5547
Conversation
|
* Safely get the error message from an error, even if it's a function. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function getSafeErrorMessage(message: string | Function): string { |
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.
The logic here is the same one that generates the error reference on the docs, which has been proven to work:tm:
packages/astro/test/units/vite-plugin-astro-server/request.test.js
Outdated
Show resolved
Hide resolved
Is this the first time we are sending errors to telemetry? Assuming so, can we have some tests that include non-anonymous error messages to verify that we are stripping them correctly (or just not sending the message, if that is the intent). |
It's actually not the first time! The code for reporting errors is from pre-1.0 and hasn't been changed (apart from the fact that we now exclusively use it for unknown errors, whereas before it was used for both known and unknown errors) |
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.
Approving as docs because this doesn’t actually require docs.
@Princesseuh Looked over the tests and the only one I think we should add for now is one to verify that the stack trace is not included. Looking at the code I'm pretty sure it will not be, but it would be good to have a test to verify and enforce that going forward. |
…on't have to cast to any later
return message; | ||
} else { | ||
return String.raw({ | ||
raw: extractStringFromFunction(message.toString()), |
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 know this method 😃
@@ -145,7 +145,6 @@ export class AstroTelemetry { | |||
// to preview what data would be sent. | |||
return Promise.resolve(); | |||
} | |||
|
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.
😎
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.
tel
you what, this looks really good...💚
Changes
This PR updates telemetry events so it uses our new AstroError's data when possible. Most importantly, this allows us to have much better information about our own errors in our stats, since we can safely extract the entire error message anonymized + have a cool name and errorCode to filter errors by. The previous anonymizing logic is kept for unknown errors, so we can still get a basic idea of what happened just in case
Additionally, this PR adds telemetry for errors encountered in dev, as previously we'd only get telemetry for dev server stops.
Testing
Added a test for a error event using our own errors, updated tests that needed it. Made it so telemetry doesn't work in tests to avoid triggering it unnecessarily
Docs
N/A