kewa-react-native 1.0.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.
Files changed (42) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +592 -0
  3. package/lib/KewaProvider.d.ts +26 -0
  4. package/lib/KewaProvider.js +91 -0
  5. package/lib/core/EventManager.d.ts +13 -0
  6. package/lib/core/EventManager.js +129 -0
  7. package/lib/core/KewaAnalytics.d.ts +41 -0
  8. package/lib/core/KewaAnalytics.js +317 -0
  9. package/lib/index.d.ts +23 -0
  10. package/lib/index.js +94 -0
  11. package/lib/types/config.d.ts +32 -0
  12. package/lib/types/config.js +2 -0
  13. package/lib/types/events.d.ts +104 -0
  14. package/lib/types/events.js +2 -0
  15. package/lib/types/index.d.ts +3 -0
  16. package/lib/types/index.js +19 -0
  17. package/lib/types/response.d.ts +15 -0
  18. package/lib/types/response.js +2 -0
  19. package/lib/utils/DeviceInfo.d.ts +4 -0
  20. package/lib/utils/DeviceInfo.js +32 -0
  21. package/lib/utils/NetworkManager.d.ts +17 -0
  22. package/lib/utils/NetworkManager.js +77 -0
  23. package/lib/utils/StorageManager.d.ts +16 -0
  24. package/lib/utils/StorageManager.js +120 -0
  25. package/lib/utils/constants.d.ts +26 -0
  26. package/lib/utils/constants.js +29 -0
  27. package/lib/utils/debug.d.ts +3 -0
  28. package/lib/utils/debug.js +17 -0
  29. package/package.json +59 -0
  30. package/src/KewaProvider.tsx +87 -0
  31. package/src/core/EventManager.ts +160 -0
  32. package/src/core/KewaAnalytics.ts +419 -0
  33. package/src/index.tsx +89 -0
  34. package/src/types/config.ts +33 -0
  35. package/src/types/events.ts +123 -0
  36. package/src/types/index.ts +3 -0
  37. package/src/types/response.ts +16 -0
  38. package/src/utils/DeviceInfo.ts +29 -0
  39. package/src/utils/NetworkManager.ts +85 -0
  40. package/src/utils/StorageManager.ts +121 -0
  41. package/src/utils/constants.ts +26 -0
  42. package/src/utils/debug.ts +15 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Topchunks Solutions
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,592 @@
1
+ # kewa-react-native
2
+
3
+ **Package:** `kewa-react-native` v1.0.0
4
+ **Author:** Topchunks Solutions Pvt Ltd
5
+
6
+ ## Table of Contents
7
+
8
+ - [Overview](#overview)
9
+ - [Requirements](#requirements)
10
+ - [Installation](#installation)
11
+ - [Initialization](#initialization)
12
+ - [SDK API](#sdk-api)
13
+ - [Use Cases](#use-cases)
14
+ - [React Integration](#react-integration)
15
+ - [Auto Tracking](#auto-tracking)
16
+ - [Automatic Events](#automatic-events)
17
+ - [Offline Queue](#offline-queue)
18
+ - [Troubleshooting](#troubleshooting)
19
+ - [License](#license)
20
+
21
+ ---
22
+
23
+ ## Overview
24
+
25
+ Kewa Analytics SDK for React Native enables tracking in mobile apps. It captures user behavior, sends events to your Kewa backend, manages contact identity, and queues events when the device is offline.
26
+
27
+ **Key capabilities:**
28
+
29
+ - Custom and predefined events (`trackEvent`, screen views, errors, button presses)
30
+ - User lifecycle tracking (login, registration, logout, properties)
31
+ - Automatic app lifecycle events (`app_launch`, `app_foreground`, `app_background`)
32
+ - Offline event queue with automatic retry
33
+ - React hooks (`KewaProvider`, `useKewa`, `useAutoTracker`)
34
+ - Full TypeScript support
35
+
36
+ ---
37
+
38
+ ## Requirements
39
+
40
+
41
+ | Dependency | Version |
42
+ | -------------- | ----------- |
43
+ | `react` | `>= 16.8.0` |
44
+ | `react-native` | `>= 0.60.0` |
45
+
46
+
47
+ Bundled dependencies (installed automatically with the package):
48
+
49
+ - `@react-native-async-storage/async-storage`
50
+ - `@react-native-community/netinfo`
51
+ - `react-native-device-info`
52
+
53
+ **Platform support:**
54
+
55
+ - Bare / core React Native — fully supported
56
+ - Expo development build — supported (`expo prebuild` + `expo run:ios` / `expo run:android`)
57
+ - Expo Go — **not supported** (`react-native-device-info` requires native code)
58
+
59
+ ---
60
+
61
+ ## Installation
62
+
63
+ ### 1. Install the package
64
+
65
+ ```bash
66
+ npm install kewa-react-native
67
+ # or
68
+ yarn add kewa-react-native
69
+ ```
70
+
71
+ ### 2. iOS
72
+
73
+ Native dependencies are linked automatically (React Native 0.60+). Install CocoaPods after adding the package:
74
+
75
+ ```bash
76
+ cd ios
77
+ pod install
78
+ cd ..
79
+ ```
80
+
81
+ Then build and run:
82
+
83
+ ```bash
84
+ npx react-native run-ios
85
+ ```
86
+
87
+ ### 3. Android
88
+
89
+ Autolinking handles native modules. Sync Gradle and run:
90
+
91
+ ```bash
92
+ npx react-native run-android
93
+ ```
94
+
95
+ If you use a custom Gradle setup, ensure your `settings.gradle` includes autolinked native modules (default in RN 0.60+).
96
+
97
+ ### 4. Expo (development build)
98
+
99
+ ```bash
100
+ npx expo prebuild
101
+ npx expo run:ios
102
+ # or
103
+ npx expo run:android
104
+ ```
105
+
106
+ ### Local development
107
+
108
+ ```bash
109
+ npm install /path/to/kewa-react-native
110
+ ```
111
+
112
+ The package runs `npm run build` automatically via the `prepare` script.
113
+
114
+ ---
115
+
116
+ ## Initialization
117
+
118
+ Wrap your app in `KewaProvider` (recommended) or call `Kewa.init()` once at startup. Do not use both.
119
+
120
+ ### Configuration options
121
+
122
+ ```typescript
123
+ interface KewaConfig {
124
+ appUrl: string; // Required — base URL of your Kewa instance
125
+ apiKey: string; // Required — sent as `secret` header
126
+ projectId?: string; // Required when tracking is enabled
127
+ disableTracking?: boolean; // Default: false — master switch; all SDK methods no-op
128
+ disableEventTracking?: boolean; // Default: false — blocks trackEvent and wrappers
129
+ disableAppStateTracking?: boolean; // Default: false — blocks app_foreground / app_background
130
+ disableScreenViewTracking?: boolean; // Default: false — blocks auto screen_view from navigation
131
+ batchSize?: number; // Default: 10 (reserved for future batch API)
132
+ maxQueueSize?: number; // Default: 100 — max offline queued events
133
+ enableDebugLogging?: boolean; // Default: false — log payloads to Metro console
134
+ }
135
+ ```
136
+
137
+
138
+ | Flag | Default | Effect |
139
+ | --------------------------- | ------- | ----------------------------------------------------------------------------------- |
140
+ | `disableTracking` | `false` | Master switch. No network, no listeners, all methods no-op |
141
+ | `disableEventTracking` | `false` | Blocks events via `trackEvent` and wrappers (`trackLogin`, `trackScreenView`, etc.) |
142
+ | `disableAppStateTracking` | `false` | Blocks only `app_foreground` and `app_background` |
143
+ | `disableScreenViewTracking` | `false` | Blocks automatic `screen_view` from React Navigation integration |
144
+
145
+
146
+ `disableTracking` overrides all other disable flags. Trailing slashes on `appUrl` are stripped automatically.
147
+
148
+ ### Option 1: `KewaProvider` (recommended)
149
+
150
+ ```tsx
151
+ import React, { useRef } from 'react';
152
+ import { NavigationContainer } from '@react-navigation/native';
153
+ import { KewaProvider, KewaAutoTracker } from 'kewa-react-native';
154
+
155
+ export default function App() {
156
+ const navigationRef = useRef(null);
157
+ const { onReady, onStateChange } = KewaAutoTracker.setupNavigationTracking(navigationRef);
158
+
159
+ return (
160
+ <KewaProvider
161
+ config={{
162
+ appUrl: 'https://your-kewa-instance.com',
163
+ projectId: '39r48kjbddkj',
164
+ apiKey: 'your-api-key',
165
+ enableDebugLogging: __DEV__,
166
+ }}
167
+ >
168
+ <NavigationContainer
169
+ ref={navigationRef}
170
+ onReady={onReady}
171
+ onStateChange={onStateChange}
172
+ >
173
+ {/* screens */}
174
+ </NavigationContainer>
175
+ </KewaProvider>
176
+ );
177
+ }
178
+ ```
179
+
180
+ `KewaProvider` calls `init()` on mount and `cleanup()` on unmount.
181
+
182
+ ### Option 2: Imperative init
183
+
184
+ ```typescript
185
+ import Kewa from 'kewa-react-native';
186
+
187
+ await Kewa.init({
188
+ appUrl: 'https://your-kewa-instance.com',
189
+ projectId: '39r48kjbddkj',
190
+ apiKey: 'your-api-key',
191
+ maxQueueSize: 100,
192
+ enableDebugLogging: __DEV__,
193
+ });
194
+
195
+ // Optional — when tearing down
196
+ Kewa.cleanup();
197
+ ```
198
+
199
+ On init, the SDK collects device info, sets up app-state listeners, drains the offline queue, and sends `app_launch` (unless event tracking is disabled).
200
+
201
+ ---
202
+
203
+ ## SDK API
204
+
205
+ All methods are available on the default `Kewa` singleton and via `useKewa()` inside `KewaProvider`.
206
+
207
+ ### `init(config: KewaConfig): Promise<void>`
208
+
209
+ Initializes the SDK. See [Initialization](#initialization).
210
+
211
+ ### `trackEvent(eventName, eventData?, contactData?): Promise<void>`
212
+
213
+ Track any custom event. Every event automatically includes user properties in the contact fields.
214
+
215
+ ```typescript
216
+ await Kewa.trackEvent('product_viewed', {
217
+ productId: 'abc123',
218
+ category: 'electronics',
219
+ price: 299.99,
220
+ });
221
+
222
+ // Attach contact fields to a single event
223
+ await Kewa.trackEvent(
224
+ 'newsletter_signup',
225
+ { source: 'home_banner' },
226
+ { email: 'user@example.com', firstname: 'Jane' },
227
+ );
228
+ ```
229
+
230
+ ### `setUserProperties(properties): Promise<void>`
231
+
232
+ Merges properties into local storage and updates in Kewa Backend automatically. All fields are optional.
233
+
234
+ ```typescript
235
+ await Kewa.setUserProperties({
236
+ email: 'user@example.com',
237
+ firstname: 'Jane',
238
+ plan: 'premium',
239
+ });
240
+ ```
241
+
242
+ ### `trackLogin(userData): Promise<void>`
243
+
244
+ Sends a `user_login` event. Default `loginMethod` is `'custom'`.
245
+
246
+ ```typescript
247
+ await Kewa.trackLogin({
248
+ userId: 'user123',
249
+ email: 'user@example.com',
250
+ loginMethod: 'google', // 'email' | 'google' | 'facebook' | 'apple' | 'phone' | 'custom'
251
+ });
252
+ ```
253
+
254
+ ### `trackRegistration(userData): Promise<void>`
255
+
256
+ Sends a `user_registration` event. Default `registrationMethod` is `'email'`.
257
+
258
+ ```typescript
259
+ await Kewa.trackRegistration({
260
+ userId: 'user123',
261
+ email: 'user@example.com',
262
+ registrationMethod: 'google', // 'email' | 'google' | 'facebook' | 'apple' | 'phone'
263
+ });
264
+ ```
265
+
266
+ ### `trackLogout(): Promise<void>`
267
+
268
+ Sends a `user_logout` event, then clears all the tracking data including any user properties set earlier.
269
+
270
+ ```typescript
271
+ await Kewa.trackLogout();
272
+ ```
273
+
274
+ ### `trackScreenView(screenName, additionalData?): Promise<void>`
275
+
276
+ Sends a `screen_view` event.
277
+
278
+ ```typescript
279
+ await Kewa.trackScreenView('ProductDetail', {
280
+ previousScreen: 'Home',
281
+ screenClass: 'ProductDetailScreen',
282
+ loadTime: 320,
283
+ params: { productId: 'abc123' },
284
+ });
285
+ ```
286
+
287
+ ### `trackError(error, context?, isFatal?): Promise<void>`
288
+
289
+ Sends an `error` event with message, stack trace, name, and optional context.
290
+
291
+ ```typescript
292
+ try {
293
+ await riskyOperation();
294
+ } catch (error) {
295
+ await Kewa.trackError(error as Error, { screen: 'Checkout' }, false);
296
+ }
297
+ ```
298
+
299
+ ### `reset(): Promise<void>`
300
+
301
+ Clears tracking data, and stored user properties locally without sending a logout event. Use when you need to wipe identity silently (e.g. account deletion flow).
302
+
303
+ ```typescript
304
+ await Kewa.reset();
305
+ ```
306
+
307
+ ### Getters
308
+
309
+
310
+ | Method | Returns | Description |
311
+ | --------------------- | ------------------------ | ------------------------------------ |
312
+ | `getKtcId()` | `Promise<string | null>` | Locally stored contact ID |
313
+ | `getDeviceId()` | `Promise<string | null>` | Kewa-assigned device ID |
314
+ | `getUserProperties()` | `Promise<ContactData>` | Merged contact properties in storage |
315
+ | `isSDKInitialized()` | `boolean` | Whether `init()` completed |
316
+
317
+
318
+ ```typescript
319
+ const contactId = await Kewa.getKtcId();
320
+ const deviceId = await Kewa.getDeviceId();
321
+ const props = await Kewa.getUserProperties();
322
+ const ready = Kewa.isSDKInitialized();
323
+ ```
324
+
325
+ ### `cleanup(): void`
326
+
327
+ Removes the `AppState` listener and network monitor. Called automatically by `KewaProvider` on unmount.
328
+
329
+ ```typescript
330
+ Kewa.cleanup();
331
+ ```
332
+
333
+ ### Package exports
334
+
335
+ ```typescript
336
+ import Kewa from 'kewa-react-native';
337
+ import { KewaProvider, useKewa, useAutoTracker } from 'kewa-react-native';
338
+ import { KewaTracker, KewaAutoTracker } from 'kewa-react-native';
339
+ import { KEWA_CONSTANTS, DeviceInfoCollector } from 'kewa-react-native';
340
+ import type { KewaConfig, ContactData, KewaEvent, KewaResponse } from 'kewa-react-native';
341
+ ```
342
+
343
+ ---
344
+
345
+ ## Use Cases
346
+
347
+ ### App login
348
+
349
+ After the user authenticates in your app, call `trackLogin` to record the login event and attach user identity to subsequent events.
350
+
351
+ ```tsx
352
+ import { useKewa } from 'kewa-react-native';
353
+
354
+ function LoginScreen() {
355
+ const { trackLogin, setUserProperties } = useKewa();
356
+
357
+ const handleLogin = async () => {
358
+ const user = await authenticateWithYourBackend();
359
+
360
+ await trackLogin({
361
+ userId: user.id,
362
+ email: user.email,
363
+ loginMethod: 'email',
364
+ });
365
+
366
+ // Optionally sync profile fields immediately
367
+ await setUserProperties({
368
+ email: user.email,
369
+ firstname: user.firstName,
370
+ lastname: user.lastName,
371
+ });
372
+
373
+ navigation.navigate('Home');
374
+ };
375
+
376
+ return <Button title="Log in" onPress={handleLogin} />;
377
+ }
378
+ ```
379
+
380
+ The backend may return a `ktc_id` and `device_id` which the SDK stores automatically for future events.
381
+
382
+ ### App register
383
+
384
+ Call `trackRegistration` when a new account is created.
385
+
386
+ ```tsx
387
+ import { useKewa } from 'kewa-react-native';
388
+
389
+ function RegisterScreen() {
390
+ const { trackRegistration, setUserProperties } = useKewa();
391
+
392
+ const handleRegister = async () => {
393
+ const user = await createAccountOnYourBackend();
394
+
395
+ await trackRegistration({
396
+ userId: user.id,
397
+ email: user.email,
398
+ registrationMethod: 'email',
399
+ });
400
+
401
+ await setUserProperties({
402
+ email: user.email,
403
+ firstname: user.firstName,
404
+ lastname: user.lastName,
405
+ });
406
+
407
+ navigation.navigate('Onboarding');
408
+ };
409
+
410
+ return <Button title="Create account" onPress={handleRegister} />;
411
+ }
412
+ ```
413
+
414
+ ### Set user properties
415
+
416
+ Update contact/profile fields at any time — after login, on profile edit, or after a purchase. Properties are merged locally and synced to the backend.
417
+
418
+ ```typescript
419
+ import Kewa from 'kewa-react-native';
420
+
421
+ // After profile update
422
+ await Kewa.setUserProperties({
423
+ plan: 'premium',
424
+ company: 'Acme Inc',
425
+ preferred_locale: 'en-US',
426
+ });
427
+
428
+ // After purchase
429
+ await Kewa.setUserProperties({
430
+ plan: 'premium',
431
+ subscriptionDate: new Date().toISOString(),
432
+ totalPurchases: 3,
433
+ });
434
+ ```
435
+
436
+ Supported fields include `id`, `email`, `firstname`, `lastname`, `mobile`, `company`, address fields, social profiles, and any custom keys via the `ContactData` index signature.
437
+
438
+ ### App logout (clears everything)
439
+
440
+ Call `trackLogout` when the user signs out. This sends a `user_logout` event and **clears all local identity** — `ktc_id`, `device_id`, and user properties — so the next session starts anonymous.
441
+
442
+ ```tsx
443
+ import { useKewa } from 'kewa-react-native';
444
+
445
+ function ProfileScreen() {
446
+ const { trackLogout } = useKewa();
447
+
448
+ const handleLogout = async () => {
449
+ await signOutFromYourBackend();
450
+ await trackLogout(); // sends user_logout + clears ktc_id, device_id, user properties
451
+ navigation.reset({ index: 0, routes: [{ name: 'Login' }] });
452
+ };
453
+
454
+ return <Button title="Log out" onPress={handleLogout} />;
455
+ }
456
+ ```
457
+
458
+ ---
459
+
460
+ ## React Integration
461
+
462
+ ### `useKewa()`
463
+
464
+ Returns the full SDK API. Must be used inside `KewaProvider`.
465
+
466
+ ```tsx
467
+ function CheckoutScreen() {
468
+ const {
469
+ trackEvent,
470
+ trackLogin,
471
+ trackLogout,
472
+ trackRegistration,
473
+ trackScreenView,
474
+ trackError,
475
+ setUserProperties,
476
+ reset,
477
+ getKtcId,
478
+ getDeviceId,
479
+ getUserProperties,
480
+ isSDKInitialized,
481
+ } = useKewa();
482
+ }
483
+ ```
484
+
485
+ ### `useAutoTracker()`
486
+
487
+ UI-focused helpers bound to the provider instance.
488
+
489
+ ```tsx
490
+ function HomeScreen() {
491
+ const { trackButtonPress, trackFormSubmission, trackError } = useAutoTracker();
492
+
493
+ return (
494
+ <>
495
+ <Button onPress={trackButtonPress('subscribe', { plan: 'premium' })} />
496
+ <Button onPress={trackFormSubmission('newsletter', { source: 'home' })} />
497
+ </>
498
+ );
499
+ }
500
+ ```
501
+
502
+ ---
503
+
504
+ ## Auto Tracking
505
+
506
+ `KewaTracker` / `KewaAutoTracker` are static utilities that use the shared `Kewa` singleton.
507
+
508
+ ### React Navigation screen tracking
509
+
510
+ ```typescript
511
+ const navigationRef = useRef(null);
512
+ const { onReady, onStateChange } = KewaAutoTracker.setupNavigationTracking(navigationRef);
513
+
514
+ <NavigationContainer ref={navigationRef} onReady={onReady} onStateChange={onStateChange}>
515
+ ```
516
+
517
+ Disabled when `disableTracking`, `disableEventTracking`, or `disableScreenViewTracking` is `true`.
518
+
519
+ ### Button and form tracking
520
+
521
+ ```typescript
522
+ <Button onPress={KewaTracker.trackButtonPress('cta_signup', { variant: 'hero' })} />
523
+ <Button onPress={KewaTracker.trackFormSubmission('contact_form', { fields: 3 })} />
524
+ ```
525
+
526
+ ### Error tracking
527
+
528
+ ```typescript
529
+ KewaAutoTracker.trackError(error, { component: 'PaymentForm' });
530
+ ```
531
+
532
+ ---
533
+
534
+ ## Automatic Events
535
+
536
+
537
+ | Event | Trigger | Disabled when |
538
+ | ---------------- | --------------------------- | ------------------------------------------------------------------------- |
539
+ | `app_launch` | SDK init completes | `disableTracking` or `disableEventTracking` |
540
+ | `app_foreground` | App returns from background | `disableTracking` or `disableAppStateTracking` |
541
+ | `app_background` | App moves to background | `disableTracking` or `disableAppStateTracking` |
542
+ | `screen_view` | Navigation route change | `disableTracking`, `disableEventTracking`, or `disableScreenViewTracking` |
543
+
544
+
545
+ Predefined event name constants are available on `KEWA_CONSTANTS.EVENTS`.
546
+
547
+ ---
548
+
549
+ ## Offline Queue
550
+
551
+ 1. If the device is offline or a send fails, the event is saved to AsyncStorage.
552
+ 2. Queue is capped at `maxQueueSize` (default **100**); oldest events are dropped when full.
553
+ 3. Queue is processed on SDK init and when the app returns to foreground.
554
+ 4. Events are sent one at a time.
555
+
556
+ ---
557
+
558
+ ## Troubleshooting
559
+
560
+
561
+ | Issue | Solution |
562
+ | ----------------------------------- | ---------------------------------------------------------------- |
563
+ | Events not sending | Verify `appUrl`, `projectId`, `apiKey`, and network connectivity |
564
+ | `projectId is required` error | Pass `projectId` or set `disableTracking: true` |
565
+ | `ktc_id` not updating | Confirm backend returns `id` in the response |
566
+ | `NativeModule.RNDeviceInfo is null` | Not running in Expo Go — use a dev build or bare RN |
567
+ | Queue growing | Check backend availability; adjust `maxQueueSize` if needed |
568
+ | Duplicate init | Use either `KewaProvider` or manual `Kewa.init()`, not both |
569
+ | SDK not initialized warning | Call `init()` via provider or manually before tracking |
570
+
571
+
572
+ ### Verify the endpoint manually
573
+
574
+ ```bash
575
+ curl -X POST 'https://your-kewa-instance.com/t/39r48kjbddkj/mtc/event/track' \
576
+ -H 'Content-Type: application/json' \
577
+ -H 'secret: YOUR_API_KEY' \
578
+ -d '{
579
+ "event": "test_event",
580
+ "timestamp": "2026-06-09T00:00:00.000Z",
581
+ "data": {},
582
+ "contact": {},
583
+ "kewa_device_id": null,
584
+ "device": { "platform": "ios", "appVersion": "1.0.0" }
585
+ }'
586
+ ```
587
+
588
+ ---
589
+
590
+ ## License
591
+
592
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,26 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { KewaAnalytics } from './core/KewaAnalytics';
3
+ import { KewaConfig, ContactData, BaseEventData, UserLoginEvent, UserRegistrationEvent, ScreenViewEvent } from './types';
4
+ export interface KewaContextValue {
5
+ trackEvent: (eventName: string, eventData?: BaseEventData, contactData?: ContactData) => Promise<void>;
6
+ setUserProperties: (properties: ContactData) => Promise<void>;
7
+ trackLogin: (userData: Partial<UserLoginEvent>) => Promise<void>;
8
+ trackLogout: () => Promise<void>;
9
+ trackRegistration: (userData: Partial<UserRegistrationEvent>) => Promise<void>;
10
+ trackScreenView: (screenName: string, additionalData?: Partial<ScreenViewEvent>) => Promise<void>;
11
+ trackError: (error: Error, context?: Record<string, any>, isFatal?: boolean) => Promise<void>;
12
+ reset: () => Promise<void>;
13
+ getKtcId: () => Promise<string | null>;
14
+ getDeviceId: () => Promise<string | null>;
15
+ getUserProperties: () => Promise<ContactData>;
16
+ isSDKInitialized: () => boolean;
17
+ }
18
+ interface KewaProviderProps {
19
+ config: KewaConfig;
20
+ children: ReactNode;
21
+ kewa?: KewaAnalytics;
22
+ }
23
+ export declare function KewaProvider({ config, children, kewa }: KewaProviderProps): React.JSX.Element;
24
+ export declare function useKewa(): KewaContextValue;
25
+ export declare function getDefaultKewaInstance(): KewaAnalytics;
26
+ export {};