Skip to content

filter our own messages to send to sentry#461

Merged
cpul merged 2 commits into
developmentfrom
chrispulsinelli/cod-1378-syntaxerror-unexpected-end-of-json-input
Jul 21, 2022
Merged

filter our own messages to send to sentry#461
cpul merged 2 commits into
developmentfrom
chrispulsinelli/cod-1378-syntaxerror-unexpected-end-of-json-input

Conversation

@cpul
Copy link
Copy Markdown
Contributor

@cpul cpul commented Jul 20, 2022

Description

Use the beforeSend Sentry callback option to filter out messages that we do not want to send to Sentry.

In order to check that it is our extension that is generating the errors, this change will look through the stacktrace and its stack frames and determine if our extension is the one that is emitting the event.

This will test the filename property on a StackFrame to see if the file matches that of our extension.
Here's an example of a stack frame that is generated locally in dev mode:
image

and here's what we see in production:
image

The regex used to test filename changes at runtime depending on the environment the extension is running in.

In order to make this test as quick as possible, the check will stop at the first matching instance where we determine the error was generated by our extension. Unfortunately, errors not generated by our extension will take longer to determine it isn't a match.

If anyone has a better idea on how to improve this lookup time for non-matching events, please let me know.

Type of Change

  • Tech Debt (refactoring, unit tests, CI changes, pre-commit hooks, etc)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Test Configuration:

  • CCL version/branch: 1.X
  • API version/branch: 1.X

Checklist:

  • I have performed a self-review of my code
  • I have used codex to provide context, particularly in hard-to-understand areas
  • Any dependent changes have been made available in downstream modules

Screenshots:

@linear
Copy link
Copy Markdown

linear Bot commented Jul 20, 2022

COD-1378 SyntaxError: Unexpected end of JSON input

Sentry Issue: VSCODE-2RK

SyntaxError: Unexpected end of JSON input
  ?, in JSON.parse
  File "/Users/dominicvonk/.vscode-insiders/extensions/mohamedbenhida.laravel-intellisense-0.2.0/src/ViewItemProvider.ts", line 63, col 30, in null.<anonymous>

@cpul cpul requested review from a team and meichend and removed request for a team July 20, 2022 20:33
@cpul cpul marked this pull request as ready for review July 20, 2022 20:34
@cpul cpul requested a review from derrickpersson July 20, 2022 20:34
release: `${SENTRY_RELEASE_PREFIX}@${process.env.VERSION}`,
environment: process.env.ENVIRONMENT || "development",
normalizeDepth: 10,
beforeSend: (event: Event) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Copy link
Copy Markdown
Contributor

@derrickpersson derrickpersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it'll work.. just wondering about 'unhandled' errors?
Not sure how they are currently logged, and if they'll be filtered by this. We definitely want to record some of the unhandled errors (as we cause them).

});

const options = {
const options: SentryTransport.SentryTransportOptions = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

@cpul
Copy link
Copy Markdown
Contributor Author

cpul commented Jul 21, 2022

@derrickpersson I have updated the PR to improve upon how we can be more certain the error is ours.
I noticed that even unhandled errors generated by other extensions were being decorated with our release metadata, so my changes effectively didn't do much, if anything at all.

This check is now more robust, but more costly to perform when the error events are not ours.

Copy link
Copy Markdown
Contributor

@derrickpersson derrickpersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
We can improve in future iterations #80/20

@cpul cpul merged commit f0533d1 into development Jul 21, 2022
@cpul cpul deleted the chrispulsinelli/cod-1378-syntaxerror-unexpected-end-of-json-input branch July 21, 2022 17:43
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

Successfully merging this pull request may close these issues.

3 participants