Skip to content

Commit

Permalink
feat(analytics): add device verification events
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed Sep 10, 2019
1 parent 89685d0 commit 650acdf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,22 @@ export const PREFERENCE_EVENTS = {
IP_RESTRICTIONS: ['preferences', 'security', 'ip_restrictions'],
TWO_FACTOR_ENABLED: ['preferences', 'security', '2fa_enabled'],
TWO_FACTOR_DISABLED: ['preferences', 'security', '2fa_disabled'],
TOR_ACCESS: ['preferences', 'security', 'tor_access']
TOR_ACCESS: ['preferences', 'security', 'tor_access'],
VERIFY_DEVICE_ACCEPTED: [
'preferences',
'security',
'verify_device_accepted'
],
VERIFY_DEVICE_EMAIL_SENT: [
'preferences',
'security',
'verify_device_email_sent'
],
VERIFY_DEVICE_REJECTED: [
'preferences',
'security',
'verify_device_rejected'
]
}
}
export const SUNRIVER_AIRDROP_EVENTS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React from 'react'
import { actions } from 'data'
import { connect } from 'react-redux'
import { getData } from './selectors'
import { bindActionCreators } from 'redux'

import { actions, model } from 'data'
import { Wrapper } from 'components/Public'

import { getData } from './selectors'
import Loading from './template.loading'
import Success from './template.success'
import Error from './template.error'
import { Wrapper } from 'components/Public'

const {
VERIFY_DEVICE_ACCEPTED,
VERIFY_DEVICE_EMAIL_SENT,
VERIFY_DEVICE_REJECTED
} = model.analytics.PREFERENCE_EVENTS.SECURITY

class AuthorizeLogin extends React.PureComponent {
constructor (props) {
Expand All @@ -21,17 +29,23 @@ class AuthorizeLogin extends React.PureComponent {
}

componentDidMount () {
this.props.miscActions.authorizeLogin(this.state.token)
const { analyticsActions, miscActions } = this.props
miscActions.authorizeLogin(this.state.token)
analyticsActions.logEvent(VERIFY_DEVICE_EMAIL_SENT)
}

onAccept (e) {
const { analyticsActions, miscActions } = this.props
e.preventDefault()
this.props.miscActions.authorizeLogin(this.state.token, true)
miscActions.authorizeLogin(this.state.token, true)
analyticsActions.logEvent(VERIFY_DEVICE_ACCEPTED)
}

onReject (e) {
const { analyticsActions, miscActions } = this.props
e.preventDefault()
this.props.miscActions.authorizeLogin(this.state.token, false)
miscActions.authorizeLogin(this.state.token, false)
analyticsActions.logEvent(VERIFY_DEVICE_REJECTED)
}

render () {
Expand Down Expand Up @@ -59,6 +73,7 @@ const mapStateToProps = state => ({
})

const mapDispatchToProps = dispatch => ({
analyticsActions: bindActionCreators(actions.analytics, dispatch),
miscActions: bindActionCreators(actions.core.data.misc, dispatch)
})

Expand Down

0 comments on commit 650acdf

Please sign in to comment.