Files
inji-wallet/screens/PasscodeScreenController.ts
PuBHARGAVI f41959bc5f feat(Inji-435): add telemetry events for vc activation flow (#949)
* refactor(INJI-435): add enum for flow type,end event status & interact event subtype

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

* fix(INJI-435): change flow type value to camel case in getEventType function

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

* feat(INJI-435): add start,interact & impression events in vc activation and create an object with telemetry constants

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

* feat(INJI-435): add end,error events in vc activation flow

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

* feat(INJI-435): increase the pressable area of kebab icon

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

* feat: generate impression event only after going into otp modal & track binding_auth_failed error

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

* refactor(INJI-435): move sendImpression event from addVc modal to otp modal

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

* fix(INJI-435): add missing impression event in issuer machine

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

* refactor(INJI-435): return bindingAuthFailedError from state machines instead of splitting the error in tsx files

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

* fix(INJI-435): add padding and fix the activation status overflow in all languages

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

* refactor(INJI-435): change the telemetry sdk path in package.json

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

* refactor(INJI-435): extract esignetMosipVcItem and existingMosipVcItem machines common functions into separate file

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

* refactor(INJI-435): remove duplicate assignments of selectors

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

---------

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: Swati Goel <meet2swati@gmail.com>
Co-authored-by: Swati Goel <meet2swati@gmail.com>
2023-10-30 10:09:28 +05:30

61 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 {
TelemetryConstants,
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),
TelemetryConstants.EndEventStatus.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),
};
}