appsprint-react-native 0.2.0 → 1.0.4

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 (44) hide show
  1. package/README.md +173 -68
  2. package/android/build.gradle +4 -2
  3. package/android/libs/appsprint-sdk.aar +0 -0
  4. package/android/src/main/AndroidManifest.xml +2 -0
  5. package/android/src/main/kotlin/com/appsprint/AppSprintBridgeModule.kt +125 -29
  6. package/appsprint-react-native.podspec +6 -1
  7. package/ios/AppSprintBridge.m +6 -0
  8. package/ios/AppSprintBridge.swift +92 -16
  9. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/AppSprintSDK +0 -0
  10. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Info.plist +0 -0
  11. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.abi.json +4757 -952
  12. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +102 -30
  13. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +102 -30
  14. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  15. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios.swiftinterface +102 -30
  16. package/ios/AppSprintSDK.xcframework/ios-arm64/AppSprintSDK.framework/PrivacyInfo.xcprivacy +91 -0
  17. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/AppSprintSDK +0 -0
  18. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Info.plist +0 -0
  19. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +4757 -952
  20. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +102 -30
  21. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +102 -30
  22. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +102 -30
  24. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +4757 -952
  25. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +102 -30
  26. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +102 -30
  27. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  28. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/Modules/AppSprintSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +102 -30
  29. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/PrivacyInfo.xcprivacy +91 -0
  30. package/ios/AppSprintSDK.xcframework/ios-arm64_x86_64-simulator/AppSprintSDK.framework/_CodeSignature/CodeResources +1 -1
  31. package/lib/commonjs/AppSprint.js +40 -4
  32. package/lib/commonjs/NativeAppSprint.js +15 -3
  33. package/lib/module/AppSprint.js +40 -4
  34. package/lib/module/NativeAppSprint.js +15 -3
  35. package/lib/typescript/AppSprint.d.ts +6 -4
  36. package/lib/typescript/index.d.ts +1 -1
  37. package/lib/typescript/types.d.ts +53 -7
  38. package/package.json +5 -2
  39. package/plugin/build/index.js +37 -10
  40. package/plugin/src/index.ts +44 -1
  41. package/src/AppSprint.ts +85 -10
  42. package/src/NativeAppSprint.ts +15 -3
  43. package/src/index.ts +1 -0
  44. package/src/types.ts +87 -7
@@ -19,11 +19,14 @@ class AppSprintBridge: NSObject {
19
19
  }
20
20
 
21
21
  Task { @MainActor in
22
- let apiUrl = config["apiUrl"] as? String
22
+ let apiUrl = (config["apiUrl"] as? String) ?? (config["endpointBaseUrl"] as? String)
23
23
  let enableAppleAds = config["enableAppleAdsAttribution"] as? Bool ?? true
24
24
  let isDebug = config["isDebug"] as? Bool ?? false
25
25
  let logLevelRaw = config["logLevel"] as? Int
26
26
  let customerUserId = config["customerUserId"] as? String
27
+ let autoTrackSessions = config["autoTrackSessions"] as? Bool ?? true
28
+ let autoRefreshAttribution = config["autoRefreshAttribution"] as? Bool ?? true
29
+ let googleAdsConsent = Self.googleAdsConsent(from: config["googleAdsConsent"])
27
30
 
28
31
  let logLevel: AppSprintLogLevel
29
32
  if let raw = logLevelRaw, let level = AppSprintLogLevel(rawValue: raw) {
@@ -37,7 +40,10 @@ class AppSprintBridge: NSObject {
37
40
  enableAppleAdsAttribution: enableAppleAds,
38
41
  isDebug: isDebug,
39
42
  logLevel: logLevel,
40
- customerUserId: customerUserId
43
+ customerUserId: customerUserId,
44
+ autoTrackSessions: autoTrackSessions,
45
+ autoRefreshAttribution: autoRefreshAttribution,
46
+ googleAdsConsent: googleAdsConsent
41
47
  )
42
48
 
43
49
  if let urlString = apiUrl, let url = URL(string: urlString) {
@@ -47,12 +53,15 @@ class AppSprintBridge: NSObject {
47
53
  enableAppleAdsAttribution: enableAppleAds,
48
54
  isDebug: isDebug,
49
55
  logLevel: logLevel,
50
- customerUserId: customerUserId
56
+ customerUserId: customerUserId,
57
+ autoTrackSessions: autoTrackSessions,
58
+ autoRefreshAttribution: autoRefreshAttribution,
59
+ googleAdsConsent: googleAdsConsent
51
60
  )
52
61
  }
53
62
 
54
63
  await AppSprint.shared.configure(sdkConfig)
55
- resolve(nil)
64
+ resolve(true)
56
65
  }
57
66
  }
58
67
 
@@ -80,7 +89,7 @@ class AppSprintBridge: NSObject {
80
89
  }
81
90
 
82
91
  await AppSprint.shared.sendEvent(type, name: name, params: params)
83
- resolve(nil)
92
+ resolve(true)
84
93
  }
85
94
  }
86
95
 
@@ -117,11 +126,21 @@ class AppSprintBridge: NSObject {
117
126
  }
118
127
  }
119
128
 
129
+ @objc func refreshAttribution(_ resolve: @escaping RCTPromiseResolveBlock,
130
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
131
+ Task { @MainActor in
132
+ guard let attr = await AppSprint.shared.refreshAttribution() else {
133
+ resolve(NSNull())
134
+ return
135
+ }
136
+ resolve(Self.attributionToDictionary(attr))
137
+ }
138
+ }
139
+
120
140
  @objc func enableAppleAdsAttribution(_ resolve: @escaping RCTPromiseResolveBlock,
121
141
  rejecter reject: @escaping RCTPromiseRejectBlock) {
122
142
  Task { @MainActor in
123
- AppSprint.shared.enableAppleAdsAttribution()
124
- resolve(nil)
143
+ resolve(AppSprint.shared.enableAppleAdsAttribution())
125
144
  }
126
145
  }
127
146
 
@@ -140,15 +159,14 @@ class AppSprintBridge: NSObject {
140
159
  resolve(NSNull())
141
160
  return
142
161
  }
143
- var dict: [String: Any] = [
144
- "source": attr.source,
145
- "confidence": attr.confidence,
146
- ]
147
- if let campaignName = attr.campaignName { dict["campaignName"] = campaignName }
148
- if let utmSource = attr.utmSource { dict["utmSource"] = utmSource }
149
- if let utmMedium = attr.utmMedium { dict["utmMedium"] = utmMedium }
150
- if let utmCampaign = attr.utmCampaign { dict["utmCampaign"] = utmCampaign }
151
- resolve(dict)
162
+ resolve(Self.attributionToDictionary(attr))
163
+ }
164
+ }
165
+
166
+ @objc func getAttributionParams(_ resolve: @escaping RCTPromiseResolveBlock,
167
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
168
+ Task { @MainActor in
169
+ resolve(AppSprint.shared.getAttributionParams())
152
170
  }
153
171
  }
154
172
 
@@ -187,9 +205,11 @@ class AppSprintBridge: NSObject {
187
205
  if let l = info.locale { dict["locale"] = l }
188
206
  if let t = info.timezone { dict["timezone"] = t }
189
207
  if let o = info.osVersion { dict["osVersion"] = o }
208
+ if let appVersion = info.appVersion { dict["appVersion"] = appVersion }
190
209
  if let v = info.idfv { dict["idfv"] = v }
191
210
  if let a = info.idfa { dict["idfa"] = a }
192
211
  if let token = info.adServicesToken { dict["adServicesToken"] = token }
212
+ if let attStatus = info.attStatus { dict["attStatus"] = attStatus.rawValue }
193
213
  resolve(dict)
194
214
  }
195
215
  }
@@ -207,4 +227,60 @@ class AppSprintBridge: NSObject {
207
227
  resolve(authorized)
208
228
  }
209
229
  }
230
+
231
+ private static func attributionToDictionary(_ attr: AttributionResult) -> [String: Any] {
232
+ var dict: [String: Any] = [
233
+ "isAttributed": attr.isAttributed,
234
+ "source": attr.source,
235
+ "confidence": attr.confidence,
236
+ ]
237
+ if let matchType = attr.matchType { dict["matchType"] = matchType }
238
+ if let campaignName = attr.campaignName { dict["campaignName"] = campaignName }
239
+ if let link = attr.link {
240
+ dict["link"] = ["id": link.id, "name": link.name]
241
+ }
242
+ if let appleAds = attr.appleAds {
243
+ var apple: [String: Any] = ["campaignId": appleAds.campaignId]
244
+ if let orgId = appleAds.orgId { apple["orgId"] = orgId }
245
+ if let adGroupId = appleAds.adGroupId { apple["adGroupId"] = adGroupId }
246
+ if let keywordId = appleAds.keywordId { apple["keywordId"] = keywordId }
247
+ if let adId = appleAds.adId { apple["adId"] = adId }
248
+ if let country = appleAds.countryOrRegion { apple["countryOrRegion"] = country }
249
+ if let claimType = appleAds.claimType { apple["claimType"] = claimType }
250
+ if let clickDate = appleAds.clickDate { apple["clickDate"] = clickDate }
251
+ if let impressionDate = appleAds.impressionDate { apple["impressionDate"] = impressionDate }
252
+ if let conversion = appleAds.conversionType { apple["conversionType"] = conversion }
253
+ if let supplyPlacement = appleAds.supplyPlacement { apple["supplyPlacement"] = supplyPlacement }
254
+ dict["appleAds"] = apple
255
+ }
256
+ if let utmSource = attr.utmSource { dict["utmSource"] = utmSource }
257
+ if let utmMedium = attr.utmMedium { dict["utmMedium"] = utmMedium }
258
+ if let utmCampaign = attr.utmCampaign { dict["utmCampaign"] = utmCampaign }
259
+ if let utmContent = attr.utmContent { dict["utmContent"] = utmContent }
260
+ if let utmTerm = attr.utmTerm { dict["utmTerm"] = utmTerm }
261
+ return dict
262
+ }
263
+
264
+ private static func googleAdsConsent(from value: Any?) -> GoogleAdsConsent? {
265
+ let dict: [String: Any]?
266
+ if let typed = value as? [String: Any] {
267
+ dict = typed
268
+ } else if let nsDict = value as? NSDictionary {
269
+ dict = nsDict as? [String: Any]
270
+ } else {
271
+ dict = nil
272
+ }
273
+
274
+ guard let dict, let status = googleAdsConsentStatus(from: dict["adUserData"]) else {
275
+ return nil
276
+ }
277
+ return GoogleAdsConsent(adUserData: status)
278
+ }
279
+
280
+ private static func googleAdsConsentStatus(from value: Any?) -> GoogleAdsConsentStatus? {
281
+ guard let raw = value as? String else {
282
+ return nil
283
+ }
284
+ return GoogleAdsConsentStatus(rawValue: raw.trimmingCharacters(in: .whitespacesAndNewlines).uppercased())
285
+ }
210
286
  }