-
Notifications
You must be signed in to change notification settings - Fork 140
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
[RUM] Catch errors thrown by user callbacks #745
Conversation
@@ -0,0 +1,11 @@ | |||
export function catchErrors<Args extends any[], R>(fn: (...args: Args) => R, errorMsg: 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.
I would rename it to catchUserErrors
to make it a bit clearer
packages/rum-core/src/domain/rumEventsCollection/view/trackViews.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Benoît <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #745 +/- ##
==========================================
- Coverage 82.58% 82.39% -0.19%
==========================================
Files 74 75 +1
Lines 3807 3806 -1
Branches 907 908 +1
==========================================
- Hits 3144 3136 -8
- Misses 663 670 +7
Continue to review full report at Codecov.
|
Co-authored-by: Bastien Caudan <[email protected]>
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.
LGTM
This is needed to make the test able to pass its own Lifecycle object and test that onNewLocation catches user errors after being wrapped. The stopViewCollection is needed because startViewCollection attaches a listener to history changes, and if not removed, it will be executed on all following tests and generates unwanted console.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.
Nice!
Motivation
Catch errors thrown by user-provided callbacks and log them using
console.error
.Changes
catchErrors
beforeSend
,onNewLocation
and callbacks given toonReady
before the SDK initialization.Testing
I have gone over the contributing documentation.