Files
inji-wallet/screens/PasscodeScreenController.ts
PuBHARGAVI 853cda3625 feat(Inji-402): track login & onboarding flow events in telemetry (#918)
* feat(INJI-402): track different flows of login and onboarding features in telemetry

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): add missing events in the login flow

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): track hardware keystore not supported error in telemetry

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* fix(INJI-402): send biometric event only when biometrics are enrolled in device

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): send error event for every 5 passcode mismatch attempts

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): add telemetry events to track passcode screen flow when biometrics change

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): add subtype to impression and interact event

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* fix(INJI-402): remove additionalParamters in error event

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): remove extra impression events and fix the biometrics reenabling flow

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* refactor(INJI-402): change getData method name to getStartEventData in telemetry utils

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* feat(INJI-402): don't show biometric failed alert message when user cancels the flow

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* refactor(INJI-402): change telemetry events name

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* fix(INJI-402): add missing functions in telemetry utils

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* refactor(INJI-402): add impression event in passcode screen and change Main to Home in event

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

---------

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
2023-10-13 18:51:05 +05:30

57 lines
1.4 KiB
TypeScript

import {useSelector} from '@xstate/react';
import {useContext, useEffect, useState} from 'react';
import {
AuthEvents,
selectAuthorized,
selectPasscode,
selectPasscodeSalt,
} from '../machines/auth';
import {PasscodeRouteProps} from '../routes';
import {GlobalContext} from '../shared/GlobalContext';
import {
getEndEventData,
getEventType,
sendEndEvent,
} from '../shared/telemetry/TelemetryUtils';
export function usePasscodeScreen(props: PasscodeRouteProps) {
const {appService} = useContext(GlobalContext);
const authService = appService.children.get('auth');
const isAuthorized = useSelector(authService, selectAuthorized);
const [passcode, setPasscode] = useState('');
const [error, setError] = useState('');
useEffect(() => {
if (isAuthorized) {
sendEndEvent(
getEndEventData(getEventType(props.route.params?.setup), 'SUCCESS'),
);
props.navigation.reset({
index: 0,
routes: [{name: 'Main'}],
});
}
}, [isAuthorized]);
return {
passcode,
setPasscode,
error,
setError,
storedPasscode: useSelector(authService, selectPasscode),
LOGIN: () => {
authService.send(AuthEvents.LOGIN());
},
SETUP_PASSCODE: () => {
authService.send(AuthEvents.SETUP_PASSCODE(passcode));
},
storedSalt: useSelector(authService, selectPasscodeSalt),
};
}