Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/actions/CreateWalletActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function createAccountTransaction(
// Hack. Keyboard pops up for some reason. Close it
dispatch(
logEvent('Activate_Wallet_Cancel', {
currencyCode: createdWalletCurrencyCode
createdWalletCurrencyCode
})
)
},
Expand All @@ -141,7 +141,7 @@ export function createAccountTransaction(
} else if (edgeTransaction) {
dispatch(
logEvent('Activate_Wallet_Done', {
currencyCode: createdWalletCurrencyCode
createdWalletCurrencyCode
})
)
const edgeMetadata: EdgeMetadata = {
Expand Down
16 changes: 11 additions & 5 deletions src/actions/CryptoExchangeActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { convertCurrency } from '../selectors/WalletSelectors'
import { RootState, ThunkAction } from '../types/reduxTypes'
import { NavigationBase } from '../types/routerTypes'
import { GuiCurrencyInfo, GuiSwapInfo } from '../types/types'
import { CryptoAmount } from '../util/CryptoAmount'
import { getCurrencyCode, getWalletTokenId } from '../util/CurrencyInfoHelpers'
import { logActivity } from '../util/logger'
import { bestOfPlugins } from '../util/ReferralHelpers'
Expand Down Expand Up @@ -338,13 +339,18 @@ export function shiftCryptoCurrency(navigation: NavigationBase, quote: EdgeSwapQ

await updateSwapCount(state)

const exchangeAmount = await toWallet.nativeToDenomination(toNativeAmount, toCurrencyCode)
dispatch(
logEvent('Exchange_Shift_Success', {
pluginId,
currencyCode: toCurrencyCode,
exchangeAmount,
orderId: result.orderId
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({
nativeAmount: toNativeAmount,
currencyCode: toCurrencyCode,
currencyConfig: toWallet.currencyConfig
}),
orderId: result.orderId,
swapProviderId: pluginId
}
})
)
} catch (error: any) {
Expand Down
31 changes: 18 additions & 13 deletions src/components/scenes/Fio/FioAddressRegisterSelectWalletScene.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { mul, toFixed } from 'biggystring'
import { EdgeAccount, EdgeCurrencyConfig, EdgeCurrencyWallet, EdgeDenomination, EdgeTransaction } from 'edge-core-js'
import * as React from 'react'
import { Alert, Image, View } from 'react-native'
import { sprintf } from 'sprintf-js'

import { FIO_STR } from '../../../constants/WalletAndCurrencyConstants'
import { lstrings } from '../../../locales/strings'
import { getExchangeDenomByCurrencyCode, selectDisplayDenom } from '../../../selectors/DenominationSelectors'
import { selectDisplayDenom } from '../../../selectors/DenominationSelectors'
import { config } from '../../../theme/appConfig'
import { connect } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { EdgeAsset } from '../../../types/types'
import { getTokenIdForced } from '../../../util/CurrencyInfoHelpers'
import { CryptoAmount } from '../../../util/CryptoAmount'
import { getWalletName } from '../../../util/CurrencyWalletHelpers'
import { getRegInfo } from '../../../util/FioAddressUtils'
import { logEvent, TrackingEventName, TrackingValues } from '../../../util/tracking'
Expand All @@ -30,7 +29,6 @@ interface StateProps {
fioPlugin?: EdgeCurrencyConfig
fioWallets: EdgeCurrencyWallet[]
fioDisplayDenomination: EdgeDenomination
pluginId: string
isConnected: boolean
}

Expand Down Expand Up @@ -150,12 +148,16 @@ export class FioAddressRegisterSelectWallet extends React.Component<Props, Local
this.props.onSelectWallet(walletId, paymentCurrencyCode)

const wallet = account.currencyWallets[walletId]
const exchangeDenomination = getExchangeDenomByCurrencyCode(wallet.currencyConfig, paymentCurrencyCode)
const exchangeAmount = allPaymentInfo[paymentCurrencyCode].amount
let nativeAmount = mul(exchangeAmount, exchangeDenomination.multiplier)
nativeAmount = toFixed(nativeAmount, 0, 0)
const { amount: exchangeAmount, address: paymentAddress } = allPaymentInfo[paymentCurrencyCode]

const cryptoAmount = new CryptoAmount({
exchangeAmount,
currencyCode: paymentCurrencyCode,
currencyConfig: wallet.currencyConfig
})

const { tokenId, nativeAmount } = cryptoAmount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, nice. Your new class may be even more useful than I expected. I like where this is going.


const tokenId = getTokenIdForced(account, wallet.currencyInfo.pluginId, paymentCurrencyCode)
const sendParams: SendScene2Params = {
walletId,
tokenId,
Expand All @@ -170,7 +172,7 @@ export class FioAddressRegisterSelectWallet extends React.Component<Props, Local
spendTargets: [
{
nativeAmount,
publicAddress: allPaymentInfo[paymentCurrencyCode].address
publicAddress: paymentAddress
}
],
metadata: {
Expand All @@ -190,8 +192,12 @@ export class FioAddressRegisterSelectWallet extends React.Component<Props, Local
[{ text: lstrings.string_ok_cap }]
)

const { currencyCode, pluginId } = wallet.currencyInfo
onLogEvent('Fio_Handle_Register', { nativeAmount, pluginId, currencyCode })
onLogEvent('Fio_Handle_Register', {
conversionValues: {
conversionType: 'crypto',
cryptoAmount
}
})
navigation.navigate('homeTab', { screen: 'home' })
}
}
Expand Down Expand Up @@ -283,7 +289,6 @@ export const FioAddressRegisterSelectWalletScene = connect<StateProps, DispatchP
fioPlugin: state.core.account.currencyConfig.fio,
fioDisplayDenomination: selectDisplayDenom(state, params.selectedWallet.currencyConfig, null),
defaultFiatCode: state.ui.settings.defaultIsoFiat,
pluginId: params.selectedWallet.currencyInfo.pluginId,
isConnected: state.network.isConnected
}),
dispatch => ({
Expand Down
9 changes: 7 additions & 2 deletions src/components/scenes/Fio/FioAddressSettingsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { refreshAllFioAddresses } from '../../../actions/FioAddressActions'
import { lstrings } from '../../../locales/strings'
import { connect } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { CryptoAmount } from '../../../util/CryptoAmount'
import { addBundledTxs, getAddBundledTxsFee, getTransferFee } from '../../../util/FioAddressUtils'
import { logEvent, TrackingEventName, TrackingValues } from '../../../util/tracking'
import { SceneWrapper } from '../../common/SceneWrapper'
Expand Down Expand Up @@ -104,8 +105,12 @@ export class FioAddressSettingsComponent extends React.Component<Props, LocalSta
}
await addBundledTxs(fioWallet, fioAddressName, fee)

const { currencyCode, pluginId } = fioWallet.currencyInfo
onLogEvent('Fio_Handle_Bundled_Tx', { nativeAmount: String(fee), pluginId, currencyCode })
onLogEvent('Fio_Handle_Bundled_Tx', {
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({ nativeAmount: String(fee), currencyConfig: fioWallet.currencyConfig, tokenId: null })
}
})
}

goToTransfer = (params: { fee: number }) => {
Expand Down
9 changes: 8 additions & 1 deletion src/components/scenes/Fio/FioCreateHandleScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ export const FioCreateHandleScene = (props: Props) => {
await dispatch(refreshAllFioAddresses())
showToast(lstrings.fio_free_handle_complete)

await dispatch(logEvent('Fio_Handle_Register', { dollarValue: 3 }))
await dispatch(
logEvent('Fio_Handle_Register', {
conversionValues: {
conversionType: 'dollar',
dollarConversionValue: 3
}
})
)

navigation.pop()
} catch (e: any) {
Expand Down
31 changes: 19 additions & 12 deletions src/components/scenes/Fio/FioDomainRegisterSelectWalletScene.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { mul, toFixed } from 'biggystring'
import { EdgeAccount, EdgeCurrencyConfig, EdgeCurrencyWallet, EdgeDenomination, EdgeTransaction } from 'edge-core-js'
import * as React from 'react'
import { View } from 'react-native'
Expand All @@ -7,12 +6,12 @@ import { sprintf } from 'sprintf-js'

import { FIO_STR } from '../../../constants/WalletAndCurrencyConstants'
import { lstrings } from '../../../locales/strings'
import { getExchangeDenomByCurrencyCode, selectDisplayDenomByCurrencyCode } from '../../../selectors/DenominationSelectors'
import { selectDisplayDenomByCurrencyCode } from '../../../selectors/DenominationSelectors'
import { config } from '../../../theme/appConfig'
import { connect } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { EdgeAsset } from '../../../types/types'
import { getTokenIdForced } from '../../../util/CurrencyInfoHelpers'
import { CryptoAmount } from '../../../util/CryptoAmount'
import { getWalletName } from '../../../util/CurrencyWalletHelpers'
import { getDomainRegInfo } from '../../../util/FioAddressUtils'
import { logEvent, TrackingEventName, TrackingValues } from '../../../util/tracking'
Expand All @@ -33,7 +32,6 @@ interface StateProps {
fioPlugin?: EdgeCurrencyConfig
fioWallets: EdgeCurrencyWallet[]
fioDisplayDenomination: EdgeDenomination
pluginId: string
isConnected: boolean
}

Expand Down Expand Up @@ -121,7 +119,7 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
}

onNextPress = (): void => {
const { account, isConnected, navigation, route, onLogEvent: logEvent } = this.props
const { account, isConnected, navigation, route, onLogEvent } = this.props
const { fioDomain, selectedWallet } = route.params
const { feeValue, paymentInfo: allPaymentInfo, paymentWallet } = this.state

Expand All @@ -143,11 +141,16 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
this.props.onSelectWallet(walletId, paymentCurrencyCode)

const wallet = account.currencyWallets[walletId]
const exchangeDenomination = getExchangeDenomByCurrencyCode(wallet.currencyConfig, paymentCurrencyCode)
let nativeAmount = mul(allPaymentInfo[paymentCurrencyCode].amount, exchangeDenomination.multiplier)
nativeAmount = toFixed(nativeAmount, 0, 0)
const { amount: exchangeAmount, address: paymentAddress } = allPaymentInfo[paymentCurrencyCode]

const cryptoAmount = new CryptoAmount({
exchangeAmount,
currencyCode: paymentCurrencyCode,
currencyConfig: wallet.currencyConfig
})

const { tokenId, nativeAmount } = cryptoAmount

const tokenId = getTokenIdForced(account, wallet.currencyInfo.pluginId, paymentCurrencyCode)
const sendParams: SendScene2Params = {
walletId,
tokenId,
Expand All @@ -162,7 +165,7 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
spendTargets: [
{
nativeAmount,
publicAddress: allPaymentInfo[paymentCurrencyCode].address
publicAddress: paymentAddress
}
],
metadata: {
Expand All @@ -184,7 +187,12 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
buttons={{ ok: { label: lstrings.string_ok_cap } }}
/>
)).catch(err => showError(err))
logEvent('Fio_Domain_Register', { exchangeAmount: String(feeValue), currencyCode: paymentWallet.currencyCode })
onLogEvent('Fio_Domain_Register', {
conversionValues: {
conversionType: 'crypto',
cryptoAmount
}
})
navigation.navigate('homeTab', { screen: 'home' })
}
}
Expand Down Expand Up @@ -276,7 +284,6 @@ export const FioDomainRegisterSelectWalletScene = connect<StateProps, DispatchPr
fioWallets: state.ui.wallets.fioWallets,
fioPlugin: state.core.account.currencyConfig.fio,
fioDisplayDenomination: selectDisplayDenomByCurrencyCode(state, params.selectedWallet.currencyConfig, FIO_STR),
pluginId: params.selectedWallet.currencyInfo.pluginId,
isConnected: state.network.isConnected
}),
dispatch => ({
Expand Down
9 changes: 5 additions & 4 deletions src/components/scenes/Fio/FioDomainSettingsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { formatDate } from '../../../locales/intl'
import { lstrings } from '../../../locales/strings'
import { connect } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { CryptoAmount } from '../../../util/CryptoAmount'
import { getDomainSetVisibilityFee, getRenewalFee, getTransferFee, renewFioDomain, setDomainVisibility } from '../../../util/FioAddressUtils'
import { logEvent, TrackingEventName, TrackingValues } from '../../../util/tracking'
import { SceneWrapper } from '../../common/SceneWrapper'
Expand Down Expand Up @@ -118,11 +119,11 @@ export class FioDomainSettingsComponent extends React.Component<Props, State> {

await renewFioDomain(fioWallet, fioDomainName, renewalFee)

const { currencyCode, pluginId } = fioWallet.currencyInfo
onLogEvent('Fio_Domain_Renew', {
nativeAmount: String(renewalFee),
currencyCode,
pluginId
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({ nativeAmount: String(renewalFee), currencyConfig: fioWallet.currencyConfig, tokenId: null })
}
})
}

Expand Down
24 changes: 17 additions & 7 deletions src/components/scenes/Fio/FioNameConfirmScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FIO_ADDRESS_DELIMITER } from '../../../constants/WalletAndCurrencyConst
import { lstrings } from '../../../locales/strings'
import { connect } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { CryptoAmount } from '../../../util/CryptoAmount'
import { fioMakeSpend, fioSignAndBroadcast } from '../../../util/FioAddressUtils'
import { logEvent, TrackingEventName, TrackingValues } from '../../../util/tracking'
import { SceneWrapper } from '../../common/SceneWrapper'
Expand Down Expand Up @@ -111,16 +112,20 @@ class FioNameConfirm extends React.PureComponent<Props> {
}
} else {
try {
const { currencyCode, pluginId } = paymentWallet.currencyInfo
if (this.isFioAddress()) {
let edgeTx = await fioMakeSpend(paymentWallet, 'registerFioAddress', { fioAddress: fioName })
edgeTx = await fioSignAndBroadcast(paymentWallet, edgeTx)
await paymentWallet.saveTx(edgeTx)

onLogEvent('Fio_Handle_Register', {
nativeAmount: edgeTx.nativeAmount,
currencyCode,
pluginId
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({
currencyConfig: paymentWallet.currencyConfig,
nativeAmount: edgeTx.nativeAmount,
tokenId: null
})
}
})

// @ts-expect-error
Expand All @@ -136,9 +141,14 @@ class FioNameConfirm extends React.PureComponent<Props> {
const expiration = edgeTx.otherParams?.broadcastResult?.expiration

onLogEvent('Fio_Domain_Register', {
nativeAmount: edgeTx.nativeAmount,
currencyCode,
pluginId
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({
currencyConfig: paymentWallet.currencyConfig,
nativeAmount: edgeTx.nativeAmount,
tokenId: null
})
}
})

// @ts-expect-error
Expand Down
15 changes: 11 additions & 4 deletions src/controllers/edgeProvider/EdgeProviderServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Dispatch } from '../../types/reduxTypes'
import { NavigationBase } from '../../types/routerTypes'
import { EdgeAsset, MapObject } from '../../types/types'
import { getCurrencyIconUris } from '../../util/CdnUris'
import { CryptoAmount } from '../../util/CryptoAmount'
import { getTokenIdForced } from '../../util/CurrencyInfoHelpers'
import { getWalletName } from '../../util/CurrencyWalletHelpers'
import { makeCurrencyCodeTable } from '../../util/tokenIdTools'
Expand Down Expand Up @@ -410,10 +411,16 @@ export class EdgeProviderServer implements EdgeProviderMethods {
.then(exchangeAmount => {
this._dispatch(
logEvent('EdgeProvider_Conversion_Success', {
pluginId: this._plugin.storeId,
orderId,
currencyCode: transaction.currencyCode,
exchangeAmount: abs(exchangeAmount)
conversionValues: {
conversionType: 'crypto',
cryptoAmount: new CryptoAmount({
currencyConfig: wallet.currencyConfig,
currencyCode: transaction.currencyCode,
exchangeAmount: abs(exchangeAmount)
}),
swapProviderId: this._plugin.storeId,
orderId
}
})
)
})
Expand Down
16 changes: 2 additions & 14 deletions src/plugins/gui/fiatPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { HomeAddress, SepaInfo } from '../../types/FormTypes'
import { GuiPlugin } from '../../types/GuiPluginTypes'
import { AppParamList, NavigationBase } from '../../types/routerTypes'
import { getNavigationAbsolutePath } from '../../util/routerUtils'
import { OnLogEvent, TrackingEventName } from '../../util/tracking'
import { OnLogEvent, SellConversionValues, TrackingEventName } from '../../util/tracking'
import {
FiatPaymentType,
FiatPluginAddressFormParams,
Expand Down Expand Up @@ -222,19 +222,7 @@ export const executePlugin = async (params: {
showToast: async (message: string, autoHideMs?: number) => {
showToast(message, autoHideMs)
},
trackConversion: async (
event: TrackingEventName,
opts: {
destCurrencyCode: string
destExchangeAmount: string
destPluginId?: string
sourceCurrencyCode: string
sourceExchangeAmount: string
sourcePluginId?: string
pluginId: string
orderId?: string
}
) => {
trackConversion: async (event: TrackingEventName, opts: { conversionValues: SellConversionValues }) => {
onLogEvent(event, opts)
},
exitScene: async () => {
Expand Down
Loading