-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
Expose metrics to JS #4654
Expose metrics to JS #4654
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4654 +/- ##
==========================================
- Coverage 71.25% 71.25% -0.01%
==========================================
Files 190 190
Lines 14916 14918 +2
Branches 1102 1102
==========================================
+ Hits 10629 10630 +1
- Misses 4284 4285 +1
Partials 3 3
Continue to review full report at Codecov.
|
vm.runInNewContext(codeToEval, sandbox, opts); | ||
return sandbox[resultKey]; | ||
} catch (error) { | ||
return () => error; |
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 returning a function that returns an error?
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 function sandboxedEval
returns a function (either to mutate the data or generate the tooltip). I'm being consistent here, and returning this ensures that the error is displayed in the tooltip (see second screenshot).
@vylc requested the ability of exposing the metrics to the JS advanced tooltip:
I also added a
try/except
block around the sandbox eval, so that the query still runs when the JS is broken, and the exception is shown: