@umituz/react-native-onboarding 2.3.0 → 2.5.0
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 +0 -65
- package/package.json +1 -6
- package/src/domain/entities/OnboardingOptions.ts +0 -12
- package/src/domain/entities/OnboardingUserData.ts +0 -12
- package/src/index.ts +0 -1
- package/src/infrastructure/storage/OnboardingStore.ts +2 -16
- package/src/presentation/screens/OnboardingScreen.tsx +1 -15
- package/src/infrastructure/services/OnboardingDeviceTrackingService.ts +0 -60
package/README.md
CHANGED
|
@@ -185,8 +185,6 @@ const slides: OnboardingSlide[] = [
|
|
|
185
185
|
| `showProgressText` | `boolean` | `true` | Show progress text (1 of 5) |
|
|
186
186
|
| `storageKey` | `string` | - | Custom storage key for completion state |
|
|
187
187
|
| `autoComplete` | `boolean` | `false` | Auto-complete on last slide |
|
|
188
|
-
| `enableDeviceTracking` | `boolean` | `false` | Collect device info during onboarding |
|
|
189
|
-
| `userId` | `string` | - | User ID for device tracking (optional) |
|
|
190
188
|
|
|
191
189
|
### OnboardingSlide Interface
|
|
192
190
|
|
|
@@ -330,69 +328,6 @@ const isComplete = userData.completedAt !== undefined;
|
|
|
330
328
|
|
|
331
329
|
// Check if onboarding was skipped
|
|
332
330
|
const wasSkipped = userData.skipped === true;
|
|
333
|
-
|
|
334
|
-
// Get device info (if device tracking was enabled)
|
|
335
|
-
const deviceInfo = userData.deviceInfo;
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
## 📱 Device Tracking (Optional)
|
|
339
|
-
|
|
340
|
-
Collect device information during onboarding for analytics or support purposes.
|
|
341
|
-
|
|
342
|
-
### Installation
|
|
343
|
-
|
|
344
|
-
First, install the device tracking package:
|
|
345
|
-
|
|
346
|
-
```bash
|
|
347
|
-
npm install @umituz/react-native-device
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
### Usage
|
|
351
|
-
|
|
352
|
-
```tsx
|
|
353
|
-
import { OnboardingScreen } from '@umituz/react-native-onboarding';
|
|
354
|
-
|
|
355
|
-
<OnboardingScreen
|
|
356
|
-
slides={slides}
|
|
357
|
-
enableDeviceTracking={true}
|
|
358
|
-
userId="user123" // Optional
|
|
359
|
-
onComplete={async () => {
|
|
360
|
-
const userData = onboardingStore.getUserData();
|
|
361
|
-
|
|
362
|
-
// Device info is now available
|
|
363
|
-
console.log('Device:', userData.deviceInfo?.platform);
|
|
364
|
-
console.log('OS:', userData.deviceInfo?.osVersion);
|
|
365
|
-
console.log('App:', userData.deviceInfo?.appVersion);
|
|
366
|
-
}}
|
|
367
|
-
/>
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
### Device Info Structure
|
|
371
|
-
|
|
372
|
-
```typescript
|
|
373
|
-
{
|
|
374
|
-
deviceId: string;
|
|
375
|
-
platform: 'ios' | 'android' | 'web';
|
|
376
|
-
osVersion: string;
|
|
377
|
-
appVersion: string;
|
|
378
|
-
deviceName: string;
|
|
379
|
-
manufacturer: string;
|
|
380
|
-
brand: string;
|
|
381
|
-
timestamp: number;
|
|
382
|
-
userId?: string; // If provided
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
### Manual Device Info Collection
|
|
387
|
-
|
|
388
|
-
```tsx
|
|
389
|
-
import { OnboardingDeviceTrackingService } from '@umituz/react-native-onboarding';
|
|
390
|
-
|
|
391
|
-
// Collect device info manually
|
|
392
|
-
const deviceInfo = await OnboardingDeviceTrackingService.collectDeviceInfo('user123');
|
|
393
|
-
|
|
394
|
-
// Check if device tracking is available
|
|
395
|
-
const isAvailable = await OnboardingDeviceTrackingService.isDeviceTrackingAvailable();
|
|
396
331
|
```
|
|
397
332
|
|
|
398
333
|
## 🔄 Resetting Onboarding
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-onboarding",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Advanced onboarding flow for React Native apps with personalization questions, theme-aware colors, animations, and customizable slides. SOLID, DRY, KISS principles applied.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -44,11 +44,6 @@
|
|
|
44
44
|
"react-native-safe-area-context": "^5.0.0",
|
|
45
45
|
"zustand": "^5.0.0"
|
|
46
46
|
},
|
|
47
|
-
"peerDependenciesMeta": {
|
|
48
|
-
"@umituz/react-native-device": {
|
|
49
|
-
"optional": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
47
|
"devDependencies": {
|
|
53
48
|
"@types/react": "^18.2.45",
|
|
54
49
|
"@types/react-native": "^0.73.0",
|
|
@@ -85,17 +85,5 @@ export interface OnboardingOptions {
|
|
|
85
85
|
* Show paywall modal on onboarding completion (default: false)
|
|
86
86
|
*/
|
|
87
87
|
showPaywallOnComplete?: boolean;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Enable device tracking (default: false)
|
|
91
|
-
* When enabled, collects device information during onboarding
|
|
92
|
-
*/
|
|
93
|
-
enableDeviceTracking?: boolean;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* User ID for device tracking (optional)
|
|
97
|
-
* Only used when enableDeviceTracking is true
|
|
98
|
-
*/
|
|
99
|
-
userId?: string;
|
|
100
88
|
}
|
|
101
89
|
|
|
@@ -39,17 +39,5 @@ export interface OnboardingUserData {
|
|
|
39
39
|
gender?: string;
|
|
40
40
|
[key: string]: any;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Device information (optional)
|
|
45
|
-
* Only collected when enableDeviceTracking is true
|
|
46
|
-
*/
|
|
47
|
-
deviceInfo?: {
|
|
48
|
-
deviceId?: string;
|
|
49
|
-
platform?: string;
|
|
50
|
-
osVersion?: string;
|
|
51
|
-
appVersion?: string;
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
};
|
|
54
42
|
}
|
|
55
43
|
|
package/src/index.ts
CHANGED
|
@@ -52,7 +52,6 @@ export {
|
|
|
52
52
|
useOnboardingNavigation,
|
|
53
53
|
type UseOnboardingNavigationReturn,
|
|
54
54
|
} from "./infrastructure/hooks/useOnboardingNavigation";
|
|
55
|
-
export { OnboardingDeviceTrackingService } from "./infrastructure/services/OnboardingDeviceTrackingService";
|
|
56
55
|
|
|
57
56
|
// =============================================================================
|
|
58
57
|
// PRESENTATION LAYER - Components and Screens
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
unwrap,
|
|
13
13
|
} from "@umituz/react-native-storage";
|
|
14
14
|
import type { OnboardingUserData } from "../../domain/entities/OnboardingUserData";
|
|
15
|
-
import { OnboardingDeviceTrackingService } from "../services/OnboardingDeviceTrackingService";
|
|
16
15
|
|
|
17
16
|
interface OnboardingStore {
|
|
18
17
|
// State
|
|
@@ -24,7 +23,7 @@ interface OnboardingStore {
|
|
|
24
23
|
|
|
25
24
|
// Actions
|
|
26
25
|
initialize: (storageKey?: string) => Promise<void>;
|
|
27
|
-
complete: (storageKey?: string
|
|
26
|
+
complete: (storageKey?: string) => Promise<void>;
|
|
28
27
|
skip: (storageKey?: string) => Promise<void>;
|
|
29
28
|
setCurrentStep: (step: number) => void;
|
|
30
29
|
reset: (storageKey?: string) => Promise<void>;
|
|
@@ -34,7 +33,6 @@ interface OnboardingStore {
|
|
|
34
33
|
getAnswer: (questionId: string) => any;
|
|
35
34
|
getUserData: () => OnboardingUserData;
|
|
36
35
|
setUserData: (data: OnboardingUserData) => Promise<void>;
|
|
37
|
-
collectDeviceInfo: (userId?: string) => Promise<void>;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
const DEFAULT_STORAGE_KEY = StorageKey.ONBOARDING_COMPLETED;
|
|
@@ -69,7 +67,7 @@ export const useOnboardingStore = create<OnboardingStore>((set, get) => ({
|
|
|
69
67
|
});
|
|
70
68
|
},
|
|
71
69
|
|
|
72
|
-
complete: async (storageKey = DEFAULT_STORAGE_KEY
|
|
70
|
+
complete: async (storageKey = DEFAULT_STORAGE_KEY) => {
|
|
73
71
|
set({ loading: true, error: null });
|
|
74
72
|
|
|
75
73
|
const result = await storageRepository.setString(storageKey, "true");
|
|
@@ -78,11 +76,6 @@ export const useOnboardingStore = create<OnboardingStore>((set, get) => ({
|
|
|
78
76
|
const userData = get().userData;
|
|
79
77
|
userData.completedAt = new Date().toISOString();
|
|
80
78
|
|
|
81
|
-
// Collect device info if enabled
|
|
82
|
-
if (options?.enableDeviceTracking) {
|
|
83
|
-
userData.deviceInfo = await OnboardingDeviceTrackingService.collectDeviceInfo(options.userId);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
79
|
await storageRepository.setObject(USER_DATA_STORAGE_KEY, userData);
|
|
87
80
|
|
|
88
81
|
set({
|
|
@@ -152,13 +145,6 @@ export const useOnboardingStore = create<OnboardingStore>((set, get) => ({
|
|
|
152
145
|
await storageRepository.setObject(USER_DATA_STORAGE_KEY, data);
|
|
153
146
|
set({ userData: data });
|
|
154
147
|
},
|
|
155
|
-
|
|
156
|
-
collectDeviceInfo: async (userId?: string) => {
|
|
157
|
-
const userData = get().userData;
|
|
158
|
-
userData.deviceInfo = await OnboardingDeviceTrackingService.collectDeviceInfo(userId);
|
|
159
|
-
await storageRepository.setObject(USER_DATA_STORAGE_KEY, userData);
|
|
160
|
-
set({ userData: { ...userData } });
|
|
161
|
-
},
|
|
162
148
|
}));
|
|
163
149
|
|
|
164
150
|
/**
|
|
@@ -62,18 +62,6 @@ export interface OnboardingScreenProps extends OnboardingOptions {
|
|
|
62
62
|
* When true, shows premium paywall before completing onboarding
|
|
63
63
|
*/
|
|
64
64
|
showPaywallOnComplete?: boolean;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Enable device tracking (default: false)
|
|
68
|
-
* When enabled, collects device information during onboarding
|
|
69
|
-
*/
|
|
70
|
-
enableDeviceTracking?: boolean;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* User ID for device tracking (optional)
|
|
74
|
-
* Only used when enableDeviceTracking is true
|
|
75
|
-
*/
|
|
76
|
-
userId?: string;
|
|
77
65
|
}
|
|
78
66
|
|
|
79
67
|
/**
|
|
@@ -100,8 +88,6 @@ export const OnboardingScreen: React.FC<OnboardingScreenProps> = ({
|
|
|
100
88
|
renderSlide,
|
|
101
89
|
onUpgrade,
|
|
102
90
|
showPaywallOnComplete = false,
|
|
103
|
-
enableDeviceTracking = false,
|
|
104
|
-
userId,
|
|
105
91
|
}) => {
|
|
106
92
|
const insets = useSafeAreaInsets();
|
|
107
93
|
const tokens = useAppDesignTokens();
|
|
@@ -126,7 +112,7 @@ export const OnboardingScreen: React.FC<OnboardingScreenProps> = ({
|
|
|
126
112
|
} = useOnboardingNavigation(
|
|
127
113
|
filteredSlides.length,
|
|
128
114
|
async () => {
|
|
129
|
-
await onboardingStore.complete(storageKey
|
|
115
|
+
await onboardingStore.complete(storageKey);
|
|
130
116
|
if (onComplete) {
|
|
131
117
|
await onComplete();
|
|
132
118
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Onboarding Device Tracking Service
|
|
3
|
-
*
|
|
4
|
-
* Handles device information collection during onboarding
|
|
5
|
-
* Single Responsibility: Device tracking only
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { OnboardingUserData } from "../../domain/entities/OnboardingUserData";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Service for device tracking during onboarding
|
|
12
|
-
* Optional feature - only used when enableDeviceTracking is true
|
|
13
|
-
*/
|
|
14
|
-
export class OnboardingDeviceTrackingService {
|
|
15
|
-
/**
|
|
16
|
-
* Collect device information
|
|
17
|
-
* @param userId - Optional user ID
|
|
18
|
-
* @returns Device information object
|
|
19
|
-
*/
|
|
20
|
-
static async collectDeviceInfo(userId?: string): Promise<OnboardingUserData['deviceInfo']> {
|
|
21
|
-
try {
|
|
22
|
-
// Dynamic import to avoid loading @umituz/react-native-device if not needed
|
|
23
|
-
// @ts-expect-error - Optional peer dependency, may not be installed
|
|
24
|
-
const { DeviceService } = await import('@umituz/react-native-device');
|
|
25
|
-
|
|
26
|
-
const systemInfo = await DeviceService.getSystemInfo({ userId });
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
deviceId: systemInfo.device.modelId || 'unknown',
|
|
30
|
-
platform: systemInfo.device.platform,
|
|
31
|
-
osVersion: systemInfo.device.osVersion || 'unknown',
|
|
32
|
-
appVersion: systemInfo.application.nativeApplicationVersion || 'unknown',
|
|
33
|
-
deviceName: systemInfo.device.deviceName || 'unknown',
|
|
34
|
-
manufacturer: systemInfo.device.manufacturer || 'unknown',
|
|
35
|
-
brand: systemInfo.device.brand || 'unknown',
|
|
36
|
-
timestamp: systemInfo.timestamp,
|
|
37
|
-
...(userId && { userId }),
|
|
38
|
-
};
|
|
39
|
-
} catch (error) {
|
|
40
|
-
/* eslint-disable-next-line no-console */
|
|
41
|
-
if (__DEV__) console.warn('Failed to collect device info:', error);
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Check if device tracking is available
|
|
48
|
-
* @returns True if @umituz/react-native-device is available
|
|
49
|
-
*/
|
|
50
|
-
static async isDeviceTrackingAvailable(): Promise<boolean> {
|
|
51
|
-
try {
|
|
52
|
-
// @ts-expect-error - Optional peer dependency, may not be installed
|
|
53
|
-
await import('@umituz/react-native-device');
|
|
54
|
-
return true;
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|