Merge pull request #587 from lbryio/first-run-analytics

additional events to track first run flow
This commit is contained in:
Akinwale Ariwodola 2019-06-21 10:17:49 +01:00 committed by GitHub
commit 64bf12718a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View file

@ -43,7 +43,7 @@ class EmailCollectPage extends React.PureComponent {
const { onEmailViewLayout } = this.props;
const content = (
<View onLayout={onEmailViewLayout}>
<View onLayout={() => onEmailViewLayout('collect')}>
<Text style={firstRunStyle.title}>Setup account</Text>
<TextInput
style={firstRunStyle.emailInput}

View file

@ -20,7 +20,7 @@ class EmailVerifyPage extends React.PureComponent {
const { onEmailViewLayout, email } = this.props;
const content = (
<View onLayout={onEmailViewLayout}>
<View onLayout={() => onEmailViewLayout('verify')}>
<Text style={firstRunStyle.title}>Verify Email</Text>
<Text style={firstRunStyle.paragraph}>
An email has been sent to{' '}

View file

@ -24,7 +24,9 @@ class FirstRunScreen extends React.PureComponent {
state = {
currentPage: null,
email: null,
emailCollectTracked: false,
emailSubmitted: false,
enterPasswordTracked: false,
isFirstRun: false,
launchUrl: null,
showSkip: false,
@ -32,7 +34,7 @@ class FirstRunScreen extends React.PureComponent {
skipAccountConfirmed: false,
showBottomContainer: false,
walletPassword: null,
syncApplyStarted: false,
syncApplyStarted: false
};
componentDidMount() {
@ -44,7 +46,10 @@ class FirstRunScreen extends React.PureComponent {
if (NativeModules.FirstRun) {
NativeModules.FirstRun.isFirstRun().then(firstRun => {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
this.setState({ isFirstRun: firstRun });
if (firstRun) {
this.setState({ currentPage: FirstRunScreen.pages[0] });
} else {
@ -118,6 +123,7 @@ class FirstRunScreen extends React.PureComponent {
handleLeftButtonPressed = () => {
// Go to setup account page when "Setup account" is pressed
if (Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT === this.state.currentPage) {
this.setState({ emailCollectTracked: false }); // reset tracked flag
return this.showPage(Constants.FIRST_RUN_PAGE_EMAIL_COLLECT);
}
@ -128,6 +134,7 @@ class FirstRunScreen extends React.PureComponent {
// Go to email collection page if user cancels from email verification
if (Constants.FIRST_RUN_PAGE_EMAIL_VERIFY === this.state.currentPage) {
this.setState({ emailCollectTracked: false }); // reset tracked flag
this.showPage(Constants.FIRST_RUN_PAGE_EMAIL_COLLECT);
}
};
@ -228,10 +235,17 @@ class FirstRunScreen extends React.PureComponent {
}
};
onEmailViewLayout = () => {
onEmailViewLayout = (phase) => {
if ('collect' === phase) {
if (!this.state.emailCollectTracked) {
// we only want to track this once
this.setState({ emailCollectTracked: true }, () => NativeModules.Firebase.track('first_run_email_collect', null));
}
} else if ('verify' === phase) {
NativeModules.Firebase.track('first_run_email_verify', null);
}
this.setState({ showBottomContainer: true, showSkip: true });
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
};
onWalletPasswordChanged = password => {
@ -239,6 +253,9 @@ class FirstRunScreen extends React.PureComponent {
};
onWalletViewLayout = () => {
if (!this.state.enterPasswordTracked) {
this.setState({ enterPasswordTracked: true }, () => NativeModules.Firebase.track('first_run_enter_password', null));
}
this.setState({ showBottomContainer: true });
};
@ -246,6 +263,11 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true });
};
onSkipAccountViewLayout = () => {
NativeModules.Firebase.track('first_run_skip_account', null);
this.setState({ showBottomContainer: true });
};
onSkipSwitchChanged = checked => {
this.setState({ skipAccountConfirmed: checked });
};