Skip to content

Commit e814b2f

Browse files
authored
feat: add mixpanel events for registration flow (#616)
1 parent 5b6a253 commit e814b2f

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

app/src/consts/analytics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export const ProofEvents = {
5858
PROOF_VERIFICATION_STARTED: 'Proof: Proof Verification Started',
5959
PROVING_PROCESS_ERROR: 'Proof: Proving Process Error',
6060
PROVING_STATE_CHANGE: 'Proof: Proving State Change',
61+
REGISTER_COMPLETED: 'Proof: Register Completed',
62+
ALREADY_REGISTERED: 'Proof: Already Registered',
6163
QR_SCAN_CANCELLED: 'Proof: QR Scan Cancelled',
6264
QR_SCAN_FAILED: 'Proof: QR Scan Failed',
6365
QR_SCAN_SUCCESS: 'Proof: QR Scan Success',
@@ -71,6 +73,7 @@ export const SettingsEvents = {
7173

7274
export const BackupEvents = {
7375
ACCOUNT_RECOVERY_STARTED: 'Backup: Account Recovery Started',
76+
ACCOUNT_RECOVERY_COMPLETED: 'Backup: Account Recovery Completed',
7477
ACCOUNT_VERIFICATION_COMPLETED: 'Backup: Account Verification Completed',
7578
CLOUD_BACKUP_CONTINUE: 'Backup: Cloud Backup Continue',
7679
CLOUD_BACKUP_STARTED: 'Backup: Cloud Backup Started',

app/src/screens/recovery/AccountRecoveryChoiceScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const AccountRecoveryChoiceScreen: React.FC<
7676
}
7777
reStorePassportDataWithRightCSCA(passportData, csca as string);
7878
trackEvent(BackupEvents.CLOUD_RESTORE_SUCCESS);
79+
trackEvent(BackupEvents.ACCOUNT_RECOVERY_COMPLETED);
7980
onRestoreFromCloudNext();
8081
setRestoring(false);
8182
} catch (e: any) {

app/src/screens/recovery/RecoverWithPhraseScreen.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import { Text, TextArea, View, XStack, YStack } from 'tamagui';
77

88
import { SecondaryButton } from '../../components/buttons/SecondaryButton';
99
import Description from '../../components/typography/Description';
10+
import { BackupEvents } from '../../consts/analytics';
1011
import Paste from '../../images/icons/paste.svg';
1112
import { useAuth } from '../../providers/authProvider';
1213
import {
1314
loadPassportDataAndSecret,
1415
reStorePassportDataWithRightCSCA,
1516
} from '../../providers/passportDataProvider';
17+
import analytics from '../../utils/analytics';
1618
import {
1719
black,
1820
slate300,
@@ -30,6 +32,7 @@ const RecoverWithPhraseScreen: React.FC<
3032
> = ({}) => {
3133
const navigation = useNavigation();
3234
const { restoreAccountFromMnemonic } = useAuth();
35+
const { trackEvent } = analytics();
3336
const [mnemonic, setMnemonic] = useState<string>();
3437
const [restoring, setRestoring] = useState(false);
3538
const onPaste = useCallback(async () => {
@@ -75,6 +78,7 @@ const RecoverWithPhraseScreen: React.FC<
7578
}
7679

7780
setRestoring(false);
81+
trackEvent(BackupEvents.ACCOUNT_RECOVERY_COMPLETED);
7882
navigation.navigate('AccountVerifiedSuccess');
7983
}, [mnemonic, restoreAccountFromMnemonic]);
8084

app/src/utils/proving/provingMachine.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { v4 } from 'uuid';
88
import { AnyActorRef, createActor, createMachine } from 'xstate';
99
import { create } from 'zustand';
1010

11+
import { ProofEvents } from '../../consts/analytics';
1112
import { navigationRef } from '../../navigation';
1213
import { unsafe_getPrivateKey } from '../../providers/authProvider';
1314
import {
@@ -17,6 +18,7 @@ import {
1718
} from '../../providers/passportDataProvider';
1819
import { useProtocolStore } from '../../stores/protocolStore';
1920
import { useSelfAppStore } from '../../stores/selfAppStore';
21+
import analytics from '../analytics';
2022
import { getPublicKey, verifyAttestation } from './attest';
2123
import {
2224
generateTEEInputsDisclose,
@@ -39,6 +41,8 @@ import {
3941
isUserRegisteredWithAlternativeCSCA,
4042
} from './validateDocument';
4143

44+
const { trackEvent } = analytics();
45+
4246
const provingMachine = createMachine({
4347
id: 'proving',
4448
initial: 'idle',
@@ -385,6 +389,9 @@ export const useProvingStore = create<ProvingState>((set, get) => {
385389
} else if (data.status === 4) {
386390
socket?.disconnect();
387391
set({ socketConnection: null });
392+
if (get().circuitType === 'register') {
393+
trackEvent(ProofEvents.REGISTER_COMPLETED);
394+
}
388395
actor!.send({ type: 'PROVE_SUCCESS' });
389396
}
390397
});
@@ -589,6 +596,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
589596
);
590597
if (isRegistered) {
591598
reStorePassportDataWithRightCSCA(passportData, csca as string);
599+
trackEvent(ProofEvents.ALREADY_REGISTERED);
592600
actor!.send({ type: 'ALREADY_REGISTERED' });
593601
return;
594602
}

0 commit comments

Comments
 (0)