Analytics fixes (closes #386) (#387)

* Only send analytics events when the user is logged in

* Only send analytics events when the user is logged in (web)

* Add analytics identify() call
This commit is contained in:
Paul Frazee 2023-04-05 11:15:22 -05:00 committed by GitHub
parent 92b80ff048
commit 8e28d3c6be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 30 deletions

View file

@ -8,7 +8,6 @@ import {
View,
} from 'react-native'
import {observer} from 'mobx-react-lite'
import {sha256} from 'js-sha256'
import {useAnalytics} from 'lib/analytics'
import {Text} from '../../util/text/Text'
import {s, colors} from 'lib/styles'
@ -22,7 +21,7 @@ import {Step3} from './Step3'
export const CreateAccount = observer(
({onPressBack}: {onPressBack: () => void}) => {
const {track, screen, identify} = useAnalytics()
const {track, screen} = useAnalytics()
const pal = usePalette('default')
const store = useStores()
const model = React.useMemo(() => new CreateAccountModel(store), [store])
@ -57,14 +56,12 @@ export const CreateAccount = observer(
} else {
try {
await model.submit()
const email_hashed = sha256(model.email)
identify(email_hashed, {email_hashed})
track('Create Account')
} catch {
// dont need to handle here
}
}
}, [model, identify, track])
}, [model, track])
return (
<ScrollView testID="createAccount" style={pal.view}>