@datadog/mobile-react-native 3.12.0 → 3.13.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 (81) hide show
  1. package/DatadogSDKReactNative.podspec +357 -14
  2. package/README.md +3 -2
  3. package/android/build.gradle +9 -9
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +27 -2
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +27 -2
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +25 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -0
  9. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +104 -0
  10. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +8 -0
  11. package/android/src/test/resources/input/complete-configuration.json +5 -0
  12. package/datadog-configuration.schema.json +21 -0
  13. package/ios/Sources/DdFlagsImplementation.swift +3 -0
  14. package/ios/Sources/DdSdkConfiguration.swift +11 -1
  15. package/ios/Sources/DdSdkNativeInitialization.swift +24 -2
  16. package/ios/Sources/RNDdSdkConfiguration.swift +14 -2
  17. package/ios/Sources/SdkVersion.swift +1 -1
  18. package/lib/commonjs/config/FileBasedConfiguration.js +2 -1
  19. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  20. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +1 -0
  21. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  22. package/lib/commonjs/config/features/RumConfiguration.js +4 -0
  23. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  24. package/lib/commonjs/config/features/RumConfigurationNative.js +4 -0
  25. package/lib/commonjs/config/types/TimeseriesConfiguration.js +25 -0
  26. package/lib/commonjs/config/types/TimeseriesConfiguration.js.map +1 -0
  27. package/lib/commonjs/config/types/index.js +7 -0
  28. package/lib/commonjs/config/types/index.js.map +1 -1
  29. package/lib/commonjs/index.js +7 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/version.js +1 -1
  32. package/lib/module/config/FileBasedConfiguration.js +2 -1
  33. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  34. package/lib/module/config/async/AutoInstrumentationConfiguration.js +1 -0
  35. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  36. package/lib/module/config/features/RumConfiguration.js +4 -0
  37. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  38. package/lib/module/config/features/RumConfigurationNative.js +1 -1
  39. package/lib/module/config/types/TimeseriesConfiguration.js +19 -0
  40. package/lib/module/config/types/TimeseriesConfiguration.js.map +1 -0
  41. package/lib/module/config/types/index.js +1 -0
  42. package/lib/module/config/types/index.js.map +1 -1
  43. package/lib/module/index.js +2 -1
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/version.js +1 -1
  46. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  47. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -1
  48. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  49. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +3 -0
  50. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  51. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -1
  52. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  53. package/lib/typescript/config/features/RumConfiguration.d.ts +3 -0
  54. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  55. package/lib/typescript/config/features/RumConfiguration.type.d.ts +9 -1
  56. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  57. package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
  58. package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
  59. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts +19 -0
  60. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts.map +1 -0
  61. package/lib/typescript/config/types/index.d.ts +2 -0
  62. package/lib/typescript/config/types/index.d.ts.map +1 -1
  63. package/lib/typescript/index.d.ts +4 -2
  64. package/lib/typescript/index.d.ts.map +1 -1
  65. package/lib/typescript/version.d.ts +1 -1
  66. package/package.json +3 -3
  67. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
  68. package/src/config/FileBasedConfiguration.ts +3 -1
  69. package/src/config/FileBasedConfiguration.type.ts +2 -0
  70. package/src/config/__tests__/FileBasedConfiguration.test.ts +7 -0
  71. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +6 -1
  72. package/src/config/async/AutoInstrumentationConfiguration.ts +4 -0
  73. package/src/config/async/PartialInitializationConfiguration.ts +2 -0
  74. package/src/config/features/RumConfiguration.ts +6 -0
  75. package/src/config/features/RumConfiguration.type.ts +11 -1
  76. package/src/config/features/RumConfigurationNative.ts +3 -0
  77. package/src/config/types/TimeseriesConfiguration.ts +26 -0
  78. package/src/config/types/index.ts +5 -0
  79. package/src/index.tsx +8 -0
  80. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +52 -0
  81. package/src/version.ts +1 -1
@@ -2,6 +2,310 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
+ # /!\ Remember to keep this version in sync with the other Datadog podspecs:
6
+ # - DatadogSDKReactNativeSessionReplay.podspec
7
+ # - DatadogSDKReactNativeWebView.podspec
8
+ # - DatadogInternalTesting.podspec
9
+ datadog_ios_version = '3.21.0'
10
+ datadog_ios_spm_url = 'https://github.com/DataDog/dd-sdk-ios.git'
11
+ datadog_ios_requirement = { kind: 'exactVersion', version: datadog_ios_version }
12
+
13
+ # The native iOS SDK is resolved through Swift Package Manager, using React Native's
14
+ # `spm_dependency` podspec helper. This requires React Native >= 0.75. Pods can be linked statically
15
+ # or as frameworks: see the post-install step below for what each linkage needs.
16
+ if !respond_to?(:spm_dependency, true)
17
+ raise "Datadog: the native iOS SDK is resolved through Swift Package Manager, which requires " \
18
+ "React Native >= 0.75 -- the first version to ship the `spm_dependency` podspec helper."
19
+ end
20
+
21
+ # Xcode builds some of the package's frameworks as dynamic frameworks: DatadogInternal, a target
22
+ # shared by every product, and a `<Product>_<hash>_PackageProduct` framework for any product that
23
+ # more than one pod requests (e.g. DatadogWebViewTracking). The pods link them, but CocoaPods'
24
+ # "[CP] Embed Pods Frameworks" phase only embeds pod frameworks, and `spm_dependency` does not
25
+ # embed them either, so a Release or archived app crashes at launch with dyld "Library not
26
+ # loaded". Debug builds hide it because Xcode adds an rpath to the build folder.
27
+ # This extends React Native's SPM post-install step, which every React Native Podfile already
28
+ # runs through `react_native_post_install`, so the app embeds them without any Podfile change.
29
+ unless defined?(SPM) && SPM.respond_to?(:apply_on_post_install)
30
+ raise "Datadog: could not find React Native's Swift Package Manager integration " \
31
+ "(SPM.apply_on_post_install), which is needed to embed the native iOS SDK frameworks."
32
+ end
33
+
34
+ unless SPM.singleton_class.method_defined?(:datadog_embeds_spm_frameworks?)
35
+ SPM.singleton_class.prepend(Module.new do
36
+ def datadog_embeds_spm_frameworks?
37
+ true
38
+ end
39
+
40
+ # When pods are linked statically, Xcode merges the object files of every package product a pod
41
+ # requests, DatadogInternal included, into that pod's static archive. With more than one Datadog
42
+ # pod each archive carries its own copy, and the app fails to link with duplicate symbols. So
43
+ # the core pod, which every other Datadog pod depends on and which is therefore built first,
44
+ # links all of their products, and the others keep only the package reference and the include
45
+ # path they compile against. This runs on the Pods project once React Native has added the
46
+ # package products to it, so it does not depend on how React Native records them.
47
+ def datadog_link_static_products_from_core(installer, core)
48
+ return if core.build_as_dynamic?
49
+
50
+ core_target = installer.pods_project.targets.find { |t| t.name == core.label }
51
+ return if core_target.nil?
52
+
53
+ packages = core_target.package_product_dependencies.map(&:package).uniq
54
+ installer.pods_project.native_targets.each do |target|
55
+ next if target == core_target
56
+ target.package_product_dependencies.select { |ref| packages.include?(ref.package) }.each do |ref|
57
+ target.package_product_dependencies.delete(ref)
58
+ if core_target.package_product_dependencies.any? { |other| other.package == ref.package && other.product_name == ref.product_name }
59
+ ref.remove_from_project
60
+ else
61
+ core_target.package_product_dependencies << ref
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ # Xcode versions before 26 hand each package object to libtool twice when they archive a pod that
68
+ # requests package products, so the core pod's static archive holds two copies of every Datadog
69
+ # object, and the -ObjC flag CocoaPods links apps and tests with loads both: duplicate symbols.
70
+ # This drops the extra byte-identical copies once the archive is built, slice by slice when it is
71
+ # a universal archive, which ar cannot read. Xcode 26 archives each object once, so it finds
72
+ # nothing to remove there and leaves the archive untouched.
73
+ def datadog_dedupe_static_archive(installer, core)
74
+ return if core.build_as_dynamic?
75
+
76
+ phase_name = '[Datadog] Remove duplicate Swift package objects'
77
+ target = installer.pods_project.targets.find { |t| t.name == core.label }
78
+ return if target.nil? || target.shell_script_build_phases.any? { |phase| phase.name == phase_name }
79
+
80
+ phase = installer.pods_project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
81
+ phase.name = phase_name
82
+ phase.shell_script = <<~'SH'
83
+ set -e
84
+ archive="${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}"
85
+ has_duplicates() {
86
+ [ -n "$(ar -t "$1" | sort | uniq -d)" ]
87
+ }
88
+ # Pulls every copy of each repeated member out of the archive and puts back one copy of each
89
+ # distinct object, so only byte-identical duplicates go: a same-named object with other code
90
+ # stays.
91
+ dedupe() {
92
+ work="$(mktemp -d "${DERIVED_FILE_DIR}/datadog-dedupe.XXXXXX")"
93
+ ar -t "$1" | sort | uniq -d | while read -r member; do
94
+ count=0
95
+ while ar -t "$1" | grep -qxF "${member}"; do
96
+ count=$((count + 1))
97
+ mkdir "${work}/${count}"
98
+ ar -p "$1" "${member}" > "${work}/${count}/${member}"
99
+ ar -d "$1" "${member}"
100
+ done
101
+ kept=""
102
+ copy=1
103
+ while [ "${copy}" -le "${count}" ]; do
104
+ distinct=true
105
+ for other in ${kept}; do
106
+ if cmp -s "${work}/${copy}/${member}" "${work}/${other}/${member}"; then
107
+ distinct=false
108
+ break
109
+ fi
110
+ done
111
+ if [ "${distinct}" = true ]; then
112
+ ar -q "$1" "${work}/${copy}/${member}"
113
+ kept="${kept} ${copy}"
114
+ fi
115
+ copy=$((copy + 1))
116
+ done
117
+ rm -rf "${work:?}"/*
118
+ done
119
+ rm -rf "${work}"
120
+ ranlib "$1"
121
+ }
122
+ archs="$(lipo -archs "${archive}")"
123
+ mkdir -p "${DERIVED_FILE_DIR}"
124
+ if [ "$(echo ${archs} | wc -w)" -eq 1 ]; then
125
+ ar -t "${archive}" > /dev/null
126
+ has_duplicates "${archive}" || exit 0
127
+ dedupe "${archive}"
128
+ exit 0
129
+ fi
130
+ # Universal archive: ar only reads thin archives, so work on each architecture's slice.
131
+ found=false
132
+ set --
133
+ for arch in ${archs}; do
134
+ slice="${DERIVED_FILE_DIR}/datadog-dedupe-${arch}.a"
135
+ lipo -thin "${arch}" "${archive}" -output "${slice}"
136
+ ar -t "${slice}" > /dev/null
137
+ if has_duplicates "${slice}"; then
138
+ found=true
139
+ dedupe "${slice}"
140
+ fi
141
+ set -- "$@" "${slice}"
142
+ done
143
+ [ "${found}" = true ] || exit 0
144
+ lipo -create "$@" -output "${archive}"
145
+ SH
146
+ phase.always_out_of_date = '1'
147
+ target.build_phases << phase
148
+ end
149
+
150
+ # CocoaPods numbers the Pods project's UUIDs from a counter without checking for collisions,
151
+ # which only holds while it creates every object itself. By the time post-install hooks run it
152
+ # has made the UUIDs deterministic, and once the batch it had left runs out the counter
153
+ # restarts, so the package objects added below can reuse a taken UUID -- the project root's
154
+ # first -- and Xcode then reports the Pods project as damaged. Whether that happens depends on
155
+ # how many objects the project has. Queue collision-checked UUIDs, generated by Xcodeproj's own
156
+ # implementation, so the objects created from here on never take one that is already in use.
157
+ # React Native 0.87 and later check for collisions themselves (`new_object`), so this only runs on
158
+ # the versions before it.
159
+ def datadog_reserve_unique_uuids(project)
160
+ return if self.class.private_method_defined?(:new_object)
161
+
162
+ Xcodeproj::Project.instance_method(:generate_available_uuid_list).bind(project).call(100)
163
+ end
164
+
165
+ # React Native 0.87 and later build every statically linked pod that requests package products straight
166
+ # into the shared products directory (see datadog_update_moved_module_map_references), and CocoaPods
167
+ # copies each Swift pod's module map and umbrella header into its build directory. With all the
168
+ # Datadog pods in one directory, clang lets only one umbrella module cover it: "Umbrella for module
169
+ # ... already covers this directory". Once datadog_link_static_products_from_core has moved every
170
+ # package product onto the core pod, the other pods request none, so React Native's reason to move
171
+ # them is gone: put them back into their own build directories, with the include path React Native
172
+ # gives the pods it does not move, and point the app's references back at their module maps. Finds
173
+ # nothing to do on earlier versions or with frameworks.
174
+ def datadog_restore_static_pod_build_dirs(installer, core)
175
+ return if core.build_as_dynamic?
176
+
177
+ products_dir = '${PODS_CONFIGURATION_BUILD_DIR}'
178
+ search_path = '${SYMROOT}/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/'
179
+ restored = installer.pod_targets.select do |pod|
180
+ next false if pod == core || !pod.pod_name.start_with?('Datadog')
181
+ target = installer.pods_project.native_targets.find { |t| t.name == pod.label }
182
+ next false if target.nil? || !target.package_product_dependencies.empty?
183
+ moved = target.build_configurations.select { |config| config.build_settings['CONFIGURATION_BUILD_DIR'] == products_dir }
184
+ moved.each do |config|
185
+ config.build_settings.delete('CONFIGURATION_BUILD_DIR')
186
+ include_paths = Array(config.build_settings['SWIFT_INCLUDE_PATHS'] || '$(inherited)')
187
+ include_paths << search_path unless include_paths.include?(search_path)
188
+ config.build_settings['SWIFT_INCLUDE_PATHS'] = include_paths
189
+ end
190
+ !moved.empty?
191
+ end
192
+ return if restored.empty?
193
+
194
+ # React Native rewrote these in the aggregate targets' in-memory xcconfigs, which later post-install
195
+ # steps save again, so edit the same objects rather than the files.
196
+ installer.aggregate_targets.each do |aggregate|
197
+ aggregate.xcconfigs.each do |config_name, xcconfig|
198
+ changed = false
199
+ %w[OTHER_CFLAGS OTHER_SWIFT_FLAGS].each do |key|
200
+ value = xcconfig.attributes[key]
201
+ next unless value
202
+ updated = restored.reduce(value) do |acc, pod|
203
+ module_name = pod.product_module_name
204
+ acc.gsub("#{products_dir}/#{module_name}.modulemap", "#{products_dir}/#{pod.label}/#{module_name}.modulemap")
205
+ end
206
+ next if updated == value
207
+ xcconfig.attributes[key] = updated
208
+ changed = true
209
+ end
210
+ xcconfig.save_as(aggregate.xcconfig_path(config_name)) if changed
211
+ end
212
+ end
213
+ end
214
+
215
+ # React Native 0.87 and later build a statically linked pod that requests package products straight
216
+ # into the shared products directory, which moves its module map from <Pod>/<Module>.modulemap to
217
+ # <Module>.modulemap. React Native updates the app's references to it but not those of other pods,
218
+ # so the Datadog pods that import the core pod fail with "module map file ... not found". This
219
+ # updates their references too, and finds nothing to do on earlier versions or with frameworks.
220
+ def datadog_update_moved_module_map_references(installer)
221
+ datadog_pods = installer.pod_targets.select { |pod| pod.pod_name.start_with?('Datadog') }
222
+ moved = datadog_pods.select do |pod|
223
+ target = installer.pods_project.native_targets.find { |t| t.name == pod.label }
224
+ target && target.build_configurations.any? { |config| config.build_settings['CONFIGURATION_BUILD_DIR'] == '${PODS_CONFIGURATION_BUILD_DIR}' }
225
+ end
226
+ return if moved.empty?
227
+
228
+ datadog_pods.each do |pod|
229
+ Dir.glob(File.join(pod.support_files_dir, '*.xcconfig')).each do |path|
230
+ xcconfig = File.read(path)
231
+ updated = moved.reduce(xcconfig) do |acc, moved_pod|
232
+ module_name = moved_pod.product_module_name
233
+ acc.gsub("${PODS_CONFIGURATION_BUILD_DIR}/#{moved_pod.label}/#{module_name}.modulemap",
234
+ "${PODS_CONFIGURATION_BUILD_DIR}/#{module_name}.modulemap")
235
+ end
236
+ File.write(path, updated) if updated != xcconfig
237
+ end
238
+ end
239
+ end
240
+
241
+ # The package requirement written into the embed script, taken from this podspec rather than from
242
+ # React Native's records of it.
243
+ define_method(:datadog_package_requirement) do
244
+ "# #{datadog_ios_spm_url} #{datadog_ios_requirement}\n"
245
+ end
246
+
247
+ def apply_on_post_install(installer)
248
+ # When one Podfile builds a pod for more than one platform, e.g. for an iOS and a tvOS app target,
249
+ # CocoaPods adds a suffix to each of its targets' names (DatadogSDKReactNative-iOS), and React
250
+ # Native, which finds a pod's target by the pod's name, fails with "undefined method
251
+ # `package_product_dependencies' for nil".
252
+ if installer.pod_targets.any? { |pod| pod.pod_name == 'DatadogSDKReactNative' && pod.label != pod.pod_name }
253
+ raise "Datadog: the native iOS SDK cannot be resolved through Swift Package Manager when one " \
254
+ "Podfile builds the Datadog pods for more than one platform."
255
+ end
256
+
257
+ datadog_reserve_unique_uuids(installer.pods_project)
258
+ core = installer.pod_targets.find { |pod| pod.pod_name == 'DatadogSDKReactNative' }
259
+ datadog_dedupe_static_archive(installer, core) unless core.nil?
260
+ super(installer)
261
+ datadog_link_static_products_from_core(installer, core) unless core.nil?
262
+ datadog_restore_static_pod_build_dirs(installer, core) unless core.nil?
263
+ datadog_update_moved_module_map_references(installer)
264
+ embed = <<~'SH'
265
+ # Embeds the Datadog Swift package frameworks that Xcode builds dynamically. Looks where Xcode
266
+ # writes them: the products dir, PackageFrameworks, or UninstalledProducts when archiving.
267
+ embed_datadog_spm_frameworks()
268
+ {
269
+ local dir framework found
270
+ for dir in "${PODS_CONFIGURATION_BUILD_DIR}" "${PODS_CONFIGURATION_BUILD_DIR}/PackageFrameworks" "${OBJROOT}/UninstalledProducts/${PLATFORM_NAME}"; do
271
+ found=false
272
+ for framework in "${dir}"/$1.framework; do
273
+ [ -d "${framework}" ] || continue
274
+ found=true
275
+ if file -b "${framework}/$(basename "${framework}" .framework)" | grep -q "dynamically linked"; then
276
+ install_framework "${framework}"
277
+ fi
278
+ done
279
+ [ "${found}" = true ] && return 0
280
+ done
281
+ # Nothing to embed (e.g. every Datadog product is linked statically) is fine; returning the
282
+ # last test's status instead would abort the script, which runs with `set -e`.
283
+ return 0
284
+ }
285
+ embed_datadog_spm_frameworks "DatadogInternal"
286
+ embed_datadog_spm_frameworks "Datadog*_PackageProduct"
287
+ SH
288
+ # The embed phase's file lists only name the pod frameworks. Listing the package requirement makes
289
+ # an SDK version change rewrite this script, an input of the phase, so Xcode runs it again and
290
+ # copies the new frameworks, as React Native does for the frameworks it embeds itself.
291
+ requirements = datadog_package_requirement
292
+ anchor =/^if \[ "\$\{COCOAPODS_PARALLEL_CODE_SIGN\}" == "true" \]; then$/
293
+ installer.aggregate_targets.each do |target|
294
+ next unless target.pod_targets.any? { |pod| pod.pod_name == 'DatadogSDKReactNative' }
295
+ script_path = target.embed_frameworks_script_path
296
+ next unless File.exist?(script_path)
297
+ script = File.read(script_path)
298
+ next if script.include?('embed_datadog_spm_frameworks()')
299
+ unless script.match?(anchor)
300
+ raise "Datadog: could not add the native iOS SDK frameworks to #{script_path}, " \
301
+ "so the app would crash at launch in Release builds."
302
+ end
303
+ File.write(script_path, script.sub(anchor) { "#{embed}#{requirements}#{$&}" })
304
+ end
305
+ end
306
+ end)
307
+ end
308
+
5
309
  Pod::Spec.new do |s|
6
310
  s.name = "DatadogSDKReactNative"
7
311
  s.version = package["version"]
@@ -10,7 +314,7 @@ Pod::Spec.new do |s|
10
314
  s.license = package["license"]
11
315
  s.authors = package["author"]
12
316
 
13
- s.platforms = { :ios => "12.0", :tvos => "12.0" }
317
+ s.platforms = { :ios => "15.0", :tvos => "15.0" }
14
318
  s.source = { :git => "https://github.com/DataDog/dd-sdk-reactnative.git", :tag => "#{s.version}" }
15
319
 
16
320
 
@@ -18,28 +322,65 @@ Pod::Spec.new do |s|
18
322
 
19
323
  s.dependency "React-Core"
20
324
 
21
- # /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
22
- s.dependency 'DatadogCore', '3.16.1'
23
- s.dependency 'DatadogLogs', '3.16.1'
24
- s.dependency 'DatadogTrace', '3.16.1'
25
- s.dependency 'DatadogRUM', '3.16.1'
26
- s.dependency 'DatadogCrashReporting', '3.16.1'
27
- s.dependency 'DatadogFlags', '3.16.1'
28
-
29
- # DatadogWebViewTracking is not available for tvOS
30
- s.ios.dependency 'DatadogWebViewTracking', '3.16.1'
325
+ # `spm_dependency` cannot be scoped per-platform the way `s.ios.dependency` can, so
326
+ # DatadogWebViewTracking is requested for every platform here. Our Swift sources already
327
+ # guard the import with `#if os(iOS)`, but dd-sdk-ios declares the product for all of its
328
+ # package platforms — building this pod for tvOS through SPM is therefore untested.
329
+ #
330
+ # Note that DatadogInternal is deliberately absent: it is an internal target of
331
+ # dd-sdk-ios, not an exported SPM product, so it cannot be requested here. Making it
332
+ # importable takes an extra search path -- see the FRAMEWORK_SEARCH_PATHS note below.
333
+ spm_dependency(s,
334
+ url: datadog_ios_spm_url,
335
+ requirement: datadog_ios_requirement,
336
+ products: [
337
+ 'DatadogCore',
338
+ 'DatadogLogs',
339
+ 'DatadogTrace',
340
+ 'DatadogRUM',
341
+ 'DatadogCrashReporting',
342
+ 'DatadogFlags',
343
+ 'DatadogWebViewTracking'
344
+ ]
345
+ )
31
346
 
32
347
  s.test_spec 'Tests' do |test_spec|
33
348
  test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
34
349
  test_spec.resources = 'ios/Tests/Fixtures'
35
- test_spec.platforms = { :ios => "13.4", :tvos => "13.4" }
350
+ test_spec.platforms = { :ios => "15.0", :tvos => "15.0" }
36
351
  end
37
352
 
353
+ # DatadogInternal is an internal target of dd-sdk-ios rather than an exported product, so
354
+ # SwiftPM builds it into PackageFrameworks/ instead of emitting a bare .swiftmodule alongside
355
+ # the products. React Native's `spm_dependency` helper only appends the products directory to
356
+ # SWIFT_INCLUDE_PATHS, which leaves the module invisible to the compiler. Our sources import it
357
+ # for AnyEncodable, CoreRegistry, DatadogCoreProtocol and FeatureScope, so add the directory
358
+ # holding the package frameworks explicitly.
359
+ #
360
+ # Note this cannot be written against BUILT_PRODUCTS_DIR: CocoaPods gives every pod target its
361
+ # own CONFIGURATION_BUILD_DIR, so for this target BUILT_PRODUCTS_DIR is
362
+ # <symroot>/<config><platform>/DatadogSDKReactNative, one level below where SwiftPM actually
363
+ # writes PackageFrameworks/. Spelling it as SYMROOT/CONFIGURATION+EFFECTIVE_PLATFORM_NAME
364
+ # matches what `spm_dependency` itself uses for SWIFT_INCLUDE_PATHS.
365
+ #
366
+ # Archive builds lay this out differently: PackageFrameworks/ stays empty and the package
367
+ # frameworks are linked straight into the products directory itself, so search that too.
368
+ datadog_spm_xcconfig = {
369
+ 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/PackageFrameworks" "$(SYMROOT)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"'
370
+ }
371
+
372
+ xcconfig = datadog_spm_xcconfig.dup
373
+
38
374
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
39
- s.pod_target_xcconfig = {
375
+ xcconfig.merge!({
40
376
  "DEFINES_MODULE" => "YES",
41
377
  "OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1"
42
- }
378
+ })
379
+
380
+ # Assign before install_modules_dependencies: the helper reads the spec's current
381
+ # pod_target_xcconfig, merges React Native's own header search paths and C++ settings into it
382
+ # and assigns the result back, so assigning afterwards would drop everything it added.
383
+ s.pod_target_xcconfig = xcconfig
43
384
 
44
385
  # install_modules_dependencies is only available on RN >= 0.71
45
386
  if respond_to?(:install_modules_dependencies, true)
@@ -47,5 +388,7 @@ Pod::Spec.new do |s|
47
388
  else
48
389
  Pod::UI.warn "Using Datadog React Native SDK with new architecture on RN < 0.71 is discouraged and not officially supported."
49
390
  end
391
+ else
392
+ s.pod_target_xcconfig = xcconfig
50
393
  end
51
394
  end
package/README.md CHANGED
@@ -16,9 +16,9 @@ To install with Yarn, run:
16
16
  yarn add @datadog/mobile-react-native
17
17
  ```
18
18
 
19
- **Minimum React Native version**: SDK supports React Native version 0.63.4 or higher. Compatibility with older versions is not guaranteed out of the box.
19
+ **Minimum React Native version**: React Native 0.75 or higher. The native iOS SDK is resolved through Swift Package Manager, which needs React Native 0.75 or higher. If your app uses an older React Native version, use SDK version `3.12.x`. See the [migration guide][5] for details.
20
20
 
21
- Versions `1.0.0-rc5` and higher require you to have `compileSdkVersion = 31` in the Android application setup, which implies that you should use Build Tools version 31, Android Gradle Plugin version 7, and Gradle version 7 or higher. To modify the versions, change the values in the `buildscript.ext` block of your application's top-level `build.gradle` file. Datadog recommends using React Native version 0.67 or higher.
21
+ Versions `1.0.0-rc5` and higher require you to have `compileSdkVersion = 31` in the Android application setup, which implies that you should use Build Tools version 31, Android Gradle Plugin version 7, and Gradle version 7 or higher. To modify the versions, change the values in the `buildscript.ext` block of your application's top-level `build.gradle` file.
22
22
 
23
23
  ### Specify application details in UI
24
24
 
@@ -129,3 +129,4 @@ of your [application sandbox][4], which can't be read by any other app installed
129
129
  [2]: https://raw.githubusercontent.com/DataDog/dd-sdk-reactnative/main/docs/image_reactnative.png
130
130
  [3]: https://source.android.com/security/app-sandbox
131
131
  [4]: https://support.apple.com/guide/security/security-of-runtime-process-sec15bfe098e/web
132
+ [5]: https://github.com/DataDog/dd-sdk-reactnative/blob/develop/MIGRATION.md
@@ -222,7 +222,7 @@ dependencies {
222
222
  // This breaks builds if the React Native target is below 0.76.0. as it relies on Gradle 8.5.0.
223
223
  // To avoid this, we enforce 1.0.0-beta01 on RN < 0.76.0
224
224
  if (reactNativeMinorVersion < 76) {
225
- implementation("com.datadoghq:dd-sdk-android-rum:3.15.0") {
225
+ implementation("com.datadoghq:dd-sdk-android-rum:3.16.0") {
226
226
  exclude group: "androidx.metrics", module: "metrics-performance"
227
227
  }
228
228
  implementation "androidx.metrics:metrics-performance:1.0.0-beta01"
@@ -242,15 +242,15 @@ dependencies {
242
242
  }
243
243
  }
244
244
  } else {
245
- implementation "com.datadoghq:dd-sdk-android-rum:3.15.0"
245
+ implementation "com.datadoghq:dd-sdk-android-rum:3.16.0"
246
246
  }
247
- implementation "com.datadoghq:dd-sdk-android-logs:3.15.0"
248
- implementation "com.datadoghq:dd-sdk-android-trace:3.15.0"
249
- implementation "com.datadoghq:dd-sdk-android-webview:3.15.0"
250
- implementation "com.datadoghq:dd-sdk-android-ndk:3.15.0"
251
- implementation "com.datadoghq:dd-sdk-android-flags:3.15.0"
252
- implementation "com.datadoghq:dd-sdk-android-internal:3.15.0"
253
- implementation "com.datadoghq:dd-sdk-android-rum-prelaunch:3.15.0"
247
+ implementation "com.datadoghq:dd-sdk-android-logs:3.16.0"
248
+ implementation "com.datadoghq:dd-sdk-android-trace:3.16.0"
249
+ implementation "com.datadoghq:dd-sdk-android-webview:3.16.0"
250
+ implementation "com.datadoghq:dd-sdk-android-ndk:3.16.0"
251
+ implementation "com.datadoghq:dd-sdk-android-flags:3.16.0"
252
+ implementation "com.datadoghq:dd-sdk-android-internal:3.16.0"
253
+ implementation "com.datadoghq:dd-sdk-android-rum-prelaunch:3.16.0"
254
254
  implementation "com.google.code.gson:gson:2.11.0"
255
255
  testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
256
256
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
@@ -65,6 +65,8 @@ data class DdSdkConfiguration(
65
65
  * @param initialResourceThreshold The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS).
66
66
  * @param telemetrySampleRate The sample rate (between 0 and 100) of telemetry events.
67
67
  * @param customEndpoint Custom RUM intake endpoint used to override the default Datadog intake.
68
+ * @param timeseries Experimental: configuration for memory and CPU timeseries collection.
69
+ * A non-null value enables timeseries collection.
68
70
  */
69
71
  data class RumConfiguration(
70
72
  val applicationId: String,
@@ -82,7 +84,23 @@ data class RumConfiguration(
82
84
  val trackNonFatalAnrs: Boolean? = null,
83
85
  val initialResourceThreshold: Double? = null,
84
86
  val telemetrySampleRate: Double? = null,
85
- val customEndpoint: String? = null
87
+ val customEndpoint: String? = null,
88
+ val timeseries: TimeseriesConfiguration? = null
89
+ )
90
+
91
+ /**
92
+ * Experimental: the default set of timeseries types to collect (cpu and memory).
93
+ */
94
+ internal val DEFAULT_TIMESERIES_COLLECT_TYPES = listOf("cpu", "memory")
95
+
96
+ /**
97
+ * Experimental: configuration for memory and CPU timeseries collection.
98
+ *
99
+ * @param collectTypes The types of timeseries data to collect ("cpu", "memory"). Required.
100
+ * Use [DEFAULT_TIMESERIES_COLLECT_TYPES] to collect the default set.
101
+ */
102
+ data class TimeseriesConfiguration(
103
+ val collectTypes: List<String>
86
104
  )
87
105
 
88
106
  /**
@@ -157,7 +175,14 @@ internal data class JSONRumConfiguration(
157
175
  val vitalsUpdateFrequency: String? = null,
158
176
  val trackMemoryWarnings: Boolean? = null,
159
177
  val telemetrySampleRate: Double? = null,
160
- val customEndpoint: String? = null
178
+ val customEndpoint: String? = null,
179
+ // Gson maps this property name to the `unstable_timeseries` JSON key.
180
+ @Suppress("ConstructorParameterNaming")
181
+ val unstable_timeseries: JSONTimeseriesConfiguration? = null
182
+ )
183
+
184
+ internal data class JSONTimeseriesConfiguration(
185
+ val collectTypes: List<String>? = null
161
186
  )
162
187
 
163
188
  internal data class JSONLogsConfiguration(
@@ -18,6 +18,7 @@ import java.net.InetSocketAddress
18
18
  import java.net.Proxy
19
19
  import java.util.Locale
20
20
 
21
+ @Suppress("LongMethod")
21
22
  internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
22
23
  val additionalConfiguration = getMap("additionalConfiguration")?.toHashMap()
23
24
 
@@ -45,7 +46,8 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
45
46
  trackNonFatalAnrs = rm.getBooleanOrNull("trackNonFatalAnrs"),
46
47
  initialResourceThreshold = rm.getDoubleOrNull("initialResourceThreshold"),
47
48
  telemetrySampleRate = rm.getDoubleOrNull("telemetrySampleRate"),
48
- customEndpoint = rm.getString("customEndpoint")
49
+ customEndpoint = rm.getString("customEndpoint"),
50
+ timeseries = rm.getMap("unstable_timeseries")?.asTimeseriesConfiguration()
49
51
  )
50
52
  }
51
53
 
@@ -86,6 +88,13 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
86
88
  }
87
89
 
88
90
 
91
+ internal fun ReadableMap.asTimeseriesConfiguration(): TimeseriesConfiguration {
92
+ return TimeseriesConfiguration(
93
+ collectTypes = getArray("collectTypes")?.toArrayList()?.filterIsInstance<String>()
94
+ ?: DEFAULT_TIMESERIES_COLLECT_TYPES
95
+ )
96
+ }
97
+
89
98
  internal fun ReadableMap.asConfigurationForTelemetry(): ConfigurationForTelemetry {
90
99
  return ConfigurationForTelemetry(
91
100
  initializationType = getString("initializationType"),
@@ -187,7 +196,8 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
187
196
  initialResourceThreshold = rum.initialResourceThreshold ?: DefaultConfiguration.initialResourceThreshold,
188
197
  telemetrySampleRate = rum.telemetrySampleRate?.toDouble()
189
198
  ?: DefaultConfiguration.telemetrySampleRate,
190
- customEndpoint = rum.customEndpoint
199
+ customEndpoint = rum.customEndpoint,
200
+ timeseries = rum.unstable_timeseries?.asTimeseriesConfiguration()
191
201
  )
192
202
  }
193
203
 
@@ -229,6 +239,12 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
229
239
  }
230
240
 
231
241
 
242
+ internal fun JSONTimeseriesConfiguration.asTimeseriesConfiguration(): TimeseriesConfiguration {
243
+ return TimeseriesConfiguration(
244
+ collectTypes = this.collectTypes ?: DEFAULT_TIMESERIES_COLLECT_TYPES
245
+ )
246
+ }
247
+
232
248
  internal fun JSONProxyConfiguration.asProxyConfig(): Pair<Proxy, ProxyAuthenticator?>? {
233
249
  return buildProxyConfig(type, address, port, username, password)
234
250
  }
@@ -331,6 +347,15 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
331
347
  rum.initialResourceThreshold?.let { rumMap.putDouble("initialResourceThreshold", it) }
332
348
  rum.telemetrySampleRate?.let { rumMap.putDouble("telemetrySampleRate", it) }
333
349
  rum.customEndpoint?.let { rumMap.putString("customEndpoint", it) }
350
+ rum.timeseries?.let { timeseries ->
351
+ val timeseriesMap = WritableNativeMap()
352
+ timeseries.collectTypes?.let { types ->
353
+ val typesArray = WritableNativeArray()
354
+ types.forEach { typesArray.pushString(it) }
355
+ timeseriesMap.putArray("collectTypes", typesArray)
356
+ }
357
+ rumMap.putMap("unstable_timeseries", timeseriesMap)
358
+ }
334
359
 
335
360
  map.putMap("rumConfiguration", rumMap)
336
361
  }
@@ -19,6 +19,7 @@ import com.datadog.android.event.EventMapper
19
19
  import com.datadog.android.log.Logs
20
20
  import com.datadog.android.log.LogsConfiguration
21
21
  import com.datadog.android.privacy.TrackingConsent
22
+ import com.datadog.android.rum.ExperimentalRumApi
22
23
  import com.datadog.android.rum.Rum
23
24
  import com.datadog.android.rum.RumConfiguration
24
25
  import com.datadog.android._InternalProxy
@@ -27,6 +28,8 @@ import com.datadog.android.rum.configuration.VitalsUpdateFrequency
27
28
  import com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIdentifier
28
29
  import com.datadog.android.rum.model.ActionEvent
29
30
  import com.datadog.android.rum.model.ResourceEvent
31
+ import com.datadog.android.rum.timeseries.TimeseriesConfiguration as NativeTimeseriesConfiguration
32
+ import com.datadog.android.rum.timeseries.TimeseriesType as NativeTimeseriesType
30
33
  import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
31
34
  import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
32
35
  import com.datadog.android.trace.Trace
@@ -253,11 +256,33 @@ class DdSdkNativeInitialization internal constructor(
253
256
  configBuilder.setInitialResourceIdentifier(TimeBasedInitialResourceIdentifier(milliseconds))
254
257
  }
255
258
 
259
+ configuration.rumConfiguration?.timeseries?.let { timeseries ->
260
+ setTimeseriesConfiguration(configBuilder, timeseries)
261
+ }
262
+
256
263
  configBuilder.setSessionListener(DdSdkSessionStartedListener.getInstance())
257
264
 
258
265
  return configBuilder.build()
259
266
  }
260
267
 
268
+ @OptIn(ExperimentalRumApi::class)
269
+ private fun setTimeseriesConfiguration(
270
+ configBuilder: RumConfiguration.Builder,
271
+ timeseries: TimeseriesConfiguration
272
+ ) {
273
+ val collectTypes = timeseries.collectTypes.mapNotNull { it.asTimeseriesType() }.toSet()
274
+
275
+ configBuilder.setTimeseriesConfiguration(NativeTimeseriesConfiguration(collectTypes))
276
+ }
277
+
278
+ private fun String.asTimeseriesType(): NativeTimeseriesType? {
279
+ return when (lowercase(Locale.US)) {
280
+ "cpu" -> NativeTimeseriesType.CPU
281
+ "memory" -> NativeTimeseriesType.MEMORY
282
+ else -> null
283
+ }
284
+ }
285
+
261
286
  private fun buildLogsConfiguration(configuration: DdSdkConfiguration): LogsConfiguration {
262
287
  val configBuilder = LogsConfiguration.Builder()
263
288
  configuration.logsConfiguration?.customEndpoint?.let {
@@ -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.12.0"
10
+ internal const val SDK_VERSION = "3.13.0"
@@ -144,6 +144,9 @@ internal class DdSdkNativeInitializationTest {
144
144
  "[B3MULTI, TRACECONTEXT]"
145
145
  )
146
146
  assertThat(configuration.rumConfiguration?.initialResourceThreshold).isEqualTo(0.5)
147
+ assertThat(configuration.rumConfiguration?.timeseries?.collectTypes).isEqualTo(
148
+ listOf("cpu")
149
+ )
147
150
  }
148
151
 
149
152
  @Test
@@ -192,6 +195,7 @@ internal class DdSdkNativeInitializationTest {
192
195
  assertThat(configuration.rumConfiguration?.firstPartyHosts).isNull()
193
196
  assertThat(configuration.logsConfiguration?.customEndpoint).isNull()
194
197
  assertThat(configuration.traceConfiguration?.customEndpoint).isNull()
198
+ assertThat(configuration.rumConfiguration?.timeseries).isNull()
195
199
  }
196
200
 
197
201
  @Test