@@ -22,10 +22,42 @@ import { ItwBaseProperties } from "./propertyTypes";
2222export const buildItwBaseProperties = (
2323 state : GlobalState
2424) : ItwBaseProperties => {
25+ const pidProps = buildPidProperties ( state ) ;
26+ const credentialProps = buildCredentialProperties ( state ) ;
27+
28+ return {
29+ ITW_STATUS_V2 : itwAuthLevelSelector ( state ) ?? "not_active" ,
30+ ...pidProps ,
31+ ...credentialProps
32+ } ;
33+ } ;
34+
35+ /**
36+ * Builds PID properties for Mixpanel analytics
37+ * IT-Wallet (L3) -> PID status is mapped to ITW_PID, while ITW_ID_V2 is not sent to preserve historical data.
38+ * Documenti su IO (L2) -> PID status is mapped to ITW_ID_V2, while ITW_PID shoul be "not_available".
39+ */
40+ export const buildPidProperties = ( state : GlobalState ) => {
2541 const isItwL3 = itwLifecycleIsITWalletValidSelector ( state ) ;
42+ const pidStatus = itwCredentialsEidStatusSelector ( state ) ;
2643
27- const ITW_STATUS_V2 = itwAuthLevelSelector ( state ) ?? "not_active" ;
28- const pidProps = buildPidProperties ( state ) ;
44+ const v2Props = {
45+ ITW_ID_V2 : mapPIDStatusToMixpanel ( pidStatus ) ,
46+ ITW_PID : "not_available"
47+ } as const ;
48+
49+ const v3Props = {
50+ ITW_PID : mapPIDStatusToMixpanel ( pidStatus )
51+ } ;
52+
53+ return isItwL3 ? v3Props : v2Props ;
54+ } ;
55+
56+ /**
57+ * IT-Wallet (L3) -> V2 properties are not sent to preserve historical data.
58+ */
59+ export const buildCredentialProperties = ( state : GlobalState ) => {
60+ const isItwL3 = itwLifecycleIsITWalletValidSelector ( state ) ;
2961
3062 const v3Props = {
3163 ITW_PG_V3 : getMixpanelCredentialStatus (
@@ -60,35 +92,9 @@ export const buildItwBaseProperties = (
6092 )
6193 } as const ;
6294
63- return {
64- ITW_STATUS_V2 ,
65- ...pidProps ,
66- ...v3Props ,
67- /**
68- * IT-Wallet (L3) -> V2 properties are not sent to preserve historical data.
69- */
70- ...( isItwL3 ? { } : v2Props )
71- } ;
72- } ;
73-
74- /**
75- * IT-Wallet (L3) -> PID status is mapped to ITW_PID, while ITW_ID_V2 is not sent to preserve historical data.
76- * Documenti su IO (L2) -> PID status is mapped to ITW_ID_V2, while ITW_PID shoul be "not_available".
77- */
78- export const buildPidProperties = ( state : GlobalState ) => {
79- const isItwL3 = itwLifecycleIsITWalletValidSelector ( state ) ;
80- const pidStatus = itwCredentialsEidStatusSelector ( state ) ;
81-
82- const v2Props = {
83- ITW_ID_V2 : mapPIDStatusToMixpanel ( pidStatus ) ,
84- ITW_PID : "not_available"
85- } as const ;
86-
87- const v3Props = {
88- ITW_PID : mapPIDStatusToMixpanel ( pidStatus )
89- } ;
90-
91- return isItwL3 ? v3Props : v2Props ;
95+ // V3 props are always included, while V2 props are included only if IT-Wallet is not valid
96+ // to preserve historical data consistency.
97+ return isItwL3 ? { ...v3Props } : { ...v3Props , ...v2Props } ;
9298} ;
9399
94100/**
0 commit comments