Skip to content

Commit

Permalink
fix: handle sentry failure and add release
Browse files Browse the repository at this point in the history
  • Loading branch information
sohrab- committed Aug 15, 2022
1 parent 760ef53 commit ada10b5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Example } from "./Examples";
import { WalletButton } from "./WalletButton";

export const Header: React.FC = () => {
const [funTitle, setFunTitle] = useState(false);
const [funTitle, setFunTitle] = useState(true);
const toast = useToast();
const set = useSessionStoreWithoutUndo((state) => state.set);

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useSendWeb3Transaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Sentry from "@sentry/react";
import { useWallet } from "@solana/wallet-adapter-react";
import { Connection, PublicKey, Signer } from "@solana/web3.js";
import { mapITransactionToWeb3Transaction } from "../mappers/internal-to-web3js";
import { ITransaction } from "../types/internal";
import { sentryCaptureException } from "../utils/sentry";
import { usePersistentStore } from "./usePersistentStore";
import { useSessionStoreWithUndo } from "./useSessionStore";
import { useWeb3Connection } from "./useWeb3Connection";
Expand Down Expand Up @@ -71,7 +71,7 @@ export const useSendWeb3Transaction = ({

onSent && onSent(signature);
} catch (err) {
Sentry.captureException(err);
sentryCaptureException(err);
const message = Object.getOwnPropertyNames(err).includes("message")
? (err as { message: string }).message
: JSON.stringify(err);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useWeb3Account.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { idlAddress } from "@project-serum/anchor/dist/cjs/idl";
import * as Sentry from "@sentry/react";
import { Connection, PublicKey } from "@solana/web3.js";
import axios from "axios";
import { useEffect, useState } from "react";
import { programLabel } from "../library/programs";
import { IPubKey, IRpcEndpoint } from "../types/internal";
import { sentryCaptureException } from "../utils/sentry";
import { isValidPublicKey } from "../utils/web3js";
import { useSessionStoreWithUndo } from "./useSessionStore";
import { useWeb3Connection } from "./useWeb3Connection";
Expand Down Expand Up @@ -84,7 +84,7 @@ export const useWeb3Account = (
};

fetch().catch((e) => {
Sentry.captureException(e);
sentryCaptureException(e);
});
}, [address, activeConnection, activeRpcEndpoint]);

Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as serviceWorker from "./serviceWorker";

Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN,
release: process.env.REACT_APP_VERSION || "local",
});

const container = document.getElementById("root");
Expand Down
10 changes: 10 additions & 0 deletions src/utils/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from "@sentry/react";

export const sentryCaptureException = (err: unknown) => {
try {
Sentry.captureException(err);
} catch (_) {
// Sentry fails on rate limting
console.error(err);
}
};

0 comments on commit ada10b5

Please sign in to comment.