@datalyr/react-native 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +3 -131
- package/android/build.gradle +0 -7
- package/android/src/main/java/com/datalyr/reactnative/DatalyrNativeModule.java +2 -380
- package/android/src/main/java/com/datalyr/reactnative/DatalyrPackage.java +1 -1
- package/datalyr-react-native.podspec +3 -7
- package/expo-module.config.json +4 -1
- package/ios/DatalyrNativeModule.swift +0 -266
- package/lib/datalyr-sdk.d.ts +1 -4
- package/lib/datalyr-sdk.js +7 -143
- package/lib/http-client.js +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/integrations/index.d.ts +3 -4
- package/lib/integrations/index.js +3 -4
- package/lib/native/DatalyrNativeBridge.d.ts +6 -22
- package/lib/native/DatalyrNativeBridge.js +6 -147
- package/lib/native/index.d.ts +1 -1
- package/lib/native/index.js +1 -1
- package/lib/types.d.ts +1 -19
- package/package.json +3 -5
- package/src/datalyr-sdk-expo.ts +6 -141
- package/src/datalyr-sdk.ts +8 -173
- package/src/http-client.ts +2 -2
- package/src/index.ts +1 -1
- package/src/integrations/index.ts +3 -4
- package/src/native/DatalyrNativeBridge.ts +6 -241
- package/src/native/index.ts +0 -2
- package/src/types.ts +2 -25
- package/src/utils-expo.ts +2 -2
- package/ios/DatalyrObjCExceptionCatcher.h +0 -14
- package/ios/DatalyrObjCExceptionCatcher.m +0 -30
- package/lib/integrations/meta-integration.d.ts +0 -77
- package/lib/integrations/meta-integration.js +0 -219
- package/lib/integrations/tiktok-integration.d.ts +0 -83
- package/lib/integrations/tiktok-integration.js +0 -360
- package/src/integrations/meta-integration.ts +0 -239
- package/src/integrations/tiktok-integration.ts +0 -363
package/src/datalyr-sdk.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { journeyManager } from './journey';
|
|
|
31
31
|
import { createAutoEventsManager, AutoEventsManager, SessionData } from './auto-events';
|
|
32
32
|
import { ConversionValueEncoder, ConversionTemplates } from './ConversionValueEncoder';
|
|
33
33
|
import { SKAdNetworkBridge } from './native/SKAdNetworkBridge';
|
|
34
|
-
import {
|
|
34
|
+
import { appleSearchAdsIntegration, playInstallReferrerIntegration } from './integrations';
|
|
35
35
|
import { AppleSearchAdsAttribution, AdvertiserInfoBridge } from './native/DatalyrNativeBridge';
|
|
36
36
|
import { networkStatusManager } from './network-status';
|
|
37
37
|
|
|
@@ -199,28 +199,6 @@ export class DatalyrSDK {
|
|
|
199
199
|
playInstallReferrerIntegration.initialize(),
|
|
200
200
|
];
|
|
201
201
|
|
|
202
|
-
// Add Meta initialization if configured
|
|
203
|
-
if (config.meta?.appId) {
|
|
204
|
-
platformInitPromises.push(
|
|
205
|
-
metaIntegration.initialize(config.meta, config.debug).then(async () => {
|
|
206
|
-
// After Meta initializes, fetch deferred deep link
|
|
207
|
-
if (config.enableAttribution !== false) {
|
|
208
|
-
const deferredLink = await metaIntegration.fetchDeferredDeepLink();
|
|
209
|
-
if (deferredLink) {
|
|
210
|
-
await this.handleDeferredDeepLink(deferredLink);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Add TikTok initialization if configured
|
|
218
|
-
if (config.tiktok?.appId && config.tiktok?.tiktokAppId) {
|
|
219
|
-
platformInitPromises.push(
|
|
220
|
-
tiktokIntegration.initialize(config.tiktok, config.debug)
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
202
|
// Wait for all platform integrations to complete
|
|
225
203
|
await Promise.all(platformInitPromises);
|
|
226
204
|
|
|
@@ -232,8 +210,6 @@ export class DatalyrSDK {
|
|
|
232
210
|
}
|
|
233
211
|
|
|
234
212
|
debugLog('Platform integrations initialized', {
|
|
235
|
-
meta: metaIntegration.isAvailable(),
|
|
236
|
-
tiktok: tiktokIntegration.isAvailable(),
|
|
237
213
|
appleSearchAds: appleSearchAdsIntegration.isAvailable(),
|
|
238
214
|
playInstallReferrer: playInstallReferrerIntegration.isAvailable(),
|
|
239
215
|
});
|
|
@@ -252,7 +228,7 @@ export class DatalyrSDK {
|
|
|
252
228
|
const installData = await attributionManager.trackInstall();
|
|
253
229
|
await this.track('app_install', {
|
|
254
230
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
255
|
-
sdk_version: '1.
|
|
231
|
+
sdk_version: '1.6.0',
|
|
256
232
|
...installData,
|
|
257
233
|
});
|
|
258
234
|
}
|
|
@@ -361,31 +337,6 @@ export class DatalyrSDK {
|
|
|
361
337
|
const dateOfBirth = (properties?.date_of_birth || properties?.dob || properties?.birthday) as string | undefined;
|
|
362
338
|
const gender = properties?.gender as string | undefined;
|
|
363
339
|
const city = properties?.city as string | undefined;
|
|
364
|
-
const state = properties?.state as string | undefined;
|
|
365
|
-
const zip = (properties?.zip || properties?.postal_code || properties?.zipcode) as string | undefined;
|
|
366
|
-
const country = properties?.country as string | undefined;
|
|
367
|
-
|
|
368
|
-
// Meta Advanced Matching
|
|
369
|
-
if (metaIntegration.isAvailable()) {
|
|
370
|
-
metaIntegration.setUserData({
|
|
371
|
-
email,
|
|
372
|
-
firstName,
|
|
373
|
-
lastName,
|
|
374
|
-
phone,
|
|
375
|
-
dateOfBirth,
|
|
376
|
-
gender,
|
|
377
|
-
city,
|
|
378
|
-
state,
|
|
379
|
-
zip,
|
|
380
|
-
country,
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// TikTok identification
|
|
385
|
-
if (tiktokIntegration.isAvailable()) {
|
|
386
|
-
tiktokIntegration.identify(email, phone, userId);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
340
|
} catch (error) {
|
|
390
341
|
errorLog('Error identifying user:', error as Error);
|
|
391
342
|
}
|
|
@@ -589,11 +540,6 @@ export class DatalyrSDK {
|
|
|
589
540
|
// Generate new session
|
|
590
541
|
this.state.sessionId = await getOrCreateSessionId();
|
|
591
542
|
|
|
592
|
-
// Clear user data from platform SDKs
|
|
593
|
-
if (metaIntegration.isAvailable()) {
|
|
594
|
-
metaIntegration.clearUserData();
|
|
595
|
-
}
|
|
596
|
-
|
|
597
543
|
debugLog('User data reset completed');
|
|
598
544
|
|
|
599
545
|
} catch (error) {
|
|
@@ -773,16 +719,6 @@ export class DatalyrSDK {
|
|
|
773
719
|
if (productId) properties.product_id = productId;
|
|
774
720
|
|
|
775
721
|
await this.trackWithSKAdNetwork('purchase', properties);
|
|
776
|
-
|
|
777
|
-
// Forward to Meta if available
|
|
778
|
-
if (metaIntegration.isAvailable()) {
|
|
779
|
-
metaIntegration.logPurchase(value, currency, { fb_content_id: productId });
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// Forward to TikTok if available
|
|
783
|
-
if (tiktokIntegration.isAvailable()) {
|
|
784
|
-
tiktokIntegration.logPurchase(value, currency, productId, 'product');
|
|
785
|
-
}
|
|
786
722
|
}
|
|
787
723
|
|
|
788
724
|
/**
|
|
@@ -797,16 +733,6 @@ export class DatalyrSDK {
|
|
|
797
733
|
if (plan) properties.plan = plan;
|
|
798
734
|
|
|
799
735
|
await this.trackWithSKAdNetwork('subscribe', properties);
|
|
800
|
-
|
|
801
|
-
// Forward to Meta if available
|
|
802
|
-
if (metaIntegration.isAvailable()) {
|
|
803
|
-
metaIntegration.logEvent('Subscribe', value, { subscription_plan: plan });
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// Forward to TikTok if available
|
|
807
|
-
if (tiktokIntegration.isAvailable()) {
|
|
808
|
-
tiktokIntegration.logSubscription(value, currency, plan);
|
|
809
|
-
}
|
|
810
736
|
}
|
|
811
737
|
|
|
812
738
|
// MARK: - Standard E-commerce Events
|
|
@@ -825,20 +751,6 @@ export class DatalyrSDK {
|
|
|
825
751
|
if (productName) properties.product_name = productName;
|
|
826
752
|
|
|
827
753
|
await this.trackWithSKAdNetwork('add_to_cart', properties);
|
|
828
|
-
|
|
829
|
-
// Forward to Meta
|
|
830
|
-
if (metaIntegration.isAvailable()) {
|
|
831
|
-
metaIntegration.logEvent('AddToCart', value, {
|
|
832
|
-
currency,
|
|
833
|
-
content_ids: productId ? [productId] : undefined,
|
|
834
|
-
content_name: productName,
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// Forward to TikTok
|
|
839
|
-
if (tiktokIntegration.isAvailable()) {
|
|
840
|
-
tiktokIntegration.logAddToCart(value, currency, productId, 'product');
|
|
841
|
-
}
|
|
842
754
|
}
|
|
843
755
|
|
|
844
756
|
/**
|
|
@@ -858,21 +770,6 @@ export class DatalyrSDK {
|
|
|
858
770
|
if (currency) properties.currency = currency;
|
|
859
771
|
|
|
860
772
|
await this.track('view_content', properties);
|
|
861
|
-
|
|
862
|
-
// Forward to Meta
|
|
863
|
-
if (metaIntegration.isAvailable()) {
|
|
864
|
-
metaIntegration.logEvent('ViewContent', value, {
|
|
865
|
-
content_ids: contentId ? [contentId] : undefined,
|
|
866
|
-
content_name: contentName,
|
|
867
|
-
content_type: contentType,
|
|
868
|
-
currency,
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
// Forward to TikTok
|
|
873
|
-
if (tiktokIntegration.isAvailable()) {
|
|
874
|
-
tiktokIntegration.logViewContent(contentId, contentName, contentType);
|
|
875
|
-
}
|
|
876
773
|
}
|
|
877
774
|
|
|
878
775
|
/**
|
|
@@ -889,20 +786,6 @@ export class DatalyrSDK {
|
|
|
889
786
|
if (productIds) properties.product_ids = productIds;
|
|
890
787
|
|
|
891
788
|
await this.trackWithSKAdNetwork('initiate_checkout', properties);
|
|
892
|
-
|
|
893
|
-
// Forward to Meta
|
|
894
|
-
if (metaIntegration.isAvailable()) {
|
|
895
|
-
metaIntegration.logEvent('InitiateCheckout', value, {
|
|
896
|
-
currency,
|
|
897
|
-
num_items: numItems,
|
|
898
|
-
content_ids: productIds,
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
// Forward to TikTok
|
|
903
|
-
if (tiktokIntegration.isAvailable()) {
|
|
904
|
-
tiktokIntegration.logInitiateCheckout(value, currency, numItems);
|
|
905
|
-
}
|
|
906
789
|
}
|
|
907
790
|
|
|
908
791
|
/**
|
|
@@ -913,16 +796,6 @@ export class DatalyrSDK {
|
|
|
913
796
|
if (method) properties.method = method;
|
|
914
797
|
|
|
915
798
|
await this.trackWithSKAdNetwork('complete_registration', properties);
|
|
916
|
-
|
|
917
|
-
// Forward to Meta
|
|
918
|
-
if (metaIntegration.isAvailable()) {
|
|
919
|
-
metaIntegration.logEvent('CompleteRegistration', undefined, { registration_method: method });
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
// Forward to TikTok
|
|
923
|
-
if (tiktokIntegration.isAvailable()) {
|
|
924
|
-
tiktokIntegration.logCompleteRegistration(method);
|
|
925
|
-
}
|
|
926
799
|
}
|
|
927
800
|
|
|
928
801
|
/**
|
|
@@ -933,19 +806,6 @@ export class DatalyrSDK {
|
|
|
933
806
|
if (resultIds) properties.result_ids = resultIds;
|
|
934
807
|
|
|
935
808
|
await this.track('search', properties);
|
|
936
|
-
|
|
937
|
-
// Forward to Meta
|
|
938
|
-
if (metaIntegration.isAvailable()) {
|
|
939
|
-
metaIntegration.logEvent('Search', undefined, {
|
|
940
|
-
search_string: query,
|
|
941
|
-
content_ids: resultIds,
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
// Forward to TikTok
|
|
946
|
-
if (tiktokIntegration.isAvailable()) {
|
|
947
|
-
tiktokIntegration.logSearch(query);
|
|
948
|
-
}
|
|
949
809
|
}
|
|
950
810
|
|
|
951
811
|
/**
|
|
@@ -957,16 +817,6 @@ export class DatalyrSDK {
|
|
|
957
817
|
if (currency) properties.currency = currency;
|
|
958
818
|
|
|
959
819
|
await this.trackWithSKAdNetwork('lead', properties);
|
|
960
|
-
|
|
961
|
-
// Forward to Meta
|
|
962
|
-
if (metaIntegration.isAvailable()) {
|
|
963
|
-
metaIntegration.logEvent('Lead', value, { currency });
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
// Forward to TikTok
|
|
967
|
-
if (tiktokIntegration.isAvailable()) {
|
|
968
|
-
tiktokIntegration.logLead(value, currency);
|
|
969
|
-
}
|
|
970
820
|
}
|
|
971
821
|
|
|
972
822
|
/**
|
|
@@ -974,16 +824,6 @@ export class DatalyrSDK {
|
|
|
974
824
|
*/
|
|
975
825
|
async trackAddPaymentInfo(success = true): Promise<void> {
|
|
976
826
|
await this.track('add_payment_info', { success });
|
|
977
|
-
|
|
978
|
-
// Forward to Meta
|
|
979
|
-
if (metaIntegration.isAvailable()) {
|
|
980
|
-
metaIntegration.logEvent('AddPaymentInfo', undefined, { success: success ? 1 : 0 });
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
// Forward to TikTok
|
|
984
|
-
if (tiktokIntegration.isAvailable()) {
|
|
985
|
-
tiktokIntegration.logAddPaymentInfo(success);
|
|
986
|
-
}
|
|
987
827
|
}
|
|
988
828
|
|
|
989
829
|
// MARK: - Platform Integration Methods
|
|
@@ -992,16 +832,14 @@ export class DatalyrSDK {
|
|
|
992
832
|
* Get deferred attribution data from platform SDKs
|
|
993
833
|
*/
|
|
994
834
|
getDeferredAttributionData(): DeferredDeepLinkResult | null {
|
|
995
|
-
return
|
|
835
|
+
return null;
|
|
996
836
|
}
|
|
997
837
|
|
|
998
838
|
/**
|
|
999
839
|
* Get platform integration status
|
|
1000
840
|
*/
|
|
1001
|
-
getPlatformIntegrationStatus(): {
|
|
841
|
+
getPlatformIntegrationStatus(): { appleSearchAds: boolean; playInstallReferrer: boolean } {
|
|
1002
842
|
return {
|
|
1003
|
-
meta: metaIntegration.isAvailable(),
|
|
1004
|
-
tiktok: tiktokIntegration.isAvailable(),
|
|
1005
843
|
appleSearchAds: appleSearchAdsIntegration.isAvailable(),
|
|
1006
844
|
playInstallReferrer: playInstallReferrerIntegration.isAvailable(),
|
|
1007
845
|
};
|
|
@@ -1034,9 +872,6 @@ export class DatalyrSDK {
|
|
|
1034
872
|
return;
|
|
1035
873
|
}
|
|
1036
874
|
|
|
1037
|
-
metaIntegration.updateTrackingAuthorization(enabled);
|
|
1038
|
-
tiktokIntegration.updateTrackingAuthorization(enabled);
|
|
1039
|
-
|
|
1040
875
|
// Refresh cached advertiser info after ATT status change
|
|
1041
876
|
try {
|
|
1042
877
|
this.cachedAdvertiserInfo = await AdvertiserInfoBridge.getAdvertiserInfo();
|
|
@@ -1156,8 +991,8 @@ export class DatalyrSDK {
|
|
|
1156
991
|
carrier: deviceInfo.carrier,
|
|
1157
992
|
network_type: getNetworkType(),
|
|
1158
993
|
timestamp: Date.now(),
|
|
1159
|
-
sdk_version: '1.
|
|
1160
|
-
// Advertiser data (IDFA/GAID, ATT status) for
|
|
994
|
+
sdk_version: '1.6.0',
|
|
995
|
+
// Advertiser data (IDFA/GAID, ATT status) for server-side postback
|
|
1161
996
|
...(advertiserInfo ? {
|
|
1162
997
|
idfa: advertiserInfo.idfa,
|
|
1163
998
|
idfv: advertiserInfo.idfv,
|
|
@@ -1468,7 +1303,7 @@ export class Datalyr {
|
|
|
1468
1303
|
datalyr.updateAutoEventsConfig(config);
|
|
1469
1304
|
}
|
|
1470
1305
|
|
|
1471
|
-
// Standard e-commerce events
|
|
1306
|
+
// Standard e-commerce events
|
|
1472
1307
|
static async trackAddToCart(
|
|
1473
1308
|
value: number,
|
|
1474
1309
|
currency = 'USD',
|
|
@@ -1518,7 +1353,7 @@ export class Datalyr {
|
|
|
1518
1353
|
return datalyr.getDeferredAttributionData();
|
|
1519
1354
|
}
|
|
1520
1355
|
|
|
1521
|
-
static getPlatformIntegrationStatus(): {
|
|
1356
|
+
static getPlatformIntegrationStatus(): { appleSearchAds: boolean; playInstallReferrer: boolean } {
|
|
1522
1357
|
return datalyr.getPlatformIntegrationStatus();
|
|
1523
1358
|
}
|
|
1524
1359
|
|
package/src/http-client.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class HttpClient {
|
|
|
72
72
|
|
|
73
73
|
const headers: Record<string, string> = {
|
|
74
74
|
'Content-Type': 'application/json',
|
|
75
|
-
'User-Agent': `@datalyr/react-native/1.
|
|
75
|
+
'User-Agent': `@datalyr/react-native/1.5.0`,
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// Server-side tracking uses X-API-Key header
|
|
@@ -197,7 +197,7 @@ export class HttpClient {
|
|
|
197
197
|
},
|
|
198
198
|
context: {
|
|
199
199
|
library: '@datalyr/react-native',
|
|
200
|
-
version: '1.
|
|
200
|
+
version: '1.5.0',
|
|
201
201
|
source: 'mobile_app', // Explicitly set source for mobile
|
|
202
202
|
userProperties: payload.userProperties,
|
|
203
203
|
},
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { ConversionValueEncoder, ConversionTemplates } from './ConversionValueEn
|
|
|
29
29
|
export { SKAdNetworkBridge } from './native/SKAdNetworkBridge';
|
|
30
30
|
|
|
31
31
|
// Export platform integrations
|
|
32
|
-
export {
|
|
32
|
+
export { appleSearchAdsIntegration, playInstallReferrerIntegration } from './integrations';
|
|
33
33
|
|
|
34
34
|
// Export network status manager
|
|
35
35
|
export { networkStatusManager } from './network-status';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Platform
|
|
3
|
-
*
|
|
2
|
+
* Platform Integrations
|
|
3
|
+
* Apple Search Ads and Google Play Install Referrer
|
|
4
|
+
* Conversion routing to Meta/TikTok/Google is handled server-side via postback.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
export { MetaIntegration, metaIntegration } from './meta-integration';
|
|
7
|
-
export { TikTokIntegration, tiktokIntegration } from './tiktok-integration';
|
|
8
7
|
export { AppleSearchAdsIntegration, appleSearchAdsIntegration } from './apple-search-ads-integration';
|
|
9
8
|
export { playInstallReferrerIntegration } from './play-install-referrer';
|
|
10
9
|
export type { PlayInstallReferrer } from './play-install-referrer';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Native Bridge for
|
|
3
|
-
*
|
|
2
|
+
* Native Bridge for Apple Search Ads, Play Install Referrer, and Advertiser Info
|
|
3
|
+
*
|
|
4
|
+
* Conversion event routing to ad platforms (Meta, TikTok, Google) is handled
|
|
5
|
+
* server-side via the postback system — no client-side ad SDKs needed.
|
|
4
6
|
*
|
|
5
7
|
* Supported Platforms:
|
|
6
|
-
* - iOS:
|
|
7
|
-
* - Android:
|
|
8
|
+
* - iOS: Apple Search Ads (AdServices), IDFA/ATT
|
|
9
|
+
* - Android: Play Install Referrer, GAID
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
import { NativeModules, Platform } from 'react-native';
|
|
@@ -48,48 +50,6 @@ export interface PlayInstallReferrerData {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
interface DatalyrNativeModule {
|
|
51
|
-
// Meta SDK Methods
|
|
52
|
-
initializeMetaSDK(
|
|
53
|
-
appId: string,
|
|
54
|
-
clientToken: string | null,
|
|
55
|
-
advertiserTrackingEnabled: boolean
|
|
56
|
-
): Promise<boolean>;
|
|
57
|
-
fetchDeferredAppLink(): Promise<string | null>;
|
|
58
|
-
logMetaEvent(
|
|
59
|
-
eventName: string,
|
|
60
|
-
valueToSum: number | null,
|
|
61
|
-
parameters: Record<string, any> | null
|
|
62
|
-
): Promise<boolean>;
|
|
63
|
-
logMetaPurchase(
|
|
64
|
-
amount: number,
|
|
65
|
-
currency: string,
|
|
66
|
-
parameters: Record<string, any> | null
|
|
67
|
-
): Promise<boolean>;
|
|
68
|
-
setMetaUserData(userData: Record<string, string | undefined>): Promise<boolean>;
|
|
69
|
-
clearMetaUserData(): Promise<boolean>;
|
|
70
|
-
updateMetaTrackingAuthorization(enabled: boolean): Promise<boolean>;
|
|
71
|
-
|
|
72
|
-
// TikTok SDK Methods
|
|
73
|
-
initializeTikTokSDK(
|
|
74
|
-
appId: string,
|
|
75
|
-
tiktokAppId: string,
|
|
76
|
-
accessToken: string | null,
|
|
77
|
-
debug: boolean
|
|
78
|
-
): Promise<boolean>;
|
|
79
|
-
trackTikTokEvent(
|
|
80
|
-
eventName: string,
|
|
81
|
-
eventId: string | null,
|
|
82
|
-
properties: Record<string, any> | null
|
|
83
|
-
): Promise<boolean>;
|
|
84
|
-
identifyTikTokUser(
|
|
85
|
-
externalId: string,
|
|
86
|
-
externalUserName: string,
|
|
87
|
-
phoneNumber: string,
|
|
88
|
-
email: string
|
|
89
|
-
): Promise<boolean>;
|
|
90
|
-
logoutTikTok(): Promise<boolean>;
|
|
91
|
-
updateTikTokTrackingAuthorization(enabled: boolean): Promise<boolean>;
|
|
92
|
-
|
|
93
53
|
// Advertiser Info (IDFA, IDFV, GAID, ATT Status)
|
|
94
54
|
getAdvertiserInfo(): Promise<{
|
|
95
55
|
idfa?: string;
|
|
@@ -104,8 +64,6 @@ interface DatalyrNativeModule {
|
|
|
104
64
|
|
|
105
65
|
// SDK Availability
|
|
106
66
|
getSDKAvailability(): Promise<{
|
|
107
|
-
meta: boolean;
|
|
108
|
-
tiktok: boolean;
|
|
109
67
|
appleSearchAds: boolean;
|
|
110
68
|
playInstallReferrer?: boolean;
|
|
111
69
|
}>;
|
|
@@ -146,14 +104,10 @@ export const isNativeModuleAvailable = (): boolean => {
|
|
|
146
104
|
* Get SDK availability status for all platforms
|
|
147
105
|
*/
|
|
148
106
|
export const getSDKAvailability = async (): Promise<{
|
|
149
|
-
meta: boolean;
|
|
150
|
-
tiktok: boolean;
|
|
151
107
|
appleSearchAds: boolean;
|
|
152
108
|
playInstallReferrer: boolean;
|
|
153
109
|
}> => {
|
|
154
110
|
const defaultAvailability = {
|
|
155
|
-
meta: false,
|
|
156
|
-
tiktok: false,
|
|
157
111
|
appleSearchAds: false,
|
|
158
112
|
playInstallReferrer: false,
|
|
159
113
|
};
|
|
@@ -174,195 +128,6 @@ export const getSDKAvailability = async (): Promise<{
|
|
|
174
128
|
}
|
|
175
129
|
};
|
|
176
130
|
|
|
177
|
-
// MARK: - Meta SDK Bridge
|
|
178
|
-
|
|
179
|
-
export const MetaNativeBridge = {
|
|
180
|
-
async initialize(
|
|
181
|
-
appId: string,
|
|
182
|
-
clientToken?: string,
|
|
183
|
-
advertiserTrackingEnabled: boolean = false
|
|
184
|
-
): Promise<boolean> {
|
|
185
|
-
if (!DatalyrNative) return false;
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
return await DatalyrNative.initializeMetaSDK(
|
|
189
|
-
appId,
|
|
190
|
-
clientToken || null,
|
|
191
|
-
advertiserTrackingEnabled
|
|
192
|
-
);
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.error('[Datalyr/MetaNative] Initialize failed:', error);
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
async fetchDeferredAppLink(): Promise<string | null> {
|
|
200
|
-
if (!DatalyrNative) return null;
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
return await DatalyrNative.fetchDeferredAppLink();
|
|
204
|
-
} catch {
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
async logEvent(
|
|
210
|
-
eventName: string,
|
|
211
|
-
valueToSum?: number,
|
|
212
|
-
parameters?: Record<string, any>
|
|
213
|
-
): Promise<boolean> {
|
|
214
|
-
if (!DatalyrNative) return false;
|
|
215
|
-
|
|
216
|
-
try {
|
|
217
|
-
return await DatalyrNative.logMetaEvent(
|
|
218
|
-
eventName,
|
|
219
|
-
valueToSum ?? null,
|
|
220
|
-
parameters || null
|
|
221
|
-
);
|
|
222
|
-
} catch (error) {
|
|
223
|
-
console.error('[Datalyr/MetaNative] Log event failed:', error);
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
async logPurchase(
|
|
229
|
-
amount: number,
|
|
230
|
-
currency: string,
|
|
231
|
-
parameters?: Record<string, any>
|
|
232
|
-
): Promise<boolean> {
|
|
233
|
-
if (!DatalyrNative) return false;
|
|
234
|
-
|
|
235
|
-
try {
|
|
236
|
-
return await DatalyrNative.logMetaPurchase(amount, currency, parameters || null);
|
|
237
|
-
} catch (error) {
|
|
238
|
-
console.error('[Datalyr/MetaNative] Log purchase failed:', error);
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
async setUserData(userData: Record<string, string | undefined>): Promise<boolean> {
|
|
244
|
-
if (!DatalyrNative) return false;
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
return await DatalyrNative.setMetaUserData(userData);
|
|
248
|
-
} catch (error) {
|
|
249
|
-
console.error('[Datalyr/MetaNative] Set user data failed:', error);
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
async clearUserData(): Promise<boolean> {
|
|
255
|
-
if (!DatalyrNative) return false;
|
|
256
|
-
|
|
257
|
-
try {
|
|
258
|
-
return await DatalyrNative.clearMetaUserData();
|
|
259
|
-
} catch (error) {
|
|
260
|
-
console.error('[Datalyr/MetaNative] Clear user data failed:', error);
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
async updateTrackingAuthorization(enabled: boolean): Promise<boolean> {
|
|
266
|
-
if (!DatalyrNative) return false;
|
|
267
|
-
|
|
268
|
-
try {
|
|
269
|
-
return await DatalyrNative.updateMetaTrackingAuthorization(enabled);
|
|
270
|
-
} catch (error) {
|
|
271
|
-
console.error('[Datalyr/MetaNative] Update tracking failed:', error);
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// MARK: - TikTok SDK Bridge
|
|
278
|
-
|
|
279
|
-
export const TikTokNativeBridge = {
|
|
280
|
-
async initialize(
|
|
281
|
-
appId: string,
|
|
282
|
-
tiktokAppId: string,
|
|
283
|
-
accessToken?: string,
|
|
284
|
-
debug: boolean = false
|
|
285
|
-
): Promise<boolean> {
|
|
286
|
-
if (!DatalyrNative) return false;
|
|
287
|
-
|
|
288
|
-
try {
|
|
289
|
-
return await DatalyrNative.initializeTikTokSDK(
|
|
290
|
-
appId,
|
|
291
|
-
tiktokAppId,
|
|
292
|
-
accessToken || null,
|
|
293
|
-
debug
|
|
294
|
-
);
|
|
295
|
-
} catch (error) {
|
|
296
|
-
console.error('[Datalyr/TikTokNative] Initialize failed:', error);
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
async trackEvent(
|
|
302
|
-
eventName: string,
|
|
303
|
-
eventId?: string,
|
|
304
|
-
properties?: Record<string, any>
|
|
305
|
-
): Promise<boolean> {
|
|
306
|
-
if (!DatalyrNative) return false;
|
|
307
|
-
|
|
308
|
-
try {
|
|
309
|
-
return await DatalyrNative.trackTikTokEvent(
|
|
310
|
-
eventName,
|
|
311
|
-
eventId || null,
|
|
312
|
-
properties || null
|
|
313
|
-
);
|
|
314
|
-
} catch (error) {
|
|
315
|
-
console.error('[Datalyr/TikTokNative] Track event failed:', error);
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
async identify(
|
|
321
|
-
externalId?: string,
|
|
322
|
-
email?: string,
|
|
323
|
-
phone?: string
|
|
324
|
-
): Promise<boolean> {
|
|
325
|
-
if (!DatalyrNative) return false;
|
|
326
|
-
|
|
327
|
-
// Only call if we have at least one value
|
|
328
|
-
if (!externalId && !email && !phone) return false;
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
return await DatalyrNative.identifyTikTokUser(
|
|
332
|
-
externalId || '',
|
|
333
|
-
'', // externalUserName - not typically available
|
|
334
|
-
phone || '',
|
|
335
|
-
email || ''
|
|
336
|
-
);
|
|
337
|
-
} catch (error) {
|
|
338
|
-
console.error('[Datalyr/TikTokNative] Identify failed:', error);
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
async logout(): Promise<boolean> {
|
|
344
|
-
if (!DatalyrNative) return false;
|
|
345
|
-
|
|
346
|
-
try {
|
|
347
|
-
return await DatalyrNative.logoutTikTok();
|
|
348
|
-
} catch (error) {
|
|
349
|
-
console.error('[Datalyr/TikTokNative] Logout failed:', error);
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
async updateTrackingAuthorization(enabled: boolean): Promise<boolean> {
|
|
355
|
-
if (!DatalyrNative) return false;
|
|
356
|
-
|
|
357
|
-
try {
|
|
358
|
-
return await DatalyrNative.updateTikTokTrackingAuthorization(enabled);
|
|
359
|
-
} catch (error) {
|
|
360
|
-
console.error('[Datalyr/TikTokNative] Update tracking failed:', error);
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
|
|
366
131
|
// MARK: - Apple Search Ads Bridge (iOS only)
|
|
367
132
|
|
|
368
133
|
export const AppleSearchAdsNativeBridge = {
|
package/src/native/index.ts
CHANGED
|
@@ -6,8 +6,6 @@ export { SKAdNetworkBridge } from './SKAdNetworkBridge';
|
|
|
6
6
|
export {
|
|
7
7
|
isNativeModuleAvailable,
|
|
8
8
|
getSDKAvailability,
|
|
9
|
-
MetaNativeBridge,
|
|
10
|
-
TikTokNativeBridge,
|
|
11
9
|
AdvertiserInfoBridge,
|
|
12
10
|
} from './DatalyrNativeBridge';
|
|
13
11
|
export type { AdvertiserInfo } from './DatalyrNativeBridge';
|