diff --git a/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--dark.png b/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--dark.png index 9d36f05d09ef..b92569da43f3 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--dark.png and b/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--dark.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--light.png b/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--light.png index 688fcabfeb22..534cffb6d758 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--light.png and b/frontend/__snapshots__/components-errors-error-display--anonymous-error-with-stack-trace--light.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--chained-error-stack--dark.png b/frontend/__snapshots__/components-errors-error-display--chained-error-stack--dark.png new file mode 100644 index 000000000000..c1814837ff50 Binary files /dev/null and b/frontend/__snapshots__/components-errors-error-display--chained-error-stack--dark.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--chained-error-stack--light.png b/frontend/__snapshots__/components-errors-error-display--chained-error-stack--light.png new file mode 100644 index 000000000000..080cb89bb468 Binary files /dev/null and b/frontend/__snapshots__/components-errors-error-display--chained-error-stack--light.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--importing-module--dark.png b/frontend/__snapshots__/components-errors-error-display--importing-module--dark.png index 0779d4d14f6d..381719b91735 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--importing-module--dark.png and b/frontend/__snapshots__/components-errors-error-display--importing-module--dark.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--importing-module--light.png b/frontend/__snapshots__/components-errors-error-display--importing-module--light.png index 982b58c5a4d7..c8f4675ddbc3 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--importing-module--light.png and b/frontend/__snapshots__/components-errors-error-display--importing-module--light.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--dark.png b/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--dark.png index 56ce3ee3c6df..cd2d7e54fa53 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--dark.png and b/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--dark.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--light.png b/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--light.png index 5fbe3c050d46..bcd3c015bac3 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--light.png and b/frontend/__snapshots__/components-errors-error-display--resize-observer-loop-limit-exceeded--light.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--safari-script-error--dark.png b/frontend/__snapshots__/components-errors-error-display--safari-script-error--dark.png index 18149ad074e7..8f8cfbcca499 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--safari-script-error--dark.png and b/frontend/__snapshots__/components-errors-error-display--safari-script-error--dark.png differ diff --git a/frontend/__snapshots__/components-errors-error-display--safari-script-error--light.png b/frontend/__snapshots__/components-errors-error-display--safari-script-error--light.png index f637ed0e1ee4..1ec0679fb10c 100644 Binary files a/frontend/__snapshots__/components-errors-error-display--safari-script-error--light.png and b/frontend/__snapshots__/components-errors-error-display--safari-script-error--light.png differ diff --git a/frontend/__snapshots__/scenes-app-errortracking--group-page--dark.png b/frontend/__snapshots__/scenes-app-errortracking--group-page--dark.png index 302f5cfad364..fdd090777de0 100644 Binary files a/frontend/__snapshots__/scenes-app-errortracking--group-page--dark.png and b/frontend/__snapshots__/scenes-app-errortracking--group-page--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-errortracking--group-page--light.png b/frontend/__snapshots__/scenes-app-errortracking--group-page--light.png index 52977a1b90d2..425f33a5644c 100644 Binary files a/frontend/__snapshots__/scenes-app-errortracking--group-page--light.png and b/frontend/__snapshots__/scenes-app-errortracking--group-page--light.png differ diff --git a/frontend/src/lib/components/Errors/ErrorDisplay.stories.tsx b/frontend/src/lib/components/Errors/ErrorDisplay.stories.tsx index ea08af47fd09..f2b1295f0b1d 100644 --- a/frontend/src/lib/components/Errors/ErrorDisplay.stories.tsx +++ b/frontend/src/lib/components/Errors/ErrorDisplay.stories.tsx @@ -144,3 +144,116 @@ export function AnonymousErrorWithStackTrace(): JSX.Element { /> ) } + +export function ChainedErrorStack(): JSX.Element { + return ( + ', + module: '__main__', + lineno: 37, + pre_context: [ + ' try:', + ' more_obfuscation()', + ' except Exception as e:', + ' raise CustomException("This is a custom exception") from e', + '', + ], + context_line: 'will_raise()', + post_context: [ + 'exit()', + '', + '', + '# print(posthog.get_all_flags("distinct_id_random_22"))', + '# print(', + ], + }, + { + filename: 'example2.py', + abs_path: '/Users/neilkakkar/Project/posthog-python/example2.py', + function: 'will_raise', + module: '__main__', + lineno: 35, + pre_context: [ + '', + 'def will_raise():', + ' try:', + ' more_obfuscation()', + ' except Exception as e:', + ], + context_line: ' raise CustomException("This is a custom exception") from e', + post_context: ['', 'will_raise()', 'exit()', '', ''], + }, + ], + }, + }, + ], + })} + /> + ) +} diff --git a/frontend/src/lib/components/Errors/ErrorDisplay.tsx b/frontend/src/lib/components/Errors/ErrorDisplay.tsx index c7602d509d40..a8896c54299b 100644 --- a/frontend/src/lib/components/Errors/ErrorDisplay.tsx +++ b/frontend/src/lib/components/Errors/ErrorDisplay.tsx @@ -12,6 +12,16 @@ interface StackFrame { lineno: number colno: number function: string + context_line?: string +} + +interface ExceptionTrace { + stacktrace: { + frames: StackFrame[] + } + module: string + type: string + value: string } function parseToFrames(rawTrace: string): StackFrame[] { @@ -25,7 +35,7 @@ function StackTrace({ rawTrace }: { rawTrace: string }): JSX.Element | null { <> {frames.length ? ( frames.map((frame, index) => { - const { filename, lineno, colno, function: functionName } = frame + const { filename, lineno, colno, function: functionName, context_line } = frame return ( {filename}:{lineno}:{colno} + {context_line ? `:${context_line}` : ''} } /> @@ -51,6 +62,23 @@ function StackTrace({ rawTrace }: { rawTrace: string }): JSX.Element | null { } } +function ChainedStackTraces({ exceptionList }: { exceptionList: ExceptionTrace[] }): JSX.Element { + return ( + <> + +

Stack Trace

+ {exceptionList.map(({ stacktrace, value }, index) => { + return ( +
+

{value}

+ +
+ ) + })} + + ) +} + function ActiveFlags({ flags }: { flags: string[] }): JSX.Element { return ( <> @@ -91,6 +119,7 @@ export function getExceptionPropertiesFrom(eventProperties: Record) } = eventProperties let $exception_stack_trace_raw = eventProperties.$exception_stack_trace_raw + let $exception_list = eventProperties.$exception_list // exception autocapture sets $exception_stack_trace_raw as a string // if it isn't present then this is probably a sentry exception. // try and grab the frames from that @@ -102,6 +131,14 @@ export function getExceptionPropertiesFrom(eventProperties: Record) } } } + // exception autocapture sets $exception_list for chained exceptions. + // If it's not present, get this list from the sentry_exception + if (!$exception_list?.length && $sentry_exception) { + if (Array.isArray($sentry_exception.values)) { + $exception_list = $sentry_exception.values + } + } + return { $exception_type, $exception_message, @@ -115,6 +152,7 @@ export function getExceptionPropertiesFrom(eventProperties: Record) $active_feature_flags, $sentry_url, $exception_stack_trace_raw, + $exception_list, $level, } } @@ -133,6 +171,7 @@ export function ErrorDisplay({ eventProperties }: { eventProperties: EventType[' $active_feature_flags, $sentry_url, $exception_stack_trace_raw, + $exception_list, $level, } = getExceptionPropertiesFrom(eventProperties) @@ -162,10 +201,12 @@ export function ErrorDisplay({ eventProperties }: { eventProperties: EventType[' /> - - + + - {!!$exception_stack_trace_raw?.length && ( + {$exception_list?.length ? ( + + ) : $exception_stack_trace_raw?.length ? ( <>
@@ -173,7 +214,7 @@ export function ErrorDisplay({ eventProperties }: { eventProperties: EventType['
- )} + ) : null}

Active Feature Flags

diff --git a/frontend/src/lib/components/Errors/error-display.test.ts b/frontend/src/lib/components/Errors/error-display.test.ts index aaffd239ed0e..fbb6bd1a6201 100644 --- a/frontend/src/lib/components/Errors/error-display.test.ts +++ b/frontend/src/lib/components/Errors/error-display.test.ts @@ -55,6 +55,27 @@ describe('Error Display', () => { $exception_message: 'There was an error creating the support ticket with zendesk.', $exception_stack_trace_raw: '[{"colno":220,"filename":"https://app-static-prod.posthog.com/static/chunk-UFQKIDIH.js","function":"submitZendeskTicket","in_app":true,"lineno":25}]', + $exception_list: [ + { + mechanism: { + handled: true, + type: 'generic', + }, + stacktrace: { + frames: [ + { + colno: 220, + filename: 'https://app-static-prod.posthog.com/static/chunk-UFQKIDIH.js', + function: 'submitZendeskTicket', + in_app: true, + lineno: 25, + }, + ], + }, + type: 'Error', + value: 'There was an error creating the support ticket with zendesk.', + }, + ], $exception_synthetic: undefined, $exception_type: 'Error', $lib: 'posthog-js',