Skip to content

Commit

Permalink
chore: clean logs, update deps, config (#1636)
Browse files Browse the repository at this point in the history
* clean up logs

* update dependencies

* update query config for products list fetch (avoid refetching on window focus)

* update sentry configs to capture console logs

* update error to include input/output token info
  • Loading branch information
janndriessen authored Nov 8, 2024
1 parent 08912f1 commit 367a8c6
Show file tree
Hide file tree
Showing 19 changed files with 2,779 additions and 1,759 deletions.
4,468 changes: 2,747 additions & 1,721 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"@indexcoop/flash-mint-sdk": "3.11.0",
"@indexcoop/tokenlists": "3.0.0",
"@rainbow-me/rainbowkit": "^2.0.7",
"@safe-global/api-kit": "2.4.4",
"@safe-global/api-kit": "2.5.4",
"@safe-global/protocol-kit": "4.0.4",
"@safe-global/safe-core-sdk-types": "5.0.3",
"@sentry/nextjs": "8.8.0",
"@sentry/nextjs": "8.37.1",
"@tanstack/react-query": "5.36.2",
"@typeform/embed-react": "4.0.0",
"@uniswap/sdk-core": "5.3.1",
Expand All @@ -46,18 +46,18 @@
"alchemy-sdk": "3.4.1",
"dayjs": "1.11.11",
"eslint": "8.42.0",
"eslint-config-next": "^13.5.4",
"eslint-config-next": "14.2.13",
"ethers": "^5.7.2",
"framer-motion": "11.2.6",
"lodash": "4.17.21",
"next": "14.2.13",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga4": "2.1.0",
"react-loading-skeleton": "^3.3.1",
"react-loading-skeleton": "3.5.0",
"tailwind-merge": "2.5.2",
"use-debounce": "^10.0.1",
"viem": "2.21.12",
"viem": "2.21.43",
"wagmi": "2.12.13"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: 'https://56a0c37921d966ca831647a0bb314226@o4507393908211712.ingest.de.sentry.io/4507393908605008',
enabled: process.env.NODE_ENV === 'production',

integrations: [Sentry.captureConsoleIntegration()],
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
})
3 changes: 1 addition & 2 deletions sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: 'https://56a0c37921d966ca831647a0bb314226@o4507393908211712.ingest.de.sentry.io/4507393908605008',
enabled: process.env.NODE_ENV === 'production',

integrations: [Sentry.captureConsoleIntegration()],
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
})
3 changes: 1 addition & 2 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: 'https://56a0c37921d966ca831647a0bb314226@o4507393908211712.ingest.de.sentry.io/4507393908605008',
enabled: process.env.NODE_ENV === 'production',

integrations: [Sentry.captureConsoleIntegration()],
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
})
4 changes: 2 additions & 2 deletions src/app/api/quote/uniswap/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export async function POST(request: NextRequest) {
}
return NextResponse.json({ route: swapRoute })
} catch (error) {
console.log('Error getting Uniswap swap quote:')
console.log(error)
console.warn('Error getting Uniswap swap quote:')
console.error(error)
return NextResponse.json({}, { status: 500 })
}
}
2 changes: 1 addition & 1 deletion src/app/leverage/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export function LeverageProvider(props: { children: any }) {
const res = await indexApi.get(`/token/${baseToken.symbol}`)
setStats(res.data)
} catch (err) {
console.log('Error fetching token stats', err)
console.warn('Error fetching token stats', err)
}
}
fetchStats()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function usePrtRewards(
)
setEarnedRewards(res.cumulative_rewards)
} catch (err) {
console.log('Error fetching prt rewards', err)
console.warn('Error fetching prt rewards', err)
}
}, [address, tokenAddress])

Expand Down
4 changes: 2 additions & 2 deletions src/app/presales/providers/presale-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function usePresaleData(symbol: string): PresaleData {
)
setTvl(marketcapRes.marketcap)
} catch (err) {
console.log('Error fetching marketcap tvl', err)
console.warn('Error fetching marketcap tvl', err)
}
} else {
try {
Expand All @@ -97,7 +97,7 @@ export function usePresaleData(symbol: string): PresaleData {
Number(formatUnits(realUnitsRes, presaleToken.decimals)),
)
} catch (err) {
console.log('Error fetching tvl', err)
console.warn('Error fetching tvl', err)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/products/components/product-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function ProductList() {
const sortDirection = searchParams.get('dir') ?? SortDirection.DESC

const { data: products, isFetching } = useQuery({
gcTime: 5 * 60 * 1000, // 5 mins
refetchOnWindowFocus: false,
initialData: [] as any[],
queryKey: ['product-list', sortBy, sortDirection],
queryFn: async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/hooks/use-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useAnalytics = () => {
},
})
} catch (e) {
console.log('Caught error in logEvent', e)
console.warn('Caught error in logEvent', e)
}
},
[arcxSdk, walletAddress],
Expand Down Expand Up @@ -90,7 +90,7 @@ export const useAnalytics = () => {
},
})
} catch (e) {
console.log('Caught error in logTransaction', e)
console.warn('Caught error in logTransaction', e)
}
},
[arcxSdk, walletAddress],
Expand All @@ -116,7 +116,7 @@ export const useAnalytics = () => {
},
})
} catch (e) {
console.log('Caught error in logConnectWallet', e)
console.warn('Caught error in logConnectWallet', e)
}
}
},
Expand Down
9 changes: 3 additions & 6 deletions src/lib/hooks/use-best-quote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export const useBestQuote = (
const outputTokenAddress = getAddressForToken(outputToken, chainId)

if (!inputTokenAddress || !outputTokenAddress) {
console.log(inputTokenAddress, outputTokenAddress)
console.error('Error can not determine input/ouput token address')
console.error(
`Error can not determine input/ouput token address: ${chainId} ${inputToken.symbol} ${outputToken.symbol}`,
)
return
}

Expand All @@ -118,7 +119,6 @@ export const useBestQuote = (
!isAvailableForRedemption(inputToken, outputToken)
) {
setIsFetchingFlashMint(true)
console.log('canFlashmintIndexToken')
const quoteFlashMint = await getFlashMintQuote({
...request,
account: address,
Expand All @@ -139,7 +139,6 @@ export const useBestQuote = (

const fetchIssuanceQuote = async () => {
if (isAvailableForIssuance(inputToken, outputToken)) {
console.log('canIssue')
setIsFetchingIssuance(true)
const quoteIssuance = await getEnhancedIssuanceQuote(
{
Expand All @@ -166,7 +165,6 @@ export const useBestQuote = (
canRedeemIndexToken &&
!isAvailableForIssuance(inputToken, outputToken)
) {
console.log('canRedeemIndexToken')
setIsFetchingRedemption(true)
const quoteRedemption = await getEnhancedRedemptionQuote(
{
Expand Down Expand Up @@ -206,7 +204,6 @@ export const useBestQuote = (
outputTokenPrice,
nativeTokenPrice,
})
console.log(quote0x)
logEvent('Quote Received', formatQuoteAnalytics(quote0x))
setIsFetching0x(false)
setQuote0x(quote0x)
Expand Down
3 changes: 1 addition & 2 deletions src/lib/hooks/use-best-quote/utils/index-quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function getIndexQuote(
const inputTokenAddress = getAddressForToken(inputToken, chainId)
const outputTokenAddress = getAddressForToken(outputToken, chainId)
const path = `/quote?takerAddress=${address}&inputToken=${inputTokenAddress}&outputToken=${outputTokenAddress}&inputAmount=${inputAmount.toString()}&chainId=${chainId}`
console.log(path)
const indexApi = new IndexApi()
const res: QuoteResponse = await indexApi.get(path)

Expand Down Expand Up @@ -138,7 +137,7 @@ export async function getIndexQuote(
: [{ name: 'RFQ', proportion: '1' }],
}
} catch (err) {
console.log('Error fetching Index quote', err)
console.warn('Error fetching Index quote', err)
return null
}
}
4 changes: 2 additions & 2 deletions src/lib/hooks/use-trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const useTrade = () => {
logTransaction(chainId ?? -1, hash, formatQuoteAnalytics(quote))
setIsTransacting(false)
} catch (error) {
console.log('Override?', override)
console.log('Error sending transaction', error)
console.info('Override?', override)
console.warn('Error sending transaction', error)
setIsTransacting(false)
if (
error instanceof GasEstimatooorFailedError &&
Expand Down
2 changes: 1 addition & 1 deletion src/lib/providers/protection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ProtectionProvider = (props: { children: any }) => {
if (response.country === 'United States') setIsProtectable(true)
})
.catch((error) => {
console.log(
console.error(
'Cant determine whether or not we should protect the user because of this error: ',
error,
)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/api/index-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class IndexApi {
})
return resp.json()
} catch (error) {
console.log('Error fetching Index API for path', path)
console.warn('Error fetching Index API for path', path)
console.log(error)
throw error
}
Expand All @@ -29,7 +29,7 @@ export class IndexApi {
})
return resp.json()
} catch (error) {
console.log('Error putting Index API for path', path)
console.warn('Error putting Index API for path', path)
console.log(error)
throw error
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export async function addMEVProtectionChain(ethereum: any): Promise<void> {
params: [MevBlockerParams],
})
} catch (addError: any) {
console.log('Error adding MEV Blocker', addError)
console.warn('Error adding MEV Blocker', addError)
}
}
6 changes: 3 additions & 3 deletions src/lib/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function fetchTvl(symbol: string) {
const res = await indexApi.get(`/${symbol.toLowerCase()}/marketcap`)
return res.marketcap as number
} catch (err) {
console.log(`Error fetching marketcap for ${symbol}`, err)
console.warn(`Error fetching marketcap for ${symbol}`, err)
return null
}
}
Expand All @@ -17,7 +17,7 @@ export async function fetchCumulativeRevenue(address: string) {
const res = await indexApi.get(`/prts/fees/${address.toLowerCase()}`)
return res.cumulative_revenue as number
} catch (err) {
console.log(`Error fetching fees for ${address}`, err)
console.warn(`Error fetching fees for ${address}`, err)
return null
}
}
Expand All @@ -35,7 +35,7 @@ export async function fetchCarryCosts() {
}
return formattedRes
} catch (err) {
console.log('Error fetching carry costs', err)
console.warn('Error fetching carry costs', err)
return null
}
}
1 change: 0 additions & 1 deletion src/lib/utils/gas-estimatooor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class GasEstimatooor {
try {
gasEstimate = await provider.estimateGas(tx)
} catch (error: any) {
// console.log('Error estimating gas:', error)
if (canFail) {
throw new GasEstimatooorFailedError()
}
Expand Down

0 comments on commit 367a8c6

Please sign in to comment.