diff --git a/app/Analytics.tsx b/app/Analytics.tsx index a085ebd1..c2db7024 100644 --- a/app/Analytics.tsx +++ b/app/Analytics.tsx @@ -1,7 +1,7 @@ 'use client'; import { usePathname } from 'lib/i18n/navigation'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import Script from 'next/script'; import { useEffect } from 'react'; diff --git a/components/exploits/ExploitChecker.tsx b/components/exploits/ExploitChecker.tsx index 70541232..e810e8be 100644 --- a/components/exploits/ExploitChecker.tsx +++ b/components/exploits/ExploitChecker.tsx @@ -10,7 +10,7 @@ import { } from 'lib/hooks/page-context/AddressPageContext'; import { isNullish } from 'lib/utils'; import { getAllowanceKey } from 'lib/utils/allowances'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { getEventKey } from 'lib/utils/events'; import { type Exploit, getExploitStatus } from 'lib/utils/exploits'; import ExploitStatus from './ExploitStatus'; diff --git a/components/footer/ColorThemeSelect.tsx b/components/footer/ColorThemeSelect.tsx index befbbbd5..c0b29985 100644 --- a/components/footer/ColorThemeSelect.tsx +++ b/components/footer/ColorThemeSelect.tsx @@ -4,7 +4,7 @@ import { ComputerDesktopIcon, MoonIcon, SunIcon } from '@heroicons/react/24/outl import Select from 'components/common/select/Select'; import { useColorTheme } from 'lib/hooks/useColorTheme'; import { useMounted } from 'lib/hooks/useMounted'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { useTranslations } from 'next-intl'; const ColorThemeSelect = () => { diff --git a/components/footer/LanguageSelect.tsx b/components/footer/LanguageSelect.tsx index 032fbee4..1f06f6f3 100644 --- a/components/footer/LanguageSelect.tsx +++ b/components/footer/LanguageSelect.tsx @@ -5,7 +5,7 @@ import Select from 'components/common/select/Select'; import type { Locale } from 'lib/i18n/config'; import { useCsrRouter } from 'lib/i18n/csr-navigation'; import { usePathname } from 'lib/i18n/navigation'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { useLocale } from 'next-intl'; import type { FormatOptionLabelMeta } from 'react-select'; diff --git a/components/signatures/cells/CancelMarketplaceCell.tsx b/components/signatures/cells/CancelMarketplaceCell.tsx index 347d427e..cf942c35 100644 --- a/components/signatures/cells/CancelMarketplaceCell.tsx +++ b/components/signatures/cells/CancelMarketplaceCell.tsx @@ -3,7 +3,7 @@ import { useHandleTransaction } from 'lib/hooks/ethereum/useHandleTransaction'; import { useAddressPageContext } from 'lib/hooks/page-context/AddressPageContext'; import { type Marketplace, type OnCancel, type TransactionSubmitted, TransactionType } from 'lib/interfaces'; import { waitForTransactionConfirmation } from 'lib/utils'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { usePublicClient, useWalletClient } from 'wagmi'; import CancelCell from './CancelCell'; diff --git a/components/signatures/cells/CancelPermitCell.tsx b/components/signatures/cells/CancelPermitCell.tsx index 8fbd075c..11ebf02f 100644 --- a/components/signatures/cells/CancelPermitCell.tsx +++ b/components/signatures/cells/CancelPermitCell.tsx @@ -4,7 +4,7 @@ import { useHandleTransaction } from 'lib/hooks/ethereum/useHandleTransaction'; import { useAddressPageContext } from 'lib/hooks/page-context/AddressPageContext'; import { type OnCancel, type TransactionSubmitted, TransactionType } from 'lib/interfaces'; import { waitForTransactionConfirmation } from 'lib/utils'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { permit } from 'lib/utils/permit'; import { type PermitTokenData, isErc721Contract } from 'lib/utils/tokens'; import { usePublicClient, useWalletClient } from 'wagmi'; diff --git a/lib/hooks/ethereum/useAllowances.tsx b/lib/hooks/ethereum/useAllowances.tsx index 42d15506..3559dcb5 100644 --- a/lib/hooks/ethereum/useAllowances.tsx +++ b/lib/hooks/ethereum/useAllowances.tsx @@ -9,7 +9,7 @@ import { getAllowancesFromEvents, stripAllowanceData, } from 'lib/utils/allowances'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { type TimeLog, type TokenEvent, getEventKey } from 'lib/utils/events'; import { hasZeroBalance } from 'lib/utils/tokens'; import { useLayoutEffect, useState } from 'react'; diff --git a/lib/hooks/ethereum/useDonate.tsx b/lib/hooks/ethereum/useDonate.tsx index fe93eec2..a1fc2cd8 100644 --- a/lib/hooks/ethereum/useDonate.tsx +++ b/lib/hooks/ethereum/useDonate.tsx @@ -4,7 +4,7 @@ import type { DonateButtonType } from 'components/common/donate/DonateModal'; import { DONATION_ADDRESS } from 'lib/constants'; import { type TransactionSubmitted, TransactionType } from 'lib/interfaces'; import { waitForTransactionConfirmation } from 'lib/utils'; -import { analytics } from 'lib/utils/analytics'; +import analytics from 'lib/utils/analytics'; import { type DocumentedChainId, getChainName, getChainNativeToken, getDefaultDonationAmount } from 'lib/utils/chains'; import { type SendTransactionParameters, parseEther } from 'viem'; import { usePublicClient, useWalletClient } from 'wagmi'; diff --git a/lib/utils/allowances.ts b/lib/utils/allowances.ts index 96002de0..3beb33db 100644 --- a/lib/utils/allowances.ts +++ b/lib/utils/allowances.ts @@ -6,7 +6,7 @@ import { type TransactionSubmitted, TransactionType } from 'lib/interfaces'; import type { TransactionStore } from 'lib/stores/transaction-store'; import { type Address, type PublicClient, type WalletClient, type WriteContractParameters, formatUnits } from 'viem'; import { deduplicateArray, isNullish, waitForTransactionConfirmation, writeContractUnlessExcessiveGas } from '.'; -import { analytics } from './analytics'; +import analytics from './analytics'; import { isNetworkError, isRevertedError, isUserRejectionError, parseErrorMessage, stringifyError } from './errors'; import { type Erc20ApprovalEvent, diff --git a/lib/utils/analytics.ts b/lib/utils/analytics.ts index 783aa94e..a820f520 100644 --- a/lib/utils/analytics.ts +++ b/lib/utils/analytics.ts @@ -1,6 +1,6 @@ import mixpanel from 'mixpanel-browser'; -export const analytics = { +const analytics = { isInitialized: false, // init only when first used init() { @@ -22,3 +22,5 @@ export const analytics = { mixpanel.track(eventName, eventProperties); }, }; + +export default analytics; diff --git a/lib/utils/batch-revoke.ts b/lib/utils/batch-revoke.ts index c19b3e08..b2923f4e 100644 --- a/lib/utils/batch-revoke.ts +++ b/lib/utils/batch-revoke.ts @@ -1,6 +1,6 @@ import { getTipSelection } from 'lib/hooks/ethereum/useDonate'; import type { TokenAllowanceData } from './allowances'; -import { analytics } from './analytics'; +import analytics from './analytics'; export type BatchType = 'eip5792' | 'queued'; diff --git a/lib/utils/index.ts b/lib/utils/index.ts index dd907c26..c4ec984e 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -17,7 +17,7 @@ import { pad, slice, } from 'viem'; -import { analytics } from './analytics'; +import analytics from './analytics'; import type { Log, TokenEvent } from './events'; export const assertFulfilled = (item: PromiseSettledResult): item is PromiseFulfilledResult => { diff --git a/lib/utils/risk.tsx b/lib/utils/risk.tsx index 726b257f..34be5945 100644 --- a/lib/utils/risk.tsx +++ b/lib/utils/risk.tsx @@ -1,6 +1,6 @@ import { ExclamationCircleIcon, ExclamationTriangleIcon, InformationCircleIcon } from '@heroicons/react/24/solid'; import type { RiskFactor, RiskLevel } from 'lib/interfaces'; -import { analytics } from './analytics'; +import analytics from './analytics'; export const RiskFactorScore: Record = { allowlist: -100, diff --git a/lib/utils/tokens.ts b/lib/utils/tokens.ts index c7432007..1b62f3cc 100644 --- a/lib/utils/tokens.ts +++ b/lib/utils/tokens.ts @@ -14,7 +14,7 @@ import { toHex, } from 'viem'; import { deduplicateArray } from '.'; -import { analytics } from './analytics'; +import analytics from './analytics'; import { type TimeLog, type TokenEvent, TokenEventType, isApprovalTokenEvent, isTransferTokenEvent } from './events'; import { formatFixedPointBigInt } from './formatting'; import { withFallback } from './promises';