Skip to content

Commit

Permalink
feat: filter out errors from third-party frames + remove unnecessary …
Browse files Browse the repository at this point in the history
…errors
  • Loading branch information
therealemjy committed Jun 24, 2024
1 parent dd665df commit 4f796d3
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 167 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-colts-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@venusprotocol/evm": minor
---

filter out errors from third-party frames + remove unnecessary errors
4 changes: 2 additions & 2 deletions apps/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@mui/utils": "^5.4.2",
"@pancakeswap/sdk": "^3.1.0",
"@radix-ui/react-slot": "^1.0.2",
"@sentry/react": "^8.3.0",
"@sentry/vite-plugin": "^2.10.1",
"@sentry/react": "^8.11.0",
"@sentry/vite-plugin": "^2.20.0",
"@wagmi/core": "^1.4.12",
"bignumber.js": "^9.1.1",
"buffer": "^6.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type BigNumber from 'bignumber.js';

import { logError } from 'libs/errors';
import type { AssetDistribution, PrimeApy, Token } from 'types';
import { calculateDailyTokenRate } from 'utilities/calculateDailyTokenRate';
import findTokenByAddress from 'utilities/findTokenByAddress';
Expand Down Expand Up @@ -57,7 +56,6 @@ const formatDistributions = ({
});

if (!rewardToken) {
logError(`Record missing for reward token: ${rewardTokenAddress}`);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import BigNumber from 'bignumber.js';
import type { getIsolatedPoolParticipantsCount } from 'clients/subgraph';
import { COMPOUND_DECIMALS } from 'constants/compoundMantissa';
import type { PoolLens } from 'libs/contracts';
import { logError } from 'libs/errors';
import type { Asset, ChainId, Pool, PrimeApy, Token, VToken } from 'types';
import addUserPropsToPool from 'utilities/addUserPropsToPool';
import areAddressesEqual from 'utilities/areAddressesEqual';
Expand Down Expand Up @@ -70,7 +69,6 @@ const formatToPools = ({
});

if (!underlyingToken) {
logError(`Record missing for underlying token: ${vTokenMetaData.underlyingAssetAddress}`);
return acc;
}

Expand Down
1 change: 0 additions & 1 deletion apps/evm/src/clients/api/queries/getIsolatedPools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const getIsolatedPools = async ({
});

if (!underlyingToken) {
logError(`Record missing for underlying token: ${vTokenMetaData.underlyingAssetAddress}`);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { COMPOUND_DECIMALS, COMPOUND_MANTISSA } from 'constants/compoundMantissa';
import MAX_UINT256 from 'constants/maxUint256';
import type { LegacyPoolComptroller, ResilientOracle, VenusLens } from 'libs/contracts';
import { logError } from 'libs/errors';
import {
type Asset,
ChainId,
Expand Down Expand Up @@ -123,7 +122,6 @@ export const formatToPool = ({
});

if (!underlyingToken) {
logError(`Record missing for token: ${vTokenMetaData.underlyingAssetAddress}`);
return;
}

Expand Down
2 changes: 0 additions & 2 deletions apps/evm/src/clients/api/queries/getLegacyPool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from 'utilities';

import { getLegacyPoolMarkets, getTokenBalances } from 'clients/api';
import { logError } from 'libs/errors';
import { formatToPool } from './formatToPool';
import type { GetLegacyPoolInput, GetLegacyPoolOutput } from './types';

Expand Down Expand Up @@ -149,7 +148,6 @@ const getLegacyPool = async ({
});

if (!underlyingToken) {
logError(`Record missing for underlying token: ${vTokenMetaData.underlyingAssetAddress}`);
return acc;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigNumber from 'bignumber.js';

import type { VenusLens } from 'libs/contracts';
import { logError } from 'libs/errors';
import type { Token } from 'types';
import { convertDollarsToCents, convertMantissaToTokens } from 'utilities';
import findTokenByAddress from 'utilities/findTokenByAddress';
Expand Down Expand Up @@ -32,7 +31,6 @@ function formatRewardSummaryData({

// Filter out result if no corresponding token is found
if (!rewardToken) {
logError(`Record missing for reward token: ${rewardSummary.rewardTokenAddress}`);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigNumber from 'bignumber.js';

import type { Prime } from 'libs/contracts';
import { logError } from 'libs/errors';
import type { Token } from 'types';
import { convertDollarsToCents, convertMantissaToTokens, findTokenByAddress } from 'utilities';

Expand Down Expand Up @@ -29,7 +28,6 @@ const formatToPrimePendingRewardGroup = ({

// Filter out result if no corresponding token is found
if (!rewardToken) {
logError(`Record missing for reward token: ${primePendingReward.rewardToken}`);
return acc;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type BigNumber from 'bignumber.js';

import { logError } from 'libs/errors';
import type { Token } from 'types';
import convertDollarsToCents from 'utilities/convertDollarsToCents';
import convertMantissaToTokens from 'utilities/convertMantissaToTokens';
Expand All @@ -25,14 +24,12 @@ const formatToVaultPendingRewardGroup = ({
const stakedToken = tokens.find(token => token.symbol === stakedTokenSymbol);

if (!stakedToken) {
logError(`Record missing for staked token: ${stakedTokenSymbol}`);
return;
}

const rewardToken = tokens.find(token => token.symbol === rewardTokenSymbol);

if (!rewardToken) {
logError(`Record missing for reward token: ${rewardTokenSymbol}`);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type BigNumber from 'bignumber.js';

import { logError } from 'libs/errors';
import type { Token } from 'types';
import convertDollarsToCents from 'utilities/convertDollarsToCents';
import convertMantissaToTokens from 'utilities/convertMantissaToTokens';
Expand Down Expand Up @@ -38,7 +37,6 @@ const formatToVestingVaultPendingRewardGroup = ({
const rewardToken = tokens.find(token => token.symbol === 'XVS');

if (!rewardToken) {
logError('Record missing for reward token: XVS');
return;
}

Expand All @@ -48,7 +46,6 @@ const formatToVestingVaultPendingRewardGroup = ({
});

if (!stakedToken) {
logError(`Record missing for staked token: ${stakedTokenAddress}`);
return;
}

Expand Down
3 changes: 1 addition & 2 deletions apps/evm/src/clients/api/queries/getPendingRewards/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BigNumber from 'bignumber.js';

import { VError, logError } from 'libs/errors';
import { VError } from 'libs/errors';
import convertPriceMantissaToDollars from 'utilities/convertPriceMantissaToDollars';
import extractSettledPromiseValue from 'utilities/extractSettledPromiseValue';
import findTokenByAddress from 'utilities/findTokenByAddress';
Expand Down Expand Up @@ -132,7 +132,6 @@ const getPendingRewards = async ({
});

if (!rewardToken) {
logError(`Record missing for reward token: ${rewardTokenAddress}`);
return acc;
}

Expand Down
2 changes: 0 additions & 2 deletions apps/evm/src/clients/api/queries/getVTokens/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BSC_MAINNET_UNLISTED_TOKEN_ADDRESSES } from 'constants/address';
import type { LegacyPoolComptroller, PoolLens, VenusLens } from 'libs/contracts';
import { logError } from 'libs/errors';
import { ChainId, type Token, type VToken } from 'types';
import { areAddressesEqual } from 'utilities';
import findTokenByAddress from 'utilities/findTokenByAddress';
Expand Down Expand Up @@ -73,7 +72,6 @@ const getVTokens = async ({
});

if (!underlyingToken) {
logError(`Record missing for token: ${metaData.underlyingAssetAddress}`);
return acc;
}

Expand Down
1 change: 1 addition & 0 deletions apps/evm/src/constants/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const APPLICATION_KEY = 'venus-evm';
7 changes: 7 additions & 0 deletions apps/evm/src/libs/errors/ErrorBoundary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Sentry from '@sentry/react';

import config from 'config';
import { APPLICATION_KEY } from 'constants/sentry';
import { version as APP_VERSION } from 'constants/version';

export interface ErrorBoundaryProps {
Expand All @@ -13,6 +14,12 @@ Sentry.init({
release: APP_VERSION,
attachStacktrace: true,
tracesSampleRate: 0,
integrations: [
Sentry.thirdPartyErrorFilterIntegration({
filterKeys: [APPLICATION_KEY],
behaviour: 'drop-error-if-contains-third-party-frames',
}),
],
});

export const ErrorBoundary: React.FC<ErrorBoundaryProps> = ({ children }) => (
Expand Down
2 changes: 2 additions & 0 deletions apps/evm/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import svgrPlugin from 'vite-plugin-svgr';
import viteTsconfigPaths from 'vite-tsconfig-paths';

import { version as APP_VERSION } from './src/constants/version';
import { APPLICATION_KEY } from 'constants/sentry';

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
Expand Down Expand Up @@ -40,6 +41,7 @@ export default defineConfig(({ mode }) => {
}),
// Put the Sentry vite plugin after all other plugins
sentryVitePlugin({
applicationKey: APPLICATION_KEY,
authToken: env.SENTRY_AUTH_TOKEN,
org: 'venus-protocol-km',
project: 'dapp',
Expand Down
Loading

0 comments on commit 4f796d3

Please sign in to comment.