Skip to content

Commit

Permalink
Merge pull request #136 from skip-mev/kiki/fre-381-send-anonymized-tr…
Browse files Browse the repository at this point in the history
…ansaction-errors-to-sentry

[FRE-381] send anonymized transaction errors to sentry
  • Loading branch information
codingki authored Jan 12, 2024
2 parents 0abb0cf + 0d49ed9 commit 1b4fb90
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/components/TransactionDialog/TransactionDialogContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useManager } from "@cosmos-kit/react";
import { ArrowLeftIcon, CheckCircleIcon } from "@heroicons/react/20/solid";
import * as Sentry from "@sentry/react";
import { RouteResponse } from "@skip-router/core";
import { clsx } from "clsx";
import { useState } from "react";
Expand All @@ -17,6 +18,7 @@ import { useAccount } from "@/hooks/useAccount";
import { useChains } from "@/hooks/useChains";
import { useFinalityTimeEstimate } from "@/hooks/useFinalityTimeEstimate";
import { useSkipClient } from "@/solve";
import { isUserRejectedRequestError } from "@/utils/error";
import { getChainExplorerUrl } from "@/utils/explorer";

import RouteDisplay from "../RouteDisplay";
Expand Down Expand Up @@ -204,6 +206,33 @@ function TransactionDialogContent({
console.error(err);
}
if (err instanceof Error) {
if (!isUserRejectedRequestError(err)) {
Sentry.withScope((scope) => {
scope.setUser({
id: srcAccount?.address,
});
scope.setTransactionName("Swap.onSubmit");
scope.setTags({
sourceChain: route.sourceAssetChainID,
destinationChain: route.destAssetChainID,
sourceAssetDenom: route.sourceAssetDenom,
destinationAssetDenom: route.destAssetDenom,
doesSwap: route.doesSwap,
});
scope.setExtras({
sourceAddress: srcAccount?.address,
destinationAddress: dstAccount?.address,
sourceChain: route.sourceAssetChainID,
destinationChain: route.destAssetChainID,
sourceAssetDenom: route.sourceAssetDenom,
destinationAssetDenom: route.destAssetDenom,
amountIn: route.amountIn,
amountOut: route.amountOut,
});
Sentry.captureException(err);
});
}

toast.error(
<p>
<strong>Swap Failed!</strong>
Expand Down
14 changes: 14 additions & 0 deletions src/utils/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const isUserRejectedRequestError = (error: Error) => {
if (
// keplr | metamask
error.message.toLowerCase().includes("rejected") ||
// leap
error.message.toLowerCase().includes("declined") ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error common user rejected request error code
error.code === 4001
) {
return true;
}
return false;
};

0 comments on commit 1b4fb90

Please sign in to comment.