Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inji 434 & INJI 441]: Add events in receiver VC sharing flow and cancel button handle #990

5 changes: 4 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ fileignoreconfig:
checksum: 6d22bc5c77398316b943c512c208ce0846a9fff674c1ccac79e07f21962acd5f
- filename: machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine.typegen.ts
checksum: 10889302ca05646a283386be1bbe7a5fb510c02bb62a308ee45f3c2a872ae64e
- filename: shared/telemetry/TelemetryConstants.js
checksum: 9d9acf3981cbde452489eacbbd70ebaa0b853c1c04e9712fa71368c089a9662b
- filename: .github/workflows/internal-build.yml
checksum: 3a3b4dea51cb496729c4e568113fc19cf5b008481bb4a5d157f211a2128b951b
- filename: .github/workflows/push-triggers.yml
Expand All @@ -74,4 +76,5 @@ fileignoreconfig:
checksum: a0686e9a5c006176fd720b84bc36ca947db1422caf65c90cd0c2d1102a9e96df
- filename: ios/fastlane/Fastfile
checksum: feea5a7f044ef6961d53e7d1e1ffb92a3e0f72761496424f6e64288e3718d605
version: ""
version: ""

2 changes: 1 addition & 1 deletion components/Passcode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {PasscodeVerify} from '../components/PasscodeVerify';
import {Column, Text} from '../components/ui';
import {Theme} from '../components/ui/styleUtils';
import {
TelemetryConstants,
getImpressionEventData,
sendImpressionEvent,
} from '../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../shared/telemetry/TelemetryConstants';

export const Passcode: React.FC<PasscodeProps> = props => {
useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions machines/QrLoginMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import i18n from '../i18n';
import {parseMetadatas, VCMetadata} from '../shared/VCMetadata';
import {
getEndEventData,
sendEndEvent,
TelemetryConstants,
sendEndEvent
} from '../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../shared/telemetry/TelemetryConstants';
import {API_URLS} from '../shared/api';
import getAllConfigurations from '../shared/commonprops/commonProps';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ import {
sendEndEvent,
sendInteractEvent,
sendStartEvent,
TelemetryConstants,
} from '../../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants';

import {API_URLS} from '../../../shared/api';

const model = createModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ import {
getEndEventData,
getStartEventData,
sendEndEvent,
TelemetryConstants,
sendInteractEvent,
getInteractEventData,
sendStartEvent,
} from '../../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants';

import {API_URLS} from '../../../shared/api';

const model = createModel(
Expand Down
140 changes: 134 additions & 6 deletions machines/bleShare/request/requestMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ import {VerifierDataEvent} from 'react-native-tuvali/src/types/events';
import {BLEError} from '../types';
import Storage from '../../../shared/storage';
import {VCMetadata} from '../../../shared/VCMetadata';
import {
getEndEventData,
getErrorEventData,
getImpressionEventData,
getStartEventData,
sendEndEvent,
sendErrorEvent,
sendImpressionEvent,
sendStartEvent,
} from '../../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants';
// import { verifyPresentation } from '../shared/vcjs/verifyPresentation';

const {verifier, EventTypes, VerificationStatus} = tuvali;
Expand Down Expand Up @@ -107,7 +118,7 @@ export const requestMachine =
},
BLE_ERROR: {
target: '.handlingBleError',
actions: 'setBleError',
actions: ['sendBLEConnectionErrorEvent', 'setBleError'],
},
RESET: {
target: '.checkNearbyDevicesPermission',
Expand Down Expand Up @@ -241,11 +252,21 @@ export const requestMachine =
},
CONNECTED: {
target: 'waitingForVc',
actions: ['setSenderInfo', 'setReceiverInfo'],
actions: [
'setSenderInfo',
'setReceiverInfo',
'sendVcSharingStartEvent',
Alka1703 marked this conversation as resolved.
Show resolved Hide resolved
],
},

DISCONNECT: {
target: 'disconnected',
on: {
CANCEL: {
target: '#request.cancelling',
actions: ['sendVCSharingTerminatedEvent'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVCReceiveTerminatedEvent.

},
},
},
},
},
Expand All @@ -268,13 +289,15 @@ export const requestMachine =
on: {
CANCEL: {
target: '#request.cancelling',
actions: 'sendVCShareFlowTimeoutEndEvent',
Alka1703 marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
on: {
DISCONNECT: {
target: 'disconnected',
actions: ['sendVCSharingDisconnectedEvent'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVCReceiveDisconnectedEvent.

},
VC_RECEIVED: {
target: 'reviewing.accepting',
Expand All @@ -300,7 +323,10 @@ export const requestMachine =
},
FACE_INVALID: {
target: 'invalidIdentity',
actions: 'setReceiveLogTypeUnverified',
actions: [
'setReceiveLogTypeUnverified',
'sendVcShareFailedEvent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVcReceiveFailedEvent.

],
},
CANCEL: {
target: 'idle',
Expand Down Expand Up @@ -394,6 +420,7 @@ export const requestMachine =
'sendVcReceived',
'setReceiveLogTypeRegular',
'logReceived',
'sendVcShareSuccessEvent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVcReceiveSuccessEvent.

],
invoke: {
src: 'sendVcResponse',
Expand All @@ -408,7 +435,11 @@ export const requestMachine =
},
},
rejected: {
entry: ['setReceiveLogTypeDiscarded', 'logReceived'],
entry: [
'setReceiveLogTypeDiscarded',
'logReceived',
'sendVcRejectedEvent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVcReceiveRejectedEvent.

],
invoke: {
src: 'sendVcResponse',
data: {
Expand Down Expand Up @@ -452,7 +483,11 @@ export const requestMachine =
},
savingFailed: {
initial: 'idle',
entry: ['setReceiveLogTypeDiscarded', 'logReceived'],
entry: [
'setReceiveLogTypeDiscarded',
'logReceived',
'sendVcRejectedEvent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this to sendVcReceiveRejectedEvent.

],
invoke: {
src: 'sendVcResponse',
data: {
Expand Down Expand Up @@ -672,6 +707,98 @@ export const requestMachine =
shouldVerifyPresence: false,
}),
}),

sendVcSharingStartEvent: () => {
sendStartEvent(
getStartEventData(TelemetryConstants.FlowType.receiverVcShare),
);
sendImpressionEvent(
getImpressionEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.Screens.sharingInProgressScreen,
),
);
},

sendVCShareFlowTimeoutEndEvent: () => {
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
{comment: 'VC sharing timeout'},
),
);
},

sendVcShareSuccessEvent: () => {
sendImpressionEvent(
getImpressionEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.Screens.vcReceivedSuccessPage,
),
);
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.success,
),
);
},

sendVcShareFailedEvent: () => {
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
),
);
},

sendBLEConnectionErrorEvent: (_, event) => {
sendErrorEvent(
getErrorEventData(
TelemetryConstants.FlowType.receiverVcShare,
event.bleError.code,
event.bleError.message,
),
);
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
),
);
},

sendVcRejectedEvent: () => {
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
{comment: 'VC Rejected by the verifier'},
),
);
},

sendVCSharingTerminatedEvent: () => {
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
{comment: 'Verifier Disconnected'},
),
);
},

sendVCSharingDisconnectedEvent: () => {
sendEndEvent(
getEndEventData(
TelemetryConstants.FlowType.receiverVcShare,
TelemetryConstants.EndEventStatus.failure,
{comment: 'VC Sharing cancelled by sender'},
),
);
},
},

services: {
Expand Down Expand Up @@ -763,14 +890,15 @@ export const requestMachine =
},

monitorConnection: () => callback => {
const verifierErrorCodePrefix = 'TVV';
const subscription = verifier.handleDataEvents(event => {
if (event.type === EventTypes.onDisconnected) {
callback({type: 'DISCONNECT'});
}

if (
event.type === EventTypes.onError &&
event.code.includes('TVV')
event.code.includes(verifierErrorCodePrefix)
) {
callback({
type: 'BLE_ERROR',
Expand Down
Loading