Skip to content

Commit

Permalink
Fix address HEX and add in wrap events. (#1478)
Browse files Browse the repository at this point in the history
* Fix address HEX and add in wrap events.

* Small fix for slice
  • Loading branch information
jonathansnow authored May 16, 2023
1 parent 4ba1077 commit bb88e88
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dapp-oeth/src/components/WalletSelectContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const WalletSelectContent = ({ isMobile }) => {
closeWalletSelectModal()
event({
'event': 'connect',
'connect_address': account
'connect_address': account?.slice(2)
})
}
}, [active])
Expand Down
46 changes: 28 additions & 18 deletions dapp-oeth/src/components/wrap/WrapHomepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getUserSource } from 'utils/user'
import usePrevious from 'utils/usePrevious'
import ApproveSwap from 'components/buySell/ApproveSwap'
import { useWeb3React } from '@web3-react/core'
import { event } from '../../../lib/gtm'

import analytics from 'utils/analytics'
import {
Expand Down Expand Up @@ -168,14 +169,14 @@ const WrapHomepage = ({
}

const onWrapOETH = async () => {
analytics.track(
swapMode === 'mint' ? 'On Wrap to wETH' : 'On Unwrap from wETH',
{
category: 'wrap',
label: swapMetadata.coinUsed,
value: swapMetadata.swapAmount,
}
)
const wrapTokenUsed = swapMode === 'mint' ? 'woeth' : 'oeth'
const wrapTokenAmount = swapMode === 'mint' ? inputAmount : wrapEstimate
// mint = wrap
event({
'event': 'wrap_started',
'wrap_token': wrapTokenUsed,
'wrap_amount': wrapTokenAmount
})

const metadata = swapMetadata()

Expand Down Expand Up @@ -208,24 +209,33 @@ const WrapHomepage = ({
setInputAmount('')

await rpcProvider.waitForTransaction(result.hash)

analytics.track('Wrap succeeded', {
category: 'wrap',
label: metadata.coinUsed,
value: metadata.swapAmount,
event({
'event': 'wrap_complete',
'wrap_type': swapMode,
'wrap_token': wrapTokenUsed,
'wrap_amount': wrapTokenAmount,
'wrap_address': '',
'wrap_tx': ''
})
} catch (e) {
const metadata = swapMetadata()
// 4001 code happens when a user rejects the transaction
if (e.code !== 4001) {
await storeTransactionError(swapMode, 'oeth')
analytics.track('Wrap failed', {
category: 'wrap',
label: e?.message,
event({
'event': 'wrap_failed',
'wrap_type': swapMode,
'wrap_token': wrapTokenUsed,
'wrap_amount': wrapTokenAmount,
'wrap_address' : ''
})
} else {
analytics.track('Wrap canceled', {
category: 'wrap',
event({
'event': 'wrap_rejected',
'wrap_type': swapMode,
'wrap_token': wrapTokenUsed,
'wrap_amount': wrapTokenAmount,
'wrap_address': ''
})
}

Expand Down

0 comments on commit bb88e88

Please sign in to comment.