Skip to content

Commit

Permalink
fix(swap): remove ab test
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jul 27, 2020
1 parent 85b63ae commit 425373f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 58 deletions.
Expand Up @@ -3,9 +3,7 @@ import { AnalyticsActionTypes, AnalyticsStateType } from './types'
import { Remote } from 'blockchain-wallet-v4/src'

const INITIAL_STATE: AnalyticsStateType = {
ab_tests: {
SwapFees: Remote.NotAsked
}
ab_tests: {}
}

export const analyticsReducer = (
Expand Down
Expand Up @@ -3,7 +3,7 @@ import { MempoolFeeType } from 'data/components/types'
import { RemoteDataType } from 'core/types'

// types
export type ABTestNameType = 'SwapFees'
export type ABTestNameType = ''

export type ABTestCmdType = {
command: MempoolFeeType
Expand Down
Expand Up @@ -29,7 +29,6 @@ import * as AT from './actionTypes'
import * as C from 'services/AlertService'
import * as Lockbox from 'services/LockboxService'
import * as S from './selectors'
import { ABTestCmdType } from 'data/analytics/types'
import { actions, actionTypes, model, selectors } from 'data'
import {
addBalanceLimit,
Expand Down Expand Up @@ -62,7 +61,6 @@ import {
import { currencySymbolMap } from 'services/CoinifyService'
import { ETH_AIRDROP_MODAL } from '../exchangeHistory/model'
import { Exchange, Remote } from 'blockchain-wallet-v4/src'
import { MempoolFeeType } from './types'
import { promptForLockbox, promptForSecondPassword } from 'services/SagaService'
import { selectReceiveAddress } from '../utils/sagas'
import utils from './sagas.utils'
Expand Down Expand Up @@ -305,12 +303,10 @@ export default ({ api, coreSagas, networks }) => {
const source = prop('source', form)
const amounts = yield call(getAmounts, getCurrentPair(form))
const sourceAmount = prop('sourceAmount', amounts)
const fee: MempoolFeeType = yield call(getSwapFeeTestFee)
return yield call(
memo ? calculatePaymentMemo : calculateProvisionalPayment,
source,
sourceAmount,
fee
sourceAmount
)
}

Expand Down Expand Up @@ -743,7 +739,6 @@ export default ({ api, coreSagas, networks }) => {
const erc20List = (yield select(
selectors.core.walletOptions.getErc20CoinList
)).getOrFail()
const fee: MempoolFeeType = yield call(getSwapFeeTestFee)
let payment = yield call(
createPayment,
symbol,
Expand All @@ -752,8 +747,7 @@ export default ({ api, coreSagas, networks }) => {
source.type,
convertStandardToBase(symbol, value),
fees,
depositMemo,
fee
depositMemo
)
// Sign transaction
if (source.type !== ADDRESS_TYPES.LOCKBOX) {
Expand Down Expand Up @@ -877,19 +871,6 @@ export default ({ api, coreSagas, networks }) => {
}
}

// SwapFees A/B Test
const getSwapFeeTestFee = function * () {
const feeTestFallback: ABTestCmdType = {
command: 'priority',
from: 'matomo',
to: 'swap'
}
const feeR = selectors.analytics.selectAbTest('SwapFees', yield select())
const fee = feeR ? feeR.getOrElse(feeTestFallback) : feeTestFallback
return fee.command
}
// SwapFees A/B Test

return {
exchangeFormInitialized,
changeSource,
Expand Down
@@ -1,12 +1,10 @@
import { ABTestCmdType } from 'data/analytics/types'
import { actions, model } from 'data'
import { bindActionCreators, compose } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import { debounce } from 'utils/helpers'
import { getData } from './selectors'
import { isEmpty } from 'ramda'
import { reduxForm } from 'redux-form'
import { Remote } from 'blockchain-wallet-v4/src'
import DataError from 'components/DataError'
import Loading from './template.loading'
import React from 'react'
Expand All @@ -20,42 +18,17 @@ const { swapCoinAndFiat, swapBaseAndCounter } = model.rates
const { EXCHANGE_FORM } = model.components.exchange

class ExchangeForm extends React.Component<Props> {
componentDidMount () {
this.props.analyticsActions.createABTest('SwapFees')

setTimeout(() => {
if (!Remote.Success.is(this.props.data)) {
this.props.analyticsActions.createABTestSuccess('SwapFees', {
to: 'swap',
from: 'matomo',
command: 'priority'
})
}
}, 3000)

window.addEventListener('message', this.receiveMessage)
}

shouldComponentUpdate (nextProps) {
return nextProps.data !== this.props.data
}

componentWillUnmount () {
this.props.actions.setShowError(false)
window.removeEventListener('message', this.receiveMessage)
}

debounceTime = 50
changeAmount = debounce(this.props.actions.changeAmount, this.debounceTime)

receiveMessage = (e: { data: ABTestCmdType }) => {
if (!e.data) return
if (e.data.from !== 'matomo') return
if (e.data.to !== 'swap') return

this.props.analyticsActions.createABTestSuccess('SwapFees', e.data)
}

initialize = () => {
const { actions, from, to, fix, amount } = this.props
actions.initialize({ from, to, fix, amount })
Expand Down
Expand Up @@ -50,13 +50,12 @@ export const getData = createDeepEqualSelector(
getBlockLockbox,
selectors.core.settings.getCurrency,
getFormValues,
getAvailablePairs,
state => selectors.analytics.selectAbTest('SwapFees', state)
getAvailablePairs
],
(blockLockbox, currencyR, formValues, availablePairsR, swapFeesR) => {
(blockLockbox, currencyR, formValues, availablePairsR) => {
const { fix, sourceCoin, targetCoin, volume } = formValues

const transform = (currency, availablePairs, swapFees) => {
const transform = (currency, availablePairs) => {
const inputField = mapFixToFieldName(fix)
const fieldCoins = {
sourceAmount: sourceCoin,
Expand All @@ -81,13 +80,12 @@ export const getData = createDeepEqualSelector(
inputSymbol: currencySymbolMap[inputCurrency],
sourceActive: sourceActive(fix),
sourceCoin,
swapFees,
targetActive: targetActive(fix),
targetCoin,
volume
}
}
return lift(transform)(currencyR, availablePairsR, swapFeesR)
return lift(transform)(currencyR, availablePairsR)
}
)

Expand Down

0 comments on commit 425373f

Please sign in to comment.