@clix-so/react-native-sdk 0.0.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/LICENSE +27 -0
- package/README.md +345 -0
- package/lib/module/core/Clix.js +217 -0
- package/lib/module/core/Clix.js.map +1 -0
- package/lib/module/core/ClixConfig.js +4 -0
- package/lib/module/core/ClixConfig.js.map +1 -0
- package/lib/module/core/ClixInitCoordinator.js +58 -0
- package/lib/module/core/ClixInitCoordinator.js.map +1 -0
- package/lib/module/core/ClixVersion.js +17 -0
- package/lib/module/core/ClixVersion.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/ClixDevice.js +51 -0
- package/lib/module/models/ClixDevice.js.map +1 -0
- package/lib/module/models/ClixPushNotificationPayload.js +21 -0
- package/lib/module/models/ClixPushNotificationPayload.js.map +1 -0
- package/lib/module/models/ClixUserProperty.js +44 -0
- package/lib/module/models/ClixUserProperty.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/services/ClixAPIClient.js +172 -0
- package/lib/module/services/ClixAPIClient.js.map +1 -0
- package/lib/module/services/DeviceAPIService.js +112 -0
- package/lib/module/services/DeviceAPIService.js.map +1 -0
- package/lib/module/services/DeviceService.js +157 -0
- package/lib/module/services/DeviceService.js.map +1 -0
- package/lib/module/services/EventAPIService.js +36 -0
- package/lib/module/services/EventAPIService.js.map +1 -0
- package/lib/module/services/EventService.js +29 -0
- package/lib/module/services/EventService.js.map +1 -0
- package/lib/module/services/NotificationService.js +549 -0
- package/lib/module/services/NotificationService.js.map +1 -0
- package/lib/module/services/StorageService.js +76 -0
- package/lib/module/services/StorageService.js.map +1 -0
- package/lib/module/services/TokenService.js +71 -0
- package/lib/module/services/TokenService.js.map +1 -0
- package/lib/module/utils/ClixError.js +63 -0
- package/lib/module/utils/ClixError.js.map +1 -0
- package/lib/module/utils/UUID.js +28 -0
- package/lib/module/utils/UUID.js.map +1 -0
- package/lib/module/utils/logging/ClixLogger.js +55 -0
- package/lib/module/utils/logging/ClixLogger.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/core/Clix.d.ts +67 -0
- package/lib/typescript/src/core/Clix.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixConfig.d.ts +9 -0
- package/lib/typescript/src/core/ClixConfig.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixInitCoordinator.d.ts +16 -0
- package/lib/typescript/src/core/ClixInitCoordinator.d.ts.map +1 -0
- package/lib/typescript/src/core/ClixVersion.d.ts +6 -0
- package/lib/typescript/src/core/ClixVersion.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixDevice.d.ts +42 -0
- package/lib/typescript/src/models/ClixDevice.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixPushNotificationPayload.d.ts +23 -0
- package/lib/typescript/src/models/ClixPushNotificationPayload.d.ts.map +1 -0
- package/lib/typescript/src/models/ClixUserProperty.d.ts +19 -0
- package/lib/typescript/src/models/ClixUserProperty.d.ts.map +1 -0
- package/lib/typescript/src/services/ClixAPIClient.d.ts +35 -0
- package/lib/typescript/src/services/ClixAPIClient.d.ts.map +1 -0
- package/lib/typescript/src/services/DeviceAPIService.d.ts +13 -0
- package/lib/typescript/src/services/DeviceAPIService.d.ts.map +1 -0
- package/lib/typescript/src/services/DeviceService.d.ts +20 -0
- package/lib/typescript/src/services/DeviceService.d.ts.map +1 -0
- package/lib/typescript/src/services/EventAPIService.d.ts +7 -0
- package/lib/typescript/src/services/EventAPIService.d.ts.map +1 -0
- package/lib/typescript/src/services/EventService.d.ts +9 -0
- package/lib/typescript/src/services/EventService.d.ts.map +1 -0
- package/lib/typescript/src/services/NotificationService.d.ts +56 -0
- package/lib/typescript/src/services/NotificationService.d.ts.map +1 -0
- package/lib/typescript/src/services/StorageService.d.ts +10 -0
- package/lib/typescript/src/services/StorageService.d.ts.map +1 -0
- package/lib/typescript/src/services/TokenService.d.ts +15 -0
- package/lib/typescript/src/services/TokenService.d.ts.map +1 -0
- package/lib/typescript/src/utils/ClixError.d.ts +41 -0
- package/lib/typescript/src/utils/ClixError.d.ts.map +1 -0
- package/lib/typescript/src/utils/UUID.d.ts +14 -0
- package/lib/typescript/src/utils/UUID.d.ts.map +1 -0
- package/lib/typescript/src/utils/logging/ClixLogger.d.ts +18 -0
- package/lib/typescript/src/utils/logging/ClixLogger.d.ts.map +1 -0
- package/package.json +151 -0
- package/src/core/Clix.ts +256 -0
- package/src/core/ClixConfig.ts +9 -0
- package/src/core/ClixInitCoordinator.ts +65 -0
- package/src/core/ClixVersion.ts +17 -0
- package/src/index.ts +5 -0
- package/src/models/ClixDevice.ts +88 -0
- package/src/models/ClixPushNotificationPayload.ts +38 -0
- package/src/models/ClixUserProperty.ts +58 -0
- package/src/services/ClixAPIClient.ts +248 -0
- package/src/services/DeviceAPIService.ts +187 -0
- package/src/services/DeviceService.ts +204 -0
- package/src/services/EventAPIService.ts +48 -0
- package/src/services/EventService.ts +45 -0
- package/src/services/NotificationService.ts +730 -0
- package/src/services/StorageService.ts +84 -0
- package/src/services/TokenService.ts +84 -0
- package/src/utils/ClixError.ts +78 -0
- package/src/utils/UUID.ts +29 -0
- package/src/utils/logging/ClixLogger.ts +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License with Custom Restrictions
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Clix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. All copies of substantial portions of the Software may only be used in connection
|
|
16
|
+
with services provided by Clix, similar to restrictions in modified MIT licenses.
|
|
17
|
+
|
|
18
|
+
3. The original and/or modified Software must be used exclusively to work with Clix
|
|
19
|
+
services, ensuring it is not repurposed for unrelated platforms without explicit permission.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
# Clix React Native SDK
|
|
2
|
+
|
|
3
|
+
Clix React Native SDK is a powerful tool for managing push notifications and user events in your React Native application. It provides a simple and intuitive interface for user engagement and analytics.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### 1. Install the SDK
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @clix-so/react-native-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or using Yarn:
|
|
14
|
+
```bash
|
|
15
|
+
yarn add @clix-so/react-native-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 2. Install Required Dependencies
|
|
19
|
+
|
|
20
|
+
You must install all required peer dependencies:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @notifee/react-native @react-native-firebase/app @react-native-firebase/messaging react-native-device-info react-native-get-random-values react-native-mmkv uuid
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or using Yarn:
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @notifee/react-native @react-native-firebase/app @react-native-firebase/messaging react-native-device-info react-native-get-random-values react-native-mmkv uuid
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or using Expo:
|
|
32
|
+
```bash
|
|
33
|
+
npx expo install @notifee/react-native @react-native-firebase/app @react-native-firebase/messaging react-native-device-info react-native-get-random-values react-native-mmkv uuid
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 3. Version Compatibility
|
|
37
|
+
|
|
38
|
+
**react-native-mmkv Version Selection (Critical)**
|
|
39
|
+
|
|
40
|
+
| React Native Version | Architecture | react-native-mmkv Version |
|
|
41
|
+
|---------------------|-------------|---------------------------|
|
|
42
|
+
| **0.70-0.73** | Old Architecture | `^2.12.2` |
|
|
43
|
+
| **0.74+** | New Architecture | `^3.0.1+` |
|
|
44
|
+
|
|
45
|
+
⚠️ **New Architecture Requirement**: react-native-mmkv v3.x requires React Native's New Architecture (TurboModules) to be enabled.
|
|
46
|
+
|
|
47
|
+
**Important Setup Note**: uuid requires react-native-get-random-values polyfill:
|
|
48
|
+
```javascript
|
|
49
|
+
import 'react-native-get-random-values'; // Must be imported first
|
|
50
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
|
|
55
|
+
- React Native 0.60.0 or later
|
|
56
|
+
- iOS 14.0+ / Android API 21+
|
|
57
|
+
- TypeScript 4.0+ (optional but recommended)
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### Initialization
|
|
62
|
+
|
|
63
|
+
Initialize the SDK with a ClixConfig. The config is required and contains your project settings.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import Clix, { ClixLogLevel } from '@clix-so/react-native-sdk';
|
|
67
|
+
|
|
68
|
+
// Initialize Clix SDK
|
|
69
|
+
await Clix.initialize({
|
|
70
|
+
projectId: 'YOUR_PROJECT_ID',
|
|
71
|
+
apiKey: 'YOUR_API_KEY',
|
|
72
|
+
logLevel: ClixLogLevel.DEBUG, // Optional: set log level
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### User Management
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Set user ID
|
|
80
|
+
await Clix.setUserId('user123');
|
|
81
|
+
|
|
82
|
+
// Set user properties
|
|
83
|
+
await Clix.setUserProperty('name', 'John Doe');
|
|
84
|
+
await Clix.setUserProperties({
|
|
85
|
+
age: 25,
|
|
86
|
+
premium: true,
|
|
87
|
+
subscription_plan: 'pro',
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Remove user properties
|
|
91
|
+
await Clix.removeUserProperty('name');
|
|
92
|
+
await Clix.removeUserProperties(['age', 'premium']);
|
|
93
|
+
|
|
94
|
+
// Remove user ID
|
|
95
|
+
await Clix.removeUserId();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Logging
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
Clix.setLogLevel(ClixLogLevel.DEBUG);
|
|
102
|
+
// Available log levels:
|
|
103
|
+
// - 'none': No logs
|
|
104
|
+
// - 'error': Error logs only
|
|
105
|
+
// - 'warning': Warning logs
|
|
106
|
+
// - 'info': Info logs
|
|
107
|
+
// - 'debug': Debug logs
|
|
108
|
+
// - 'verbose': All logs
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Push Notification Integration
|
|
112
|
+
|
|
113
|
+
The Clix React Native SDK automatically handles push notification integration through Firebase Cloud Messaging.
|
|
114
|
+
|
|
115
|
+
#### Setup Firebase
|
|
116
|
+
|
|
117
|
+
**Complete Firebase Setup**: Follow the comprehensive setup guide at [React Native Firebase](https://rnfirebase.io/), which includes:
|
|
118
|
+
|
|
119
|
+
- Creating a Firebase project
|
|
120
|
+
- Adding your app to Firebase
|
|
121
|
+
- Installing configuration files (`google-services.json` for Android, `GoogleService-Info.plist` for iOS)
|
|
122
|
+
- Platform-specific setup for push notifications
|
|
123
|
+
- Enabling Firebase Cloud Messaging in your Firebase console
|
|
124
|
+
|
|
125
|
+
For push notifications specifically, ensure you complete the [Messaging setup guide](https://rnfirebase.io/messaging/usage).
|
|
126
|
+
|
|
127
|
+
#### Background Message Handler Setup
|
|
128
|
+
|
|
129
|
+
**Important**: The background message handler must be set up outside of your application lifecycle, typically in your `index.js` file:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// index.js
|
|
133
|
+
import { AppRegistry } from 'react-native';
|
|
134
|
+
import { name as appName } from './app.json';
|
|
135
|
+
import App from './src/App';
|
|
136
|
+
import { NotificationService } from '@clix-so/react-native-sdk';
|
|
137
|
+
|
|
138
|
+
// Setup background message handler outside of application lifecycle
|
|
139
|
+
NotificationService.setupBackgroundMessageHandler();
|
|
140
|
+
|
|
141
|
+
AppRegistry.registerComponent(appName, () => App);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Handling Notifications
|
|
145
|
+
|
|
146
|
+
The SDK automatically handles notification registration and token management. Notifications are processed internally for analytics and tracking.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// Notification handling is automatic - no additional code required
|
|
150
|
+
// The SDK will track notification delivery and engagement automatically
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Firebase Setup
|
|
154
|
+
|
|
155
|
+
### iOS Setup
|
|
156
|
+
|
|
157
|
+
1. Add your `GoogleService-Info.plist` to the iOS project in Xcode
|
|
158
|
+
2. Enable Push Notifications capability in your iOS project
|
|
159
|
+
3. Add Background Modes capability and check "Remote notifications"
|
|
160
|
+
4. Update your `ios/Podfile`:
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
platform :ios, '14.0'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
5. Run `cd ios && pod install`
|
|
167
|
+
|
|
168
|
+
### Android Setup
|
|
169
|
+
|
|
170
|
+
1. Add your `google-services.json` to `android/app/`
|
|
171
|
+
2. Add the Google Services plugin to your `android/build.gradle`:
|
|
172
|
+
|
|
173
|
+
```gradle
|
|
174
|
+
buildscript {
|
|
175
|
+
dependencies {
|
|
176
|
+
classpath 'com.google.gms:google-services:4.3.15'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
3. Apply the plugin in `android/app/build.gradle`:
|
|
182
|
+
|
|
183
|
+
```gradle
|
|
184
|
+
apply plugin: 'com.google.gms.google-services'
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Configuration Options
|
|
188
|
+
|
|
189
|
+
### ClixConfig
|
|
190
|
+
|
|
191
|
+
- `projectId` (required): Your Clix project ID
|
|
192
|
+
- `apiKey` (required): Your Clix API key
|
|
193
|
+
- `endpoint`: API endpoint (default: 'https://api.clix.so')
|
|
194
|
+
- `logLevel`: Logging level (default: 'error')
|
|
195
|
+
- `extraHeaders`: Additional HTTP headers for API requests
|
|
196
|
+
|
|
197
|
+
### Log Levels
|
|
198
|
+
|
|
199
|
+
- `verbose`: All logs including detailed debugging
|
|
200
|
+
- `debug`: Debug information and above
|
|
201
|
+
- `info`: General information and above
|
|
202
|
+
- `warning`: Warning messages and above
|
|
203
|
+
- `error`: Error messages only
|
|
204
|
+
- `none`: No logging
|
|
205
|
+
|
|
206
|
+
## Sample App
|
|
207
|
+
|
|
208
|
+
A comprehensive sample app is provided in the `samples/BasicApp` directory. The sample demonstrates:
|
|
209
|
+
|
|
210
|
+
- Basic Clix SDK integration
|
|
211
|
+
- Push notification handling with Firebase
|
|
212
|
+
- User property management
|
|
213
|
+
- Device information display
|
|
214
|
+
|
|
215
|
+
To run the sample:
|
|
216
|
+
|
|
217
|
+
1. Navigate to `samples/BasicApp`
|
|
218
|
+
2. Install dependencies: `npm install` or `yarn install`
|
|
219
|
+
3. Setup Firebase (add your config files)
|
|
220
|
+
4. Update `src/ClixInfo.ts` with your project details
|
|
221
|
+
5. Run the app:
|
|
222
|
+
- iOS: `cd ios && pod install && cd .. && npx react-native run-ios`
|
|
223
|
+
- Android: `npx react-native run-android`
|
|
224
|
+
|
|
225
|
+
## Error Handling
|
|
226
|
+
|
|
227
|
+
All SDK operations can throw `ClixError`. Always handle potential errors:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
try {
|
|
231
|
+
await Clix.setUserId('user123');
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error('Failed to set user ID:', error);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Thread Safety
|
|
238
|
+
|
|
239
|
+
The SDK is thread-safe and all operations can be called from any thread. Async operations will automatically wait for SDK initialization to complete.
|
|
240
|
+
|
|
241
|
+
## Advanced Features
|
|
242
|
+
|
|
243
|
+
### Notification Service Features
|
|
244
|
+
|
|
245
|
+
The `NotificationService` is split into two parts:
|
|
246
|
+
|
|
247
|
+
- **Static Background Handler**: Handles messages when the app is in background or terminated
|
|
248
|
+
- **Instance Foreground Handler**: Handles messages when the app is in foreground
|
|
249
|
+
|
|
250
|
+
Key features:
|
|
251
|
+
- Automatic permission handling
|
|
252
|
+
- Token refresh management
|
|
253
|
+
- Local notification display
|
|
254
|
+
- Event tracking for analytics
|
|
255
|
+
- Background notification storage
|
|
256
|
+
|
|
257
|
+
### Custom Properties
|
|
258
|
+
|
|
259
|
+
User properties support various data types:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
await Clix.setUserProperties({
|
|
263
|
+
name: 'John Doe', // String
|
|
264
|
+
age: 25, // Number
|
|
265
|
+
premium: true, // Boolean
|
|
266
|
+
tags: ['react-native', 'mobile'], // Array
|
|
267
|
+
metadata: { // Object
|
|
268
|
+
source: 'mobile_app',
|
|
269
|
+
version: '1.0.0',
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Platform-Specific Considerations
|
|
275
|
+
|
|
276
|
+
### iOS
|
|
277
|
+
|
|
278
|
+
- Requires iOS 14.0 or later
|
|
279
|
+
- Push notifications require user permission
|
|
280
|
+
- Background processing is automatically handled
|
|
281
|
+
- Ensure proper entitlements are configured
|
|
282
|
+
|
|
283
|
+
### Android
|
|
284
|
+
|
|
285
|
+
- Requires Android API level 21 or later
|
|
286
|
+
- Notification channels are automatically managed
|
|
287
|
+
- Background processing follows Android guidelines
|
|
288
|
+
- FCM token refresh is handled automatically
|
|
289
|
+
|
|
290
|
+
## Performance
|
|
291
|
+
|
|
292
|
+
- Lightweight initialization
|
|
293
|
+
- Efficient background processing
|
|
294
|
+
- Minimal memory footprint
|
|
295
|
+
- Optimized network requests
|
|
296
|
+
- Batched event processing
|
|
297
|
+
|
|
298
|
+
## Privacy
|
|
299
|
+
|
|
300
|
+
The SDK respects user privacy:
|
|
301
|
+
- Only collects necessary device information
|
|
302
|
+
- User data is handled according to your privacy policy
|
|
303
|
+
- Push tokens are managed securely
|
|
304
|
+
- No personal data is collected without consent
|
|
305
|
+
|
|
306
|
+
## TypeScript Support
|
|
307
|
+
|
|
308
|
+
The SDK is written in TypeScript and provides full type definitions:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
import { Clix, ClixConfig, ClixUserProperty } from '@clix-so/react-native-sdk';
|
|
312
|
+
|
|
313
|
+
const config: ClixConfig = {
|
|
314
|
+
projectId: 'YOUR_PROJECT_ID',
|
|
315
|
+
apiKey: 'YOUR_API_KEY',
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const properties: Record<string, ClixUserProperty> = {
|
|
319
|
+
name: 'John Doe',
|
|
320
|
+
age: 25,
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
This project is licensed under the MIT License with Custom Restrictions. See the [LICENSE](LICENSE) file for details.
|
|
327
|
+
|
|
328
|
+
## Changelog
|
|
329
|
+
|
|
330
|
+
See the full release history and changes in the [CHANGELOG.md](CHANGELOG.md) file.
|
|
331
|
+
|
|
332
|
+
## Contributing
|
|
333
|
+
|
|
334
|
+
We welcome contributions! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) guide before submitting issues or pull requests.
|
|
335
|
+
|
|
336
|
+
## Support
|
|
337
|
+
|
|
338
|
+
For support and questions:
|
|
339
|
+
- Check the sample app for implementation examples
|
|
340
|
+
- Review the API documentation
|
|
341
|
+
- Contact support through your Clix dashboard
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ClixAPIClient } from "../services/ClixAPIClient.js";
|
|
4
|
+
import { DeviceAPIService } from "../services/DeviceAPIService.js";
|
|
5
|
+
import { DeviceService } from "../services/DeviceService.js";
|
|
6
|
+
import { EventAPIService } from "../services/EventAPIService.js";
|
|
7
|
+
import { EventService } from "../services/EventService.js";
|
|
8
|
+
import { NotificationService } from "../services/NotificationService.js";
|
|
9
|
+
import { StorageService } from "../services/StorageService.js";
|
|
10
|
+
import { TokenService } from "../services/TokenService.js";
|
|
11
|
+
import { ClixError } from "../utils/ClixError.js";
|
|
12
|
+
import { ClixLogger, ClixLogLevel } from "../utils/logging/ClixLogger.js";
|
|
13
|
+
import { ClixInitCoordinator } from "./ClixInitCoordinator.js";
|
|
14
|
+
export class Clix {
|
|
15
|
+
static initCoordinator = new ClixInitCoordinator();
|
|
16
|
+
constructor() {}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initialize Clix SDK
|
|
20
|
+
*/
|
|
21
|
+
static async initialize(config) {
|
|
22
|
+
try {
|
|
23
|
+
if (this.initCoordinator.isInitializationFailed()) {
|
|
24
|
+
this.initCoordinator.reset();
|
|
25
|
+
}
|
|
26
|
+
ClixLogger.setLogLevel(config.logLevel || ClixLogLevel.ERROR);
|
|
27
|
+
ClixLogger.debug('Initializing Clix SDK');
|
|
28
|
+
this.shared = new Clix();
|
|
29
|
+
await this.shared.setConfig(config);
|
|
30
|
+
ClixLogger.debug('Clix SDK initialized successfully');
|
|
31
|
+
this.initCoordinator.completeInitialization();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
|
34
|
+
this.initCoordinator.failInitialization(errorInstance);
|
|
35
|
+
throw ClixError.notInitialized({
|
|
36
|
+
cause: errorInstance
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Set user ID
|
|
43
|
+
*/
|
|
44
|
+
static async setUserId(userId) {
|
|
45
|
+
try {
|
|
46
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
47
|
+
if (this.shared?.deviceService) {
|
|
48
|
+
await this.shared.deviceService.setProjectUserId(userId);
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
ClixLogger.error(`Failed to set user ID: ${error}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Remove user ID
|
|
57
|
+
*/
|
|
58
|
+
static async removeUserId() {
|
|
59
|
+
try {
|
|
60
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
61
|
+
if (this.shared?.deviceService) {
|
|
62
|
+
await this.shared.deviceService.removeProjectUserId();
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
ClixLogger.error(`Failed to remove user ID: ${error}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Set user property
|
|
71
|
+
*/
|
|
72
|
+
static async setUserProperty(key, value) {
|
|
73
|
+
try {
|
|
74
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
75
|
+
if (this.shared?.deviceService) {
|
|
76
|
+
await this.shared.deviceService.updateUserProperties({
|
|
77
|
+
[key]: value
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
ClixLogger.error(`Failed to set user property: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Set user properties
|
|
87
|
+
*/
|
|
88
|
+
static async setUserProperties(userProperties) {
|
|
89
|
+
try {
|
|
90
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
91
|
+
if (this.shared?.deviceService) {
|
|
92
|
+
await this.shared.deviceService.updateUserProperties(userProperties);
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
ClixLogger.error(`Failed to set user properties: ${error}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Remove user property
|
|
101
|
+
*/
|
|
102
|
+
static async removeUserProperty(key) {
|
|
103
|
+
try {
|
|
104
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
105
|
+
if (this.shared?.deviceService) {
|
|
106
|
+
await this.shared.deviceService.removeUserProperties([key]);
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
ClixLogger.error(`Failed to remove user property: ${error}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Remove user properties
|
|
115
|
+
*/
|
|
116
|
+
static async removeUserProperties(keys) {
|
|
117
|
+
try {
|
|
118
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
119
|
+
if (this.shared?.deviceService) {
|
|
120
|
+
await this.shared.deviceService.removeUserProperties(keys);
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
ClixLogger.error(`Failed to remove user properties: ${error}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get device ID
|
|
129
|
+
*/
|
|
130
|
+
static async getDeviceId() {
|
|
131
|
+
try {
|
|
132
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
133
|
+
if (this.shared?.deviceService) {
|
|
134
|
+
const deviceId = await this.shared.deviceService.getCurrentDeviceId();
|
|
135
|
+
return deviceId;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
ClixLogger.error(`Failed to get device ID: ${error}`);
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get push token
|
|
146
|
+
*/
|
|
147
|
+
static async getPushToken() {
|
|
148
|
+
try {
|
|
149
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
150
|
+
if (this.shared?.notificationService) {
|
|
151
|
+
const token = await this.shared.notificationService.getCurrentToken();
|
|
152
|
+
return token || undefined;
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
ClixLogger.error(`Failed to get push token: ${error}`);
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Set log level
|
|
163
|
+
*/
|
|
164
|
+
static setLogLevel(level) {
|
|
165
|
+
ClixLogger.setLogLevel(level);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Track event
|
|
170
|
+
*/
|
|
171
|
+
static async trackEvent(name, options) {
|
|
172
|
+
try {
|
|
173
|
+
await Clix.initCoordinator.waitForInitialization();
|
|
174
|
+
if (this.shared?.eventService) {
|
|
175
|
+
await this.shared.eventService.trackEvent(name, options?.properties, options?.messageId);
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
ClixLogger.error(`Failed to track event: ${error}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Set configuration
|
|
184
|
+
*/
|
|
185
|
+
async setConfig(config) {
|
|
186
|
+
this.storageService = new StorageService();
|
|
187
|
+
try {
|
|
188
|
+
await this.storageService.set('project_id', config.projectId);
|
|
189
|
+
await this.storageService.set('api_key', config.apiKey);
|
|
190
|
+
await this.storageService.set('clix_config', {
|
|
191
|
+
projectId: config.projectId,
|
|
192
|
+
apiKey: config.apiKey,
|
|
193
|
+
endpoint: config.endpoint,
|
|
194
|
+
logLevel: config.logLevel,
|
|
195
|
+
extraHeaders: config.extraHeaders
|
|
196
|
+
});
|
|
197
|
+
} catch (error) {
|
|
198
|
+
ClixLogger.warn('Failed to store configuration in storage, continuing with in-memory config', error);
|
|
199
|
+
}
|
|
200
|
+
const apiClient = new ClixAPIClient({
|
|
201
|
+
...config,
|
|
202
|
+
endpoint: config.endpoint || 'https://api.clix.so',
|
|
203
|
+
logLevel: config.logLevel || ClixLogLevel.ERROR
|
|
204
|
+
});
|
|
205
|
+
const deviceAPIService = new DeviceAPIService(apiClient);
|
|
206
|
+
const eventAPIService = new EventAPIService(apiClient);
|
|
207
|
+
const tokenService = new TokenService(this.storageService);
|
|
208
|
+
this.deviceService = new DeviceService(this.storageService, tokenService, deviceAPIService);
|
|
209
|
+
this.eventService = new EventService(eventAPIService, this.deviceService);
|
|
210
|
+
try {
|
|
211
|
+
this.notificationService = await NotificationService.getInstance().initialize(this.eventService, this.storageService, this.deviceService, tokenService);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
ClixLogger.warn('Failed to fully initialize notification service, some features may be limited', error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=Clix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ClixAPIClient","DeviceAPIService","DeviceService","EventAPIService","EventService","NotificationService","StorageService","TokenService","ClixError","ClixLogger","ClixLogLevel","ClixInitCoordinator","Clix","initCoordinator","constructor","initialize","config","isInitializationFailed","reset","setLogLevel","logLevel","ERROR","debug","shared","setConfig","completeInitialization","error","errorInstance","Error","String","failInitialization","notInitialized","cause","setUserId","userId","waitForInitialization","deviceService","setProjectUserId","removeUserId","removeProjectUserId","setUserProperty","key","value","updateUserProperties","setUserProperties","userProperties","removeUserProperty","removeUserProperties","keys","getDeviceId","deviceId","getCurrentDeviceId","undefined","getPushToken","notificationService","token","getCurrentToken","level","trackEvent","name","options","eventService","properties","messageId","storageService","set","projectId","apiKey","endpoint","extraHeaders","warn","apiClient","deviceAPIService","eventAPIService","tokenService","getInstance"],"sourceRoot":"../../../src","sources":["core/Clix.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,8BAA2B;AACzD,SAASC,gBAAgB,QAAQ,iCAA8B;AAC/D,SAASC,aAAa,QAAQ,8BAA2B;AACzD,SAASC,eAAe,QAAQ,gCAA6B;AAC7D,SAASC,YAAY,QAAQ,6BAA0B;AACvD,SAASC,mBAAmB,QAAQ,oCAAiC;AACrE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,YAAY,QAAQ,6BAA0B;AACvD,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SAASC,UAAU,EAAEC,YAAY,QAAQ,gCAA6B;AAEtE,SAASC,mBAAmB,QAAQ,0BAAuB;AAE3D,OAAO,MAAMC,IAAI,CAAC;EAEhB,OAAeC,eAAe,GAAG,IAAIF,mBAAmB,CAAC,CAAC;EAOlDG,WAAWA,CAAA,EAAG,CAAC;;EAEvB;AACF;AACA;EACE,aAAaC,UAAUA,CAACC,MAAkB,EAAiB;IACzD,IAAI;MACF,IAAI,IAAI,CAACH,eAAe,CAACI,sBAAsB,CAAC,CAAC,EAAE;QACjD,IAAI,CAACJ,eAAe,CAACK,KAAK,CAAC,CAAC;MAC9B;MAEAT,UAAU,CAACU,WAAW,CAACH,MAAM,CAACI,QAAQ,IAAIV,YAAY,CAACW,KAAK,CAAC;MAC7DZ,UAAU,CAACa,KAAK,CAAC,uBAAuB,CAAC;MAEzC,IAAI,CAACC,MAAM,GAAG,IAAIX,IAAI,CAAC,CAAC;MACxB,MAAM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,CAACoD,QAAQ,IAAI,qBAAqB;MAClDhD,QAAQ,EAAEJ,MAAM,CAACI,QAAQ,IAAIV,YAAY,CAACW;IAC5C,CAAC,CAAC;IAEF,MAAMmD,gBAAgB,GAAG,IAAIvE,gBAAgB,CAACsE,SAAS,CAAC;IACxD,MAAME,eAAe,GAAG,IAAItE,eAAe,CAACoE,SAAS,CAAC;IACtD,MAAMG,YAAY,GAAG,IAAInE,YAAY,CAAC,IAAI,CAACyD,cAAc,CAAC;IAC1D,IAAI,CAAC5B,aAAa,GAAG,IAAIlC,aAAa,CACpC,IAAI,CAAC8D,cAAc,EACnBU,YAAY,EACZF,gBACF,CAAC;IACD,IAAI,CAACX,YAAY,GAAG,IAAIzD,YAAY,CAACqE,eAAe,EAAE,IAAI,CAACrC,aAAa,CAAC;IACzE,IAAI;MACF,IAAI,CAACkB,mBAAmB,GACtB,MAAMjD,mBAAmB,CAACsE,WAAW,CAAC,CAAC,CAAC5D,UAAU,CAChD,IAAI,CAAC8C,YAAY,EACjB,IAAI,CAACG,cAAc,EACnB,IAAI,CAAC5B,aAAa,EAClBsC,YACF,CAAC;IACL,CAAC,CAAC,OAAOhD,KAAK,EAAE;MACdjB,UAAU,CAAC6D,IAAI,CACb,+EAA+E,EAC/E5C,KACF,CAAC;IACH;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["core/ClixConfig.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ClixLogger } from "../utils/logging/ClixLogger.js";
|
|
4
|
+
export class ClixInitCoordinator {
|
|
5
|
+
resolve = null;
|
|
6
|
+
reject = null;
|
|
7
|
+
isCompleted = false;
|
|
8
|
+
isFailed = false;
|
|
9
|
+
constructor() {
|
|
10
|
+
this.promise = new Promise((resolve, reject) => {
|
|
11
|
+
this.resolve = resolve;
|
|
12
|
+
this.reject = reject;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async waitForInitialization() {
|
|
16
|
+
if (this.isCompleted) {
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
}
|
|
19
|
+
return this.promise;
|
|
20
|
+
}
|
|
21
|
+
isInitializationFailed() {
|
|
22
|
+
return this.isFailed;
|
|
23
|
+
}
|
|
24
|
+
isInitializationCompleted() {
|
|
25
|
+
return this.isCompleted;
|
|
26
|
+
}
|
|
27
|
+
completeInitialization() {
|
|
28
|
+
if (this.isAlreadyFinalized()) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.isCompleted = true;
|
|
32
|
+
this.resolve?.();
|
|
33
|
+
}
|
|
34
|
+
failInitialization(error) {
|
|
35
|
+
if (this.isAlreadyFinalized()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.isFailed = true;
|
|
39
|
+
ClixLogger.warn('Clix initialization failed:', error);
|
|
40
|
+
this.reject?.(error);
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
this.isCompleted = false;
|
|
44
|
+
this.isFailed = false;
|
|
45
|
+
this.promise = new Promise((resolve, reject) => {
|
|
46
|
+
this.resolve = resolve;
|
|
47
|
+
this.reject = reject;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
isAlreadyFinalized() {
|
|
51
|
+
if (this.isCompleted || this.isFailed) {
|
|
52
|
+
ClixLogger.warn('Initialization already completed or failed');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ClixInitCoordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ClixLogger","ClixInitCoordinator","resolve","reject","isCompleted","isFailed","constructor","promise","Promise","waitForInitialization","isInitializationFailed","isInitializationCompleted","completeInitialization","isAlreadyFinalized","failInitialization","error","warn","reset"],"sourceRoot":"../../../src","s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ACE,OAAO,GAAG,IAAIC,OAAO,CAAO,CAACN,OAAO,EAAEC,MAAM,KAAK;MACpD,IAAI,CAACD,OAAO,GAAGA,OAAO;MACtB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACtB,CAAC,CAAC;EACJ;EAEQU,kBAAkBA,CAAA,EAAY;IACpC,IAAI,IAAI,CAACT,WAAW,IAAI,IAAI,CAACC,QAAQ,EAAE;MACrCL,UAAU,CAACgB,IAAI,CAAC,4CAA4C,CAAC;MAC7D,OAAO,IAAI;IACb;IACA,OAAO,KAAK;EACd;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export class ClixVersion {
|
|
4
|
+
static fallBackVersion = '0.0.0';
|
|
5
|
+
static async getVersion() {
|
|
6
|
+
if (this.cachedVersion) {
|
|
7
|
+
return this.cachedVersion;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
this.cachedVersion = require('../../../package.json').version || this.fallBackVersion;
|
|
11
|
+
return this.cachedVersion;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return '0.0.0';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ClixVersion.js.map
|