@trustchex/react-native-sdk 1.253.0 → 1.266.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/android/src/main/java/com/trustchex/reactnativesdk/DeviceBrightnessModule.kt +66 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +12 -0
- package/ios/DeviceBrightnessModule.h +4 -0
- package/ios/DeviceBrightnessModule.m +27 -0
- package/lib/module/Screens/Dynamic/ContractAcceptanceScreen.js +25 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +19 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +19 -0
- package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +18 -5
- package/lib/module/Screens/Static/QrCodeScanningScreen.js +10 -2
- package/lib/module/Screens/Static/ResultScreen.js +52 -3
- package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +41 -2
- package/lib/module/Shared/Components/EIDScanner.js +63 -3
- package/lib/module/Shared/Components/FaceCamera.js +69 -4
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +4 -1
- package/lib/module/Shared/Components/NavigationManager.js +2 -0
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +2 -0
- package/lib/module/Shared/Contexts/AppContext.js +3 -1
- package/lib/module/Shared/Libs/analytics.utils.js +430 -0
- package/lib/module/Shared/Libs/camera.utils.js +58 -2
- package/lib/module/Shared/Libs/deeplink.utils.js +8 -0
- package/lib/module/Shared/Libs/http-client.js +89 -28
- package/lib/module/Shared/Services/AnalyticsService.js +404 -0
- package/lib/module/Shared/Types/analytics.types.js +111 -0
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +1 -0
- package/lib/module/Translation/index.js +5 -0
- package/lib/module/Trustchex.js +47 -4
- package/lib/module/index.js +3 -0
- package/lib/module/version.js +5 -0
- package/lib/typescript/src/Screens/Dynamic/ContractAcceptanceScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +7 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/NavigationManager.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Contexts/AppContext.d.ts +2 -0
- package/lib/typescript/src/Shared/Contexts/AppContext.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts +98 -0
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +19 -1
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts +86 -0
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Types/analytics.types.d.ts +146 -0
- package/lib/typescript/src/Shared/Types/analytics.types.d.ts.map +1 -0
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +1 -1
- package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
- package/lib/typescript/src/Translation/index.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +1 -0
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +2 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +6 -2
- package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +35 -1
- package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +30 -0
- package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +30 -0
- package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +30 -4
- package/src/Screens/Static/QrCodeScanningScreen.tsx +12 -2
- package/src/Screens/Static/ResultScreen.tsx +79 -4
- package/src/Screens/Static/VerificationSessionCheckScreen.tsx +65 -10
- package/src/Shared/Components/EIDScanner.tsx +132 -3
- package/src/Shared/Components/FaceCamera.tsx +77 -2
- package/src/Shared/Components/IdentityDocumentCamera.tsx +4 -4
- package/src/Shared/Components/NavigationManager.tsx +2 -0
- package/src/Shared/Components/QrCodeScannerCamera.tsx +2 -0
- package/src/Shared/Contexts/AppContext.ts +4 -0
- package/src/Shared/Libs/analytics.utils.ts +644 -0
- package/src/Shared/Libs/camera.utils.ts +74 -2
- package/src/Shared/Libs/deeplink.utils.ts +5 -0
- package/src/Shared/Libs/http-client.ts +105 -31
- package/src/Shared/Services/AnalyticsService.ts +470 -0
- package/src/Shared/Types/analytics.types.ts +179 -0
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +1 -0
- package/src/Translation/Resources/tr.ts +2 -1
- package/src/Translation/index.ts +9 -0
- package/src/Trustchex.tsx +54 -2
- package/src/index.tsx +33 -0
- package/src/version.ts +3 -0
package/src/Trustchex.tsx
CHANGED
|
@@ -15,6 +15,11 @@ import QrCodeScanningScreen from './Screens/Static/QrCodeScanningScreen';
|
|
|
15
15
|
import AppContext from './Shared/Contexts/AppContext';
|
|
16
16
|
import i18n from './Translation';
|
|
17
17
|
import { initializeTTS } from './Shared/Libs/tts.utils';
|
|
18
|
+
import { analyticsService } from './Shared/Services/AnalyticsService';
|
|
19
|
+
import {
|
|
20
|
+
AnalyticsEventCategory,
|
|
21
|
+
AnalyticsEventName,
|
|
22
|
+
} from './Shared/Types/analytics.types';
|
|
18
23
|
|
|
19
24
|
const Stack = createNativeStackNavigator();
|
|
20
25
|
|
|
@@ -32,6 +37,7 @@ interface TrustchexProps {
|
|
|
32
37
|
locale?: 'en' | 'tr';
|
|
33
38
|
onCompleted?: () => void;
|
|
34
39
|
onError?: (error: string) => void;
|
|
40
|
+
enableAnalytics?: boolean;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
const DEFAULT_BRANDING: TrustchexBranding = {
|
|
@@ -48,13 +54,19 @@ const Trustchex: React.FC<TrustchexProps> = ({
|
|
|
48
54
|
locale: propLocale,
|
|
49
55
|
onCompleted,
|
|
50
56
|
onError,
|
|
57
|
+
enableAnalytics = true,
|
|
51
58
|
}) => {
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
console.log('[Trustchex] Props updated:', { baseUrl: propBaseUrl, sessionId: propSessionId, enableAnalytics });
|
|
61
|
+
}, [propBaseUrl, propSessionId, enableAnalytics]);
|
|
62
|
+
|
|
52
63
|
const [baseUrl, setBaseUrl] = useState<string | null>(null);
|
|
53
64
|
const [sessionId, setSessionId] = useState<string | null>(null);
|
|
54
65
|
const [locale, setLocale] = useState(
|
|
55
66
|
propLocale || (i18n.language as 'en' | 'tr')
|
|
56
67
|
);
|
|
57
68
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
69
|
+
const [analyticsInitialized, setAnalyticsInitialized] = useState(false);
|
|
58
70
|
|
|
59
71
|
const branding = useMemo(
|
|
60
72
|
() => ({
|
|
@@ -67,11 +79,11 @@ const Trustchex: React.FC<TrustchexProps> = ({
|
|
|
67
79
|
const contextValue = useMemo(
|
|
68
80
|
() => ({
|
|
69
81
|
isDemoSession: false,
|
|
70
|
-
baseUrl,
|
|
82
|
+
baseUrl: baseUrl || '',
|
|
71
83
|
locale,
|
|
72
84
|
branding,
|
|
73
85
|
identificationInfo: {
|
|
74
|
-
sessionId,
|
|
86
|
+
sessionId: sessionId || '',
|
|
75
87
|
identificationId: '',
|
|
76
88
|
consent: {
|
|
77
89
|
contractIds: [],
|
|
@@ -81,10 +93,49 @@ const Trustchex: React.FC<TrustchexProps> = ({
|
|
|
81
93
|
},
|
|
82
94
|
onCompleted,
|
|
83
95
|
onError,
|
|
96
|
+
setSessionId,
|
|
97
|
+
setBaseUrl,
|
|
84
98
|
}),
|
|
85
99
|
[baseUrl, locale, branding, sessionId, propLocale, onCompleted, onError]
|
|
86
100
|
);
|
|
87
101
|
|
|
102
|
+
// Initialize analytics IMMEDIATELY when SDK mounts or session ID changes
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
console.log('[Trustchex] Analytics check:', {
|
|
105
|
+
enableAnalytics,
|
|
106
|
+
hasBaseUrl: !!baseUrl,
|
|
107
|
+
hasSessionId: !!sessionId,
|
|
108
|
+
analyticsInitialized,
|
|
109
|
+
sessionId: sessionId?.substring(0, 8) + '...'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (enableAnalytics && baseUrl && sessionId && !analyticsInitialized) {
|
|
113
|
+
console.log('[Trustchex] Initializing analytics...');
|
|
114
|
+
// Initialize analytics synchronously with the verification sessionId
|
|
115
|
+
analyticsService
|
|
116
|
+
.initialize({
|
|
117
|
+
enabled: true,
|
|
118
|
+
baseUrl: baseUrl,
|
|
119
|
+
verificationSessionId: sessionId, // Pass the verification session ID from backend
|
|
120
|
+
})
|
|
121
|
+
.then(() => {
|
|
122
|
+
console.log('[Trustchex] Analytics initialized successfully');
|
|
123
|
+
setAnalyticsInitialized(true);
|
|
124
|
+
// Track session start as the very first event
|
|
125
|
+
analyticsService.trackEvent(
|
|
126
|
+
AnalyticsEventName.SESSION_START,
|
|
127
|
+
AnalyticsEventCategory.SESSION,
|
|
128
|
+
{
|
|
129
|
+
source: 'sdk_init',
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
})
|
|
133
|
+
.catch((error) => {
|
|
134
|
+
console.warn('[Trustchex] Failed to initialize analytics:', error);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, [enableAnalytics, baseUrl, sessionId, analyticsInitialized]);
|
|
138
|
+
|
|
88
139
|
useEffect(() => {
|
|
89
140
|
initializeTTS();
|
|
90
141
|
}, []);
|
|
@@ -108,6 +159,7 @@ const Trustchex: React.FC<TrustchexProps> = ({
|
|
|
108
159
|
if (propLocale) {
|
|
109
160
|
setLocale(propLocale);
|
|
110
161
|
i18n.changeLanguage(propLocale);
|
|
162
|
+
analyticsService.setLocale(propLocale);
|
|
111
163
|
}
|
|
112
164
|
}, [propLocale]);
|
|
113
165
|
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import Trustchex from './Trustchex';
|
|
2
2
|
|
|
3
3
|
export { handleDeepLink } from './Shared/Libs/deeplink.utils';
|
|
4
|
+
export { analyticsService } from './Shared/Services/AnalyticsService';
|
|
5
|
+
export {
|
|
6
|
+
trackScreenView,
|
|
7
|
+
trackScreenExit,
|
|
8
|
+
trackButtonClick,
|
|
9
|
+
trackError,
|
|
10
|
+
trackErrorWithDetails,
|
|
11
|
+
trackApiCall,
|
|
12
|
+
trackVerificationStart,
|
|
13
|
+
trackVerificationComplete,
|
|
14
|
+
trackConsentGiven,
|
|
15
|
+
trackSessionStart,
|
|
16
|
+
trackSessionEnd,
|
|
17
|
+
trackNFCScanStart,
|
|
18
|
+
trackNFCScanComplete,
|
|
19
|
+
trackNFCScanFailed,
|
|
20
|
+
trackFunnelStep,
|
|
21
|
+
trackStepAbandoned,
|
|
22
|
+
trackStepSkipped,
|
|
23
|
+
useScreenTracking,
|
|
24
|
+
} from './Shared/Libs/analytics.utils';
|
|
25
|
+
export {
|
|
26
|
+
AnalyticsEventCategory,
|
|
27
|
+
AnalyticsEventName,
|
|
28
|
+
ErrorCategory,
|
|
29
|
+
} from './Shared/Types/analytics.types';
|
|
30
|
+
export type {
|
|
31
|
+
AnalyticsConfig,
|
|
32
|
+
AnalyticsEvent,
|
|
33
|
+
ErrorSeverity,
|
|
34
|
+
ErrorContext,
|
|
35
|
+
ErrorEventMetadata,
|
|
36
|
+
} from './Shared/Types/analytics.types';
|
|
4
37
|
|
|
5
38
|
export default Trustchex;
|
package/src/version.ts
ADDED