From 36cbbc67505bd38b98348fd9dd5b685d0a8ca996 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Mon, 5 Feb 2024 18:13:45 +0700 Subject: [PATCH 1/4] update common ui version 1.0.5 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bcfc5195c..40cd63d1c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2969,9 +2969,9 @@ shx "^0.3.4" "@oraichain/oraidex-common-ui@^1.0.4": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common-ui/-/oraidex-common-ui-1.0.4.tgz#5c55dd83cb4c5c1ec5563d32077daa68ccdd01ab" - integrity sha512-Y6CD+/J398iip2SC20BBl7+bo2lSbGqATb7P2mCW3W7iWOAVE/WyTdSdgKeBn3qH5prW8daSJygwyK+IILH6sg== + version "1.0.5" + resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common-ui/-/oraidex-common-ui-1.0.5.tgz#ec6d2e7e3602a6d7885ca7d6304293602e8a4e39" + integrity sha512-PTwh4Kw7qSDSp+ke4kTIj7Tm9tbGeD9zKNNiW28Wxsbt1Z87G0YYos+rMDP4gw/BMloJBHD8CM/yghHZ7BuAgA== dependencies: axios "^0.26.1" axios-extensions "^3.1.3" From 3f24e69558d04a30192e3121d3059f54d9b0a807 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Tue, 6 Feb 2024 11:31:25 +0700 Subject: [PATCH 2/4] add mixpanel --- package.json | 3 +- src/index.tsx | 4 +++ src/pages/UniversalSwap/SwapV3/index.tsx | 36 ++++++++++++++++-------- yarn.lock | 5 ++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 1c4a1dd86..03d605790 100644 --- a/package.json +++ b/package.json @@ -12,13 +12,13 @@ "@cosmjs/tendermint-rpc": "^0.31.0", "@duckdb/duckdb-wasm": "1.28.0", "@injectivelabs/sdk-ts": "1.12.1", + "@leapwallet/cosmos-snap-provider": "0.1.25", "@oraichain/common-contracts-sdk": "^1.0.31", "@oraichain/ethereum-multicall": "^1.0.2", "@oraichain/kawaiiverse-txs": "^0.0.3", "@oraichain/oraidex-common-ui": "^1.0.4", "@oraichain/oraidex-contracts-sdk": "^1.0.26", "@oraichain/oraidex-universal-swap": "^1.0.49", - "@leapwallet/cosmos-snap-provider": "0.1.25", "@reduxjs/toolkit": "^1.9.3", "@sentry/react": "^7.47.0", "@tanstack/react-query": "^4.32.6", @@ -33,6 +33,7 @@ "ethers": "^5.0.15", "idb-keyval": "^6.2.1", "lottie-react": "^2.4.0", + "mixpanel-browser": "^2.49.0", "qrcode": "^1.5.3", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/index.tsx b/src/index.tsx index 299a7622f..18b114f10 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,6 +11,7 @@ import { Bounce, ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { PersistGate } from 'redux-persist/integration/react'; import { persistor, store } from 'store/configure'; +import mixpanel from 'mixpanel-browser'; import './index.scss'; import App from './layouts/App'; import ScrollToTop from './layouts/ScrollToTop'; @@ -35,6 +36,9 @@ if (process.env.REACT_APP_SENTRY_ENVIRONMENT === 'production') { // We recommend adjusting this value in production tracesSampleRate: 1 }); + + // init mixpanel track event + mixpanel.init(process.env.REACT_APP_SENTRY_ENVIRONMENT); } const initApp = async () => { diff --git a/src/pages/UniversalSwap/SwapV3/index.tsx b/src/pages/UniversalSwap/SwapV3/index.tsx index 711a9fb6e..f834c650b 100644 --- a/src/pages/UniversalSwap/SwapV3/index.tsx +++ b/src/pages/UniversalSwap/SwapV3/index.tsx @@ -55,6 +55,7 @@ import InputSwap from './InputSwapV3'; import { useGetTransHistory, useSimulate, useTaxRate } from './hooks'; import { useGetPriceByUSD } from './hooks/useGetPriceByUSD'; import styles from './index.module.scss'; +import mixpanel from 'mixpanel-browser'; const cx = cn.bind(styles); // TODO: hardcode decimal relayerFee @@ -238,12 +239,12 @@ const SwapComponent: React.FC<{ const isSimulateDataDisplay = simulateData && simulateData.displayAmount; const minimumReceive = isAverageRatio ? calculateMinReceive( - // @ts-ignore - Math.trunc(new BigDecimal(averageRatio.amount) / INIT_AMOUNT).toString(), - fromAmountTokenBalance.toString(), - userSlippage, - originalFromToken.decimals - ) + // @ts-ignore + Math.trunc(new BigDecimal(averageRatio.amount) / INIT_AMOUNT).toString(), + fromAmountTokenBalance.toString(), + userSlippage, + originalFromToken.decimals + ) : '0'; const isWarningSlippage = +minimumReceive > +simulateData?.amount; const simulateDisplayAmount = simulateData && simulateData.displayAmount ? simulateData.displayAmount : 0; @@ -254,8 +255,8 @@ const SwapComponent: React.FC<{ const minimumReceiveDisplay = isSimulateDataDisplay ? new BigDecimal( - simulateDisplayAmount - (simulateDisplayAmount * userSlippage) / 100 - relayerFee - bridgeTokenFee - ).toNumber() + simulateDisplayAmount - (simulateDisplayAmount * userSlippage) / 100 - relayerFee - bridgeTokenFee + ).toNumber() : 0; const expectOutputDisplay = isSimulateDataDisplay @@ -338,6 +339,20 @@ const SwapComponent: React.FC<{ }); } finally { setSwapLoading(false); + let address = ''; + if (oraiAddress) address += oraiAddress + " "; + if (metamaskAddress) address += metamaskAddress + " "; + if (tronAddress) address += tronAddress + " "; + const logEvent = { + address, + fromToken: `${originalFromToken.name} - ${originalFromToken.chainId}`, + fromAmount: `${fromAmountToken}`, + toToken: `${originalToToken.name} - ${originalToToken.chainId}`, + toAmount: `${toAmountToken}`, + fromNetwork: originalFromToken.chainId, + toNetwork: originalToToken.chainId + }; + mixpanel.track("Universal Swap Oraidex", logEvent); } }; @@ -446,9 +461,8 @@ const SwapComponent: React.FC<{ />
- {`1 ${originalFromToken.name} ≈ ${ - averageRatio ? Number((averageRatio.displayAmount / INIT_AMOUNT).toFixed(6)) : '0' - } ${originalToToken.name}`} + {`1 ${originalFromToken.name} ≈ ${averageRatio ? Number((averageRatio.displayAmount / INIT_AMOUNT).toFixed(6)) : '0' + } ${originalToToken.name}`}
diff --git a/yarn.lock b/yarn.lock index 40cd63d1c..6f2732e95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11744,6 +11744,11 @@ minizlib@^2.1.1, minizlib@^2.1.2: minipass "^3.0.0" yallist "^4.0.0" +mixpanel-browser@^2.49.0: + version "2.49.0" + resolved "https://registry.yarnpkg.com/mixpanel-browser/-/mixpanel-browser-2.49.0.tgz#de3f4f2d0f3a32b4babf6d827ef983a9fd48a711" + integrity sha512-RZJCO7XXuuHBAWG5fd9Mavz994M7v7W3Qiaq8NzmN631pa4BQ0vNZQtRFqKcCCOBn4xqOZbX2GkuC7ZkQoL4cQ== + "mkdirp@>=0.5 0", mkdirp@^0.5.6, mkdirp@~0.5.1: version "0.5.6" resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz" From ed18f3f875df55cc876b90942fadafe6a06812e1 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Tue, 6 Feb 2024 11:33:59 +0700 Subject: [PATCH 3/4] add mixpanel --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 18b114f10..edec3e727 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -38,7 +38,7 @@ if (process.env.REACT_APP_SENTRY_ENVIRONMENT === 'production') { }); // init mixpanel track event - mixpanel.init(process.env.REACT_APP_SENTRY_ENVIRONMENT); + mixpanel.init(process.env.REACT_APP_MIX_PANEL_ENVIRONMENT); } const initApp = async () => { From fd0d58cae0f92dbbcf27bd2951e296c64d683a50 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Tue, 6 Feb 2024 12:02:27 +0700 Subject: [PATCH 4/4] add mixpanel --- .env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 1a1afd315..e66c8a639 100644 --- a/.env.example +++ b/.env.example @@ -3,4 +3,5 @@ REACT_APP_SITE_DESC="OraiDEX is an IBC and CosmWasm-based decentralized exchange REACT_APP_BASE_API_URL=https://api.oraidex.io -REACT_APP_KADO_API_KEY=df0d2b3f-d829-4453-a4f6-1d6e8870e8f4 \ No newline at end of file +REACT_APP_KADO_API_KEY=df0d2b3f-d829-4453-a4f6-1d6e8870e8f4 +REACT_APP_MIX_PANEL_ENVIRONMENT=acbafd21a85654933cbb0332c5a6f4f8 \ No newline at end of file