Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics updates #6417

Merged
merged 4 commits into from
Apr 9, 2019
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class TransactionViewBalance extends PureComponent {
eventOpts: {
category: 'Navigation',
action: 'Home',
name: 'Clicked Send',
name: selectedToken ? 'Clicked Send: Token' : 'Clicked Send: Eth',
},
})
history.push(SEND_ROUTE)
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class ConfirmDeployContract extends Component {
render () {
return (
<ConfirmTransactionBase
action={this.context.t('contractDeployment')}
actionKey={'contractDeployment'}
dataComponent={this.renderData()}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class ConfirmSendEther extends Component {

return (
<ConfirmTransactionBase
action={this.context.t('confirm')}
actionKey={'confirm'}
hideData={hideData}
onEdit={confirmTransactionData => this.handleEdit(confirmTransactionData)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class ConfirmTransactionBase extends Component {
updateGasAndCalculate: PropTypes.func,
customGas: PropTypes.object,
// Component props
action: PropTypes.string,
actionKey: PropTypes.string,
contentComponent: PropTypes.node,
dataComponent: PropTypes.node,
detailsComponent: PropTypes.node,
Expand Down Expand Up @@ -159,7 +159,7 @@ export default class ConfirmTransactionBase extends Component {
}

handleEditGas () {
const { onEditGas, showCustomizeGasModal, action, txData: { origin }, methodData = {} } = this.props
const { onEditGas, showCustomizeGasModal, actionKey, txData: { origin }, methodData = {} } = this.props

this.context.metricsEvent({
eventOpts: {
Expand All @@ -169,7 +169,7 @@ export default class ConfirmTransactionBase extends Component {
},
customVariables: {
recipientKnown: null,
functionType: action || getMethodName(methodData.name) || this.context.t('contractInteraction'),
functionType: actionKey || getMethodName(methodData.name) || 'contractInteraction',
origin,
},
})
Expand Down Expand Up @@ -292,7 +292,7 @@ export default class ConfirmTransactionBase extends Component {
}

handleEdit () {
const { txData, tokenData, tokenProps, onEdit, action, txData: { origin }, methodData = {} } = this.props
const { txData, tokenData, tokenProps, onEdit, actionKey, txData: { origin }, methodData = {} } = this.props

this.context.metricsEvent({
eventOpts: {
Expand All @@ -302,7 +302,7 @@ export default class ConfirmTransactionBase extends Component {
},
customVariables: {
recipientKnown: null,
functionType: action || getMethodName(methodData.name) || this.context.t('contractInteraction'),
functionType: actionKey || getMethodName(methodData.name) || 'contractInteraction',
origin,
},
})
Expand Down Expand Up @@ -331,7 +331,7 @@ export default class ConfirmTransactionBase extends Component {

handleCancel () {
const { metricsEvent } = this.context
const { onCancel, txData, cancelTransaction, history, clearConfirmTransaction, action, txData: { origin }, methodData = {} } = this.props
const { onCancel, txData, cancelTransaction, history, clearConfirmTransaction, actionKey, txData: { origin }, methodData = {} } = this.props

if (onCancel) {
metricsEvent({
Expand All @@ -342,7 +342,7 @@ export default class ConfirmTransactionBase extends Component {
},
customVariables: {
recipientKnown: null,
functionType: action || getMethodName(methodData.name) || this.context.t('contractInteraction'),
functionType: actionKey || getMethodName(methodData.name) || 'contractInteraction',
origin,
},
})
Expand All @@ -358,7 +358,7 @@ export default class ConfirmTransactionBase extends Component {

handleSubmit () {
const { metricsEvent } = this.context
const { txData: { origin }, sendTransaction, clearConfirmTransaction, txData, history, onSubmit, action, metaMetricsSendCount = 0, setMetaMetricsSendCount, methodData = {} } = this.props
const { txData: { origin }, sendTransaction, clearConfirmTransaction, txData, history, onSubmit, actionKey, metaMetricsSendCount = 0, setMetaMetricsSendCount, methodData = {} } = this.props
const { submitting } = this.state

if (submitting) {
Expand All @@ -377,7 +377,7 @@ export default class ConfirmTransactionBase extends Component {
},
customVariables: {
recipientKnown: null,
functionType: action || getMethodName(methodData.name) || this.context.t('contractInteraction'),
functionType: actionKey || getMethodName(methodData.name) || 'contractInteraction',
origin,
},
})
Expand Down Expand Up @@ -517,7 +517,7 @@ export default class ConfirmTransactionBase extends Component {
valid: propsValid = true,
errorMessage,
errorKey: propsErrorKey,
action,
actionKey,
title,
subtitle,
hideSubtitle,
Expand All @@ -543,7 +543,7 @@ export default class ConfirmTransactionBase extends Component {
toName={toName}
toAddress={toAddress}
showEdit={onEdit && !isTxReprice}
action={action || getMethodName(name) || this.context.t('contractInteraction')}
action={this.context.t(actionKey) || getMethodName(name) || this.context.t('contractInteraction')}
title={title}
titleComponent={this.renderTitleComponent()}
subtitle={subtitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ export default class ImportWithSeedPhrase extends PureComponent {
.join(' ')
}

componentWillMount () {
window.onbeforeunload = () => this.context.metricsEvent({
eventOpts: {
category: 'Onboarding',
action: 'Import Seed Phrase',
name: 'Close window on import screen',
},
customVariables: {
errorLabel: 'Seed Phrase Error',
errorMessage: this.state.seedPhraseError,
},
})
}

handleSeedPhraseChange (seedPhrase) {
let seedPhraseError = ''

Expand Down Expand Up @@ -172,6 +186,10 @@ export default class ImportWithSeedPhrase extends PureComponent {
action: 'Import Seed Phrase',
name: 'Go Back from Onboarding Import',
},
customVariables: {
errorLabel: 'Seed Phrase Error',
errorMessage: seedPhraseError,
},
})
this.props.history.push(INITIALIZE_SELECT_ACTION_ROUTE)
}}
Expand Down