Skip to content

Commit

Permalink
chore: move analytics to export default
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Jan 16, 2025
1 parent 17e9b34 commit 168af56
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion components/exploits/ExploitChecker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/footer/ColorThemeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
2 changes: 1 addition & 1 deletion components/footer/LanguageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion components/signatures/cells/CancelMarketplaceCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion components/signatures/cells/CancelPermitCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/ethereum/useAllowances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/ethereum/useDonate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/allowances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mixpanel from 'mixpanel-browser';

export const analytics = {
const analytics = {
isInitialized: false,
// init only when first used
init() {
Expand All @@ -22,3 +22,5 @@ export const analytics = {
mixpanel.track(eventName, eventProperties);
},
};

export default analytics;
2 changes: 1 addition & 1 deletion lib/utils/batch-revoke.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T>(item: PromiseSettledResult<T>): item is PromiseFulfilledResult<T> => {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/risk.tsx
Original file line number Diff line number Diff line change
@@ -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<string, number> = {
allowlist: -100,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 168af56

Please sign in to comment.