Skip to content

Commit 11c7ec2

Browse files
fix(IT Wallet): [SIW-2921,SIW-2922,SIW-2923] Fix IT Wallet Mixpanel Events (#7327)
## Short description This PR fixes and adjusts several Mixpanel tracking events related to IT Wallet flows. ## List of changes proposed in this pull request - Updated `ITW_PROXIMITY_SUCCESS` to `ITW_PROXIMITY_UX_SUCCESS` - Changed the property name for the event `ITW_REMOTE_UX_SUCCESS` in `redirect_url` - Added tracking for `ITW_START_DEACTIVATION` also when the PID deactivation flow starts - Updated `ITW_DEACTIVATED` to include the PID when the deactivation is related to IT Wallet - On the PIN input screen, clicking “Dove trovo …” now only fires `ITW_CIE_PIN_INFO` - `ITW_CONTINUE_WITH_CIEID_CLOSE` is no longer fired when continuing to the CieID app ## How to test Verify that the updated events are correctly triggered and sent to Mixpanel with the expected properties
1 parent 2d1d0f3 commit 11c7ec2

File tree

9 files changed

+32
-17
lines changed

9 files changed

+32
-17
lines changed

ts/features/itwallet/identification/cie/hooks/useCieInfoBottomSheet.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ export const useCieInfoBottomSheet = ({
133133

134134
return {
135135
...bottomSheet,
136-
present: () => {
137-
trackBottomSheetView(type, routeName, itw_flow);
136+
// When opening the bottom sheet, track the view event by default.
137+
// Pass { skipTracking: true } to skip sending the analytics event.
138+
present: (options?: { skipTracking: boolean }) => {
139+
if (!options?.skipTracking) {
140+
trackBottomSheetView(type, routeName, itw_flow);
141+
}
138142
bottomSheet.present();
139143
}
140144
};

ts/features/itwallet/identification/cie/screens/ItwCiePinScreen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ export const ItwCiePinScreen = () => {
117117
)}
118118
onPress={() => {
119119
trackItWalletCiePinInfo(itw_flow);
120-
pinInfoBottomSheet.present();
120+
pinInfoBottomSheet.present({
121+
skipTracking: true
122+
});
121123
}}
122124
/>
123125
<VSpacer size={24} />

ts/features/itwallet/identification/common/screens/ItwL3IdentificationModeSelectionScreen.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
VStack
1111
} from "@pagopa/io-app-design-system";
1212
import { useFocusEffect, useRoute } from "@react-navigation/native";
13-
import { useCallback } from "react";
13+
import { useCallback, useRef } from "react";
1414
import { View } from "react-native";
1515
import I18n from "i18next";
1616
import IOMarkdown from "../../../../../components/IOMarkdown";
@@ -189,14 +189,20 @@ export const ItwL3IdentificationModeSelectionScreen = () => {
189189
*/
190190
const useCieIdBottomSheet = () => {
191191
const machineRef = ItwEidIssuanceMachineContext.useActorRef();
192+
// Ref used to temporarily skip tracking when the bottom sheet is dismissed
193+
const skipDismissTracking = useRef(false);
192194

193195
const bottomSheet = useIOBottomSheetModal({
194196
title: I18n.t(
195197
"features.itWallet.identification.mode.l3.bottomSheet.cieId.title"
196198
),
197199
onDismiss: () => {
198-
// Track the dismissal of the bottom sheet also when the user closes it with the X button
199-
trackItwContinueWithCieIDClose();
200+
// Track the dismissal of the bottom sheet also when the user closes it with the X button unless tracking was suppressed
201+
if (!skipDismissTracking.current) {
202+
trackItwContinueWithCieIDClose();
203+
}
204+
// eslint-disable-next-line functional/immutable-data
205+
skipDismissTracking.current = false;
200206
},
201207
component: (
202208
<VStack space={24}>
@@ -220,6 +226,8 @@ const useCieIdBottomSheet = () => {
220226
type: "select-identification-mode",
221227
mode: "cieId"
222228
});
229+
// eslint-disable-next-line functional/immutable-data
230+
skipDismissTracking.current = true;
223231
bottomSheet.dismiss();
224232
}
225233
},

ts/features/itwallet/machine/eid/actions.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { itwLifecycleWalletReset } from "../../lifecycle/store/actions";
2828
import { ITW_ROUTES } from "../../navigation/routes";
2929
import { itwWalletInstanceAttestationStore } from "../../walletInstance/store/actions";
3030
import { itwWalletInstanceAttestationSelector } from "../../walletInstance/store/selectors";
31+
import { itwLifecycleIsITWalletValidSelector } from "../../lifecycle/store/selectors";
3132
import { Context } from "./context";
3233
import { EidIssuanceEvents } from "./events";
3334

@@ -263,11 +264,9 @@ export const createEidIssuanceActionsImplementation = (
263264
trackSaveCredentialSuccess(isL3 ? "ITW_PID" : "ITW_ID_V2");
264265
updateITWStatusAndPIDProperties(store.getState());
265266
},
266-
trackWalletInstanceRevocation: ({
267-
context
268-
}: ActionArgs<Context, EidIssuanceEvents, EidIssuanceEvents>) => {
269-
const isL3 = context.identification?.level === "L3";
270-
trackItwDeactivated(store.getState(), isL3 ? "ITW_PID" : "ITW_ID_V2");
267+
trackWalletInstanceRevocation: () => {
268+
const isItwL3 = itwLifecycleIsITWalletValidSelector(store.getState());
269+
trackItwDeactivated(store.getState(), isItwL3 ? "ITW_PID" : "ITW_ID_V2");
271270
},
272271

273272
storeAuthLevel: ({

ts/features/itwallet/machine/eid/machine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ export const itwEidIssuanceMachine = setup({
272272
src: "revokeWalletInstance",
273273
onDone: {
274274
actions: [
275+
"trackWalletInstanceRevocation",
275276
"resetWalletInstance",
276-
"closeIssuance",
277-
"trackWalletInstanceRevocation"
277+
"closeIssuance"
278278
]
279279
},
280280
onError: [

ts/features/itwallet/presentation/details/components/ItwPresentationPidDetailFooter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import I18n from "i18next";
66
import { useItwStartCredentialSupportRequest } from "../hooks/useItwStartCredentialSupportRequest";
77
import { StoredCredential } from "../../../common/utils/itwTypesUtils";
88
import { ItwEidIssuanceMachineContext } from "../../../machine/eid/provider";
9+
import { trackWalletStartDeactivation } from "../../../analytics";
910

1011
const POWERED_BY_IT_WALLET = "Powered by IT-Wallet";
1112

@@ -23,6 +24,7 @@ const ItwPresentationPidDetailFooter = ({ credential }: Props) => {
2324
);
2425

2526
const handleRevokePress = () => {
27+
trackWalletStartDeactivation("ITW_PID");
2628
Alert.alert(
2729
I18n.t("features.itWallet.presentation.itWalletId.dialog.revoke.title"),
2830
I18n.t("features.itWallet.presentation.itWalletId.dialog.revoke.message"),

ts/features/itwallet/presentation/proximity/analytics/enum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export enum ITW_PROXIMITY_SCREENVIEW_EVENTS {
66
ITW_BLUETOOTH_NOT_ACTIVATED = "ITW_BLUETOOTH_NOT_ACTIVATED",
77
ITW_PROXIMITY_QR_CODE = "ITW_PROXIMITY_QR_CODE",
88
ITW_PROXIMITY_DATA_SHARE = "ITW_PROXIMITY_DATA_SHARE",
9-
ITW_PROXIMITY_SUCCESS = "ITW_PROXIMITY_SUCCESS"
9+
ITW_PROXIMITY_UX_SUCCESS = "ITW_PROXIMITY_UX_SUCCESS"
1010
}
1111

1212
export enum ITW_PROXIMITY_ACTIONS_EVENTS {

ts/features/itwallet/presentation/proximity/analytics/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const trackItwProximityDataShare = () => {
6868

6969
export const trackItwProximityPresentationCompleted = () => {
7070
void mixpanelTrack(
71-
ITW_PROXIMITY_SCREENVIEW_EVENTS.ITW_PROXIMITY_SUCCESS,
71+
ITW_PROXIMITY_SCREENVIEW_EVENTS.ITW_PROXIMITY_UX_SUCCESS,
7272
buildEventProperties("UX", "screen_view")
7373
);
7474
};

ts/features/itwallet/presentation/remote/analytics/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export function trackItwRemoteInvalidAuthResponseBottomSheet() {
5555
);
5656
}
5757

58-
export function trackItwRemotePresentationCompleted(redirect_uri: boolean) {
58+
export function trackItwRemotePresentationCompleted(redirect_url: boolean) {
5959
void mixpanelTrack(
6060
ITW_REMOTE_SCREENVIEW_EVENTS.ITW_REMOTE_UX_SUCCESS,
61-
buildEventProperties("UX", "screen_view", { redirect_uri })
61+
buildEventProperties("UX", "screen_view", { redirect_url })
6262
);
6363
}
6464

0 commit comments

Comments
 (0)