-
Notifications
You must be signed in to change notification settings - Fork 128
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -51,7 +51,6 @@ export interface StackFrame { | |||
} | |||
|
|||
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/ | |||
const STRIP_FRAME_REGEXP = /captureException/ |
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 😂
Size Change: +2.05 kB (+0.07%) Total Size: 2.83 MB
ℹ️ View Unchanged
|
@@ -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 comment
The 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 comment
The 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 unknown
but for a user to be shown Error
as the type
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
oh wait, this doesn't work well for the case where currently we're not seeing stack traces, it's a different captureException function that's called: https://github.com/PostHog/posthog-js/blob/master/src/extensions/exception-autocapture/index.ts#L76 |
@neilkakkar you're right, this actually only fixes the issue where the stack trace is missing after a user manually called The global The case where the stack trace is missing from a genuine error is probably more likely related to this issue: https://sentry.io/answers/script-error/ (I'm going to try recreating this now, I would suspect that the script just needs to be loaded anonymously) |
Changes
Why miss out on a stack trace if you call
captureException
with a string?This changes things to throw an error to capture the current stack trace and strips the final frame (e.g. inside our
captureException
function)