@datalyr/react-native 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +82 -121
- 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 +14 -5
- package/lib/datalyr-sdk.js +90 -144
- 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 +5 -19
- package/package.json +3 -5
- package/src/datalyr-sdk-expo.ts +96 -140
- package/src/datalyr-sdk.ts +102 -174
- 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 +11 -26
- 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/lib/datalyr-sdk.js
CHANGED
|
@@ -7,7 +7,7 @@ import { journeyManager } from './journey';
|
|
|
7
7
|
import { AutoEventsManager } from './auto-events';
|
|
8
8
|
import { ConversionValueEncoder, ConversionTemplates } from './ConversionValueEncoder';
|
|
9
9
|
import { SKAdNetworkBridge } from './native/SKAdNetworkBridge';
|
|
10
|
-
import {
|
|
10
|
+
import { appleSearchAdsIntegration, playInstallReferrerIntegration } from './integrations';
|
|
11
11
|
import { AdvertiserInfoBridge } from './native/DatalyrNativeBridge';
|
|
12
12
|
import { networkStatusManager } from './network-status';
|
|
13
13
|
export class DatalyrSDK {
|
|
@@ -49,7 +49,7 @@ export class DatalyrSDK {
|
|
|
49
49
|
* Initialize the SDK with configuration
|
|
50
50
|
*/
|
|
51
51
|
async initialize(config) {
|
|
52
|
-
var _a
|
|
52
|
+
var _a;
|
|
53
53
|
try {
|
|
54
54
|
debugLog('Initializing Datalyr SDK...', { workspaceId: config.workspaceId });
|
|
55
55
|
// Validate configuration
|
|
@@ -152,22 +152,6 @@ export class DatalyrSDK {
|
|
|
152
152
|
// Google Play Install Referrer (Android only)
|
|
153
153
|
playInstallReferrerIntegration.initialize(),
|
|
154
154
|
];
|
|
155
|
-
// Add Meta initialization if configured
|
|
156
|
-
if ((_b = config.meta) === null || _b === void 0 ? void 0 : _b.appId) {
|
|
157
|
-
platformInitPromises.push(metaIntegration.initialize(config.meta, config.debug).then(async () => {
|
|
158
|
-
// After Meta initializes, fetch deferred deep link
|
|
159
|
-
if (config.enableAttribution !== false) {
|
|
160
|
-
const deferredLink = await metaIntegration.fetchDeferredDeepLink();
|
|
161
|
-
if (deferredLink) {
|
|
162
|
-
await this.handleDeferredDeepLink(deferredLink);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
// Add TikTok initialization if configured
|
|
168
|
-
if (((_c = config.tiktok) === null || _c === void 0 ? void 0 : _c.appId) && ((_d = config.tiktok) === null || _d === void 0 ? void 0 : _d.tiktokAppId)) {
|
|
169
|
-
platformInitPromises.push(tiktokIntegration.initialize(config.tiktok, config.debug));
|
|
170
|
-
}
|
|
171
155
|
// Wait for all platform integrations to complete
|
|
172
156
|
await Promise.all(platformInitPromises);
|
|
173
157
|
// Cache advertiser info (IDFA/GAID, ATT status) once at init to avoid per-event native bridge calls
|
|
@@ -178,8 +162,6 @@ export class DatalyrSDK {
|
|
|
178
162
|
errorLog('Failed to cache advertiser info:', error);
|
|
179
163
|
}
|
|
180
164
|
debugLog('Platform integrations initialized', {
|
|
181
|
-
meta: metaIntegration.isAvailable(),
|
|
182
|
-
tiktok: tiktokIntegration.isAvailable(),
|
|
183
165
|
appleSearchAds: appleSearchAdsIntegration.isAvailable(),
|
|
184
166
|
playInstallReferrer: playInstallReferrerIntegration.isAvailable(),
|
|
185
167
|
});
|
|
@@ -195,7 +177,7 @@ export class DatalyrSDK {
|
|
|
195
177
|
const installData = await attributionManager.trackInstall();
|
|
196
178
|
await this.track('app_install', {
|
|
197
179
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
198
|
-
sdk_version: '1.
|
|
180
|
+
sdk_version: '1.6.1',
|
|
199
181
|
...installData,
|
|
200
182
|
});
|
|
201
183
|
}
|
|
@@ -287,28 +269,6 @@ export class DatalyrSDK {
|
|
|
287
269
|
const dateOfBirth = ((properties === null || properties === void 0 ? void 0 : properties.date_of_birth) || (properties === null || properties === void 0 ? void 0 : properties.dob) || (properties === null || properties === void 0 ? void 0 : properties.birthday));
|
|
288
270
|
const gender = properties === null || properties === void 0 ? void 0 : properties.gender;
|
|
289
271
|
const city = properties === null || properties === void 0 ? void 0 : properties.city;
|
|
290
|
-
const state = properties === null || properties === void 0 ? void 0 : properties.state;
|
|
291
|
-
const zip = ((properties === null || properties === void 0 ? void 0 : properties.zip) || (properties === null || properties === void 0 ? void 0 : properties.postal_code) || (properties === null || properties === void 0 ? void 0 : properties.zipcode));
|
|
292
|
-
const country = properties === null || properties === void 0 ? void 0 : properties.country;
|
|
293
|
-
// Meta Advanced Matching
|
|
294
|
-
if (metaIntegration.isAvailable()) {
|
|
295
|
-
metaIntegration.setUserData({
|
|
296
|
-
email,
|
|
297
|
-
firstName,
|
|
298
|
-
lastName,
|
|
299
|
-
phone,
|
|
300
|
-
dateOfBirth,
|
|
301
|
-
gender,
|
|
302
|
-
city,
|
|
303
|
-
state,
|
|
304
|
-
zip,
|
|
305
|
-
country,
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
// TikTok identification
|
|
309
|
-
if (tiktokIntegration.isAvailable()) {
|
|
310
|
-
tiktokIntegration.identify(email, phone, userId);
|
|
311
|
-
}
|
|
312
272
|
}
|
|
313
273
|
catch (error) {
|
|
314
274
|
errorLog('Error identifying user:', error);
|
|
@@ -483,10 +443,6 @@ export class DatalyrSDK {
|
|
|
483
443
|
await Storage.removeItem(STORAGE_KEYS.USER_PROPERTIES);
|
|
484
444
|
// Generate new session
|
|
485
445
|
this.state.sessionId = await getOrCreateSessionId();
|
|
486
|
-
// Clear user data from platform SDKs
|
|
487
|
-
if (metaIntegration.isAvailable()) {
|
|
488
|
-
metaIntegration.clearUserData();
|
|
489
|
-
}
|
|
490
446
|
debugLog('User data reset completed');
|
|
491
447
|
}
|
|
492
448
|
catch (error) {
|
|
@@ -632,14 +588,6 @@ export class DatalyrSDK {
|
|
|
632
588
|
if (productId)
|
|
633
589
|
properties.product_id = productId;
|
|
634
590
|
await this.trackWithSKAdNetwork('purchase', properties);
|
|
635
|
-
// Forward to Meta if available
|
|
636
|
-
if (metaIntegration.isAvailable()) {
|
|
637
|
-
metaIntegration.logPurchase(value, currency, { fb_content_id: productId });
|
|
638
|
-
}
|
|
639
|
-
// Forward to TikTok if available
|
|
640
|
-
if (tiktokIntegration.isAvailable()) {
|
|
641
|
-
tiktokIntegration.logPurchase(value, currency, productId, 'product');
|
|
642
|
-
}
|
|
643
591
|
}
|
|
644
592
|
/**
|
|
645
593
|
* Track subscription with automatic revenue encoding and platform forwarding
|
|
@@ -649,14 +597,6 @@ export class DatalyrSDK {
|
|
|
649
597
|
if (plan)
|
|
650
598
|
properties.plan = plan;
|
|
651
599
|
await this.trackWithSKAdNetwork('subscribe', properties);
|
|
652
|
-
// Forward to Meta if available
|
|
653
|
-
if (metaIntegration.isAvailable()) {
|
|
654
|
-
metaIntegration.logEvent('Subscribe', value, { subscription_plan: plan });
|
|
655
|
-
}
|
|
656
|
-
// Forward to TikTok if available
|
|
657
|
-
if (tiktokIntegration.isAvailable()) {
|
|
658
|
-
tiktokIntegration.logSubscription(value, currency, plan);
|
|
659
|
-
}
|
|
660
600
|
}
|
|
661
601
|
// MARK: - Standard E-commerce Events
|
|
662
602
|
/**
|
|
@@ -669,18 +609,6 @@ export class DatalyrSDK {
|
|
|
669
609
|
if (productName)
|
|
670
610
|
properties.product_name = productName;
|
|
671
611
|
await this.trackWithSKAdNetwork('add_to_cart', properties);
|
|
672
|
-
// Forward to Meta
|
|
673
|
-
if (metaIntegration.isAvailable()) {
|
|
674
|
-
metaIntegration.logEvent('AddToCart', value, {
|
|
675
|
-
currency,
|
|
676
|
-
content_ids: productId ? [productId] : undefined,
|
|
677
|
-
content_name: productName,
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
// Forward to TikTok
|
|
681
|
-
if (tiktokIntegration.isAvailable()) {
|
|
682
|
-
tiktokIntegration.logAddToCart(value, currency, productId, 'product');
|
|
683
|
-
}
|
|
684
612
|
}
|
|
685
613
|
/**
|
|
686
614
|
* Track view content/product event
|
|
@@ -696,19 +624,6 @@ export class DatalyrSDK {
|
|
|
696
624
|
if (currency)
|
|
697
625
|
properties.currency = currency;
|
|
698
626
|
await this.track('view_content', properties);
|
|
699
|
-
// Forward to Meta
|
|
700
|
-
if (metaIntegration.isAvailable()) {
|
|
701
|
-
metaIntegration.logEvent('ViewContent', value, {
|
|
702
|
-
content_ids: contentId ? [contentId] : undefined,
|
|
703
|
-
content_name: contentName,
|
|
704
|
-
content_type: contentType,
|
|
705
|
-
currency,
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
// Forward to TikTok
|
|
709
|
-
if (tiktokIntegration.isAvailable()) {
|
|
710
|
-
tiktokIntegration.logViewContent(contentId, contentName, contentType);
|
|
711
|
-
}
|
|
712
627
|
}
|
|
713
628
|
/**
|
|
714
629
|
* Track initiate checkout event
|
|
@@ -720,18 +635,6 @@ export class DatalyrSDK {
|
|
|
720
635
|
if (productIds)
|
|
721
636
|
properties.product_ids = productIds;
|
|
722
637
|
await this.trackWithSKAdNetwork('initiate_checkout', properties);
|
|
723
|
-
// Forward to Meta
|
|
724
|
-
if (metaIntegration.isAvailable()) {
|
|
725
|
-
metaIntegration.logEvent('InitiateCheckout', value, {
|
|
726
|
-
currency,
|
|
727
|
-
num_items: numItems,
|
|
728
|
-
content_ids: productIds,
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
// Forward to TikTok
|
|
732
|
-
if (tiktokIntegration.isAvailable()) {
|
|
733
|
-
tiktokIntegration.logInitiateCheckout(value, currency, numItems);
|
|
734
|
-
}
|
|
735
638
|
}
|
|
736
639
|
/**
|
|
737
640
|
* Track complete registration event
|
|
@@ -741,14 +644,6 @@ export class DatalyrSDK {
|
|
|
741
644
|
if (method)
|
|
742
645
|
properties.method = method;
|
|
743
646
|
await this.trackWithSKAdNetwork('complete_registration', properties);
|
|
744
|
-
// Forward to Meta
|
|
745
|
-
if (metaIntegration.isAvailable()) {
|
|
746
|
-
metaIntegration.logEvent('CompleteRegistration', undefined, { registration_method: method });
|
|
747
|
-
}
|
|
748
|
-
// Forward to TikTok
|
|
749
|
-
if (tiktokIntegration.isAvailable()) {
|
|
750
|
-
tiktokIntegration.logCompleteRegistration(method);
|
|
751
|
-
}
|
|
752
647
|
}
|
|
753
648
|
/**
|
|
754
649
|
* Track search event
|
|
@@ -758,17 +653,6 @@ export class DatalyrSDK {
|
|
|
758
653
|
if (resultIds)
|
|
759
654
|
properties.result_ids = resultIds;
|
|
760
655
|
await this.track('search', properties);
|
|
761
|
-
// Forward to Meta
|
|
762
|
-
if (metaIntegration.isAvailable()) {
|
|
763
|
-
metaIntegration.logEvent('Search', undefined, {
|
|
764
|
-
search_string: query,
|
|
765
|
-
content_ids: resultIds,
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
// Forward to TikTok
|
|
769
|
-
if (tiktokIntegration.isAvailable()) {
|
|
770
|
-
tiktokIntegration.logSearch(query);
|
|
771
|
-
}
|
|
772
656
|
}
|
|
773
657
|
/**
|
|
774
658
|
* Track lead/contact form submission
|
|
@@ -780,43 +664,25 @@ export class DatalyrSDK {
|
|
|
780
664
|
if (currency)
|
|
781
665
|
properties.currency = currency;
|
|
782
666
|
await this.trackWithSKAdNetwork('lead', properties);
|
|
783
|
-
// Forward to Meta
|
|
784
|
-
if (metaIntegration.isAvailable()) {
|
|
785
|
-
metaIntegration.logEvent('Lead', value, { currency });
|
|
786
|
-
}
|
|
787
|
-
// Forward to TikTok
|
|
788
|
-
if (tiktokIntegration.isAvailable()) {
|
|
789
|
-
tiktokIntegration.logLead(value, currency);
|
|
790
|
-
}
|
|
791
667
|
}
|
|
792
668
|
/**
|
|
793
669
|
* Track add payment info event
|
|
794
670
|
*/
|
|
795
671
|
async trackAddPaymentInfo(success = true) {
|
|
796
672
|
await this.track('add_payment_info', { success });
|
|
797
|
-
// Forward to Meta
|
|
798
|
-
if (metaIntegration.isAvailable()) {
|
|
799
|
-
metaIntegration.logEvent('AddPaymentInfo', undefined, { success: success ? 1 : 0 });
|
|
800
|
-
}
|
|
801
|
-
// Forward to TikTok
|
|
802
|
-
if (tiktokIntegration.isAvailable()) {
|
|
803
|
-
tiktokIntegration.logAddPaymentInfo(success);
|
|
804
|
-
}
|
|
805
673
|
}
|
|
806
674
|
// MARK: - Platform Integration Methods
|
|
807
675
|
/**
|
|
808
676
|
* Get deferred attribution data from platform SDKs
|
|
809
677
|
*/
|
|
810
678
|
getDeferredAttributionData() {
|
|
811
|
-
return
|
|
679
|
+
return null;
|
|
812
680
|
}
|
|
813
681
|
/**
|
|
814
682
|
* Get platform integration status
|
|
815
683
|
*/
|
|
816
684
|
getPlatformIntegrationStatus() {
|
|
817
685
|
return {
|
|
818
|
-
meta: metaIntegration.isAvailable(),
|
|
819
|
-
tiktok: tiktokIntegration.isAvailable(),
|
|
820
686
|
appleSearchAds: appleSearchAdsIntegration.isAvailable(),
|
|
821
687
|
playInstallReferrer: playInstallReferrerIntegration.isAvailable(),
|
|
822
688
|
};
|
|
@@ -836,8 +702,83 @@ export class DatalyrSDK {
|
|
|
836
702
|
const data = playInstallReferrerIntegration.getReferrerData();
|
|
837
703
|
return data ? playInstallReferrerIntegration.getAttributionData() : null;
|
|
838
704
|
}
|
|
705
|
+
// MARK: - Third-Party Integration Methods
|
|
839
706
|
/**
|
|
840
|
-
*
|
|
707
|
+
* Get attribution data formatted for Superwall's setUserAttributes()
|
|
708
|
+
* Returns a flat Record<string, string> with only non-empty values
|
|
709
|
+
*/
|
|
710
|
+
getSuperwallAttributes() {
|
|
711
|
+
const attribution = attributionManager.getAttributionData();
|
|
712
|
+
const advertiser = this.cachedAdvertiserInfo;
|
|
713
|
+
const attrs = {};
|
|
714
|
+
const set = (key, value) => {
|
|
715
|
+
if (value != null && String(value) !== '')
|
|
716
|
+
attrs[key] = String(value);
|
|
717
|
+
};
|
|
718
|
+
set('datalyr_id', this.state.visitorId);
|
|
719
|
+
set('media_source', attribution.utm_source);
|
|
720
|
+
set('campaign', attribution.utm_campaign);
|
|
721
|
+
set('adgroup', attribution.adset_id || attribution.utm_content);
|
|
722
|
+
set('ad', attribution.ad_id);
|
|
723
|
+
set('keyword', attribution.keyword);
|
|
724
|
+
set('network', attribution.network);
|
|
725
|
+
set('utm_source', attribution.utm_source);
|
|
726
|
+
set('utm_medium', attribution.utm_medium);
|
|
727
|
+
set('utm_campaign', attribution.utm_campaign);
|
|
728
|
+
set('utm_term', attribution.utm_term);
|
|
729
|
+
set('utm_content', attribution.utm_content);
|
|
730
|
+
set('lyr', attribution.lyr);
|
|
731
|
+
set('fbclid', attribution.fbclid);
|
|
732
|
+
set('gclid', attribution.gclid);
|
|
733
|
+
set('ttclid', attribution.ttclid);
|
|
734
|
+
set('idfa', advertiser === null || advertiser === void 0 ? void 0 : advertiser.idfa);
|
|
735
|
+
set('gaid', advertiser === null || advertiser === void 0 ? void 0 : advertiser.gaid);
|
|
736
|
+
set('att_status', advertiser === null || advertiser === void 0 ? void 0 : advertiser.att_status);
|
|
737
|
+
return attrs;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Get attribution data formatted for RevenueCat's Purchases.setAttributes()
|
|
741
|
+
* Returns a flat Record<string, string> with $-prefixed reserved keys
|
|
742
|
+
*/
|
|
743
|
+
getRevenueCatAttributes() {
|
|
744
|
+
const attribution = attributionManager.getAttributionData();
|
|
745
|
+
const advertiser = this.cachedAdvertiserInfo;
|
|
746
|
+
const attrs = {};
|
|
747
|
+
const set = (key, value) => {
|
|
748
|
+
if (value != null && String(value) !== '')
|
|
749
|
+
attrs[key] = String(value);
|
|
750
|
+
};
|
|
751
|
+
// Reserved attributes ($ prefix)
|
|
752
|
+
set('$datalyrId', this.state.visitorId);
|
|
753
|
+
set('$mediaSource', attribution.utm_source);
|
|
754
|
+
set('$campaign', attribution.utm_campaign);
|
|
755
|
+
set('$adGroup', attribution.adset_id);
|
|
756
|
+
set('$ad', attribution.ad_id);
|
|
757
|
+
set('$keyword', attribution.keyword);
|
|
758
|
+
set('$idfa', advertiser === null || advertiser === void 0 ? void 0 : advertiser.idfa);
|
|
759
|
+
set('$gpsAdId', advertiser === null || advertiser === void 0 ? void 0 : advertiser.gaid);
|
|
760
|
+
if ((advertiser === null || advertiser === void 0 ? void 0 : advertiser.att_status) != null) {
|
|
761
|
+
const statusMap = { 0: 'notDetermined', 1: 'restricted', 2: 'denied', 3: 'authorized' };
|
|
762
|
+
set('$attConsentStatus', statusMap[advertiser.att_status] || String(advertiser.att_status));
|
|
763
|
+
}
|
|
764
|
+
// Custom attributes
|
|
765
|
+
set('utm_source', attribution.utm_source);
|
|
766
|
+
set('utm_medium', attribution.utm_medium);
|
|
767
|
+
set('utm_campaign', attribution.utm_campaign);
|
|
768
|
+
set('utm_term', attribution.utm_term);
|
|
769
|
+
set('utm_content', attribution.utm_content);
|
|
770
|
+
set('lyr', attribution.lyr);
|
|
771
|
+
set('fbclid', attribution.fbclid);
|
|
772
|
+
set('gclid', attribution.gclid);
|
|
773
|
+
set('ttclid', attribution.ttclid);
|
|
774
|
+
set('wbraid', attribution.wbraid);
|
|
775
|
+
set('gbraid', attribution.gbraid);
|
|
776
|
+
set('network', attribution.network);
|
|
777
|
+
set('creative_id', attribution.creative_id);
|
|
778
|
+
return attrs;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Update tracking authorization status
|
|
841
782
|
* Call this AFTER the user responds to the ATT permission dialog
|
|
842
783
|
*/
|
|
843
784
|
async updateTrackingAuthorization(enabled) {
|
|
@@ -845,8 +786,6 @@ export class DatalyrSDK {
|
|
|
845
786
|
errorLog('SDK not initialized. Call initialize() first.');
|
|
846
787
|
return;
|
|
847
788
|
}
|
|
848
|
-
metaIntegration.updateTrackingAuthorization(enabled);
|
|
849
|
-
tiktokIntegration.updateTrackingAuthorization(enabled);
|
|
850
789
|
// Refresh cached advertiser info after ATT status change
|
|
851
790
|
try {
|
|
852
791
|
this.cachedAdvertiserInfo = await AdvertiserInfoBridge.getAdvertiserInfo();
|
|
@@ -957,8 +896,8 @@ export class DatalyrSDK {
|
|
|
957
896
|
carrier: deviceInfo.carrier,
|
|
958
897
|
network_type: getNetworkType(),
|
|
959
898
|
timestamp: Date.now(),
|
|
960
|
-
sdk_version: '1.
|
|
961
|
-
// Advertiser data (IDFA/GAID, ATT status) for
|
|
899
|
+
sdk_version: '1.6.1',
|
|
900
|
+
// Advertiser data (IDFA/GAID, ATT status) for server-side postback
|
|
962
901
|
...(advertiserInfo ? {
|
|
963
902
|
idfa: advertiserInfo.idfa,
|
|
964
903
|
idfv: advertiserInfo.idfv,
|
|
@@ -1218,7 +1157,7 @@ export class Datalyr {
|
|
|
1218
1157
|
static updateAutoEventsConfig(config) {
|
|
1219
1158
|
datalyr.updateAutoEventsConfig(config);
|
|
1220
1159
|
}
|
|
1221
|
-
// Standard e-commerce events
|
|
1160
|
+
// Standard e-commerce events
|
|
1222
1161
|
static async trackAddToCart(value, currency = 'USD', productId, productName) {
|
|
1223
1162
|
await datalyr.trackAddToCart(value, currency, productId, productName);
|
|
1224
1163
|
}
|
|
@@ -1253,6 +1192,13 @@ export class Datalyr {
|
|
|
1253
1192
|
static async updateTrackingAuthorization(enabled) {
|
|
1254
1193
|
await datalyr.updateTrackingAuthorization(enabled);
|
|
1255
1194
|
}
|
|
1195
|
+
// Third-party integration methods
|
|
1196
|
+
static getSuperwallAttributes() {
|
|
1197
|
+
return datalyr.getSuperwallAttributes();
|
|
1198
|
+
}
|
|
1199
|
+
static getRevenueCatAttributes() {
|
|
1200
|
+
return datalyr.getRevenueCatAttributes();
|
|
1201
|
+
}
|
|
1256
1202
|
}
|
|
1257
1203
|
// Export default instance for backward compatibility
|
|
1258
1204
|
export default datalyr;
|
package/lib/http-client.js
CHANGED
|
@@ -45,7 +45,7 @@ export class HttpClient {
|
|
|
45
45
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
46
46
|
const headers = {
|
|
47
47
|
'Content-Type': 'application/json',
|
|
48
|
-
'User-Agent': `@datalyr/react-native/1.
|
|
48
|
+
'User-Agent': `@datalyr/react-native/1.5.0`,
|
|
49
49
|
};
|
|
50
50
|
// Server-side tracking uses X-API-Key header
|
|
51
51
|
if (this.config.useServerTracking !== false) {
|
|
@@ -152,7 +152,7 @@ export class HttpClient {
|
|
|
152
152
|
},
|
|
153
153
|
context: {
|
|
154
154
|
library: '@datalyr/react-native',
|
|
155
|
-
version: '1.
|
|
155
|
+
version: '1.5.0',
|
|
156
156
|
source: 'mobile_app', // Explicitly set source for mobile
|
|
157
157
|
userProperties: payload.userProperties,
|
|
158
158
|
},
|
package/lib/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export * from './event-queue';
|
|
|
12
12
|
export { DatalyrSDK };
|
|
13
13
|
export { ConversionValueEncoder, ConversionTemplates } from './ConversionValueEncoder';
|
|
14
14
|
export { SKAdNetworkBridge } from './native/SKAdNetworkBridge';
|
|
15
|
-
export {
|
|
15
|
+
export { appleSearchAdsIntegration, playInstallReferrerIntegration } from './integrations';
|
|
16
16
|
export { networkStatusManager } from './network-status';
|
|
17
17
|
export type { NetworkState, NetworkStateListener } from './network-status';
|
|
18
18
|
export type { AppleSearchAdsAttribution } from './native/DatalyrNativeBridge';
|
package/lib/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export { DatalyrSDK };
|
|
|
20
20
|
export { ConversionValueEncoder, ConversionTemplates } from './ConversionValueEncoder';
|
|
21
21
|
export { SKAdNetworkBridge } from './native/SKAdNetworkBridge';
|
|
22
22
|
// Export platform integrations
|
|
23
|
-
export {
|
|
23
|
+
export { appleSearchAdsIntegration, playInstallReferrerIntegration } from './integrations';
|
|
24
24
|
// Export network status manager
|
|
25
25
|
export { networkStatusManager } from './network-status';
|
|
26
26
|
// Default export for compatibility
|
|
@@ -1,9 +1,8 @@
|
|
|
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
|
-
export { MetaIntegration, metaIntegration } from './meta-integration';
|
|
6
|
-
export { TikTokIntegration, tiktokIntegration } from './tiktok-integration';
|
|
7
6
|
export { AppleSearchAdsIntegration, appleSearchAdsIntegration } from './apple-search-ads-integration';
|
|
8
7
|
export { playInstallReferrerIntegration } from './play-install-referrer';
|
|
9
8
|
export type { PlayInstallReferrer } from './play-install-referrer';
|
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
export { MetaIntegration, metaIntegration } from './meta-integration';
|
|
6
|
-
export { TikTokIntegration, tiktokIntegration } from './tiktok-integration';
|
|
7
6
|
export { AppleSearchAdsIntegration, appleSearchAdsIntegration } from './apple-search-ads-integration';
|
|
8
7
|
export { playInstallReferrerIntegration } 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
|
* Apple Search Ads attribution data returned from AdServices API (iOS only)
|
|
@@ -49,27 +51,9 @@ export declare const isNativeModuleAvailable: () => boolean;
|
|
|
49
51
|
* Get SDK availability status for all platforms
|
|
50
52
|
*/
|
|
51
53
|
export declare const getSDKAvailability: () => Promise<{
|
|
52
|
-
meta: boolean;
|
|
53
|
-
tiktok: boolean;
|
|
54
54
|
appleSearchAds: boolean;
|
|
55
55
|
playInstallReferrer: boolean;
|
|
56
56
|
}>;
|
|
57
|
-
export declare const MetaNativeBridge: {
|
|
58
|
-
initialize(appId: string, clientToken?: string, advertiserTrackingEnabled?: boolean): Promise<boolean>;
|
|
59
|
-
fetchDeferredAppLink(): Promise<string | null>;
|
|
60
|
-
logEvent(eventName: string, valueToSum?: number, parameters?: Record<string, any>): Promise<boolean>;
|
|
61
|
-
logPurchase(amount: number, currency: string, parameters?: Record<string, any>): Promise<boolean>;
|
|
62
|
-
setUserData(userData: Record<string, string | undefined>): Promise<boolean>;
|
|
63
|
-
clearUserData(): Promise<boolean>;
|
|
64
|
-
updateTrackingAuthorization(enabled: boolean): Promise<boolean>;
|
|
65
|
-
};
|
|
66
|
-
export declare const TikTokNativeBridge: {
|
|
67
|
-
initialize(appId: string, tiktokAppId: string, accessToken?: string, debug?: boolean): Promise<boolean>;
|
|
68
|
-
trackEvent(eventName: string, eventId?: string, properties?: Record<string, any>): Promise<boolean>;
|
|
69
|
-
identify(externalId?: string, email?: string, phone?: string): Promise<boolean>;
|
|
70
|
-
logout(): Promise<boolean>;
|
|
71
|
-
updateTrackingAuthorization(enabled: boolean): Promise<boolean>;
|
|
72
|
-
};
|
|
73
57
|
export declare const AppleSearchAdsNativeBridge: {
|
|
74
58
|
/**
|
|
75
59
|
* Get Apple Search Ads attribution data
|
|
@@ -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
|
var _a, _b;
|
|
10
12
|
import { NativeModules, Platform } from 'react-native';
|
|
@@ -39,8 +41,6 @@ export const isNativeModuleAvailable = () => {
|
|
|
39
41
|
*/
|
|
40
42
|
export const getSDKAvailability = async () => {
|
|
41
43
|
const defaultAvailability = {
|
|
42
|
-
meta: false,
|
|
43
|
-
tiktok: false,
|
|
44
44
|
appleSearchAds: false,
|
|
45
45
|
playInstallReferrer: false,
|
|
46
46
|
};
|
|
@@ -59,147 +59,6 @@ export const getSDKAvailability = async () => {
|
|
|
59
59
|
return defaultAvailability;
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
// MARK: - Meta SDK Bridge
|
|
63
|
-
export const MetaNativeBridge = {
|
|
64
|
-
async initialize(appId, clientToken, advertiserTrackingEnabled = false) {
|
|
65
|
-
if (!DatalyrNative)
|
|
66
|
-
return false;
|
|
67
|
-
try {
|
|
68
|
-
return await DatalyrNative.initializeMetaSDK(appId, clientToken || null, advertiserTrackingEnabled);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.error('[Datalyr/MetaNative] Initialize failed:', error);
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
async fetchDeferredAppLink() {
|
|
76
|
-
if (!DatalyrNative)
|
|
77
|
-
return null;
|
|
78
|
-
try {
|
|
79
|
-
return await DatalyrNative.fetchDeferredAppLink();
|
|
80
|
-
}
|
|
81
|
-
catch (_a) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
async logEvent(eventName, valueToSum, parameters) {
|
|
86
|
-
if (!DatalyrNative)
|
|
87
|
-
return false;
|
|
88
|
-
try {
|
|
89
|
-
return await DatalyrNative.logMetaEvent(eventName, valueToSum !== null && valueToSum !== void 0 ? valueToSum : null, parameters || null);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
console.error('[Datalyr/MetaNative] Log event failed:', error);
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
async logPurchase(amount, currency, parameters) {
|
|
97
|
-
if (!DatalyrNative)
|
|
98
|
-
return false;
|
|
99
|
-
try {
|
|
100
|
-
return await DatalyrNative.logMetaPurchase(amount, currency, parameters || null);
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
console.error('[Datalyr/MetaNative] Log purchase failed:', error);
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
async setUserData(userData) {
|
|
108
|
-
if (!DatalyrNative)
|
|
109
|
-
return false;
|
|
110
|
-
try {
|
|
111
|
-
return await DatalyrNative.setMetaUserData(userData);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
console.error('[Datalyr/MetaNative] Set user data failed:', error);
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
async clearUserData() {
|
|
119
|
-
if (!DatalyrNative)
|
|
120
|
-
return false;
|
|
121
|
-
try {
|
|
122
|
-
return await DatalyrNative.clearMetaUserData();
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
console.error('[Datalyr/MetaNative] Clear user data failed:', error);
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
async updateTrackingAuthorization(enabled) {
|
|
130
|
-
if (!DatalyrNative)
|
|
131
|
-
return false;
|
|
132
|
-
try {
|
|
133
|
-
return await DatalyrNative.updateMetaTrackingAuthorization(enabled);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
console.error('[Datalyr/MetaNative] Update tracking failed:', error);
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
// MARK: - TikTok SDK Bridge
|
|
142
|
-
export const TikTokNativeBridge = {
|
|
143
|
-
async initialize(appId, tiktokAppId, accessToken, debug = false) {
|
|
144
|
-
if (!DatalyrNative)
|
|
145
|
-
return false;
|
|
146
|
-
try {
|
|
147
|
-
return await DatalyrNative.initializeTikTokSDK(appId, tiktokAppId, accessToken || null, debug);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
console.error('[Datalyr/TikTokNative] Initialize failed:', error);
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
async trackEvent(eventName, eventId, properties) {
|
|
155
|
-
if (!DatalyrNative)
|
|
156
|
-
return false;
|
|
157
|
-
try {
|
|
158
|
-
return await DatalyrNative.trackTikTokEvent(eventName, eventId || null, properties || null);
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
console.error('[Datalyr/TikTokNative] Track event failed:', error);
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
async identify(externalId, email, phone) {
|
|
166
|
-
if (!DatalyrNative)
|
|
167
|
-
return false;
|
|
168
|
-
// Only call if we have at least one value
|
|
169
|
-
if (!externalId && !email && !phone)
|
|
170
|
-
return false;
|
|
171
|
-
try {
|
|
172
|
-
return await DatalyrNative.identifyTikTokUser(externalId || '', '', // externalUserName - not typically available
|
|
173
|
-
phone || '', email || '');
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
console.error('[Datalyr/TikTokNative] Identify failed:', error);
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
async logout() {
|
|
181
|
-
if (!DatalyrNative)
|
|
182
|
-
return false;
|
|
183
|
-
try {
|
|
184
|
-
return await DatalyrNative.logoutTikTok();
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
console.error('[Datalyr/TikTokNative] Logout failed:', error);
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
async updateTrackingAuthorization(enabled) {
|
|
192
|
-
if (!DatalyrNative)
|
|
193
|
-
return false;
|
|
194
|
-
try {
|
|
195
|
-
return await DatalyrNative.updateTikTokTrackingAuthorization(enabled);
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
console.error('[Datalyr/TikTokNative] Update tracking failed:', error);
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
62
|
// MARK: - Apple Search Ads Bridge (iOS only)
|
|
204
63
|
export const AppleSearchAdsNativeBridge = {
|
|
205
64
|
/**
|
package/lib/native/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Native Module Exports
|
|
3
3
|
*/
|
|
4
4
|
export { SKAdNetworkBridge } from './SKAdNetworkBridge';
|
|
5
|
-
export { isNativeModuleAvailable, getSDKAvailability,
|
|
5
|
+
export { isNativeModuleAvailable, getSDKAvailability, AdvertiserInfoBridge, } from './DatalyrNativeBridge';
|
|
6
6
|
export type { AdvertiserInfo } from './DatalyrNativeBridge';
|