@adshift/react-native-plugin 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 (54) hide show
  1. package/AdShiftReactNativePlugin.podspec +30 -0
  2. package/LICENSE +45 -0
  3. package/README.md +810 -0
  4. package/android/build.gradle +80 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +420 -0
  8. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginPackage.kt +33 -0
  9. package/ios/AdShiftReactNativePlugin.h +24 -0
  10. package/ios/AdShiftReactNativePlugin.mm +258 -0
  11. package/ios/AdShiftReactNativePluginHelper.swift +413 -0
  12. package/lib/module/Adshift.js +468 -0
  13. package/lib/module/Adshift.js.map +1 -0
  14. package/lib/module/NativeAdShiftReactNativePlugin.js +18 -0
  15. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -0
  16. package/lib/module/index.js +57 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/module/types/AdshiftConfig.js +44 -0
  20. package/lib/module/types/AdshiftConfig.js.map +1 -0
  21. package/lib/module/types/AdshiftConsent.js +101 -0
  22. package/lib/module/types/AdshiftConsent.js.map +1 -0
  23. package/lib/module/types/AdshiftDeepLink.js +121 -0
  24. package/lib/module/types/AdshiftDeepLink.js.map +1 -0
  25. package/lib/module/types/AdshiftEventType.js +108 -0
  26. package/lib/module/types/AdshiftEventType.js.map +1 -0
  27. package/lib/module/types/index.js +10 -0
  28. package/lib/module/types/index.js.map +1 -0
  29. package/lib/typescript/package.json +1 -0
  30. package/lib/typescript/src/Adshift.d.ts +335 -0
  31. package/lib/typescript/src/Adshift.d.ts.map +1 -0
  32. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts +143 -0
  33. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
  34. package/lib/typescript/src/index.d.ts +47 -0
  35. package/lib/typescript/src/index.d.ts.map +1 -0
  36. package/lib/typescript/src/types/AdshiftConfig.d.ts +74 -0
  37. package/lib/typescript/src/types/AdshiftConfig.d.ts.map +1 -0
  38. package/lib/typescript/src/types/AdshiftConsent.d.ts +88 -0
  39. package/lib/typescript/src/types/AdshiftConsent.d.ts.map +1 -0
  40. package/lib/typescript/src/types/AdshiftDeepLink.d.ts +93 -0
  41. package/lib/typescript/src/types/AdshiftDeepLink.d.ts.map +1 -0
  42. package/lib/typescript/src/types/AdshiftEventType.d.ts +87 -0
  43. package/lib/typescript/src/types/AdshiftEventType.d.ts.map +1 -0
  44. package/lib/typescript/src/types/index.d.ts +5 -0
  45. package/lib/typescript/src/types/index.d.ts.map +1 -0
  46. package/package.json +143 -0
  47. package/src/Adshift.ts +539 -0
  48. package/src/NativeAdShiftReactNativePlugin.ts +177 -0
  49. package/src/index.tsx +68 -0
  50. package/src/types/AdshiftConfig.ts +108 -0
  51. package/src/types/AdshiftConsent.ts +127 -0
  52. package/src/types/AdshiftDeepLink.ts +194 -0
  53. package/src/types/AdshiftEventType.ts +135 -0
  54. package/src/types/index.ts +7 -0
package/src/Adshift.ts ADDED
@@ -0,0 +1,539 @@
1
+ /**
2
+ * AdShift SDK for React Native
3
+ *
4
+ * Main SDK interface providing type-safe access to native AdShift functionality.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { Adshift, AdshiftEventType } from '@adshift/react-native-plugin';
9
+ *
10
+ * // 1. Initialize
11
+ * Adshift.initialize({ apiKey: 'your-api-key', isDebug: true });
12
+ *
13
+ * // 2. Start tracking
14
+ * await Adshift.start();
15
+ *
16
+ * // 3. Track events
17
+ * await Adshift.trackEvent(AdshiftEventType.Purchase, { price: 9.99 });
18
+ *
19
+ * // 4. Listen for deep links
20
+ * const subscription = Adshift.onDeepLink((deepLink) => {
21
+ * console.log('Deep link received:', deepLink);
22
+ * });
23
+ * // Later: subscription.remove();
24
+ * ```
25
+ */
26
+
27
+ import { NativeEventEmitter, Platform } from 'react-native';
28
+ import NativeAdShiftReactNativePlugin from './NativeAdShiftReactNativePlugin';
29
+ import type { AdshiftConfig, AdshiftConsent, AdshiftDeepLink } from './types';
30
+ import {
31
+ configToMap,
32
+ consentToMap,
33
+ AdshiftDeepLink as AdshiftDeepLinkHelpers,
34
+ } from './types';
35
+
36
+ // ============ Types ============
37
+
38
+ /**
39
+ * Result returned from Adshift.start()
40
+ */
41
+ export interface StartResult {
42
+ /** Whether start was successful */
43
+ success: boolean;
44
+ /** Optional message from native SDK */
45
+ message?: string;
46
+ }
47
+
48
+ /**
49
+ * Values that can be passed to trackEvent
50
+ */
51
+ export type EventValues = Record<string, string | number | boolean>;
52
+
53
+ /**
54
+ * Parameters for trackPurchase
55
+ */
56
+ export interface PurchaseParams {
57
+ /** Product identifier */
58
+ productId: string;
59
+ /** Purchase amount (revenue) */
60
+ revenue: number;
61
+ /** ISO currency code (e.g., "USD") */
62
+ currency: string;
63
+ /** Transaction ID / purchase receipt token */
64
+ transactionId: string;
65
+ }
66
+
67
+ /**
68
+ * Subscription returned from onDeepLink
69
+ */
70
+ export interface DeepLinkSubscription {
71
+ /** Removes the deep link listener */
72
+ remove(): void;
73
+ }
74
+
75
+ /**
76
+ * Callback for deep link events
77
+ */
78
+ export type DeepLinkCallback = (deepLink: AdshiftDeepLink) => void;
79
+
80
+ // ============ Internal State ============
81
+
82
+ let _isInitialized = false;
83
+ let _eventEmitter: NativeEventEmitter | null = null;
84
+
85
+ // ============ Internal Helpers ============
86
+
87
+ function ensureInitialized(): void {
88
+ if (!_isInitialized) {
89
+ throw new Error(
90
+ 'AdShift SDK not initialized. Call Adshift.initialize(config) first.'
91
+ );
92
+ }
93
+ }
94
+
95
+ function getEventEmitter(): NativeEventEmitter {
96
+ if (!_eventEmitter) {
97
+ _eventEmitter = new NativeEventEmitter(NativeAdShiftReactNativePlugin);
98
+ }
99
+ return _eventEmitter;
100
+ }
101
+
102
+ // ============ Main SDK API ============
103
+
104
+ /**
105
+ * AdShift SDK main interface.
106
+ *
107
+ * Provides type-safe access to all SDK functionality.
108
+ */
109
+ export const Adshift = {
110
+ // ============ Lifecycle ============
111
+
112
+ /**
113
+ * Initializes the SDK with configuration.
114
+ *
115
+ * Must be called before any other SDK methods.
116
+ * Call this early in your app's lifecycle (e.g., in App.tsx or index.js).
117
+ *
118
+ * @param config - SDK configuration
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * Adshift.initialize({
123
+ * apiKey: 'your-api-key',
124
+ * isDebug: __DEV__,
125
+ * // iOS only
126
+ * waitForATTBeforeStart: true,
127
+ * // Android only
128
+ * collectOaid: true,
129
+ * });
130
+ * ```
131
+ */
132
+ initialize(config: AdshiftConfig): void {
133
+ if (!config.apiKey) {
134
+ throw new Error('AdShift SDK: apiKey is required in config');
135
+ }
136
+
137
+ const configMap = configToMap(config);
138
+ NativeAdShiftReactNativePlugin.initialize(configMap);
139
+ _isInitialized = true;
140
+ },
141
+
142
+ /**
143
+ * Starts the SDK.
144
+ *
145
+ * Validates API key, sends install event (if first launch), and begins tracking.
146
+ * Call this after initialize().
147
+ *
148
+ * @returns Promise resolving to start result
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * try {
153
+ * const result = await Adshift.start();
154
+ * console.log('SDK started:', result);
155
+ * } catch (error) {
156
+ * console.error('SDK start failed:', error);
157
+ * }
158
+ * ```
159
+ */
160
+ async start(): Promise<StartResult> {
161
+ ensureInitialized();
162
+
163
+ try {
164
+ const result = (await NativeAdShiftReactNativePlugin.start()) as Record<
165
+ string,
166
+ unknown
167
+ >;
168
+ return {
169
+ success: true,
170
+ message: result?.message as string | undefined,
171
+ };
172
+ } catch (error) {
173
+ const message = error instanceof Error ? error.message : 'Unknown error';
174
+ return {
175
+ success: false,
176
+ message,
177
+ };
178
+ }
179
+ },
180
+
181
+ /**
182
+ * Stops the SDK.
183
+ *
184
+ * Pauses all tracking. Can be restarted with start().
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * Adshift.stop();
189
+ * ```
190
+ */
191
+ stop(): void {
192
+ ensureInitialized();
193
+ NativeAdShiftReactNativePlugin.stop();
194
+ },
195
+
196
+ /**
197
+ * Checks if SDK is currently started.
198
+ *
199
+ * @returns true if SDK is running
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * if (Adshift.isStarted()) {
204
+ * // SDK is tracking
205
+ * }
206
+ * ```
207
+ */
208
+ isStarted(): boolean {
209
+ ensureInitialized();
210
+ return NativeAdShiftReactNativePlugin.isStarted();
211
+ },
212
+
213
+ // ============ Configuration ============
214
+
215
+ /**
216
+ * Sets custom user identifier for attribution.
217
+ *
218
+ * Associate events with your own user ID. Can be called before or after start().
219
+ *
220
+ * @param userId - Your user identifier
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * Adshift.setCustomerUserId('user_123');
225
+ * ```
226
+ */
227
+ setCustomerUserId(userId: string): void {
228
+ ensureInitialized();
229
+
230
+ if (!userId || typeof userId !== 'string') {
231
+ throw new Error('AdShift SDK: userId must be a non-empty string');
232
+ }
233
+
234
+ NativeAdShiftReactNativePlugin.setCustomerUserId(userId);
235
+ },
236
+
237
+ /**
238
+ * Enables/disables debug logging at runtime.
239
+ *
240
+ * Note: Can also be set via config.isDebug during initialize().
241
+ *
242
+ * @param enabled - true to enable debug logs
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * // Enable debug in production for troubleshooting
247
+ * Adshift.setDebugEnabled(true);
248
+ * ```
249
+ */
250
+ setDebugEnabled(enabled: boolean): void {
251
+ ensureInitialized();
252
+ NativeAdShiftReactNativePlugin.setDebugEnabled(enabled);
253
+ },
254
+
255
+ /**
256
+ * Sets app open debounce time in milliseconds.
257
+ *
258
+ * Used to deduplicate rapid app open events.
259
+ * Note: Can also be set via config.appOpenDebounceMs during initialize().
260
+ *
261
+ * @param ms - Debounce time in milliseconds (e.g., 5000 for 5 seconds)
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * Adshift.setAppOpenDebounceMs(5000);
266
+ * ```
267
+ */
268
+ setAppOpenDebounceMs(ms: number): void {
269
+ ensureInitialized();
270
+
271
+ if (typeof ms !== 'number' || ms < 0) {
272
+ throw new Error('AdShift SDK: ms must be a non-negative number');
273
+ }
274
+
275
+ NativeAdShiftReactNativePlugin.setAppOpenDebounceMs(ms);
276
+ },
277
+
278
+ // ============ Consent (GDPR/DMA) ============
279
+
280
+ /**
281
+ * Sets user consent data manually.
282
+ *
283
+ * Use this for manual consent collection (not CMP).
284
+ * Use AdshiftConsent.forGDPRUser() or AdshiftConsent.forNonGDPRUser() helpers.
285
+ *
286
+ * @param consent - Consent data
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * // GDPR user who accepted all
291
+ * Adshift.setConsentData(
292
+ * AdshiftConsent.forGDPRUser({
293
+ * hasConsentForDataUsage: true,
294
+ * hasConsentForAdsPersonalization: true,
295
+ * hasConsentForAdStorage: true,
296
+ * })
297
+ * );
298
+ *
299
+ * // Non-GDPR user
300
+ * Adshift.setConsentData(AdshiftConsent.forNonGDPRUser());
301
+ * ```
302
+ */
303
+ setConsentData(consent: AdshiftConsent): void {
304
+ ensureInitialized();
305
+ const consentMap = consentToMap(consent);
306
+ NativeAdShiftReactNativePlugin.setConsentData(consentMap);
307
+ },
308
+
309
+ /**
310
+ * Enables/disables automatic TCF v2.2 data collection from CMP.
311
+ *
312
+ * When enabled, SDK reads IAB TCF consent strings from device storage
313
+ * (set by CMPs like Google Funding Choices, Didomi, etc.)
314
+ *
315
+ * Call this BEFORE start().
316
+ *
317
+ * @param enabled - true to enable TCF collection
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * Adshift.enableTCFDataCollection(true);
322
+ * await Adshift.start();
323
+ * ```
324
+ */
325
+ enableTCFDataCollection(enabled: boolean): void {
326
+ ensureInitialized();
327
+ NativeAdShiftReactNativePlugin.enableTCFDataCollection(enabled);
328
+ },
329
+
330
+ /**
331
+ * Refreshes consent state from TCF/CMP or manual sources.
332
+ *
333
+ * Call this after CMP dialog closes to pick up updated consent.
334
+ * Priority: Manual > TCF > None
335
+ *
336
+ * @returns Promise resolving to consent snapshot
337
+ *
338
+ * @example
339
+ * ```typescript
340
+ * // After CMP dialog closes
341
+ * const snapshot = await Adshift.refreshConsent();
342
+ * console.log('Consent source:', snapshot.source);
343
+ * ```
344
+ */
345
+ async refreshConsent(): Promise<Record<string, unknown>> {
346
+ ensureInitialized();
347
+ const result =
348
+ (await NativeAdShiftReactNativePlugin.refreshConsent()) as Record<
349
+ string,
350
+ unknown
351
+ >;
352
+ return result;
353
+ },
354
+
355
+ // ============ Event Tracking ============
356
+
357
+ /**
358
+ * Tracks an in-app event.
359
+ *
360
+ * Use AdshiftEventType constants for predefined events, or custom strings.
361
+ * Events are queued until SDK is started.
362
+ *
363
+ * @param eventName - Event name (use AdshiftEventType or custom string)
364
+ * @param values - Optional event parameters
365
+ * @returns Promise resolving on success
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * // Predefined event
370
+ * await Adshift.trackEvent(AdshiftEventType.AddToCart, {
371
+ * product_id: 'SKU123',
372
+ * price: 29.99,
373
+ * });
374
+ *
375
+ * // Custom event
376
+ * await Adshift.trackEvent('custom_event', { key: 'value' });
377
+ * ```
378
+ */
379
+ async trackEvent(eventName: string, values?: EventValues): Promise<void> {
380
+ ensureInitialized();
381
+
382
+ if (!eventName || typeof eventName !== 'string') {
383
+ throw new Error('AdShift SDK: eventName must be a non-empty string');
384
+ }
385
+
386
+ await NativeAdShiftReactNativePlugin.trackEvent(eventName, values ?? null);
387
+ },
388
+
389
+ /**
390
+ * Tracks a purchase event.
391
+ *
392
+ * Use for revenue tracking and SKAdNetwork conversion value calculation.
393
+ *
394
+ * @param params - Purchase parameters
395
+ * @returns Promise resolving on success
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * await Adshift.trackPurchase({
400
+ * productId: 'premium_subscription',
401
+ * revenue: 9.99,
402
+ * currency: 'USD',
403
+ * transactionId: 'TXN_123456',
404
+ * });
405
+ * ```
406
+ */
407
+ async trackPurchase(params: PurchaseParams): Promise<void> {
408
+ ensureInitialized();
409
+
410
+ const { productId, revenue, currency, transactionId } = params;
411
+
412
+ if (!productId) {
413
+ throw new Error('AdShift SDK: productId is required');
414
+ }
415
+ if (typeof revenue !== 'number' || revenue < 0) {
416
+ throw new Error('AdShift SDK: revenue must be a non-negative number');
417
+ }
418
+ if (!currency) {
419
+ throw new Error('AdShift SDK: currency is required');
420
+ }
421
+ if (!transactionId) {
422
+ throw new Error('AdShift SDK: transactionId is required');
423
+ }
424
+
425
+ // Native SDK uses price/token naming internally
426
+ await NativeAdShiftReactNativePlugin.trackPurchase(
427
+ productId,
428
+ revenue,
429
+ currency,
430
+ transactionId
431
+ );
432
+ },
433
+
434
+ // ============ Deep Links ============
435
+
436
+ /**
437
+ * Handles a deep link URL.
438
+ *
439
+ * Call this when your app receives a deep link (e.g., from Linking API).
440
+ * Extracts campaign parameters for attribution.
441
+ *
442
+ * @param url - Deep link URL string
443
+ * @returns Promise resolving to deep link response
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * import { Linking } from 'react-native';
448
+ *
449
+ * Linking.addEventListener('url', async ({ url }) => {
450
+ * const deepLink = await Adshift.handleDeepLink(url);
451
+ * if (deepLink.status === AdshiftDeepLinkStatus.Found) {
452
+ * // Navigate based on deepLink.params
453
+ * }
454
+ * });
455
+ * ```
456
+ */
457
+ async handleDeepLink(url: string): Promise<AdshiftDeepLink> {
458
+ ensureInitialized();
459
+
460
+ if (!url || typeof url !== 'string') {
461
+ return AdshiftDeepLinkHelpers.error('Invalid URL');
462
+ }
463
+
464
+ try {
465
+ const result = (await NativeAdShiftReactNativePlugin.handleDeepLink(
466
+ url
467
+ )) as Record<string, unknown>;
468
+ return AdshiftDeepLinkHelpers.fromMap(result);
469
+ } catch (error) {
470
+ const message = error instanceof Error ? error.message : 'Unknown error';
471
+ return AdshiftDeepLinkHelpers.error(message);
472
+ }
473
+ },
474
+
475
+ /**
476
+ * Registers a listener for deep link events.
477
+ *
478
+ * Called when:
479
+ * - Deferred deep links are resolved (after first install)
480
+ * - App links are received while app is running
481
+ *
482
+ * If a deep link was received before listener was set (cold start),
483
+ * the callback is called immediately with the cached deep link.
484
+ *
485
+ * @param callback - Function called when deep link is received
486
+ * @returns Subscription object with remove() method
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * useEffect(() => {
491
+ * const subscription = Adshift.onDeepLink((deepLink) => {
492
+ * if (deepLink.status === AdshiftDeepLinkStatus.Found) {
493
+ * console.log('Deep link:', deepLink.deepLink);
494
+ * console.log('Params:', deepLink.params);
495
+ * // Navigate to appropriate screen
496
+ * }
497
+ * });
498
+ *
499
+ * return () => subscription.remove();
500
+ * }, []);
501
+ * ```
502
+ */
503
+ onDeepLink(callback: DeepLinkCallback): DeepLinkSubscription {
504
+ ensureInitialized();
505
+
506
+ const eventEmitter = getEventEmitter();
507
+
508
+ const subscription = eventEmitter.addListener(
509
+ 'onDeepLink',
510
+ (event: unknown) => {
511
+ const deepLink = AdshiftDeepLinkHelpers.fromMap(
512
+ event as Record<string, unknown>
513
+ );
514
+ callback(deepLink);
515
+ }
516
+ );
517
+
518
+ return {
519
+ remove: () => {
520
+ subscription.remove();
521
+ },
522
+ };
523
+ },
524
+
525
+ // ============ Debug ============
526
+
527
+ /**
528
+ * Returns SDK version and platform info.
529
+ * Useful for debugging.
530
+ */
531
+ getInfo(): { platform: string; version: string } {
532
+ return {
533
+ platform: Platform.OS,
534
+ version: '1.0.0', // TODO: Get from package.json
535
+ };
536
+ },
537
+ };
538
+
539
+ export default Adshift;
@@ -0,0 +1,177 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ /**
4
+ * AdShift React Native Plugin - Turbo Module Specification
5
+ *
6
+ * This interface defines the contract between JavaScript and native code.
7
+ * Codegen generates native interfaces from this spec:
8
+ * - iOS: NativeAdShiftReactNativePluginSpecJSI (C++)
9
+ * - Android: NativeAdShiftReactNativePluginSpec (Kotlin)
10
+ *
11
+ * Note: Custom types (AdshiftConfig, etc.) are not supported in Turbo Module Spec.
12
+ * We use `Object` here and add type safety in the wrapper layer (Adshift.ts).
13
+ */
14
+ export interface Spec extends TurboModule {
15
+ // ============ Lifecycle ============
16
+
17
+ /**
18
+ * Initializes the SDK with configuration.
19
+ * Must be called before start().
20
+ *
21
+ * @param config - Configuration object containing:
22
+ * - apiKey: string (required)
23
+ * - isDebug?: boolean
24
+ * - appOpenDebounceMs?: number
25
+ * - disableSKAN?: boolean (iOS only)
26
+ * - waitForATTBeforeStart?: boolean (iOS only)
27
+ * - attTimeoutMs?: number (iOS only)
28
+ * - collectOaid?: boolean (Android only)
29
+ */
30
+ initialize(config: Object): void;
31
+
32
+ /**
33
+ * Starts the SDK.
34
+ * Validates API key, sends install event (if first launch), and begins tracking.
35
+ *
36
+ * @returns Promise resolving to result object or rejecting with error
37
+ */
38
+ start(): Promise<Object>;
39
+
40
+ /**
41
+ * Stops the SDK.
42
+ * Pauses all tracking. Can be restarted with start().
43
+ */
44
+ stop(): void;
45
+
46
+ /**
47
+ * Checks if SDK is currently started.
48
+ *
49
+ * @returns true if SDK is running
50
+ */
51
+ isStarted(): boolean;
52
+
53
+ // ============ Configuration ============
54
+
55
+ /**
56
+ * Sets custom user identifier for attribution.
57
+ * Can be called before or after start().
58
+ *
59
+ * @param userId - Your user identifier
60
+ */
61
+ setCustomerUserId(userId: string): void;
62
+
63
+ /**
64
+ * Enables/disables debug logging at runtime.
65
+ *
66
+ * @param enabled - true to enable debug logs
67
+ */
68
+ setDebugEnabled(enabled: boolean): void;
69
+
70
+ /**
71
+ * Sets app open debounce time in milliseconds.
72
+ * Used to deduplicate rapid app open events.
73
+ *
74
+ * @param ms - Debounce time in milliseconds
75
+ */
76
+ setAppOpenDebounceMs(ms: number): void;
77
+
78
+ // ============ Consent (GDPR/DMA) ============
79
+
80
+ /**
81
+ * Sets user consent data manually.
82
+ * Use for custom consent UI (not CMP).
83
+ *
84
+ * @param consent - Consent object containing:
85
+ * - isUserSubjectToGDPR: boolean
86
+ * - hasConsentForDataUsage: boolean
87
+ * - hasConsentForAdsPersonalization: boolean
88
+ * - hasConsentForAdStorage: boolean
89
+ */
90
+ setConsentData(consent: Object): void;
91
+
92
+ /**
93
+ * Enables/disables automatic TCF v2.2 data collection from CMP.
94
+ * Call BEFORE start() to enable consent collection from CMPs
95
+ * (Google Funding Choices, Didomi, etc.)
96
+ *
97
+ * @param enabled - true to enable TCF collection
98
+ */
99
+ enableTCFDataCollection(enabled: boolean): void;
100
+
101
+ /**
102
+ * Refreshes consent state from TCF/CMP or manual sources.
103
+ * Call this after CMP dialog closes to pick up updated consent.
104
+ *
105
+ * @returns Promise resolving to consent snapshot
106
+ */
107
+ refreshConsent(): Promise<Object>;
108
+
109
+ // ============ Event Tracking ============
110
+
111
+ /**
112
+ * Tracks an in-app event with optional parameters.
113
+ * Events are queued until SDK is started.
114
+ *
115
+ * @param eventName - Event name (use AdshiftEventType constants or custom string)
116
+ * @param values - Optional event parameters (nullable)
117
+ * @returns Promise resolving on success or rejecting with error
118
+ */
119
+ trackEvent(eventName: string, values: Object | null): Promise<void>;
120
+
121
+ /**
122
+ * Tracks a purchase event with standardized parameters.
123
+ *
124
+ * @param productId - Product identifier
125
+ * @param price - Purchase amount
126
+ * @param currency - ISO currency code (e.g., "USD")
127
+ * @param token - Purchase token/receipt
128
+ * @returns Promise resolving on success or rejecting with error
129
+ */
130
+ trackPurchase(
131
+ productId: string,
132
+ price: number,
133
+ currency: string,
134
+ token: string
135
+ ): Promise<void>;
136
+
137
+ // ============ Deep Links ============
138
+
139
+ /**
140
+ * Handles a deep link URL.
141
+ * Extracts campaign parameters for attribution.
142
+ *
143
+ * @param url - Deep link URL string
144
+ * @returns Promise resolving to deep link response object containing:
145
+ * - deepLink?: string
146
+ * - deepLinkValue?: string
147
+ * - params?: Object
148
+ * - isDeferred: boolean
149
+ * - status: 'found' | 'notFound' | 'error'
150
+ * - errorMessage?: string
151
+ * - deepLinkSub1-5?: string
152
+ */
153
+ handleDeepLink(url: string): Promise<Object>;
154
+
155
+ // ============ Event Emitter Support ============
156
+ // Required for NativeEventEmitter to receive deep link events from native
157
+
158
+ /**
159
+ * Registers a listener for native events.
160
+ * Called internally by NativeEventEmitter.
161
+ *
162
+ * @param eventType - Event name to listen for
163
+ */
164
+ addListener(eventType: string): void;
165
+
166
+ /**
167
+ * Removes event listeners.
168
+ * Called internally by NativeEventEmitter.
169
+ *
170
+ * @param count - Number of listeners to remove
171
+ */
172
+ removeListeners(count: number): void;
173
+ }
174
+
175
+ export default TurboModuleRegistry.getEnforcing<Spec>(
176
+ 'AdShiftReactNativePlugin'
177
+ );