/ src / components / TransactionEventHandler.tsx
TransactionEventHandler.tsx
 1  // import { useEffect, useState } from 'react';
 2  // import { useRootStore } from 'src/store/root';
 3  // import { selectSuccessfulTransactions } from 'src/store/transactionsSelectors';
 4  // import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
 5  // import { GENERAL } from 'src/utils/mixPanelEvents';
 6  // import { useShallow } from 'zustand/shallow';
 7  
 8  export const TransactionEventHandler = () => {
 9    // const [postedTransactions, setPostedTransactions] = useState<{ [chainId: string]: string[] }>({});
10  
11    // const trackEvent = useRootStore((store) => store.trackEvent);
12    // const successfulTransactions = useRootStore(useShallow(selectSuccessfulTransactions));
13  
14    //tx's currently tracked: supply, borrow, withdraw, repay, repay with coll, collateral switch
15  
16    // useEffect(() => {
17    //   Object.keys(successfulTransactions).forEach((chainId) => {
18    //     const chainIdNumber = +chainId;
19    //     const networkConfig = getNetworkConfig(chainIdNumber);
20    //     Object.keys(successfulTransactions[chainIdNumber]).forEach((txHash) => {
21    //       if (!postedTransactions[chainIdNumber]?.includes(txHash)) {
22    //         const tx = successfulTransactions[chainIdNumber][txHash];
23    //         // const event = actionToEvent(tx.action);
24    //         trackEvent(GENERAL.TRANSACTION, {
25    //           transactionType: tx.action,
26    //           tokenAmount: tx.amount,
27    //           assetName: tx.assetName,
28    //           asset: tx.asset,
29    //           market: tx.market === null ? undefined : tx.market,
30    //           txHash: txHash,
31    //           proposalId: tx.proposalId,
32    //           support: tx.support,
33    //           previousState: tx.previousState,
34    //           newState: tx.newState,
35    //           outAsset: tx.outAsset,
36    //           outAmount: tx.outAmount,
37    //           outAssetName: tx.outAssetName,
38    //           amountUsd: tx.amountUsd,
39    //           outAmountUsd: tx.outAmountUsd,
40    //           chainId: chainIdNumber,
41    //           chainName: networkConfig.displayName || networkConfig.name,
42    //         });
43  
44    //         // update local state
45    //         if (postedTransactions[chainIdNumber]) {
46    //           setPostedTransactions((prev) => ({
47    //             ...prev,
48    //             [chainIdNumber]: [...prev[chainIdNumber], txHash],
49    //           }));
50    //         } else {
51    //           setPostedTransactions((prev) => ({
52    //             ...prev,
53    //             [+chainId]: [txHash],
54    //           }));
55    //         }
56    //       }
57    //     });
58    //   });
59    // }, [trackEvent, postedTransactions, successfulTransactions]);
60  
61    return null;
62  };