feat(studio): add stack traces to all error telemetry events

Send `stack_trace` (up to 4KB) on crash, unhandled_error, and
unhandled_promise_rejection events so PostHog captures the full JS
call stack for debugging. Also bump `component_stack` from 500→2000
chars, and add `error_name` to promise rejections.
This commit is contained in:
Miguel Ángel
2026-05-21 12:18:55 -04:00
parent 114b83bbf6
commit 6a868b3787
2 changed files with 22 additions and 7 deletions
@@ -21,7 +21,8 @@ export class StudioErrorBoundary extends Component<Props, State> {
trackStudioEvent("crash", {
error_message: error.message,
error_name: error.name,
component_stack: info.componentStack?.slice(0, 500) ?? null,
stack_trace: error.stack?.slice(0, 4000) ?? null,
component_stack: info.componentStack?.slice(0, 2000) ?? null,
});
}
+20 -6
View File
@@ -7,19 +7,33 @@ import "./styles/studio.css";
trackStudioEvent("session_start");
function errorProps(value: unknown): {
error_message: string;
error_name: string | null;
stack_trace: string | null;
} {
if (value instanceof Error) {
return {
error_message: value.message,
error_name: value.name,
stack_trace: value.stack?.slice(0, 4000) ?? null,
};
}
return { error_message: String(value), error_name: null, stack_trace: null };
}
window.addEventListener("error", (event) => {
trackStudioEvent("unhandled_error", {
...errorProps(event.error),
error_message: event.message,
filename: event.filename ?? null,
lineno: event.lineno ?? null,
colno: event.colno ?? null,
filename: event.filename,
lineno: event.lineno,
colno: event.colno,
});
});
window.addEventListener("unhandledrejection", (event) => {
trackStudioEvent("unhandled_promise_rejection", {
error_message: event.reason instanceof Error ? event.reason.message : String(event.reason),
});
trackStudioEvent("unhandled_promise_rejection", errorProps(event.reason));
});
createRoot(document.getElementById("root")!).render(