From 8e732a62d0090a1026ff721a03401d283466d84c Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Tue, 3 Dec 2024 16:02:04 -0500 Subject: [PATCH] Enable posthog error capture in error boundry (#1086) --- packages/keychain/src/components/ErrorBoundary.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/keychain/src/components/ErrorBoundary.tsx b/packages/keychain/src/components/ErrorBoundary.tsx index 3e2685b70..342041525 100644 --- a/packages/keychain/src/components/ErrorBoundary.tsx +++ b/packages/keychain/src/components/ErrorBoundary.tsx @@ -5,22 +5,27 @@ import { Button, HStack, Link, Text } from "@chakra-ui/react"; import { useConnection } from "hooks/connection"; import NextLink from "next/link"; import { CARTRIDGE_DISCORD_LINK } from "const"; +import posthog from "posthog-js"; export class ErrorBoundary extends React.Component< PropsWithChildren, { error?: Error } > { - constructor(props) { + constructor(props: PropsWithChildren) { super(props); this.state = {}; } - static getDerivedStateFromError(error) { + static getDerivedStateFromError(error: Error) { return { error }; } - componentDidCatch(error, errorInfo) { + componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.log({ error, errorInfo }); + posthog?.captureException(error, { + info: errorInfo, + source: "ErrorBoundary", + }); } render() {