Skip to content

Commit

Permalink
Enable posthog error capture in error boundry (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev authored Dec 3, 2024
1 parent 90e60a7 commit 8e732a6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/keychain/src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 8e732a6

Please sign in to comment.