-
Notifications
You must be signed in to change notification settings - Fork 121
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
feat: add stack to stacktraceless "exceptions" #1472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1826,14 +1826,15 @@ export class PostHog { | |
|
||
/** Capture a caught exception manually */ | ||
captureException(error: Error, additionalProperties?: Properties): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to update the type here as well now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was torn... technically I'd still like people to send us errors but it is a little misleading to ourselves to think that the input will always be an error. What I really want is to type it as |
||
const syntheticException = new Error('PostHog syntheticException') | ||
const properties: Properties = isFunction(assignableWindow.__PosthogExtensions__?.parseErrorAsProperties) | ||
? assignableWindow.__PosthogExtensions__.parseErrorAsProperties([ | ||
error.message, | ||
undefined, | ||
undefined, | ||
undefined, | ||
error, | ||
]) | ||
? assignableWindow.__PosthogExtensions__.parseErrorAsProperties( | ||
[error.message, undefined, undefined, undefined, error], | ||
// create synthetic error to get stack in cases where user input does not contain one | ||
// creating the exceptionas soon into our code as possible means we should only have to | ||
// remove a single frame (this 'captureException' method) from the resultant stack | ||
{ syntheticException } | ||
) | ||
: { | ||
$exception_level: 'error', | ||
$exception_list: [ | ||
|
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.
This is a superior approach but I couldn't get it to work. The function name I was seeing was
t.value
in the stack trace. Perhaps there's some Javascript function construction magic needed to ensure the function name gets caught in the stack. Open to any thoughts if people have them?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.
probably because array.js is minified? Or the loaded extensions are if we're using the npm version of main package..
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.
Probably true - very meta given our current work 😂