-
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
fix(errors): Better define schema, align with python #1460
Changes from 4 commits
e1ab25d
57cf509
7b5aca3
89d2f46
7223c4d
925886c
53359d3
ae1e74e
27cf484
ab4bd72
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 |
---|---|---|
|
@@ -11,7 +11,45 @@ import { | |
import { defaultStackParser, StackFrame } from './stack-trace' | ||
|
||
import { isEmptyString, isNumber, isString, isUndefined } from '../../utils/type-utils' | ||
import { ErrorEventArgs, ErrorProperties, SeverityLevel, severityLevels } from '../../types' | ||
import { ErrorEventArgs, SeverityLevel, severityLevels } from '../../types' | ||
|
||
export interface ErrorProperties { | ||
$exception_type: string | ||
$exception_message: string | ||
$exception_level: SeverityLevel | ||
$exception_list?: Exception[] | ||
// $exception_source?: string | ||
// $exception_lineno?: number | ||
// $exception_colno?: number | ||
$exception_DOMException_code?: string | ||
$exception_is_synthetic?: boolean | ||
// $exception_stack_trace_raw?: string | ||
$exception_handled?: boolean | ||
$exception_personURL?: string | ||
$exception_language?: string | ||
} | ||
|
||
export interface Exception { | ||
type?: string | ||
value?: string | ||
mechanism?: { | ||
handled?: boolean | ||
type?: string | ||
neilkakkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
source?: string | ||
synthetic?: boolean | ||
} | ||
module?: string | ||
thread_id?: number | ||
neilkakkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
language?: string | ||
stacktrace?: { | ||
frames?: StackFrame[] | ||
} | ||
} | ||
|
||
export interface ErrorConversions { | ||
errorToProperties: (args: ErrorEventArgs) => ErrorProperties | ||
unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties | ||
} | ||
|
||
/** | ||
* based on the very wonderful MIT licensed Sentry SDK | ||
|
@@ -59,7 +97,15 @@ function errorPropertiesFromError(error: Error): ErrorProperties { | |
return { | ||
$exception_type: error.name, | ||
$exception_message: error.message, | ||
$exception_stack_trace_raw: JSON.stringify(frames), | ||
$exception_list: [ | ||
{ | ||
type: error.name, | ||
value: error.message, | ||
stacktrace: { | ||
frames, | ||
}, | ||
}, | ||
], | ||
$exception_level: 'error', | ||
} | ||
} | ||
|
@@ -111,7 +157,8 @@ function errorPropertiesFromObject(candidate: Record<string, unknown>): ErrorPro | |
} | ||
} | ||
|
||
export function errorToProperties([event, source, lineno, colno, error]: ErrorEventArgs): ErrorProperties { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function errorToProperties([event, _, __, ___, error]: ErrorEventArgs): ErrorProperties { | ||
// some properties are not optional but, it's useful to start off without them enforced | ||
let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message' | '$exception_level'> & { | ||
$exception_type?: string | ||
|
@@ -177,13 +224,7 @@ export function errorToProperties([event, source, lineno, colno, error]: ErrorEv | |
$exception_level: isSeverityLevel(errorProperties.$exception_level) | ||
? errorProperties.$exception_level | ||
: 'error', | ||
...(source | ||
? { | ||
$exception_source: source, // TODO get this from URL if not present | ||
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 came here to ask if we should get rid of this... ahead of me :) |
||
} | ||
: {}), | ||
...(lineno ? { $exception_lineno: lineno } : {}), | ||
...(colno ? { $exception_colno: colno } : {}), | ||
Comment on lines
-185
to
-186
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. Let's remove these from the other places they're referenced in a follow up PR 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. they aren't referenced anywhere I think 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 think they're mentioned in the new Rust service. They're also in the taxonomy descriptions but that's less important because arguably they should stick around there... 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. uh oh, that shouldn't be the case, it should use the values from the frame instead 🤔 - let me check again 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. oh it's optional, all good, need it to stay there to support old versions that might send events 💀 , but yeah we don't need to use this at all imo |
||
$exception_language: 'javascript', | ||
} | ||
} | ||
|
||
|
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.
One for the future but would be cool to have a shared schema similar to what we have for TS <-> Python we have for queries
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.
will rm the commented out stuff 👀