Skip to content

Commit

Permalink
Metrics tracking gas changed - slow, average, fast, custom - on edit …
Browse files Browse the repository at this point in the history
…screen.-
  • Loading branch information
danjm committed Apr 8, 2019
1 parent 4963ed6 commit 5454266
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class SendFooter extends Component {
unapprovedTxs: PropTypes.object,
update: PropTypes.func,
sendErrors: PropTypes.object,
gasChangedLabel: PropTypes.string,
}

static contextTypes = {
Expand Down Expand Up @@ -57,6 +58,7 @@ export default class SendFooter extends Component {
update,
toAccounts,
history,
gasChangedLabel,
} = this.props
const { metricsEvent } = this.context

Expand Down Expand Up @@ -91,6 +93,9 @@ export default class SendFooter extends Component {
action: 'Edit Screen',
name: 'Complete',
},
customVariables: {
gasChanged: gasChangedLabel,
},
})
history.push(CONFIRM_TRANSACTION_ROUTE)
})
Expand Down
12 changes: 12 additions & 0 deletions ui/app/components/app/send/send-footer/send-footer.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ import {
constructTxParams,
constructUpdatedTx,
} from './send-footer.utils'
import {
getRenderableEstimateDataForSmallButtonsFromGWEI,
getDefaultActiveButtonIndex,
} from '../../../../selectors/custom-gas'

export default connect(mapStateToProps, mapDispatchToProps)(SendFooter)

function mapStateToProps (state) {
const gasButtonInfo = getRenderableEstimateDataForSmallButtonsFromGWEI(state)
const gasPrice = getGasPrice(state)
const activeButtonIndex = getDefaultActiveButtonIndex(gasButtonInfo, gasPrice)
const gasChangedLabel = activeButtonIndex >= 0
? gasButtonInfo[activeButtonIndex].labelKey
: 'custom'

return {
amount: getSendAmount(state),
data: getSendHexData(state),
Expand All @@ -50,6 +61,7 @@ function mapStateToProps (state) {
tokenBalance: getTokenBalance(state),
unapprovedTxs: getUnapprovedTxs(state),
sendErrors: getSendErrors(state),
gasChangedLabel,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ proxyquire('../send-footer.container.js', {
},
'./send-footer.selectors': { isSendFormInError: (s) => `mockInError:${s}` },
'./send-footer.utils': utilsStubs,
'../../../../selectors/custom-gas': {
getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => ([{ labelKey: `mockLabel:${s}` }]),
getDefaultActiveButtonIndex: () => 0,
},
})

describe('send-footer container', () => {
Expand All @@ -68,6 +72,7 @@ describe('send-footer container', () => {
tokenBalance: 'mockTokenBalance:mockState',
unapprovedTxs: 'mockUnapprovedTxs:mockState',
sendErrors: 'mockSendErrors:mockState',
gasChangedLabel: 'mockLabel:mockState',
})
})

Expand Down
2 changes: 2 additions & 0 deletions ui/app/helpers/utils/metametrics.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const METAMETRICS_CUSTOM_ERROR_FIELD = 'errorField'
const METAMETRICS_CUSTOM_ERROR_MESSAGE = 'errorMessage'
const METAMETRICS_CUSTOM_RPC_NETWORK_ID = 'networkId'
const METAMETRICS_CUSTOM_RPC_CHAIN_ID = 'chainId'
const METAMETRICS_CUSTOM_GAS_CHANGED = 'gasChanged'

const METAMETRICS_CUSTOM_NETWORK = 'network'
const METAMETRICS_CUSTOM_ENVIRONMENT_TYPE = 'environmentType'
Expand All @@ -43,6 +44,7 @@ const customVariableNameIdMap = {
[METAMETRICS_CUSTOM_RPC_CHAIN_ID]: 2,
[METAMETRICS_CUSTOM_ERROR_FIELD]: 1,
[METAMETRICS_CUSTOM_ERROR_MESSAGE]: 2,
[METAMETRICS_CUSTOM_GAS_CHANGED]: 1,
}

const customDimensionsNameIdMap = {
Expand Down

0 comments on commit 5454266

Please sign in to comment.