@datadog/mobile-react-native 3.6.0 → 3.8.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.
Files changed (38) hide show
  1. package/DatadogSDKReactNative.podspec +7 -7
  2. package/android/build.gradle +8 -8
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +7 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  5. package/ios/Sources/DdFlagsImplementation.swift +3 -4
  6. package/ios/Sources/DdLogsImplementation.swift +8 -8
  7. package/ios/Sources/DdRumImplementation.swift +23 -23
  8. package/ios/Sources/DdSdkImplementation.swift +20 -21
  9. package/ios/Sources/DdTraceImplementation.swift +2 -2
  10. package/ios/Sources/RCTPromiseTypes.swift +18 -0
  11. package/ios/Sources/SdkVersion.swift +1 -1
  12. package/lib/commonjs/flags/internal.js +9 -1
  13. package/lib/commonjs/flags/internal.js.map +1 -1
  14. package/lib/commonjs/flags/rumIntegration.js +104 -0
  15. package/lib/commonjs/flags/rumIntegration.js.map +1 -0
  16. package/lib/commonjs/index.js +7 -0
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/version.js +1 -1
  19. package/lib/module/flags/internal.js +9 -1
  20. package/lib/module/flags/internal.js.map +1 -1
  21. package/lib/module/flags/rumIntegration.js +97 -0
  22. package/lib/module/flags/rumIntegration.js.map +1 -0
  23. package/lib/module/index.js +2 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/version.js +1 -1
  26. package/lib/typescript/flags/internal.d.ts.map +1 -1
  27. package/lib/typescript/flags/rumIntegration.d.ts +14 -0
  28. package/lib/typescript/flags/rumIntegration.d.ts.map +1 -0
  29. package/lib/typescript/index.d.ts +2 -1
  30. package/lib/typescript/index.d.ts.map +1 -1
  31. package/lib/typescript/version.d.ts +1 -1
  32. package/package.json +2 -2
  33. package/src/flags/__tests__/internal.test.ts +39 -0
  34. package/src/flags/__tests__/rumIntegration.test.ts +493 -0
  35. package/src/flags/internal.ts +12 -1
  36. package/src/flags/rumIntegration.ts +140 -0
  37. package/src/index.tsx +3 -1
  38. package/src/version.ts +1 -1
@@ -19,15 +19,15 @@ Pod::Spec.new do |s|
19
19
  s.dependency "React-Core"
20
20
 
21
21
  # /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
22
- s.dependency 'DatadogCore', '3.11.0'
23
- s.dependency 'DatadogLogs', '3.11.0'
24
- s.dependency 'DatadogTrace', '3.11.0'
25
- s.dependency 'DatadogRUM', '3.11.0'
26
- s.dependency 'DatadogCrashReporting', '3.11.0'
27
- s.dependency 'DatadogFlags', '3.11.0'
22
+ s.dependency 'DatadogCore', '3.16.0'
23
+ s.dependency 'DatadogLogs', '3.16.0'
24
+ s.dependency 'DatadogTrace', '3.16.0'
25
+ s.dependency 'DatadogRUM', '3.16.0'
26
+ s.dependency 'DatadogCrashReporting', '3.16.0'
27
+ s.dependency 'DatadogFlags', '3.16.0'
28
28
 
29
29
  # DatadogWebViewTracking is not available for tvOS
30
- s.ios.dependency 'DatadogWebViewTracking', '3.11.0'
30
+ s.ios.dependency 'DatadogWebViewTracking', '3.16.0'
31
31
 
32
32
  s.test_spec 'Tests' do |test_spec|
33
33
  test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
@@ -213,7 +213,7 @@ dependencies {
213
213
  // This breaks builds if the React Native target is below 0.76.0. as it relies on Gradle 8.5.0.
214
214
  // To avoid this, we enforce 1.0.0-beta01 on RN < 0.76.0
215
215
  if (reactNativeMinorVersion < 76) {
216
- implementation("com.datadoghq:dd-sdk-android-rum:3.12.1") {
216
+ implementation("com.datadoghq:dd-sdk-android-rum:3.13.1") {
217
217
  exclude group: "androidx.metrics", module: "metrics-performance"
218
218
  }
219
219
  implementation "androidx.metrics:metrics-performance:1.0.0-beta01"
@@ -233,14 +233,14 @@ dependencies {
233
233
  }
234
234
  }
235
235
  } else {
236
- implementation "com.datadoghq:dd-sdk-android-rum:3.12.1"
236
+ implementation "com.datadoghq:dd-sdk-android-rum:3.13.1"
237
237
  }
238
- implementation "com.datadoghq:dd-sdk-android-logs:3.12.1"
239
- implementation "com.datadoghq:dd-sdk-android-trace:3.12.1"
240
- implementation "com.datadoghq:dd-sdk-android-webview:3.12.1"
241
- implementation "com.datadoghq:dd-sdk-android-ndk:3.12.1"
242
- implementation "com.datadoghq:dd-sdk-android-flags:3.12.1"
243
- implementation "com.datadoghq:dd-sdk-android-internal:3.12.1"
238
+ implementation "com.datadoghq:dd-sdk-android-logs:3.13.1"
239
+ implementation "com.datadoghq:dd-sdk-android-trace:3.13.1"
240
+ implementation "com.datadoghq:dd-sdk-android-webview:3.13.1"
241
+ implementation "com.datadoghq:dd-sdk-android-ndk:3.13.1"
242
+ implementation "com.datadoghq:dd-sdk-android-flags:3.13.1"
243
+ implementation "com.datadoghq:dd-sdk-android-internal:3.13.1"
244
244
  implementation "com.google.code.gson:gson:2.11.0"
245
245
  testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
246
246
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
@@ -182,6 +182,8 @@ private fun buildEvaluationContext(
182
182
  return EvaluationContext(targetingKey, parsed)
183
183
  }
184
184
 
185
+ private const val SERIAL_ID_KEY = "serialId"
186
+
185
187
  private fun convertUnparsedFlagToMap(
186
188
  flagKey: String,
187
189
  flag: UnparsedFlag,
@@ -222,6 +224,8 @@ private fun convertUnparsedFlagToMap(
222
224
  "reason" to flag.reason,
223
225
  "doLog" to flag.doLog,
224
226
  "extraLogging" to flag.extraLogging.toMap(),
227
+ // Serialized as a String because the React Native bridge converts Long values to Double
228
+ SERIAL_ID_KEY to flag.serialId?.toString()
225
229
  )
226
230
  }
227
231
 
@@ -237,4 +241,7 @@ private fun convertMapToUnparsedFlag(map: Map<String, Any>): UnparsedFlag =
237
241
  (map["extraLogging"] as? Map<String, Any>)?.toJSONObject()
238
242
  ?: JSONObject()
239
243
  override val reason: String = map["reason"] as? String ?: ""
244
+ override val serialId: Long? =
245
+ (map[SERIAL_ID_KEY] as? String)?.toLongOrNull()
246
+ ?: (map[SERIAL_ID_KEY] as? Number)?.toLong()
240
247
  }
@@ -7,4 +7,4 @@
7
7
  package com.datadog.reactnative
8
8
 
9
9
  // This is automatically updated by the update-version.sh script
10
- internal const val SDK_VERSION = "3.6.0"
10
+ internal const val SDK_VERSION = "3.8.0"
@@ -26,7 +26,7 @@ public class DdFlagsImplementation: NSObject {
26
26
  }
27
27
 
28
28
  @objc
29
- public func enable(_ configuration: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
29
+ public func enable(_ configuration: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
30
30
  // Client providers become stale upon subsequent enable calls (which can happen e.g. in case of a React Native hot reload).
31
31
  clientProviders.removeAll()
32
32
 
@@ -53,9 +53,8 @@ public class DdFlagsImplementation: NSObject {
53
53
  return client
54
54
  }
55
55
 
56
- // Using @escaping RCTPromiseResolveBlock type will result in an issue when compiling the Swift header file.
57
56
  @objc
58
- public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping ((Any?) -> Void), reject: @escaping ((String?, String?, NSError?) -> Void)) {
57
+ public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
59
58
  let client = getClient(name: clientName)
60
59
  guard let clientInternal = client as? FlagsClientInternal else {
61
60
  reject("CLIENT_NOT_INITIALIZED", "Flags client '\(clientName)' is not properly initialized. Make sure the Datadog SDK has been initialized and Flags.enable() has been called.", nil)
@@ -102,7 +101,7 @@ public class DdFlagsImplementation: NSObject {
102
101
  }
103
102
 
104
103
  @objc
105
- public func trackEvaluation(_ clientName: String, key: String, rawFlag: NSDictionary, targetingKey: String, attributes: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
104
+ public func trackEvaluation(_ clientName: String, key: String, rawFlag: NSDictionary, targetingKey: String, attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
106
105
  guard let client = getClient(name: clientName) as? FlagsClientInternal else {
107
106
  reject("CLIENT_NOT_INITIALIZED", "Flags client '\(clientName)' is not properly initialized. Make sure the Datadog SDK has been initialized and Flags.enable() has been called.", nil)
108
107
  return
@@ -36,56 +36,56 @@ public class DdLogsImplementation: NSObject {
36
36
  }
37
37
 
38
38
  @objc
39
- public func debug(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
39
+ public func debug(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
40
40
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
41
41
  logger.debug(message, error: nil, attributes: attributes)
42
42
  resolve(nil)
43
43
  }
44
44
 
45
45
  @objc
46
- public func info(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
46
+ public func info(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
47
47
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
48
48
  logger.info(message, error: nil, attributes: attributes)
49
49
  resolve(nil)
50
50
  }
51
51
 
52
52
  @objc
53
- public func warn(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
53
+ public func warn(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
54
54
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
55
55
  logger.warn(message, error: nil, attributes: attributes)
56
56
  resolve(nil)
57
57
  }
58
58
 
59
59
  @objc
60
- public func error(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
60
+ public func error(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
61
61
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
62
62
  logger.error(message, error: nil, attributes: attributes)
63
63
  resolve(nil)
64
64
  }
65
65
 
66
66
  @objc
67
- public func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
67
+ public func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
68
68
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
69
69
  logger._internal.log(level: .debug, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
70
70
  resolve(nil)
71
71
  }
72
72
 
73
73
  @objc
74
- public func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
74
+ public func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
75
75
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
76
76
  logger._internal.log(level: .info, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
77
77
  resolve(nil)
78
78
  }
79
79
 
80
80
  @objc
81
- public func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
81
+ public func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
82
82
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
83
83
  logger._internal.log(level: .warn, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
84
84
  resolve(nil)
85
85
  }
86
86
 
87
87
  @objc
88
- public func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
88
+ public func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
89
89
  let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
90
90
  logger._internal.log(level: .error, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
91
91
  resolve(nil)
@@ -131,31 +131,31 @@ public class DdRumImplementation: NSObject {
131
131
  }
132
132
 
133
133
  @objc
134
- public func startView(key: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
134
+ public func startView(key: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
135
135
  nativeRUM.startView(key: key, name: name, attributes: attributes(from: context, with: timestampMs))
136
136
  resolve(nil)
137
137
  }
138
138
 
139
139
  @objc
140
- public func stopView(key: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
140
+ public func stopView(key: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
141
141
  nativeRUM.stopView(key: key, attributes: attributes(from: context, with: timestampMs))
142
142
  resolve(nil)
143
143
  }
144
144
 
145
145
  @objc
146
- public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
146
+ public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
147
147
  nativeRUM.startAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
148
148
  resolve(nil)
149
149
  }
150
150
 
151
151
  @objc
152
- public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
152
+ public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
153
153
  nativeRUM.stopAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
154
154
  resolve(nil)
155
155
  }
156
156
 
157
157
  @objc
158
- public func addAction(type: String, name: String, touch: NSDictionary?, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
158
+ public func addAction(type: String, name: String, touch: NSDictionary?, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
159
159
  if
160
160
  let touch,
161
161
  let reactTag = touch["reactTag"] as? NSNumber,
@@ -180,13 +180,13 @@ public class DdRumImplementation: NSObject {
180
180
  }
181
181
 
182
182
  @objc
183
- public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
183
+ public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
184
184
  nativeRUM.startResource(resourceKey: key, httpMethod: RUMMethod(from: method), urlString: url, attributes: attributes(from: context, with: timestampMs))
185
185
  resolve(nil)
186
186
  }
187
187
 
188
188
  @objc
189
- public func stopResource(key: String, statusCode: Int64, kind: String, size: Double, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
189
+ public func stopResource(key: String, statusCode: Int64, kind: String, size: Double, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
190
190
  let mutableContext = NSMutableDictionary(dictionary: context)
191
191
  if let resourceTimings = mutableContext.object(forKey: Self.resourceTimingsKey) as? [String: Any] {
192
192
  mutableContext.removeObject(forKey: Self.resourceTimingsKey)
@@ -205,7 +205,7 @@ public class DdRumImplementation: NSObject {
205
205
  }
206
206
 
207
207
  @objc
208
- public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, fingerprint: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
208
+ public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, fingerprint: String, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
209
209
 
210
210
  func addErrorWithContext(errorContext: NSDictionary) -> Void {
211
211
  nativeRUM.addError(message: message, type: nil, stack: stacktrace, source: RUMErrorSource(from: source), attributes: attributes(from: errorContext, with: timestampMs), file: nil, line: nil)
@@ -223,13 +223,13 @@ public class DdRumImplementation: NSObject {
223
223
  }
224
224
 
225
225
  @objc
226
- public func addTiming(name: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
226
+ public func addTiming(name: String, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
227
227
  nativeRUM.addTiming(name: name)
228
228
  resolve(nil)
229
229
  }
230
230
 
231
231
  @objc
232
- public func addViewAttribute(key: AttributeKey, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
232
+ public func addViewAttribute(key: AttributeKey, value: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
233
233
  if let attributeValue = value.object(forKey: "value") {
234
234
  let castedAttribute = castValueToSwift(attributeValue)
235
235
  nativeRUM.addViewAttribute(forKey: key, value: castedAttribute)
@@ -238,38 +238,38 @@ public class DdRumImplementation: NSObject {
238
238
  }
239
239
 
240
240
  @objc
241
- public func removeViewAttribute(key: AttributeKey, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
241
+ public func removeViewAttribute(key: AttributeKey, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
242
242
  nativeRUM.removeViewAttribute(forKey: key)
243
243
  resolve(nil)
244
244
  }
245
245
 
246
246
  @objc
247
- public func addViewAttributes(attributes: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
247
+ public func addViewAttributes(attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
248
248
  let castedAttributes = castAttributesToSwift(attributes)
249
249
  nativeRUM.addViewAttributes(castedAttributes)
250
250
  resolve(nil)
251
251
  }
252
252
 
253
253
  @objc
254
- public func removeViewAttributes(keys: [AttributeKey], resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
254
+ public func removeViewAttributes(keys: [AttributeKey], resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
255
255
  nativeRUM.removeViewAttributes(forKeys: keys)
256
256
  resolve(nil)
257
257
  }
258
258
 
259
259
  @objc
260
- public func addViewLoadingTime(overwrite: Bool, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
260
+ public func addViewLoadingTime(overwrite: Bool, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
261
261
  nativeRUM.addViewLoadingTime(overwrite: overwrite)
262
262
  resolve(nil)
263
263
  }
264
264
 
265
265
  @objc
266
- public func stopSession(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
266
+ public func stopSession(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
267
267
  nativeRUM.stopSession()
268
268
  resolve(nil)
269
269
  }
270
270
 
271
271
  @objc
272
- public func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
272
+ public func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
273
273
  let valueAsEncodable = castAttributesToSwift(value)
274
274
  if let value = valueAsEncodable["value"] {
275
275
  nativeRUM.addFeatureFlagEvaluation(name: name, value: value)
@@ -278,7 +278,7 @@ public class DdRumImplementation: NSObject {
278
278
  }
279
279
 
280
280
  @objc
281
- public func getCurrentSessionId(_ resolve: @escaping (Any?) -> Void, reject: RCTPromiseRejectBlock) -> Void {
281
+ public func getCurrentSessionId(_ resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
282
282
  nativeRUM.currentSessionID { sessionId in
283
283
  resolve(sessionId)
284
284
  }
@@ -289,8 +289,8 @@ public class DdRumImplementation: NSObject {
289
289
  name: String,
290
290
  operationKey: String?,
291
291
  attributes: NSDictionary,
292
- resolve: @escaping (Any?) -> Void,
293
- reject: RCTPromiseRejectBlock
292
+ resolve: @escaping RCTPromiseResolve,
293
+ reject: @escaping RCTPromiseReject
294
294
  ){
295
295
  let castedAttributes = castAttributesToSwift(attributes)
296
296
  nativeRUM.startFeatureOperation(name: name, operationKey: operationKey, attributes: castedAttributes)
@@ -302,8 +302,8 @@ public class DdRumImplementation: NSObject {
302
302
  name: String,
303
303
  operationKey: String?,
304
304
  attributes: NSDictionary,
305
- resolve: @escaping (Any?) -> Void,
306
- reject: RCTPromiseRejectBlock
305
+ resolve: @escaping RCTPromiseResolve,
306
+ reject: @escaping RCTPromiseReject
307
307
  ){
308
308
  let castedAttributes = castAttributesToSwift(attributes)
309
309
  nativeRUM.succeedFeatureOperation(name: name, operationKey: operationKey, attributes: castedAttributes)
@@ -316,8 +316,8 @@ public class DdRumImplementation: NSObject {
316
316
  operationKey: String?,
317
317
  reason: String,
318
318
  attributes: NSDictionary,
319
- resolve: @escaping (Any?) -> Void,
320
- reject: RCTPromiseRejectBlock
319
+ resolve: @escaping RCTPromiseResolve,
320
+ reject: @escaping RCTPromiseReject
321
321
  ){
322
322
  let castedAttributes = castAttributesToSwift(attributes)
323
323
  nativeRUM.failFeatureOperation(name: name, operationKey: operationKey,
@@ -62,11 +62,10 @@ public class DdSdkImplementation: NSObject {
62
62
  super.init()
63
63
  }
64
64
 
65
- // Using @escaping RCTPromiseResolveBlock type will result in an issue when compiling the Swift header file.
66
65
  @objc
67
66
  public func initialize(
68
- configuration: NSDictionary, resolve: @escaping ((Any?) -> Void),
69
- reject: RCTPromiseRejectBlock
67
+ configuration: NSDictionary, resolve: @escaping RCTPromiseResolve,
68
+ reject: @escaping RCTPromiseReject
70
69
  ) {
71
70
  let sdkConfiguration = configuration.asDdSdkConfiguration()
72
71
  let nativeInitialization = DdSdkNativeInitialization()
@@ -94,8 +93,8 @@ public class DdSdkImplementation: NSObject {
94
93
 
95
94
  @objc
96
95
  public func addAttribute(
97
- key: AttributeKey, value: NSDictionary, resolve: RCTPromiseResolveBlock,
98
- reject: RCTPromiseRejectBlock
96
+ key: AttributeKey, value: NSDictionary, resolve: @escaping RCTPromiseResolve,
97
+ reject: @escaping RCTPromiseReject
99
98
  ) {
100
99
  if let attributeValue = value.object(forKey: "value") {
101
100
  let castedValue = castValueToSwift(attributeValue)
@@ -108,7 +107,7 @@ public class DdSdkImplementation: NSObject {
108
107
 
109
108
  @objc
110
109
  public func removeAttribute(
111
- key: AttributeKey, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
110
+ key: AttributeKey, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
112
111
  ) {
113
112
  RUMMonitorProvider()?.removeAttribute(forKey: key)
114
113
  GlobalState.removeAttribute(key: key)
@@ -118,7 +117,7 @@ public class DdSdkImplementation: NSObject {
118
117
 
119
118
  @objc
120
119
  public func addAttributes(
121
- attributes: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
120
+ attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
122
121
  ) {
123
122
  let castedAttributes = castAttributesToSwift(attributes)
124
123
  for (key, value) in castedAttributes {
@@ -131,7 +130,7 @@ public class DdSdkImplementation: NSObject {
131
130
 
132
131
  @objc
133
132
  public func removeAttributes(
134
- keys: [AttributeKey], resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
133
+ keys: [AttributeKey], resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
135
134
  ) {
136
135
  RUMMonitorProvider()?.removeAttributes(forKeys: keys)
137
136
  for (key) in keys {
@@ -143,7 +142,7 @@ public class DdSdkImplementation: NSObject {
143
142
 
144
143
  @objc
145
144
  public func setUserInfo(
146
- userInfo: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
145
+ userInfo: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
147
146
  ) {
148
147
  let castedUserInfo = castAttributesToSwift(userInfo)
149
148
  let id = castedUserInfo["id"] as? String
@@ -166,7 +165,7 @@ public class DdSdkImplementation: NSObject {
166
165
 
167
166
  @objc
168
167
  public func addUserExtraInfo(
169
- extraInfo: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
168
+ extraInfo: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
170
169
  ) {
171
170
  let castedExtraInfo = castAttributesToSwift(extraInfo)
172
171
 
@@ -175,14 +174,14 @@ public class DdSdkImplementation: NSObject {
175
174
  }
176
175
 
177
176
  @objc
178
- public func clearUserInfo(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
177
+ public func clearUserInfo(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
179
178
  Datadog.clearUserInfo()
180
179
  resolve(nil)
181
180
  }
182
181
 
183
182
  @objc
184
183
  public func setAccountInfo(
185
- accountInfo: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
184
+ accountInfo: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
186
185
  ) {
187
186
  let castedAccountInfo = castAttributesToSwift(accountInfo)
188
187
  let id = castedAccountInfo["id"] as? String
@@ -204,7 +203,7 @@ public class DdSdkImplementation: NSObject {
204
203
 
205
204
  @objc
206
205
  public func addAccountExtraInfo(
207
- extraInfo: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
206
+ extraInfo: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
208
207
  ) {
209
208
  let castedExtraInfo = castAttributesToSwift(extraInfo)
210
209
 
@@ -213,14 +212,14 @@ public class DdSdkImplementation: NSObject {
213
212
  }
214
213
 
215
214
  @objc
216
- public func clearAccountInfo(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
215
+ public func clearAccountInfo(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
217
216
  Datadog.clearAccountInfo()
218
217
  resolve(nil)
219
218
  }
220
219
 
221
220
  @objc
222
221
  public func setTrackingConsent(
223
- trackingConsent: NSString, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
222
+ trackingConsent: NSString, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
224
223
  ) {
225
224
  Datadog.set(trackingConsent: (trackingConsent as NSString?).asTrackingConsent())
226
225
  resolve(nil)
@@ -229,7 +228,7 @@ public class DdSdkImplementation: NSObject {
229
228
  @objc
230
229
  public func sendTelemetryLog(
231
230
  message: NSString, attributes: NSDictionary, config: NSDictionary,
232
- resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
231
+ resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
233
232
  ) {
234
233
  let castedAttributes = castAttributesToSwift(attributes)
235
234
  let castedConfig = castAttributesToSwift(config)
@@ -241,7 +240,7 @@ public class DdSdkImplementation: NSObject {
241
240
  @objc
242
241
 
243
242
  public func telemetryDebug(
244
- message: NSString, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
243
+ message: NSString, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
245
244
  ) {
246
245
  DdTelemetry.telemetryDebug(
247
246
  id: "datadog_react_native:\(message)", message: message as String)
@@ -250,8 +249,8 @@ public class DdSdkImplementation: NSObject {
250
249
 
251
250
  @objc
252
251
  public func telemetryError(
253
- message: NSString, stack: NSString, kind: NSString, resolve: RCTPromiseResolveBlock,
254
- reject: RCTPromiseRejectBlock
252
+ message: NSString, stack: NSString, kind: NSString, resolve: @escaping RCTPromiseResolve,
253
+ reject: @escaping RCTPromiseReject
255
254
  ) {
256
255
  DdTelemetry.telemetryError(
257
256
  id: "datadog_react_native:\(String(describing: kind)):\(message)",
@@ -262,7 +261,7 @@ public class DdSdkImplementation: NSObject {
262
261
  #if os(iOS)
263
262
  @objc
264
263
  public func consumeWebviewEvent(
265
- message: NSString, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
264
+ message: NSString, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
266
265
  ) {
267
266
  do {
268
267
  try DatadogSDKWrapper.shared.sendWebviewMessage(body: message)
@@ -280,7 +279,7 @@ public class DdSdkImplementation: NSObject {
280
279
  #endif
281
280
 
282
281
  @objc
283
- public func clearAllData(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
282
+ public func clearAllData(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
284
283
  Datadog.clearAllData()
285
284
  resolve(nil)
286
285
  }
@@ -31,7 +31,7 @@ public class DdTraceImplementation: NSObject {
31
31
  @objc
32
32
  public func startSpan(
33
33
  operation: String, context: NSDictionary, timestampMs: Double,
34
- resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
34
+ resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
35
35
  ) {
36
36
  objc_sync_enter(self)
37
37
  defer { objc_sync_exit(self) }
@@ -57,7 +57,7 @@ public class DdTraceImplementation: NSObject {
57
57
  @objc
58
58
  public func finishSpan(
59
59
  spanId: NSString, context: NSDictionary, timestampMs: Double,
60
- resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock
60
+ resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject
61
61
  ) {
62
62
  objc_sync_enter(self)
63
63
  defer { objc_sync_exit(self) }
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import Foundation
8
+
9
+ /// Local equivalents of `RCTPromiseResolveBlock`/`RCTPromiseRejectBlock` from `React/RCTBridgeModule.h`.
10
+ ///
11
+ /// Using these plain Swift closure types instead of React's typealiases keeps the generated
12
+ /// Objective-C interface header (`-Swift.h`) from referencing `RCTPromiseResolveBlock`/`RCTPromiseRejectBlock`
13
+ /// by name: Swift emits the underlying block signature directly instead, so the header no longer
14
+ /// depends on `RCTBridgeModule.h` being importable wherever it is consumed. The block signatures are
15
+ /// structurally identical to React's, so `.mm` callers can pass `RCTPromiseResolveBlock`/`RCTPromiseRejectBlock`
16
+ /// values through unchanged.
17
+ public typealias RCTPromiseResolve = (Any?) -> Void
18
+ public typealias RCTPromiseReject = (String, String, NSError?) -> Void
@@ -7,4 +7,4 @@
7
7
  import Foundation
8
8
 
9
9
  // This is automatically updated by the update-version.sh script
10
- let SdkVersion = "3.6.0"
10
+ let SdkVersion = "3.8.0"
@@ -13,10 +13,18 @@ var _SdkVerbosity = require("../config/types/SdkVerbosity");
13
13
  */
14
14
 
15
15
  const processEvaluationContext = context => {
16
- const {
16
+ let {
17
17
  targetingKey
18
18
  } = context;
19
19
 
20
+ // Validate only the final targeting key, after any RUM/application merge. Its source must
21
+ // not affect validation or cause a fallback to a lower-precedence user's identity.
22
+ // Both online and offline clients share this boundary; native calls require a string.
23
+ if (typeof targetingKey !== 'string') {
24
+ _InternalLog.InternalLog.log("The evaluation context targetingKey is not a string. Using the anonymous subject ('') instead.", _SdkVerbosity.SdkVerbosity.WARN);
25
+ targetingKey = '';
26
+ }
27
+
20
28
  // We should ignore non-primitive values in the context as per FFE SDK requirements OF.3.
21
29
  const providedAttributes = context.attributes ?? {};
22
30
 
@@ -1 +1 @@
1
- {"version":3,"names":["_InternalLog","require","_SdkVerbosity","processEvaluationContext","context","targetingKey","providedAttributes","attributes","Map","key","value","Object","entries","isPrimitiveValue","undefined","InternalLog","log","SdkVerbosity","WARN","set","fromEntries","exports"],"sourceRoot":"../../../src","sources":["flags/internal.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;;AAmBO,MAAME,wBAAwB,GACjCC,OAA0B,IACN;EACpB,MAAM;IAAEC;EAAa,CAAC,GAAGD,OAAO;;EAEhC;EACA,MAAME,kBAA2C,GAC7CF,OAAO,CAACG,UAAU,IAAI,CAAC,CAAC;;EAE5B;EACA;EACA;EACA,MAAMA,UAAU,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAEpD,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,kBAAkB,CAAC,EAAE;IAC3D,MAAMO,gBAAgB,GAClB,OAAOH,KAAK,KAAK,SAAS,IAC1B,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAKI,SAAS,IACnBJ,KAAK,KAAK,IAAI;IAElB,IAAI,CAACG,gBAAgB,EAAE;MACnBE,wBAAW,CAACC,GAAG,CACX,sCAAsCP,GAAG,0EAA0E,EACnHQ,0BAAY,CAACC,IACjB,CAAC;MAED;IACJ;IAEA,IAAIR,KAAK,KAAKI,SAAS,EAAE;MACrB;IACJ;IAEAP,UAAU,CAACY,GAAG,CAACV,GAAG,EAAEC,KAAuB,CAAC;EAChD;EAEA,OAAO;IACHL,YAAY;IACZE,UAAU,EAAEI,MAAM,CAACS,WAAW,CAACb,UAAU;EAC7C,CAAC;AACL,CAAC;AAACc,OAAA,CAAAlB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_InternalLog","require","_SdkVerbosity","processEvaluationContext","context","targetingKey","InternalLog","log","SdkVerbosity","WARN","providedAttributes","attributes","Map","key","value","Object","entries","isPrimitiveValue","undefined","set","fromEntries","exports"],"sourceRoot":"../../../src","sources":["flags/internal.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;;AAmBO,MAAME,wBAAwB,GACjCC,OAA0B,IACN;EACpB,IAAI;IAAEC;EAAa,CAAC,GAAGD,OAAO;;EAE9B;EACA;EACA;EACA,IAAI,OAAOC,YAAY,KAAK,QAAQ,EAAE;IAClCC,wBAAW,CAACC,GAAG,CACX,gGAAgG,EAChGC,0BAAY,CAACC,IACjB,CAAC;IACDJ,YAAY,GAAG,EAAE;EACrB;;EAEA;EACA,MAAMK,kBAA2C,GAC7CN,OAAO,CAACO,UAAU,IAAI,CAAC,CAAC;;EAE5B;EACA;EACA;EACA,MAAMA,UAAU,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAEpD,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,kBAAkB,CAAC,EAAE;IAC3D,MAAMO,gBAAgB,GAClB,OAAOH,KAAK,KAAK,SAAS,IAC1B,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAKI,SAAS,IACnBJ,KAAK,KAAK,IAAI;IAElB,IAAI,CAACG,gBAAgB,EAAE;MACnBX,wBAAW,CAACC,GAAG,CACX,sCAAsCM,GAAG,0EAA0E,EACnHL,0BAAY,CAACC,IACjB,CAAC;MAED;IACJ;IAEA,IAAIK,KAAK,KAAKI,SAAS,EAAE;MACrB;IACJ;IAEAP,UAAU,CAACQ,GAAG,CAACN,GAAG,EAAEC,KAAuB,CAAC;EAChD;EAEA,OAAO;IACHT,YAAY;IACZM,UAAU,EAAEI,MAAM,CAACK,WAAW,CAACT,UAAU;EAC7C,CAAC;AACL,CAAC;AAACU,OAAA,CAAAlB,wBAAA,GAAAA,wBAAA","ignoreList":[]}