@datalyr/react-native 1.1.1 → 1.2.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +31 -140
  2. package/LICENSE +21 -0
  3. package/README.md +434 -217
  4. package/datalyr-react-native.podspec +31 -0
  5. package/ios/DatalyrNative.m +74 -0
  6. package/ios/DatalyrNative.swift +332 -0
  7. package/ios/DatalyrSKAdNetwork.m +26 -0
  8. package/lib/datalyr-sdk.d.ts +73 -3
  9. package/lib/datalyr-sdk.js +353 -3
  10. package/lib/index.d.ts +2 -0
  11. package/lib/index.js +4 -2
  12. package/lib/integrations/apple-search-ads-integration.d.ts +43 -0
  13. package/lib/integrations/apple-search-ads-integration.js +106 -0
  14. package/lib/integrations/index.d.ts +7 -0
  15. package/lib/integrations/index.js +7 -0
  16. package/lib/integrations/meta-integration.d.ts +76 -0
  17. package/lib/integrations/meta-integration.js +218 -0
  18. package/lib/integrations/tiktok-integration.d.ts +82 -0
  19. package/lib/integrations/tiktok-integration.js +356 -0
  20. package/lib/native/DatalyrNativeBridge.d.ts +57 -0
  21. package/lib/native/DatalyrNativeBridge.js +187 -0
  22. package/lib/native/index.d.ts +5 -0
  23. package/lib/native/index.js +5 -0
  24. package/lib/types.d.ts +29 -0
  25. package/package.json +11 -5
  26. package/src/datalyr-sdk-expo.ts +997 -0
  27. package/src/datalyr-sdk.ts +455 -19
  28. package/src/expo.ts +42 -18
  29. package/src/index.ts +8 -2
  30. package/src/integrations/apple-search-ads-integration.ts +119 -0
  31. package/src/integrations/index.ts +8 -0
  32. package/src/integrations/meta-integration.ts +238 -0
  33. package/src/integrations/tiktok-integration.ts +360 -0
  34. package/src/native/DatalyrNativeBridge.ts +313 -0
  35. package/src/native/index.ts +11 -0
  36. package/src/types.ts +39 -0
  37. package/src/utils-expo.ts +25 -3
  38. package/src/utils-interface.ts +38 -0
  39. package/EXPO_INSTALL.md +0 -297
  40. package/INSTALL.md +0 -402
  41. package/examples/attribution-example.tsx +0 -377
  42. package/examples/auto-events-example.tsx +0 -403
  43. package/examples/example.tsx +0 -250
  44. package/examples/skadnetwork-example.tsx +0 -380
  45. package/examples/test-implementation.tsx +0 -163
@@ -0,0 +1,360 @@
1
+ /**
2
+ * TikTok Business SDK Integration
3
+ * Uses bundled native iOS SDK for event forwarding and user identification
4
+ */
5
+
6
+ import { Platform } from 'react-native';
7
+ import { TikTokConfig } from '../types';
8
+ import { TikTokNativeBridge, isNativeModuleAvailable } from '../native/DatalyrNativeBridge';
9
+
10
+ /**
11
+ * TikTok standard event names (current as of 2025)
12
+ * Note: CompletePayment and SubmitForm are legacy, use Purchase and Lead instead
13
+ */
14
+ const TikTokEvents = {
15
+ // Commerce events
16
+ PURCHASE: 'Purchase',
17
+ ADD_TO_CART: 'AddToCart',
18
+ ADD_TO_WISHLIST: 'AddToWishlist',
19
+ INITIATE_CHECKOUT: 'InitiateCheckout',
20
+ ADD_PAYMENT_INFO: 'AddPaymentInfo',
21
+ VIEW_CONTENT: 'ViewContent',
22
+ SEARCH: 'Search',
23
+
24
+ // User events
25
+ COMPLETE_REGISTRATION: 'CompleteRegistration',
26
+ SUBSCRIBE: 'Subscribe',
27
+ START_TRIAL: 'StartTrial',
28
+ LEAD: 'Lead',
29
+ CONTACT: 'Contact',
30
+
31
+ // App events
32
+ DOWNLOAD: 'Download',
33
+ SCHEDULE: 'Schedule',
34
+ SUBMIT_APPLICATION: 'SubmitApplication',
35
+ } as const;
36
+
37
+ /**
38
+ * TikTok Integration class for handling TikTok Business SDK operations
39
+ * Uses native iOS SDK bundled via CocoaPods (no additional npm packages required)
40
+ */
41
+ export class TikTokIntegration {
42
+ private config: TikTokConfig | null = null;
43
+ private initialized: boolean = false;
44
+ private available: boolean = false;
45
+ private debug: boolean = false;
46
+
47
+ /**
48
+ * Initialize TikTok SDK with configuration
49
+ */
50
+ async initialize(config: TikTokConfig, debug: boolean = false): Promise<void> {
51
+ this.debug = debug;
52
+ this.config = config;
53
+
54
+ // Only available on iOS via native module
55
+ if (Platform.OS !== 'ios') {
56
+ this.log('TikTok SDK only available on iOS');
57
+ return;
58
+ }
59
+
60
+ this.available = isNativeModuleAvailable();
61
+
62
+ if (!this.available) {
63
+ this.log('TikTok native module not available');
64
+ return;
65
+ }
66
+
67
+ try {
68
+ const success = await TikTokNativeBridge.initialize(
69
+ config.appId,
70
+ config.tiktokAppId,
71
+ config.accessToken,
72
+ debug
73
+ );
74
+
75
+ if (success) {
76
+ this.initialized = true;
77
+ this.log(`TikTok SDK initialized with App ID: ${config.tiktokAppId}`);
78
+ }
79
+ } catch (error) {
80
+ this.logError('Failed to initialize TikTok SDK:', error);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Update tracking authorization status (call after ATT prompt)
86
+ */
87
+ async updateTrackingAuthorization(enabled: boolean): Promise<void> {
88
+ if (!this.available || !this.initialized) return;
89
+
90
+ try {
91
+ // TikTok SDK auto-handles ATT, but we track the event
92
+ if (enabled) {
93
+ await this.trackEvent('ATTAuthorized');
94
+ }
95
+ await TikTokNativeBridge.updateTrackingAuthorization(enabled);
96
+ this.log(`TikTok ATT status: ${enabled ? 'authorized' : 'not authorized'}`);
97
+ } catch (error) {
98
+ this.logError('Failed to update TikTok tracking authorization:', error);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Log purchase event to TikTok (uses Purchase - TikTok's current standard event)
104
+ */
105
+ async logPurchase(
106
+ value: number,
107
+ currency: string,
108
+ contentId?: string,
109
+ contentType?: string,
110
+ parameters?: Record<string, any>
111
+ ): Promise<void> {
112
+ if (!this.available || !this.initialized) return;
113
+ if (this.config?.enableAppEvents === false) return;
114
+
115
+ try {
116
+ const properties: Record<string, any> = {
117
+ value,
118
+ currency,
119
+ ...parameters,
120
+ };
121
+
122
+ if (contentId) properties.content_id = contentId;
123
+ if (contentType) properties.content_type = contentType;
124
+
125
+ await TikTokNativeBridge.trackEvent(TikTokEvents.PURCHASE, undefined, properties);
126
+ this.log(`TikTok Purchase event logged: ${value} ${currency}`);
127
+ } catch (error) {
128
+ this.logError('Failed to log TikTok purchase:', error);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Log subscription event to TikTok
134
+ */
135
+ async logSubscription(value: number, currency: string, plan?: string): Promise<void> {
136
+ if (!this.available || !this.initialized) return;
137
+ if (this.config?.enableAppEvents === false) return;
138
+
139
+ try {
140
+ const properties: Record<string, any> = {
141
+ value,
142
+ currency,
143
+ };
144
+
145
+ if (plan) {
146
+ properties.content_id = plan;
147
+ properties.content_type = 'subscription';
148
+ }
149
+
150
+ await TikTokNativeBridge.trackEvent(TikTokEvents.SUBSCRIBE, undefined, properties);
151
+ this.log(`TikTok subscription event logged: ${value} ${currency}`);
152
+ } catch (error) {
153
+ this.logError('Failed to log TikTok subscription:', error);
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Log add to cart event
159
+ */
160
+ async logAddToCart(value: number, currency: string, contentId?: string, contentType?: string): Promise<void> {
161
+ if (!this.available || !this.initialized) return;
162
+ if (this.config?.enableAppEvents === false) return;
163
+
164
+ try {
165
+ const properties: Record<string, any> = {
166
+ value,
167
+ currency,
168
+ };
169
+
170
+ if (contentId) properties.content_id = contentId;
171
+ if (contentType) properties.content_type = contentType;
172
+
173
+ await TikTokNativeBridge.trackEvent(TikTokEvents.ADD_TO_CART, undefined, properties);
174
+ this.log('TikTok add to cart event logged');
175
+ } catch (error) {
176
+ this.logError('Failed to log TikTok add to cart:', error);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Log view content event
182
+ */
183
+ async logViewContent(contentId?: string, contentName?: string, contentType?: string): Promise<void> {
184
+ if (!this.available || !this.initialized) return;
185
+ if (this.config?.enableAppEvents === false) return;
186
+
187
+ try {
188
+ const properties: Record<string, any> = {};
189
+ if (contentId) properties.content_id = contentId;
190
+ if (contentName) properties.content_name = contentName;
191
+ if (contentType) properties.content_type = contentType;
192
+
193
+ await TikTokNativeBridge.trackEvent(TikTokEvents.VIEW_CONTENT, undefined, properties);
194
+ this.log('TikTok view content event logged');
195
+ } catch (error) {
196
+ this.logError('Failed to log TikTok view content:', error);
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Log initiate checkout event
202
+ */
203
+ async logInitiateCheckout(value: number, currency: string, numItems?: number): Promise<void> {
204
+ if (!this.available || !this.initialized) return;
205
+ if (this.config?.enableAppEvents === false) return;
206
+
207
+ try {
208
+ const properties: Record<string, any> = {
209
+ value,
210
+ currency,
211
+ };
212
+ if (numItems) properties.quantity = numItems;
213
+
214
+ await TikTokNativeBridge.trackEvent(TikTokEvents.INITIATE_CHECKOUT, undefined, properties);
215
+ this.log('TikTok initiate checkout event logged');
216
+ } catch (error) {
217
+ this.logError('Failed to log TikTok initiate checkout:', error);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Log complete registration event
223
+ */
224
+ async logCompleteRegistration(method?: string): Promise<void> {
225
+ if (!this.available || !this.initialized) return;
226
+ if (this.config?.enableAppEvents === false) return;
227
+
228
+ try {
229
+ const properties: Record<string, any> = {};
230
+ if (method) properties.registration_method = method;
231
+
232
+ await TikTokNativeBridge.trackEvent(TikTokEvents.COMPLETE_REGISTRATION, undefined, properties);
233
+ this.log('TikTok complete registration event logged');
234
+ } catch (error) {
235
+ this.logError('Failed to log TikTok complete registration:', error);
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Log search event
241
+ */
242
+ async logSearch(query: string): Promise<void> {
243
+ if (!this.available || !this.initialized) return;
244
+ if (this.config?.enableAppEvents === false) return;
245
+
246
+ try {
247
+ await TikTokNativeBridge.trackEvent(TikTokEvents.SEARCH, undefined, { query });
248
+ this.log('TikTok search event logged');
249
+ } catch (error) {
250
+ this.logError('Failed to log TikTok search:', error);
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Log lead event (uses Lead - current standard, SubmitForm is legacy)
256
+ */
257
+ async logLead(value?: number, currency?: string): Promise<void> {
258
+ if (!this.available || !this.initialized) return;
259
+ if (this.config?.enableAppEvents === false) return;
260
+
261
+ try {
262
+ const properties: Record<string, any> = {};
263
+ if (value !== undefined) properties.value = value;
264
+ if (currency) properties.currency = currency;
265
+
266
+ await TikTokNativeBridge.trackEvent(TikTokEvents.LEAD, undefined, properties);
267
+ this.log('TikTok lead event logged');
268
+ } catch (error) {
269
+ this.logError('Failed to log TikTok lead:', error);
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Log add payment info event
275
+ */
276
+ async logAddPaymentInfo(success: boolean): Promise<void> {
277
+ if (!this.available || !this.initialized) return;
278
+ if (this.config?.enableAppEvents === false) return;
279
+
280
+ try {
281
+ await TikTokNativeBridge.trackEvent(TikTokEvents.ADD_PAYMENT_INFO, undefined, { success });
282
+ this.log('TikTok add payment info event logged');
283
+ } catch (error) {
284
+ this.logError('Failed to log TikTok add payment info:', error);
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Log custom event to TikTok
290
+ */
291
+ async trackEvent(eventName: string, properties?: Record<string, any>): Promise<void> {
292
+ if (!this.available || !this.initialized) return;
293
+ if (this.config?.enableAppEvents === false) return;
294
+
295
+ try {
296
+ await TikTokNativeBridge.trackEvent(eventName, undefined, properties || {});
297
+ this.log(`TikTok event logged: ${eventName}`);
298
+ } catch (error) {
299
+ this.logError('Failed to log TikTok event:', error);
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Identify user for improved attribution matching
305
+ */
306
+ async identify(email?: string, phone?: string, externalId?: string): Promise<void> {
307
+ if (!this.available || !this.initialized) return;
308
+
309
+ // Only call identify if we have at least one value
310
+ if (!email && !phone && !externalId) return;
311
+
312
+ try {
313
+ await TikTokNativeBridge.identify(externalId, email, phone);
314
+ this.log('TikTok user identification set');
315
+ } catch (error) {
316
+ this.logError('Failed to identify TikTok user:', error);
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Clear user session (call on logout)
322
+ */
323
+ async logout(): Promise<void> {
324
+ if (!this.available || !this.initialized) return;
325
+
326
+ try {
327
+ await TikTokNativeBridge.logout();
328
+ this.log('TikTok user logged out');
329
+ } catch (error) {
330
+ this.logError('Failed to logout TikTok user:', error);
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Check if TikTok SDK is available and initialized
336
+ */
337
+ isAvailable(): boolean {
338
+ return this.available && this.initialized;
339
+ }
340
+
341
+ /**
342
+ * Check if TikTok SDK native module is installed
343
+ */
344
+ isInstalled(): boolean {
345
+ return this.available;
346
+ }
347
+
348
+ private log(message: string, data?: any): void {
349
+ if (this.debug) {
350
+ console.log(`[Datalyr/TikTok] ${message}`, data || '');
351
+ }
352
+ }
353
+
354
+ private logError(message: string, error: any): void {
355
+ console.error(`[Datalyr/TikTok] ${message}`, error);
356
+ }
357
+ }
358
+
359
+ // Export singleton instance
360
+ export const tiktokIntegration = new TikTokIntegration();
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Native Bridge for Meta, TikTok, and Apple Search Ads
3
+ * Uses bundled native modules instead of separate npm packages
4
+ */
5
+
6
+ import { NativeModules, Platform } from 'react-native';
7
+
8
+ /**
9
+ * Apple Search Ads attribution data returned from AdServices API
10
+ */
11
+ export interface AppleSearchAdsAttribution {
12
+ attribution: boolean;
13
+ orgId?: number;
14
+ orgName?: string;
15
+ campaignId?: number;
16
+ campaignName?: string;
17
+ adGroupId?: number;
18
+ adGroupName?: string;
19
+ keywordId?: number;
20
+ keyword?: string;
21
+ clickDate?: string;
22
+ conversionType?: string;
23
+ countryOrRegion?: string;
24
+ }
25
+
26
+ interface DatalyrNativeModule {
27
+ // Meta SDK Methods
28
+ initializeMetaSDK(
29
+ appId: string,
30
+ clientToken: string | null,
31
+ advertiserTrackingEnabled: boolean
32
+ ): Promise<boolean>;
33
+ fetchDeferredAppLink(): Promise<string | null>;
34
+ logMetaEvent(
35
+ eventName: string,
36
+ valueToSum: number | null,
37
+ parameters: Record<string, any> | null
38
+ ): Promise<boolean>;
39
+ logMetaPurchase(
40
+ amount: number,
41
+ currency: string,
42
+ parameters: Record<string, any> | null
43
+ ): Promise<boolean>;
44
+ setMetaUserData(userData: Record<string, string | undefined>): Promise<boolean>;
45
+ clearMetaUserData(): Promise<boolean>;
46
+ updateMetaTrackingAuthorization(enabled: boolean): Promise<boolean>;
47
+
48
+ // TikTok SDK Methods
49
+ initializeTikTokSDK(
50
+ appId: string,
51
+ tiktokAppId: string,
52
+ accessToken: string | null,
53
+ debug: boolean
54
+ ): Promise<boolean>;
55
+ trackTikTokEvent(
56
+ eventName: string,
57
+ eventId: string | null,
58
+ properties: Record<string, any> | null
59
+ ): Promise<boolean>;
60
+ identifyTikTokUser(
61
+ externalId: string,
62
+ externalUserName: string,
63
+ phoneNumber: string,
64
+ email: string
65
+ ): Promise<boolean>;
66
+ logoutTikTok(): Promise<boolean>;
67
+ updateTikTokTrackingAuthorization(enabled: boolean): Promise<boolean>;
68
+
69
+ // Apple Search Ads Methods
70
+ getAppleSearchAdsAttribution(): Promise<AppleSearchAdsAttribution | null>;
71
+
72
+ // SDK Availability
73
+ getSDKAvailability(): Promise<{ meta: boolean; tiktok: boolean; appleSearchAds: boolean }>;
74
+ }
75
+
76
+ // Native module is only available on iOS
77
+ const DatalyrNative: DatalyrNativeModule | null =
78
+ Platform.OS === 'ios' ? NativeModules.DatalyrNative : null;
79
+
80
+ /**
81
+ * Check if native module is available
82
+ */
83
+ export const isNativeModuleAvailable = (): boolean => {
84
+ return DatalyrNative !== null;
85
+ };
86
+
87
+ /**
88
+ * Get SDK availability status
89
+ */
90
+ export const getSDKAvailability = async (): Promise<{
91
+ meta: boolean;
92
+ tiktok: boolean;
93
+ appleSearchAds: boolean;
94
+ }> => {
95
+ if (!DatalyrNative) {
96
+ return { meta: false, tiktok: false, appleSearchAds: false };
97
+ }
98
+
99
+ try {
100
+ return await DatalyrNative.getSDKAvailability();
101
+ } catch {
102
+ return { meta: false, tiktok: false, appleSearchAds: false };
103
+ }
104
+ };
105
+
106
+ // MARK: - Meta SDK Bridge
107
+
108
+ export const MetaNativeBridge = {
109
+ async initialize(
110
+ appId: string,
111
+ clientToken?: string,
112
+ advertiserTrackingEnabled: boolean = false
113
+ ): Promise<boolean> {
114
+ if (!DatalyrNative) return false;
115
+
116
+ try {
117
+ return await DatalyrNative.initializeMetaSDK(
118
+ appId,
119
+ clientToken || null,
120
+ advertiserTrackingEnabled
121
+ );
122
+ } catch (error) {
123
+ console.error('[Datalyr/MetaNative] Initialize failed:', error);
124
+ return false;
125
+ }
126
+ },
127
+
128
+ async fetchDeferredAppLink(): Promise<string | null> {
129
+ if (!DatalyrNative) return null;
130
+
131
+ try {
132
+ return await DatalyrNative.fetchDeferredAppLink();
133
+ } catch {
134
+ return null;
135
+ }
136
+ },
137
+
138
+ async logEvent(
139
+ eventName: string,
140
+ valueToSum?: number,
141
+ parameters?: Record<string, any>
142
+ ): Promise<boolean> {
143
+ if (!DatalyrNative) return false;
144
+
145
+ try {
146
+ return await DatalyrNative.logMetaEvent(
147
+ eventName,
148
+ valueToSum ?? null,
149
+ parameters || null
150
+ );
151
+ } catch (error) {
152
+ console.error('[Datalyr/MetaNative] Log event failed:', error);
153
+ return false;
154
+ }
155
+ },
156
+
157
+ async logPurchase(
158
+ amount: number,
159
+ currency: string,
160
+ parameters?: Record<string, any>
161
+ ): Promise<boolean> {
162
+ if (!DatalyrNative) return false;
163
+
164
+ try {
165
+ return await DatalyrNative.logMetaPurchase(amount, currency, parameters || null);
166
+ } catch (error) {
167
+ console.error('[Datalyr/MetaNative] Log purchase failed:', error);
168
+ return false;
169
+ }
170
+ },
171
+
172
+ async setUserData(userData: Record<string, string | undefined>): Promise<boolean> {
173
+ if (!DatalyrNative) return false;
174
+
175
+ try {
176
+ return await DatalyrNative.setMetaUserData(userData);
177
+ } catch (error) {
178
+ console.error('[Datalyr/MetaNative] Set user data failed:', error);
179
+ return false;
180
+ }
181
+ },
182
+
183
+ async clearUserData(): Promise<boolean> {
184
+ if (!DatalyrNative) return false;
185
+
186
+ try {
187
+ return await DatalyrNative.clearMetaUserData();
188
+ } catch (error) {
189
+ console.error('[Datalyr/MetaNative] Clear user data failed:', error);
190
+ return false;
191
+ }
192
+ },
193
+
194
+ async updateTrackingAuthorization(enabled: boolean): Promise<boolean> {
195
+ if (!DatalyrNative) return false;
196
+
197
+ try {
198
+ return await DatalyrNative.updateMetaTrackingAuthorization(enabled);
199
+ } catch (error) {
200
+ console.error('[Datalyr/MetaNative] Update tracking failed:', error);
201
+ return false;
202
+ }
203
+ },
204
+ };
205
+
206
+ // MARK: - TikTok SDK Bridge
207
+
208
+ export const TikTokNativeBridge = {
209
+ async initialize(
210
+ appId: string,
211
+ tiktokAppId: string,
212
+ accessToken?: string,
213
+ debug: boolean = false
214
+ ): Promise<boolean> {
215
+ if (!DatalyrNative) return false;
216
+
217
+ try {
218
+ return await DatalyrNative.initializeTikTokSDK(
219
+ appId,
220
+ tiktokAppId,
221
+ accessToken || null,
222
+ debug
223
+ );
224
+ } catch (error) {
225
+ console.error('[Datalyr/TikTokNative] Initialize failed:', error);
226
+ return false;
227
+ }
228
+ },
229
+
230
+ async trackEvent(
231
+ eventName: string,
232
+ eventId?: string,
233
+ properties?: Record<string, any>
234
+ ): Promise<boolean> {
235
+ if (!DatalyrNative) return false;
236
+
237
+ try {
238
+ return await DatalyrNative.trackTikTokEvent(
239
+ eventName,
240
+ eventId || null,
241
+ properties || null
242
+ );
243
+ } catch (error) {
244
+ console.error('[Datalyr/TikTokNative] Track event failed:', error);
245
+ return false;
246
+ }
247
+ },
248
+
249
+ async identify(
250
+ externalId?: string,
251
+ email?: string,
252
+ phone?: string
253
+ ): Promise<boolean> {
254
+ if (!DatalyrNative) return false;
255
+
256
+ // Only call if we have at least one value
257
+ if (!externalId && !email && !phone) return false;
258
+
259
+ try {
260
+ return await DatalyrNative.identifyTikTokUser(
261
+ externalId || '',
262
+ '', // externalUserName - not typically available
263
+ phone || '',
264
+ email || ''
265
+ );
266
+ } catch (error) {
267
+ console.error('[Datalyr/TikTokNative] Identify failed:', error);
268
+ return false;
269
+ }
270
+ },
271
+
272
+ async logout(): Promise<boolean> {
273
+ if (!DatalyrNative) return false;
274
+
275
+ try {
276
+ return await DatalyrNative.logoutTikTok();
277
+ } catch (error) {
278
+ console.error('[Datalyr/TikTokNative] Logout failed:', error);
279
+ return false;
280
+ }
281
+ },
282
+
283
+ async updateTrackingAuthorization(enabled: boolean): Promise<boolean> {
284
+ if (!DatalyrNative) return false;
285
+
286
+ try {
287
+ return await DatalyrNative.updateTikTokTrackingAuthorization(enabled);
288
+ } catch (error) {
289
+ console.error('[Datalyr/TikTokNative] Update tracking failed:', error);
290
+ return false;
291
+ }
292
+ },
293
+ };
294
+
295
+ // MARK: - Apple Search Ads Bridge
296
+
297
+ export const AppleSearchAdsNativeBridge = {
298
+ /**
299
+ * Get Apple Search Ads attribution data
300
+ * Uses AdServices framework (iOS 14.3+)
301
+ * Returns null if user didn't come from Apple Search Ads or on older iOS
302
+ */
303
+ async getAttribution(): Promise<AppleSearchAdsAttribution | null> {
304
+ if (!DatalyrNative) return null;
305
+
306
+ try {
307
+ return await DatalyrNative.getAppleSearchAdsAttribution();
308
+ } catch (error) {
309
+ console.error('[Datalyr/AppleSearchAds] Get attribution failed:', error);
310
+ return null;
311
+ }
312
+ },
313
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Native Module Exports
3
+ */
4
+
5
+ export { SKAdNetworkBridge } from './SKAdNetworkBridge';
6
+ export {
7
+ isNativeModuleAvailable,
8
+ getSDKAvailability,
9
+ MetaNativeBridge,
10
+ TikTokNativeBridge,
11
+ } from './DatalyrNativeBridge';