@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
|
@@ -1,283 +1,17 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
|
-
import FBSDKCoreKit
|
|
3
|
-
import TikTokBusinessSDK
|
|
4
2
|
import AdServices
|
|
5
3
|
import AppTrackingTransparency
|
|
6
4
|
import AdSupport
|
|
7
5
|
|
|
8
6
|
public class DatalyrNativeModule: Module {
|
|
9
|
-
private var tiktokInitialized = false
|
|
10
|
-
private var metaInitialized = false
|
|
11
7
|
|
|
12
8
|
public func definition() -> ModuleDefinition {
|
|
13
9
|
Name("DatalyrNative")
|
|
14
10
|
|
|
15
|
-
// MARK: - Meta (Facebook) SDK Methods
|
|
16
|
-
|
|
17
|
-
AsyncFunction("initializeMetaSDK") { (appId: String, clientToken: String?, advertiserTrackingEnabled: Bool, promise: Promise) in
|
|
18
|
-
DispatchQueue.main.async { [weak self] in
|
|
19
|
-
Settings.shared.appID = appId
|
|
20
|
-
|
|
21
|
-
if let token = clientToken, !token.isEmpty {
|
|
22
|
-
Settings.shared.clientToken = token
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
Settings.shared.isAdvertiserTrackingEnabled = advertiserTrackingEnabled
|
|
26
|
-
Settings.shared.isAdvertiserIDCollectionEnabled = advertiserTrackingEnabled
|
|
27
|
-
|
|
28
|
-
var initError: NSError?
|
|
29
|
-
let success = DatalyrObjCExceptionCatcher.tryBlock({
|
|
30
|
-
ApplicationDelegate.shared.application(
|
|
31
|
-
UIApplication.shared,
|
|
32
|
-
didFinishLaunchingWithOptions: nil
|
|
33
|
-
)
|
|
34
|
-
}, error: &initError)
|
|
35
|
-
|
|
36
|
-
if success {
|
|
37
|
-
self?.metaInitialized = true
|
|
38
|
-
promise.resolve(true)
|
|
39
|
-
} else {
|
|
40
|
-
let message = initError?.localizedDescription ?? "Unknown ObjC exception during Meta SDK init"
|
|
41
|
-
promise.reject("meta_init_error", message)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
AsyncFunction("fetchDeferredAppLink") { (promise: Promise) in
|
|
47
|
-
DispatchQueue.main.async {
|
|
48
|
-
AppLinkUtility.fetchDeferredAppLink { url, error in
|
|
49
|
-
if error != nil {
|
|
50
|
-
promise.resolve(nil)
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if let url = url {
|
|
55
|
-
promise.resolve(url.absoluteString)
|
|
56
|
-
} else {
|
|
57
|
-
promise.resolve(nil)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
AsyncFunction("logMetaEvent") { (eventName: String, valueToSum: Double?, parameters: [String: Any]?, promise: Promise) in
|
|
64
|
-
guard self.metaInitialized else {
|
|
65
|
-
promise.reject("meta_not_initialized", "Meta SDK not initialized. Call initializeMetaSDK first.")
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
DispatchQueue.main.async {
|
|
70
|
-
var params: [AppEvents.ParameterName: Any] = [:]
|
|
71
|
-
|
|
72
|
-
if let dict = parameters {
|
|
73
|
-
for (key, value) in dict {
|
|
74
|
-
params[AppEvents.ParameterName(key)] = value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var logError: NSError?
|
|
79
|
-
DatalyrObjCExceptionCatcher.tryBlock({
|
|
80
|
-
if let value = valueToSum {
|
|
81
|
-
AppEvents.shared.logEvent(AppEvents.Name(eventName), valueToSum: value, parameters: params)
|
|
82
|
-
} else if params.isEmpty {
|
|
83
|
-
AppEvents.shared.logEvent(AppEvents.Name(eventName))
|
|
84
|
-
} else {
|
|
85
|
-
AppEvents.shared.logEvent(AppEvents.Name(eventName), parameters: params)
|
|
86
|
-
}
|
|
87
|
-
}, error: &logError)
|
|
88
|
-
|
|
89
|
-
if let logError = logError {
|
|
90
|
-
promise.reject("meta_event_error", logError.localizedDescription)
|
|
91
|
-
} else {
|
|
92
|
-
promise.resolve(true)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
AsyncFunction("logMetaPurchase") { (amount: Double, currency: String, parameters: [String: Any]?, promise: Promise) in
|
|
98
|
-
guard self.metaInitialized else {
|
|
99
|
-
promise.reject("meta_not_initialized", "Meta SDK not initialized. Call initializeMetaSDK first.")
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
DispatchQueue.main.async {
|
|
104
|
-
var params: [AppEvents.ParameterName: Any] = [:]
|
|
105
|
-
|
|
106
|
-
if let dict = parameters {
|
|
107
|
-
for (key, value) in dict {
|
|
108
|
-
params[AppEvents.ParameterName(key)] = value
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var logError: NSError?
|
|
113
|
-
DatalyrObjCExceptionCatcher.tryBlock({
|
|
114
|
-
AppEvents.shared.logPurchase(amount: amount, currency: currency, parameters: params)
|
|
115
|
-
}, error: &logError)
|
|
116
|
-
|
|
117
|
-
if let logError = logError {
|
|
118
|
-
promise.reject("meta_event_error", logError.localizedDescription)
|
|
119
|
-
} else {
|
|
120
|
-
promise.resolve(true)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
AsyncFunction("setMetaUserData") { (userData: [String: Any], promise: Promise) in
|
|
126
|
-
guard self.metaInitialized else {
|
|
127
|
-
promise.reject("meta_not_initialized", "Meta SDK not initialized. Call initializeMetaSDK first.")
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
DispatchQueue.main.async {
|
|
132
|
-
if let email = userData["email"] as? String { AppEvents.shared.setUserData(email, forType: .email) }
|
|
133
|
-
if let firstName = userData["firstName"] as? String { AppEvents.shared.setUserData(firstName, forType: .firstName) }
|
|
134
|
-
if let lastName = userData["lastName"] as? String { AppEvents.shared.setUserData(lastName, forType: .lastName) }
|
|
135
|
-
if let phone = userData["phone"] as? String { AppEvents.shared.setUserData(phone, forType: .phone) }
|
|
136
|
-
if let dateOfBirth = userData["dateOfBirth"] as? String { AppEvents.shared.setUserData(dateOfBirth, forType: .dateOfBirth) }
|
|
137
|
-
if let gender = userData["gender"] as? String { AppEvents.shared.setUserData(gender, forType: .gender) }
|
|
138
|
-
if let city = userData["city"] as? String { AppEvents.shared.setUserData(city, forType: .city) }
|
|
139
|
-
if let state = userData["state"] as? String { AppEvents.shared.setUserData(state, forType: .state) }
|
|
140
|
-
if let zip = userData["zip"] as? String { AppEvents.shared.setUserData(zip, forType: .zip) }
|
|
141
|
-
if let country = userData["country"] as? String { AppEvents.shared.setUserData(country, forType: .country) }
|
|
142
|
-
|
|
143
|
-
promise.resolve(true)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
AsyncFunction("clearMetaUserData") { (promise: Promise) in
|
|
148
|
-
guard self.metaInitialized else {
|
|
149
|
-
promise.reject("meta_not_initialized", "Meta SDK not initialized. Call initializeMetaSDK first.")
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
DispatchQueue.main.async {
|
|
154
|
-
AppEvents.shared.clearUserData()
|
|
155
|
-
promise.resolve(true)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
AsyncFunction("updateMetaTrackingAuthorization") { (enabled: Bool, promise: Promise) in
|
|
160
|
-
guard self.metaInitialized else {
|
|
161
|
-
promise.reject("meta_not_initialized", "Meta SDK not initialized. Call initializeMetaSDK first.")
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
DispatchQueue.main.async {
|
|
166
|
-
Settings.shared.isAdvertiserTrackingEnabled = enabled
|
|
167
|
-
Settings.shared.isAdvertiserIDCollectionEnabled = enabled
|
|
168
|
-
promise.resolve(true)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// MARK: - TikTok SDK Methods
|
|
173
|
-
|
|
174
|
-
AsyncFunction("initializeTikTokSDK") { (appId: String, tiktokAppId: String, accessToken: String?, debug: Bool, promise: Promise) in
|
|
175
|
-
DispatchQueue.main.async { [weak self] in
|
|
176
|
-
guard let token = accessToken, !token.isEmpty else {
|
|
177
|
-
promise.reject("tiktok_init_error", "TikTok accessToken is required. The deprecated init without accessToken has been removed.")
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
let config = TikTokConfig(accessToken: token, appId: appId, tiktokAppId: tiktokAppId)
|
|
182
|
-
|
|
183
|
-
if debug {
|
|
184
|
-
config?.setLogLevel(TikTokLogLevelDebug)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
guard let validConfig = config else {
|
|
188
|
-
promise.reject("tiktok_init_error", "Failed to create TikTok config")
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
var initError: NSError?
|
|
193
|
-
let success = DatalyrObjCExceptionCatcher.tryBlock({
|
|
194
|
-
TikTokBusiness.initializeSdk(validConfig)
|
|
195
|
-
}, error: &initError)
|
|
196
|
-
|
|
197
|
-
if success {
|
|
198
|
-
self?.tiktokInitialized = true
|
|
199
|
-
promise.resolve(true)
|
|
200
|
-
} else {
|
|
201
|
-
let message = initError?.localizedDescription ?? "Unknown ObjC exception during TikTok SDK init"
|
|
202
|
-
promise.reject("tiktok_init_error", message)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
AsyncFunction("trackTikTokEvent") { (eventName: String, eventId: String?, properties: [String: Any]?, promise: Promise) in
|
|
208
|
-
guard self.tiktokInitialized else {
|
|
209
|
-
promise.reject("tiktok_not_initialized", "TikTok SDK not initialized. Call initializeTikTokSDK first.")
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
DispatchQueue.main.async {
|
|
214
|
-
let event: TikTokBaseEvent
|
|
215
|
-
|
|
216
|
-
if let eid = eventId, !eid.isEmpty {
|
|
217
|
-
event = TikTokBaseEvent(eventName: eventName, eventId: eid)
|
|
218
|
-
} else {
|
|
219
|
-
event = TikTokBaseEvent(eventName: eventName)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if let dict = properties {
|
|
223
|
-
for (key, value) in dict {
|
|
224
|
-
event.addProperty(withKey: key, value: value)
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
var trackError: NSError?
|
|
229
|
-
DatalyrObjCExceptionCatcher.tryBlock({
|
|
230
|
-
TikTokBusiness.trackTTEvent(event)
|
|
231
|
-
}, error: &trackError)
|
|
232
|
-
|
|
233
|
-
if let trackError = trackError {
|
|
234
|
-
promise.reject("tiktok_event_error", trackError.localizedDescription)
|
|
235
|
-
} else {
|
|
236
|
-
promise.resolve(true)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
AsyncFunction("identifyTikTokUser") { (externalId: String, externalUserName: String, phoneNumber: String, email: String, promise: Promise) in
|
|
242
|
-
guard self.tiktokInitialized else {
|
|
243
|
-
promise.reject("tiktok_not_initialized", "TikTok SDK not initialized. Call initializeTikTokSDK first.")
|
|
244
|
-
return
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
DispatchQueue.main.async {
|
|
248
|
-
TikTokBusiness.identify(
|
|
249
|
-
withExternalID: externalId.isEmpty ? nil : externalId,
|
|
250
|
-
externalUserName: externalUserName.isEmpty ? nil : externalUserName,
|
|
251
|
-
phoneNumber: phoneNumber.isEmpty ? nil : phoneNumber,
|
|
252
|
-
email: email.isEmpty ? nil : email
|
|
253
|
-
)
|
|
254
|
-
promise.resolve(true)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
AsyncFunction("logoutTikTok") { (promise: Promise) in
|
|
259
|
-
guard self.tiktokInitialized else {
|
|
260
|
-
promise.reject("tiktok_not_initialized", "TikTok SDK not initialized. Call initializeTikTokSDK first.")
|
|
261
|
-
return
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
DispatchQueue.main.async {
|
|
265
|
-
TikTokBusiness.logout()
|
|
266
|
-
promise.resolve(true)
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
AsyncFunction("updateTikTokTrackingAuthorization") { (enabled: Bool, promise: Promise) in
|
|
271
|
-
// TikTok SDK handles ATT automatically, but we track the change
|
|
272
|
-
promise.resolve(true)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
11
|
// MARK: - SDK Availability Check
|
|
276
12
|
|
|
277
13
|
AsyncFunction("getSDKAvailability") { (promise: Promise) in
|
|
278
14
|
promise.resolve([
|
|
279
|
-
"meta": true,
|
|
280
|
-
"tiktok": true,
|
|
281
15
|
"appleSearchAds": true
|
|
282
16
|
])
|
|
283
17
|
}
|
package/lib/datalyr-sdk.d.ts
CHANGED
|
@@ -162,8 +162,6 @@ export declare class DatalyrSDK {
|
|
|
162
162
|
* Get platform integration status
|
|
163
163
|
*/
|
|
164
164
|
getPlatformIntegrationStatus(): {
|
|
165
|
-
meta: boolean;
|
|
166
|
-
tiktok: boolean;
|
|
167
165
|
appleSearchAds: boolean;
|
|
168
166
|
playInstallReferrer: boolean;
|
|
169
167
|
};
|
|
@@ -178,7 +176,17 @@ export declare class DatalyrSDK {
|
|
|
178
176
|
*/
|
|
179
177
|
getPlayInstallReferrer(): Record<string, any> | null;
|
|
180
178
|
/**
|
|
181
|
-
*
|
|
179
|
+
* Get attribution data formatted for Superwall's setUserAttributes()
|
|
180
|
+
* Returns a flat Record<string, string> with only non-empty values
|
|
181
|
+
*/
|
|
182
|
+
getSuperwallAttributes(): Record<string, string>;
|
|
183
|
+
/**
|
|
184
|
+
* Get attribution data formatted for RevenueCat's Purchases.setAttributes()
|
|
185
|
+
* Returns a flat Record<string, string> with $-prefixed reserved keys
|
|
186
|
+
*/
|
|
187
|
+
getRevenueCatAttributes(): Record<string, string>;
|
|
188
|
+
/**
|
|
189
|
+
* Update tracking authorization status
|
|
182
190
|
* Call this AFTER the user responds to the ATT permission dialog
|
|
183
191
|
*/
|
|
184
192
|
updateTrackingAuthorization(enabled: boolean): Promise<void>;
|
|
@@ -276,11 +284,12 @@ export declare class Datalyr {
|
|
|
276
284
|
static trackAddPaymentInfo(success?: boolean): Promise<void>;
|
|
277
285
|
static getDeferredAttributionData(): DeferredDeepLinkResult | null;
|
|
278
286
|
static getPlatformIntegrationStatus(): {
|
|
279
|
-
meta: boolean;
|
|
280
|
-
tiktok: boolean;
|
|
281
287
|
appleSearchAds: boolean;
|
|
288
|
+
playInstallReferrer: boolean;
|
|
282
289
|
};
|
|
283
290
|
static getAppleSearchAdsAttribution(): AppleSearchAdsAttribution | null;
|
|
284
291
|
static updateTrackingAuthorization(enabled: boolean): Promise<void>;
|
|
292
|
+
static getSuperwallAttributes(): Record<string, string>;
|
|
293
|
+
static getRevenueCatAttributes(): Record<string, string>;
|
|
285
294
|
}
|
|
286
295
|
export default datalyr;
|