@datadog/mobile-react-native 2.14.6 → 2.14.7

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 (28) hide show
  1. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +9 -0
  2. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +13 -6
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSessionStartedListener.kt +93 -22
  4. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  5. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +68 -0
  6. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkSessionStartedListenerTest.kt +38 -1
  7. package/ios/Sources/DdSdkNativeInitialization.swift +24 -18
  8. package/ios/Sources/DdSdkSessionStartedListener.swift +28 -1
  9. package/ios/Sources/SdkVersion.swift +1 -1
  10. package/lib/commonjs/metro/debugIdResolver.js +5 -3
  11. package/lib/commonjs/metro/debugIdResolver.js.map +1 -1
  12. package/lib/commonjs/metro/plugin/metroSerializer.js +4 -3
  13. package/lib/commonjs/metro/plugin/metroSerializer.js.map +1 -1
  14. package/lib/commonjs/version.js +1 -1
  15. package/lib/module/metro/debugIdResolver.js +5 -3
  16. package/lib/module/metro/debugIdResolver.js.map +1 -1
  17. package/lib/module/metro/plugin/metroSerializer.js +4 -3
  18. package/lib/module/metro/plugin/metroSerializer.js.map +1 -1
  19. package/lib/module/version.js +1 -1
  20. package/lib/typescript/metro/debugIdResolver.d.ts.map +1 -1
  21. package/lib/typescript/metro/plugin/metroSerializer.d.ts +1 -1
  22. package/lib/typescript/metro/plugin/metroSerializer.d.ts.map +1 -1
  23. package/lib/typescript/version.d.ts +1 -1
  24. package/package.json +2 -2
  25. package/src/metro/__tests__/metro.test.ts +13 -0
  26. package/src/metro/debugIdResolver.ts +7 -3
  27. package/src/metro/plugin/metroSerializer.ts +11 -3
  28. package/src/version.ts +1 -1
@@ -39,6 +39,15 @@ class DdSdkImplementation(
39
39
  fun initialize(configuration: ReadableMap, promise: Promise) {
40
40
  val ddSdkConfiguration = configuration.asDdSdkConfiguration()
41
41
 
42
+ // On new arch DdSdk is a lazy TurboModule — it's instantiated on the first JS-side
43
+ // method call (typically this initialize()), which usually lands AFTER the activity's
44
+ // first onHostResume. That means registerLifecycleEvents's listener missed the first
45
+ // resume, reactContext is still null on the session listener, and the replay inside
46
+ // nativeInitialization.initialize → onRnSdkInitialized has no emitter target. Setting
47
+ // the reactContext here — we are provably being dispatched through an active one —
48
+ // closes that race so the cached session ID is delivered on the first JS init.
49
+ DdSdkSessionStartedListener.getInstance().setReactContext(reactContext)
50
+
42
51
  val nativeInitialization = DdSdkNativeInitialization(appContext, datadog)
43
52
  nativeInitialization.initialize(ddSdkConfiguration)
44
53
 
@@ -39,7 +39,7 @@ class DdSdkNativeInitialization internal constructor(
39
39
  private val datadog: DatadogWrapper = DatadogSDKWrapper(),
40
40
  private val jsonFileReader: JSONFileReader = JSONFileReader()
41
41
  ) {
42
- internal fun initialize(ddSdkConfiguration: DdSdkConfiguration) {
42
+ internal fun initialize(ddSdkConfiguration: DdSdkConfiguration, isCalledFromJs: Boolean = true) {
43
43
  val sdkConfiguration = buildSdkConfiguration(ddSdkConfiguration)
44
44
  val rumConfiguration = buildRumConfiguration(ddSdkConfiguration)
45
45
  val logsConfiguration = buildLogsConfiguration(ddSdkConfiguration)
@@ -49,10 +49,14 @@ class DdSdkNativeInitialization internal constructor(
49
49
  configureSdkVerbosity(ddSdkConfiguration)
50
50
  configureRumAndTracesForLogs(ddSdkConfiguration)
51
51
 
52
- if (datadog.isInitialized()) {
53
- datadog.getRumMonitor().getCurrentSessionId {
54
- it?.let { sessionId ->
55
- DdSdkSessionStartedListener.getInstance().onSessionStarted(sessionId, false)
52
+ if (isCalledFromJs) {
53
+ DdSdkSessionStartedListener.getInstance().onRnSdkInitialized()
54
+ // Handles the case in which the SDK was already initialized with initFromNative.
55
+ if (datadog.isInitialized()) {
56
+ datadog.getRumMonitor().getCurrentSessionId {
57
+ it?.let { sessionId ->
58
+ DdSdkSessionStartedListener.getInstance().onSessionStarted(sessionId, false)
59
+ }
56
60
  }
57
61
  }
58
62
  }
@@ -376,7 +380,10 @@ class DdSdkNativeInitialization internal constructor(
376
380
  fun initFromNative(appContext: Context) {
377
381
  val nativeInitialization = DdSdkNativeInitialization(appContext.applicationContext)
378
382
  try {
379
- nativeInitialization.initialize(nativeInitialization.getConfigurationFromJSONFile())
383
+ nativeInitialization.initialize(
384
+ ddSdkConfiguration = nativeInitialization.getConfigurationFromJSONFile(),
385
+ isCalledFromJs = false
386
+ )
380
387
  } catch (@Suppress("TooGenericExceptionCaught") error: Exception) {
381
388
  Log.w(
382
389
  DdSdkNativeInitialization::class.java.canonicalName,
@@ -14,13 +14,27 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
14
14
  import org.jetbrains.annotations.TestOnly
15
15
 
16
16
 
17
- internal class DdSdkSessionStartedListener private constructor(): RumSessionListener {
17
+ internal class DdSdkSessionStartedListener private constructor() : RumSessionListener {
18
18
  companion object {
19
+ // JS-side callable module registered via BatchedBridge.registerCallableModule.
19
20
  private const val BRIDGE_MODULE_NAME = "DatadogInternalReactBridge"
20
21
  private const val BRIDGE_MODULE_METHOD = "__datadogOnMessageReceived"
21
22
 
22
23
  private var instance: DdSdkSessionStartedListener? = null
23
24
 
25
+ // Process-level state — tracks whether JS initialize() has ever run since the
26
+ // app process started. Kept outside the instance on purpose: the listener
27
+ // singleton is recreated on every onHostPause/onHostDestroy via invalidate(),
28
+ // but the JS bridge module registration survives activity lifecycle events, so
29
+ // this flag must survive them too.
30
+ private var isRnSdkInitialized: Boolean = false
31
+
32
+ // Routes UI-thread dispatch through an injectable abstraction. Tests inject
33
+ // TestUiThreadExecutor (synchronous, no main looper required) instead of the
34
+ // real ReactUiThreadExecutor that wraps UiThreadUtil.
35
+ private var uiThreadExecutor: UiThreadExecutor = ReactUiThreadExecutor()
36
+
37
+ // Returns the shared listener instance, creating it on first call.
24
38
  fun getInstance(): DdSdkSessionStartedListener {
25
39
  if (instance == null) {
26
40
  instance = DdSdkSessionStartedListener()
@@ -28,26 +42,67 @@ internal class DdSdkSessionStartedListener private constructor(): RumSessionList
28
42
  return instance!!
29
43
  }
30
44
 
45
+ // Resets the singleton — used in tests and on host pause/destroy to release the
46
+ // React context reference. Does NOT reset isRnSdkInitialized, which tracks
47
+ // process-level JS-bridge registration state.
31
48
  fun invalidate() {
32
49
  instance = null
33
50
  }
51
+
52
+ @TestOnly
53
+ fun resetIsRnSdkInitialized() {
54
+ isRnSdkInitialized = false
55
+ }
56
+
57
+ @TestOnly
58
+ fun isRnSdkInitializedForTests(): Boolean = isRnSdkInitialized
34
59
  }
35
60
 
36
- private var reactContext: ReactContext? = null
61
+ // Cached so it can be delivered once the bridge becomes available.
37
62
  private var lastSessionId: String? = null
63
+
64
+ // Set from onHostResume; null until the React activity is first resumed.
65
+ private var reactContext: ReactContext? = null
66
+ // Overridable in tests — NativeArray cannot be instantiated without the native SO.
38
67
  private var convertToNativeArray: ((array: Array<String>) -> NativeArray?)? = null
39
- private var exceptionHandler: ((error:Exception)->Unit)? = null
68
+ // Overridable in tests to assert on bridge exceptions without crashing.
69
+ private var exceptionHandler: ((error: Exception) -> Unit)? = null
70
+ // Lazily resolved from BuildConfig; overridable in tests.
40
71
  private var isNewArchitecture: Boolean? = null
41
72
 
73
+ // Stores the session ID and attempts immediate delivery.
42
74
  override fun onSessionStarted(sessionId: String, isDiscarded: Boolean) {
43
- sendSessionStartedToJS(sessionId)
75
+ this.lastSessionId = sessionId
76
+ trySendSessionStartedToJS(sessionId)
44
77
  }
45
78
 
79
+ // Stores the React context and schedules a catch-up delivery for any cached session
80
+ // ID on the UI thread. Called from:
81
+ // - DdSdk#onHostResume (both architectures) via the lifecycle listener
82
+ // - DdSdkImplementation#initialize (new-arch race fix — the TurboModule is lazy-
83
+ // instantiated, so the first onHostResume may have fired before its lifecycle
84
+ // listener was registered; setting the context here guarantees a non-null
85
+ // target for onRnSdkInitialized's replay)
86
+ //
87
+ // Delivery is dispatched to the UI thread because sendSessionIdWithBridge and
88
+ // sendSessionIdWithEventEmitter are @MainThread. The field assignment stays
89
+ // synchronous so callers that rely on reactContext being set immediately after
90
+ // this call (e.g. a same-stack onRnSdkInitialized) see the new value.
46
91
  fun setReactContext(reactContext: ReactContext) {
47
92
  this.reactContext = reactContext
48
- if (hasValidBridge()) {
49
- this.lastSessionId?.let { sendSessionStartedToJS(it) }
50
- }
93
+ val cached = this.lastSessionId ?: return
94
+ uiThreadExecutor.runOnUiThread { trySendSessionStartedToJS(cached) }
95
+ }
96
+
97
+ // Called when the RN SDK is initialized from JS for the first time while the native
98
+ // SDK was already running. At this point DatadogInternalReactBridge is guaranteed to
99
+ // be registered, so it is safe to deliver any session ID that was stored before the
100
+ // React bridge was available. Delivery is posted to the UI thread for the same
101
+ // reason as setReactContext.
102
+ fun onRnSdkInitialized() {
103
+ isRnSdkInitialized = true
104
+ val cached = this.lastSessionId ?: return
105
+ uiThreadExecutor.runOnUiThread { trySendSessionStartedToJS(cached) }
51
106
  }
52
107
 
53
108
  @TestOnly
@@ -65,14 +120,28 @@ internal class DdSdkSessionStartedListener private constructor(): RumSessionList
65
120
  this.isNewArchitecture = isNewArch
66
121
  }
67
122
 
123
+ @TestOnly
124
+ fun setIsRnSdkInitialized(value: Boolean) {
125
+ isRnSdkInitialized = value
126
+ }
127
+
128
+ @TestOnly
129
+ fun setUiThreadExecutor(executor: UiThreadExecutor) {
130
+ uiThreadExecutor = executor
131
+ }
132
+
133
+ // Returns true only when it is safe to call callFunction on the JS thread.
68
134
  private fun hasValidBridge(): Boolean {
69
135
  val context = reactContext ?: return false
70
136
  val instance = context.catalystInstance ?: return false
71
137
  return !isNewArchitecture() &&
72
138
  !instance.isDestroyed &&
73
- context.hasActiveReactInstance()
139
+ context.hasActiveReactInstance() &&
140
+ isRnSdkInitialized
74
141
  }
75
142
 
143
+ // Lazily cached — BuildConfig is a compile-time constant but reading it through the
144
+ // nullable override lets tests inject the value without reflection.
76
145
  private fun isNewArchitecture(): Boolean {
77
146
  isNewArchitecture?.let { return it }
78
147
  BuildConfig.IS_NEW_ARCHITECTURE_ENABLED.let {
@@ -81,8 +150,8 @@ internal class DdSdkSessionStartedListener private constructor(): RumSessionList
81
150
  }
82
151
  }
83
152
 
84
- private fun sendSessionStartedToJS(sessionId: String) {
85
- this.lastSessionId = sessionId
153
+ // Routes delivery to the appropriate path based on arch and bridge readiness.
154
+ private fun trySendSessionStartedToJS(sessionId: String) {
86
155
  if (hasValidBridge()) {
87
156
  sendSessionIdWithBridge(sessionId)
88
157
  } else {
@@ -90,30 +159,32 @@ internal class DdSdkSessionStartedListener private constructor(): RumSessionList
90
159
  }
91
160
  }
92
161
 
162
+ // Old-arch delivery path via BatchedBridge.
93
163
  @MainThread
94
164
  private fun sendSessionIdWithBridge(sessionId: String) {
95
165
  @Suppress("TooGenericExceptionCaught")
96
166
  try {
97
- val args = arrayOf(sessionId)
98
- val nativeArray = if (convertToNativeArray != null) {
99
- convertToNativeArray?.invoke(args)
100
- } else {
101
- WritableNativeArray().apply {
102
- pushString("RUMSessionStarted")
103
- pushString(sessionId)
104
- }
105
- }
106
-
167
+ val args = arrayOf("RUMSessionStarted", sessionId)
107
168
  reactContext?.catalystInstance?.callFunction(
108
169
  BRIDGE_MODULE_NAME,
109
170
  BRIDGE_MODULE_METHOD,
110
- nativeArray
171
+ buildBridgeArgs(args)
111
172
  )
112
- } catch(err: Exception) {
173
+ } catch (err: Exception) {
113
174
  exceptionHandler?.invoke(err)
114
175
  }
115
176
  }
116
177
 
178
+ private fun buildBridgeArgs(args: Array<String>): NativeArray? {
179
+ if (convertToNativeArray != null) {
180
+ return convertToNativeArray?.invoke(args)
181
+ }
182
+ return WritableNativeArray().apply {
183
+ args.forEach { pushString(it) }
184
+ }
185
+ }
186
+
187
+ // New-arch delivery path and fallback when the bridge is not active.
117
188
  @MainThread
118
189
  private fun sendSessionIdWithEventEmitter(sessionId: String) {
119
190
  val context = reactContext ?: return
@@ -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 = "2.14.6"
10
+ internal const val SDK_VERSION = "2.14.7"
@@ -7,6 +7,7 @@
7
7
  package com.datadog.reactnative
8
8
 
9
9
  import android.content.pm.PackageInfo
10
+ import com.datadog.android.rum.RumMonitor
10
11
  import com.datadog.tools.unit.GenericAssert.Companion.assertThat
11
12
  import com.datadog.tools.unit.forge.BaseConfigurator
12
13
  import com.facebook.react.bridge.ReactApplicationContext
@@ -24,8 +25,12 @@ import org.mockito.Answers
24
25
  import org.mockito.Mock
25
26
  import org.mockito.junit.jupiter.MockitoExtension
26
27
  import org.mockito.junit.jupiter.MockitoSettings
28
+ import org.mockito.kotlin.any
27
29
  import org.mockito.kotlin.doReturn
28
30
  import org.mockito.kotlin.isNull
31
+ import org.mockito.kotlin.mock
32
+ import org.mockito.kotlin.never
33
+ import org.mockito.kotlin.verify
29
34
  import org.mockito.kotlin.whenever
30
35
  import org.mockito.quality.Strictness
31
36
 
@@ -66,6 +71,9 @@ internal class DdSdkNativeInitializationTest {
66
71
  mockDatadog,
67
72
  mockJSONFileReader
68
73
  )
74
+
75
+ DdSdkSessionStartedListener.invalidate()
76
+ DdSdkSessionStartedListener.resetIsRnSdkInitialized()
69
77
  }
70
78
 
71
79
  // region getConfigurationFromJSONFile
@@ -180,4 +188,64 @@ internal class DdSdkNativeInitializationTest {
180
188
  }
181
189
 
182
190
  // endregion
191
+
192
+ // region initialize()
193
+
194
+ @Test
195
+ fun `𝕄 mark RN SDK initialized and catch up session 𝕎 initialize() { isCalledFromJs=true, datadog already initialized }`() { // ktlint-disable-line max-line-length
196
+ // Given
197
+ val mockRumMonitor: RumMonitor = mock()
198
+ whenever(mockDatadog.isInitialized()) doReturn true
199
+ whenever(mockDatadog.getRumMonitor()) doReturn mockRumMonitor
200
+
201
+ // When
202
+ testedNativeInitialization.initialize(
203
+ ddSdkConfiguration = minimalConfiguration(),
204
+ isCalledFromJs = true
205
+ )
206
+
207
+ // Then
208
+ assertThat(DdSdkSessionStartedListener.isRnSdkInitializedForTests()).isTrue()
209
+ verify(mockRumMonitor).getCurrentSessionId(any())
210
+ }
211
+
212
+ @Test
213
+ fun `𝕄 mark RN SDK initialized without catch up 𝕎 initialize() { isCalledFromJs=true, datadog not initialized }`() { // ktlint-disable-line max-line-length
214
+ // Given
215
+ whenever(mockDatadog.isInitialized()) doReturn false
216
+
217
+ // When
218
+ testedNativeInitialization.initialize(
219
+ ddSdkConfiguration = minimalConfiguration(),
220
+ isCalledFromJs = true
221
+ )
222
+
223
+ // Then
224
+ assertThat(DdSdkSessionStartedListener.isRnSdkInitializedForTests()).isTrue()
225
+ verify(mockDatadog, never()).getRumMonitor()
226
+ }
227
+
228
+ @Test
229
+ fun `𝕄 not mark RN SDK initialized or catch up 𝕎 initialize() { isCalledFromJs=false }`() {
230
+ // Given
231
+ whenever(mockDatadog.isInitialized()) doReturn true
232
+
233
+ // When
234
+ testedNativeInitialization.initialize(
235
+ ddSdkConfiguration = minimalConfiguration(),
236
+ isCalledFromJs = false
237
+ )
238
+
239
+ // Then
240
+ assertThat(DdSdkSessionStartedListener.isRnSdkInitializedForTests()).isFalse()
241
+ verify(mockDatadog, never()).getRumMonitor()
242
+ }
243
+
244
+ // endregion
245
+
246
+ private fun minimalConfiguration(): DdSdkConfiguration = DdSdkConfiguration(
247
+ clientToken = "fake-client-token",
248
+ env = "fake-env",
249
+ applicationId = "fake-app-id"
250
+ )
183
251
  }
@@ -8,6 +8,7 @@
8
8
  package com.datadog.reactnative
9
9
 
10
10
  import com.datadog.tools.unit.GenericAssert.Companion.assertThat
11
+ import com.datadog.tools.unit.TestUiThreadExecutor
11
12
  import com.datadog.tools.unit.forge.BaseConfigurator
12
13
  import com.facebook.react.bridge.CatalystInstance
13
14
  import com.facebook.react.bridge.NativeArray
@@ -55,6 +56,8 @@ internal class DdSdkSessionStartedListenerTest {
55
56
  @BeforeEach
56
57
  fun `set up`() {
57
58
  DdSdkSessionStartedListener.invalidate()
59
+ DdSdkSessionStartedListener.resetIsRnSdkInitialized()
60
+ DdSdkSessionStartedListener.getInstance().setUiThreadExecutor(TestUiThreadExecutor())
58
61
  }
59
62
 
60
63
  @Test
@@ -91,6 +94,7 @@ internal class DdSdkSessionStartedListenerTest {
91
94
  instance.setReactContext(mockReactContext)
92
95
  instance.setExceptionHandler(mockExceptionHandler)
93
96
  instance.setIsNewArchitecture(false)
97
+ instance.setIsRnSdkInitialized(true)
94
98
 
95
99
  val passedArgs = mutableListOf<String>()
96
100
  instance.setConvertToNativeArray {
@@ -111,6 +115,36 @@ internal class DdSdkSessionStartedListenerTest {
111
115
  )
112
116
  }
113
117
 
118
+ @Test
119
+ fun `𝕄 session ID is NOT sent via bridge W { setReactContext fires before onRnSdkInitialized }`() { // ktlint-disable-line max-line-length
120
+ // GIVEN — bridge looks valid but RN SDK has not called initialize() from JS yet
121
+ whenever(mockReactContext.hasActiveReactInstance()).thenReturn(true)
122
+ whenever(mockReactContext.catalystInstance).thenReturn(mockCatalystInstance)
123
+ whenever(mockCatalystInstance.isDestroyed).thenReturn(false)
124
+ whenever(mockReactContext.fabricUIManager).thenReturn(null)
125
+
126
+ val instance = DdSdkSessionStartedListener.getInstance()
127
+
128
+ val mockConvertToNativeArray = mock<(array: Array<String>) -> NativeArray?>()
129
+ instance.setConvertToNativeArray(mockConvertToNativeArray)
130
+ instance.setIsNewArchitecture(false)
131
+
132
+ // WHEN — native session starts and context becomes available before JS initialize()
133
+ instance.onSessionStarted("TEST-SESSION-ID", false)
134
+ instance.setReactContext(mockReactContext)
135
+
136
+ // THEN — bridge must NOT be called (DatadogInternalReactBridge not yet registered)
137
+ verifyNoInteractions(mockConvertToNativeArray)
138
+
139
+ // WHEN — JS initialize() runs, guaranteeing the callable module is registered
140
+ instance.onRnSdkInitialized()
141
+
142
+ // THEN — catch-up delivery is now safe and matches __datadogOnMessageReceived(eventName, data)
143
+ verify(mockConvertToNativeArray).invoke(
144
+ argWhere { it.size == 2 && it[0] == "RUMSessionStarted" && it[1] == "TEST-SESSION-ID" }
145
+ )
146
+ }
147
+
114
148
  @Test
115
149
  fun `𝕄 session ID event is delayed until context is available W { bridge }`() {
116
150
  // GIVEN
@@ -134,9 +168,12 @@ internal class DdSdkSessionStartedListenerTest {
134
168
  verifyNoInteractions(mockConvertToNativeArray)
135
169
 
136
170
  // WHEN
171
+ instance.setIsRnSdkInitialized(true)
137
172
  instance.setReactContext(mockReactContext)
138
173
 
139
174
  // THEN
140
- verify(mockConvertToNativeArray).invoke(argWhere { it.first() == "TEST-SESSION-ID" })
175
+ verify(mockConvertToNativeArray).invoke(
176
+ argWhere { it.size == 2 && it[0] == "RUMSessionStarted" && it[1] == "TEST-SESSION-ID" }
177
+ )
141
178
  }
142
179
  }
@@ -32,33 +32,39 @@ public class DdSdkNativeInitialization: NSObject {
32
32
  self.jsonFileReader = jsonFileReader
33
33
  }
34
34
 
35
- internal func initialize(sdkConfiguration: DdSdkConfiguration) {
36
- // TODO: see if this `if` is still needed
35
+ internal func initialize(sdkConfiguration: DdSdkConfiguration, isCalledFromJs: Bool = true) {
37
36
  if DatadogSDKWrapper.shared.isInitialized() {
38
37
  // Initializing the SDK twice results in Global.rum and
39
38
  // Global.sharedTracer to be set to no-op instances
40
39
  consolePrint("Datadog SDK is already initialized, skipping initialization.", .debug)
41
40
  DatadogSDKWrapper.shared.telemetryDebug(id: "datadog_react_native: RN SDK was already initialized in native", message: "RN SDK was already initialized in native")
41
+ } else {
42
+ self.setVerbosityLevel(configuration: sdkConfiguration)
42
43
 
43
- RUMMonitor.shared().currentSessionID { sessionId in
44
- guard let id = sessionId else { return }
45
- DdSdkSessionStartedListener.instance.rumSessionListener?(id, false)
46
- }
44
+ let coreConfiguration = self.buildSDKConfiguration(configuration: sdkConfiguration)
45
+ DatadogSDKWrapper.shared.initialize(
46
+ coreConfiguration: coreConfiguration,
47
+ loggerConfiguration: DatadogLogs.Logger.Configuration(sdkConfiguration),
48
+ trackingConsent: sdkConfiguration.trackingConsent
49
+ )
47
50
 
48
- return
51
+ self.enableFeatures(sdkConfiguration: sdkConfiguration)
49
52
  }
50
- self.setVerbosityLevel(configuration: sdkConfiguration)
51
-
52
- let coreConfiguration = self.buildSDKConfiguration(configuration: sdkConfiguration)
53
- DatadogSDKWrapper.shared.initialize(
54
- coreConfiguration: coreConfiguration,
55
- loggerConfiguration: DatadogLogs.Logger.Configuration(sdkConfiguration),
56
- trackingConsent: sdkConfiguration.trackingConsent
57
- )
58
53
 
59
- self.enableFeatures(sdkConfiguration: sdkConfiguration)
54
+ if isCalledFromJs {
55
+ DdSdkSessionStartedListener.instance.onRnSdkInitialized()
56
+ // Handles the case in which the SDK was already initialized via initFromNative.
57
+ // Replay the current session ID so the listener can deliver it now that the
58
+ // JS-side DatadogInternalReactBridge module is guaranteed to be registered.
59
+ if DatadogSDKWrapper.shared.isInitialized() {
60
+ RUMMonitor.shared().currentSessionID { sessionId in
61
+ guard let id = sessionId else { return }
62
+ DdSdkSessionStartedListener.instance.rumSessionListener?(id, false)
63
+ }
64
+ }
65
+ }
60
66
  }
61
-
67
+
62
68
  internal func getConfigurationFromJSONFile() -> DdSdkConfiguration? {
63
69
  if let jsonResult = jsonFileReader.parseResourceFile(resourcePath: "datadog-configuration") as? Dictionary<String, AnyObject> {
64
70
  do {
@@ -75,7 +81,7 @@ public class DdSdkNativeInitialization: NSObject {
75
81
  @objc
76
82
  public func initializeFromNative() -> Void {
77
83
  if let configuration = getConfigurationFromJSONFile() {
78
- self.initialize(sdkConfiguration: configuration)
84
+ self.initialize(sdkConfiguration: configuration, isCalledFromJs: false)
79
85
  }
80
86
  }
81
87
 
@@ -29,6 +29,11 @@ public class DdSdkSessionStartedListener: NSObject {
29
29
  private static let BRIDGE_EVENT_NAME = "RUMSessionStarted"
30
30
  private static var _instance: DdSdkSessionStartedListener?
31
31
 
32
+ // Process-level state — survives instance invalidate() because the JS-side
33
+ // DatadogInternalReactBridge registration survives bridge-lifecycle resets
34
+ // for the lifetime of the JS runtime / process.
35
+ private static var isRnSdkInitialized: Bool = false
36
+
32
37
  private var rctBridge: RCTBridge?
33
38
  private var rctEventEmitter: RCTEventEmitter?
34
39
  private var lastSessionId: String?
@@ -57,11 +62,22 @@ public class DdSdkSessionStartedListener: NSObject {
57
62
  tryToSendSessionId()
58
63
  }
59
64
 
65
+ /// Called when the RN SDK is initialized from JS. At this point
66
+ /// DatadogInternalReactBridge (the JS-side callable module registered by
67
+ /// BatchedBridge.registerCallableModule) is guaranteed to be registered,
68
+ /// so it is safe to deliver any session ID that was buffered before the
69
+ /// bridge was usable.
70
+ @objc public func onRnSdkInitialized() {
71
+ Self.isRnSdkInitialized = true
72
+ tryToSendSessionId()
73
+ }
74
+
60
75
  func invalidate() {
61
76
  self.rctBridge = nil
62
77
  self.listener = nil
63
78
  self.hasListeners = false
64
79
  self.lastSessionId = nil
80
+ // isRnSdkInitialized is intentionally NOT reset — see field comment.
65
81
  }
66
82
 
67
83
  private func tryToSendSessionId() {
@@ -71,9 +87,12 @@ public class DdSdkSessionStartedListener: NSObject {
71
87
 
72
88
  if isBridgeless() {
73
89
  sendToJsWithListener(sessionId: sessionId)
74
- } else {
90
+ } else if Self.isRnSdkInitialized {
75
91
  sendToJsWithBridge(sessionId: sessionId)
76
92
  }
93
+ // else: bridge path is gated until JS DdSdk.initialize() runs, so that
94
+ // DatadogInternalReactBridge is guaranteed to be registered. The cached
95
+ // lastSessionId will be replayed when onRnSdkInitialized() fires.
77
96
  }
78
97
 
79
98
  private func sendToJsWithBridge(sessionId: String) {
@@ -102,4 +121,12 @@ public class DdSdkSessionStartedListener: NSObject {
102
121
  private func isBridgeless() -> Bool {
103
122
  return self.rctBridge == nil
104
123
  }
124
+
125
+ static func resetIsRnSdkInitializedForTests() {
126
+ isRnSdkInitialized = false
127
+ }
128
+
129
+ static func isRnSdkInitializedForTests() -> Bool {
130
+ return isRnSdkInitialized
131
+ }
105
132
  }
@@ -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 = "2.14.6"
10
+ let SdkVersion = "2.14.7"
@@ -20,17 +20,19 @@ function loadDebugId() {
20
20
  if (typeof globalThis === 'undefined') {
21
21
  return;
22
22
  }
23
+ const shouldWarn = process.env.NODE_ENV !== 'test' && __DEV__ !== true;
23
24
  try {
24
25
  const debugIds = globalThis._datadogDebugIds;
25
- if (!debugIds || Object.keys(debugIds).length === 0) {
26
- if (process.env.NODE_ENV !== 'test') {
26
+ const hasDebugId = debugIds && Object.keys(debugIds).length > 0;
27
+ if (!hasDebugId) {
28
+ if (shouldWarn) {
27
29
  console.warn('[Datadog SDK] Debug ID not found. Are you using @datadog/mobile-react-native/metro config?');
28
30
  }
29
31
  return;
30
32
  }
31
33
  exports.debugId = debugId = debugIds[Object.keys(debugIds)[0]];
32
34
  } catch (error) {
33
- if (process.env.NODE_ENV !== 'test') {
35
+ if (shouldWarn) {
34
36
  console.warn('[Datadog SDK] Error while retrieving Debug ID. Are you using @datadog/mobile-react-native/metro config?');
35
37
  }
36
38
  }
@@ -1 +1 @@
1
- {"version":3,"names":["debugId","exports","loadDebugId","globalThis","debugIds","_datadogDebugIds","Object","keys","length","process","env","NODE_ENV","console","warn","error"],"sourceRoot":"../../../src","sources":["metro/debugIdResolver.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAIA,OAAmB,GAAAC,OAAA,CAAAD,OAAA,GAAG,IAAI;;AAE9B;AACA;AACA;AACA,SAASE,WAAWA,CAAA,EAAG;EACnB,IAAI,OAAOC,UAAU,KAAK,WAAW,EAAE;IACnC;EACJ;EACA,IAAI;IACA,MAAMC,QAAQ,GAAID,UAAU,CAASE,gBAAgB;IACrD,IAAI,CAACD,QAAQ,IAAIE,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,MAAM,KAAK,CAAC,EAAE;MACjD,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;QACjCC,OAAO,CAACC,IAAI,CACR,4FACJ,CAAC;MACL;MACA;IACJ;IAEAZ,OAAA,CAAAD,OAAA,GAAAA,OAAO,GAAGI,QAAQ,CAACE,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EAChD,CAAC,CAAC,OAAOU,KAAK,EAAE;IACZ,IAAIL,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;MACjCC,OAAO,CAACC,IAAI,CACR,yGACJ,CAAC;IACL;EACJ;AACJ;AAEAX,WAAW,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["debugId","exports","loadDebugId","globalThis","shouldWarn","process","env","NODE_ENV","__DEV__","debugIds","_datadogDebugIds","hasDebugId","Object","keys","length","console","warn","error"],"sourceRoot":"../../../src","sources":["metro/debugIdResolver.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAIA,OAAmB,GAAAC,OAAA,CAAAD,OAAA,GAAG,IAAI;;AAE9B;AACA;AACA;AACA,SAASE,WAAWA,CAAA,EAAG;EACnB,IAAI,OAAOC,UAAU,KAAK,WAAW,EAAE;IACnC;EACJ;EAEA,MAAMC,UAAU,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,IAAIC,OAAO,KAAK,IAAI;EACtE,IAAI;IACA,MAAMC,QAAQ,GAAIN,UAAU,CAASO,gBAAgB;IACrD,MAAMC,UAAU,GAAGF,QAAQ,IAAIG,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAACK,MAAM,GAAG,CAAC;IAE/D,IAAI,CAACH,UAAU,EAAE;MACb,IAAIP,UAAU,EAAE;QACZW,OAAO,CAACC,IAAI,CACR,4FACJ,CAAC;MACL;MACA;IACJ;IAEAf,OAAA,CAAAD,OAAA,GAAAA,OAAO,GAAGS,QAAQ,CAACG,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EAChD,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACZ,IAAIb,UAAU,EAAE;MACZW,OAAO,CAACC,IAAI,CACR,yGACJ,CAAC;IACL;EACJ;AACJ;AAEAd,WAAW,CAAC,CAAC","ignoreList":[]}
@@ -26,8 +26,8 @@ var _utils = require("./utils");
26
26
  const createDatadogMetroSerializer = customSerializer => {
27
27
  const serializer = customSerializer || createDefaultMetroSerializer();
28
28
  return async (entryPoint, preModules, graph, options) => {
29
- // Skip for hot reload mode
30
- if (graph.transformOptions.hot) {
29
+ // Skip for hot reload mode and web builds
30
+ if (graph.transformOptions.hot || graph.transformOptions.platform === 'web') {
31
31
  return serializer(entryPoint, preModules, graph, options);
32
32
  }
33
33
 
@@ -128,10 +128,11 @@ const createDatadogBundleCallback = debugIdModule => {
128
128
  */
129
129
  exports.createDatadogBundleCallback = createDatadogBundleCallback;
130
130
  function unstable_beforeAssetSerializationPlugin({
131
+ graph,
131
132
  premodules,
132
133
  debugId
133
134
  }) {
134
- if (!debugId || (0, _debugIdHelper.checkIfDebugIdModuleExists)(premodules)) {
135
+ if (graph.transformOptions.platform === 'web' || !debugId || (0, _debugIdHelper.checkIfDebugIdModuleExists)(premodules)) {
135
136
  return premodules;
136
137
  }
137
138
  return [...(0, _debugIdHelper.addDebugIdModule)(premodules, (0, _debugIdHelper.createDebugIdModule)(debugId))];
@@ -1 +1 @@
1
- {"version":3,"names":["_debugIdHelper","require","_utils","createDatadogMetroSerializer","customSerializer","serializer","createDefaultMetroSerializer","entryPoint","preModules","graph","options","transformOptions","hot","checkIfDebugIdModuleExists","debugIdModule","createDebugIdModule","DEBUG_ID_PLACEHOLDER","datadogBundleCallback","createDatadogBundleCallback","preModulesWithDebugId","addDebugIdModule","serializerOutput","code","map","getMetroBundleWithMap","debugId","getDebugIdFromBundleSource","Error","result","injectDebugIdInCodeAndSourceMap","exports","baseJSBundle","getBaseJSBundleFunction","bundle","bundleToString","getBundleToStringFunction","sourceMapString","getSourceMapStringFunction","getSortedModules","processModuleFilter","shouldAddToIgnoreList","createDebugIdFromBundle","getSource","toString","setSource","injectDebugIdInCode","pre","unstable_beforeAssetSerializationPlugin","premodules"],"sourceRoot":"../../../../src","sources":["metro/plugin/metroSerializer.ts"],"mappings":";;;;;;;AAQA,IAAAA,cAAA,GAAAC,OAAA;AAmBA,IAAAC,MAAA,GAAAD,OAAA;AA3BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,4BAA4B,GACrCC,gBAAkC,IACT;EACzB,MAAMC,UAAU,GAAGD,gBAAgB,IAAIE,4BAA4B,CAAC,CAAC;EACrE,OAAO,OAAOC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,KAAK;IACrD;IACA,IAAKD,KAAK,CAACE,gBAAgB,CAASC,GAAG,EAAE;MACrC,OAAOP,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,IAAI,IAAAG,yCAA0B,EAACL,UAAU,CAAC,EAAE;MACxC,OAAOH,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,MAAMI,aAAa,GAAG,IAAAC,kCAAmB,EAACC,mCAAoB,CAAC;;IAE/D;IACAN,OAAO,CAACO,qBAAqB,GAAGC,2BAA2B,CACvDJ,aACJ,CAAC;;IAED;IACA,MAAMK,qBAAqB,GAAG,IAAAC,+BAAgB,EAC1CZ,UAAU,EACVM,aACJ,CAAC;;IAED;IACA,MAAMO,gBAAgB,GAAGhB,UAAU,CAC/BE,UAAU,EACVY,qBAAqB,EACrBV,KAAK,EACLC,OACJ,CAAC;;IAED;IACA,MAAM;MAAEY,IAAI;MAAEC;IAAI,CAAC,G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,EAAE7B,OAAO,CAAC6B,mBAAmB;MAChDC,qBAAqB,EAAE9B,OAAO,CAAC8B;IACnC,CACJ,CAAC;IAED,OAAO;MAAElB,IAAI;MAAEC;IAAI,CAAC;EACxB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAO,OAAA,CAAAxB,4BAAA,GAAAA,4BAAA;AAKO,MAAMY,2BAA2B,GACpCJ,aAAmC,IAClC;EACD,OAAQmB,MAAc,IAAK;IACvB,MAAMR,OAAO,GAAG,IAAAgB,sCAAuB,EAACR,MAAM,CAAC;IAC/C,MAAMX,IAAI,GAAGR,aAAa,CAAC4B,SAAS,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;IACjD7B,aAAa,CAAC8B,SAAS,CAAC,IAAAC,kCAAmB,EAACvB,IAAI,EAAEG,OAAO,CAAC,CAAC;IAC3DQ,MAAM,CAACa,GAAG,GAAG,IAAAD,kCAAmB,EAACZ,MAAM,CAACa,GAAG,EAAErB,OAAO,CAAC;IACrD,OAAOQ,MAAM;EACjB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AAFAH,OAAA,CAAAZ,2BAAA,GAAAA,2BAAA;AAGO,SAAS6B,uCAAuCA,CAAC;EACpDC,UAAU;EACVvB;AAKJ,CAAC,EAAY;EACT,IAAI,CAACA,OAAO,IAAI,IAAAZ,yCAA0B,EAACmC,UAAU,CAAC,EAAE;IACpD,OAAOA,UAAU;EACrB;EACA,OAAO,CAAC,GAAG,IAAA5B,+BAAgB,EAAC4B,UAAU,EAAE,IAAAjC,kCAAmB,EAACU,OAAO,CAAC,CAAC,CAAC;AAC1E","ignoreList":[]}
1
+ {"version":3,"names":["_debugIdHelper","require","_utils","createDatadogMetroSerializer","customSerializer","serializer","createDefaultMetroSerializer","entryPoint","preModules","graph","options","transformOptions","hot","platform","checkIfDebugIdModuleExists","debugIdModule","createDebugIdModule","DEBUG_ID_PLACEHOLDER","datadogBundleCallback","createDatadogBundleCallback","preModulesWithDebugId","addDebugIdModule","serializerOutput","code","map","getMetroBundleWithMap","debugId","getDebugIdFromBundleSource","Error","result","injectDebugIdInCodeAndSourceMap","exports","baseJSBundle","getBaseJSBundleFunction","bundle","bundleToString","getBundleToStringFunction","sourceMapString","getSourceMapStringFunction","getSortedModules","processModuleFilter","shouldAddToIgnoreList","createDebugIdFromBundle","getSource","toString","setSource","injectDebugIdInCode","pre","unstable_beforeAssetSerializationPlugin","premodules"],"sourceRoot":"../../../../src","sources":["metro/plugin/metroSerializer.ts"],"mappings":";;;;;;;AAQA,IAAAA,cAAA,GAAAC,OAAA;AAmBA,IAAAC,MAAA,GAAAD,OAAA;AA3BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,4BAA4B,GACrCC,gBAAkC,IACT;EACzB,MAAMC,UAAU,GAAGD,gBAAgB,IAAIE,4BAA4B,CAAC,CAAC;EACrE,OAAO,OAAOC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,KAAK;IACrD;IACA,IACKD,KAAK,CAACE,gBAAgB,CAASC,GAAG,IACnCH,KAAK,CAACE,gBAAgB,CAACE,QAAQ,KAAK,KAAK,EAC3C;MACE,OAAOR,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,IAAI,IAAAI,yCAA0B,EAACN,UAAU,CAAC,EAAE;MACxC,OAAOH,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,MAAMK,aAAa,GAAG,IAAAC,kCAAmB,EAACC,mCAAoB,CAAC;;IAE/D;IACAP,OAAO,CAACQ,qBAAqB,GAAGC,2BAA2B,CACvDJ,aACJ,CAAC;;IAED;IACA,MAAMK,qBAAqB,GAAG,IAAAC,+BAAgB,EAC1Cb,UAAU,EACVO,aACJ,CAAC;;IAED;IACA,MAAMO,gBAAgB,GAAGj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exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = exports.version = '2.14.6';
8
+ const version = exports.version = '2.14.7';
9
9
  //# sourceMappingURL=version.js.map
@@ -14,17 +14,19 @@ function loadDebugId() {
14
14
  if (typeof globalThis === 'undefined') {
15
15
  return;
16
16
  }
17
+ const shouldWarn = process.env.NODE_ENV !== 'test' && __DEV__ !== true;
17
18
  try {
18
19
  const debugIds = globalThis._datadogDebugIds;
19
- if (!debugIds || Object.keys(debugIds).length === 0) {
20
- if (process.env.NODE_ENV !== 'test') {
20
+ const hasDebugId = debugIds && Object.keys(debugIds).length > 0;
21
+ if (!hasDebugId) {
22
+ if (shouldWarn) {
21
23
  console.warn('[Datadog SDK] Debug ID not found. Are you using @datadog/mobile-react-native/metro config?');
22
24
  }
23
25
  return;
24
26
  }
25
27
  debugId = debugIds[Object.keys(debugIds)[0]];
26
28
  } catch (error) {
27
- if (process.env.NODE_ENV !== 'test') {
29
+ if (shouldWarn) {
28
30
  console.warn('[Datadog SDK] Error while retrieving Debug ID. Are you using @datadog/mobile-react-native/metro config?');
29
31
  }
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"names":["debugId","loadDebugId","globalThis","debugIds","_datadogDebugIds","Object","keys","length","process","env","NODE_ENV","console","warn","error"],"sourceRoot":"../../../src","sources":["metro/debugIdResolver.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAIA,OAAmB,GAAG,IAAI;;AAE9B;AACA;AACA;AACA,SAASC,WAAWA,CAAA,EAAG;EACnB,IAAI,OAAOC,UAAU,KAAK,WAAW,EAAE;IACnC;EACJ;EACA,IAAI;IACA,MAAMC,QAAQ,GAAID,UAAU,CAASE,gBAAgB;IACrD,IAAI,CAACD,QAAQ,IAAIE,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,MAAM,KAAK,CAAC,EAAE;MACjD,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;QACjCC,OAAO,CAACC,IAAI,CACR,4FACJ,CAAC;MACL;MACA;IACJ;IAEAZ,OAAO,GAAGG,QAAQ,CAACE,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EAChD,CAAC,CAAC,OAAOU,KAAK,EAAE;IACZ,IAAIL,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;MACjCC,OAAO,CAACC,IAAI,CACR,yGACJ,CAAC;IACL;EACJ;AACJ;AAEAX,WAAW,CAAC,CAAC;AAEb,SAASD,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["debugId","loadDebugId","globalThis","shouldWarn","process","env","NODE_ENV","__DEV__","debugIds","_datadogDebugIds","hasDebugId","Object","keys","length","console","warn","error"],"sourceRoot":"../../../src","sources":["metro/debugIdResolver.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAIA,OAAmB,GAAG,IAAI;;AAE9B;AACA;AACA;AACA,SAASC,WAAWA,CAAA,EAAG;EACnB,IAAI,OAAOC,UAAU,KAAK,WAAW,EAAE;IACnC;EACJ;EAEA,MAAMC,UAAU,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,IAAIC,OAAO,KAAK,IAAI;EACtE,IAAI;IACA,MAAMC,QAAQ,GAAIN,UAAU,CAASO,gBAAgB;IACrD,MAAMC,UAAU,GAAGF,QAAQ,IAAIG,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAACK,MAAM,GAAG,CAAC;IAE/D,IAAI,CAACH,UAAU,EAAE;MACb,IAAIP,UAAU,EAAE;QACZW,OAAO,CAACC,IAAI,CACR,4FACJ,CAAC;MACL;MACA;IACJ;IAEAf,OAAO,GAAGQ,QAAQ,CAACG,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;EAChD,CAAC,CAAC,OAAOQ,KAAK,EAAE;IACZ,IAAIb,UAAU,EAAE;MACZW,OAAO,CAACC,IAAI,CACR,yGACJ,CAAC;IACL;EACJ;AACJ;AAEAd,WAAW,CAAC,CAAC;AAEb,SAASD,OAAO","ignoreList":[]}
@@ -19,8 +19,8 @@ import { getBaseJSBundleFunction, getBundleToStringFunction, convertSerializerOu
19
19
  export const createDatadogMetroSerializer = customSerializer => {
20
20
  const serializer = customSerializer || createDefaultMetroSerializer();
21
21
  return async (entryPoint, preModules, graph, options) => {
22
- // Skip for hot reload mode
23
- if (graph.transformOptions.hot) {
22
+ // Skip for hot reload mode and web builds
23
+ if (graph.transformOptions.hot || graph.transformOptions.platform === 'web') {
24
24
  return serializer(entryPoint, preModules, graph, options);
25
25
  }
26
26
 
@@ -118,10 +118,11 @@ export const createDatadogBundleCallback = debugIdModule => {
118
118
  * Adds Debug ID module for runtime injection, used for Expo.
119
119
  */
120
120
  export function unstable_beforeAssetSerializationPlugin({
121
+ graph,
121
122
  premodules,
122
123
  debugId
123
124
  }) {
124
- if (!debugId || checkIfDebugIdModuleExists(premodules)) {
125
+ if (graph.transformOptions.platform === 'web' || !debugId || checkIfDebugIdModuleExists(premodules)) {
125
126
  return premodules;
126
127
  }
127
128
  return [...addDebugIdModule(premodules, createDebugIdModule(debugId))];
@@ -1 +1 @@
1
- {"version":3,"names":["DEBUG_ID_PLACEHOLDER","addDebugIdModule","checkIfDebugIdModuleExists","createDebugIdFromBundle","createDebugIdModule","getDebugIdFromBundleSource","injectDebugIdInCode","injectDebugIdInCodeAndSourceMap","getBaseJSBundleFunction","getBundleToStringFunction","convertSerializerOutput","getMetroBundleWithMap","getSortedModules","getSourceMapStringFunction","createDatadogMetroSerializer","customSerializer","serializer","createDefaultMetroSerializer","entryPoint","preModules","graph","options","transformOptions","hot","debugIdModule","datadogBundleCallback","createDatadogBundleCallback","preModulesWithDebugId","serializerOutput","code","map","debugId","Error","result","baseJSBundle","bundle","bundleToString","sourceMapString","processModuleFilter","shouldAddToIgnoreList","getSource","toString","setSource","pre","unstable_beforeAssetSerializationPlugin","premodules"],"sourceRoot":"../../../../src","sources":["metro/plugin/metroSerializer.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACIA,oBAAoB,EACpBC,gBAAgB,EAChBC,0BAA0B,EAC1BC,uBAAuB,EACvBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,+BAA+B,QAC5B,iBAAiB;AAUxB,SACIC,uBAAuB,EACvBC,yBAAyB,EACzBC,uBAAuB,IAAIC,qBAAqB,EAChDC,gBAAgB,EAChBC,0BAA0B,QACvB,SAAS;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GACrCC,gBAAkC,IACT;EACzB,MAAMC,UAAU,GAAGD,gBAAgB,IAAIE,4BAA4B,CAAC,CAAC;EACrE,OAAO,OAAOC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,KAAK;IACrD;IACA,IAAKD,KAAK,CAACE,gBAAgB,CAASC,GAAG,EAAE;MACrC,OAAOP,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,IAAInB,0BAA0B,CAACiB,UAAU,CAAC,EAAE;MACxC,OAAOH,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,MAAMG,aAAa,GAAGpB,mBAAmB,CAACJ,oBAAoB,CAAC;;IAE/D;IACAqB,OAAO,CAACI,qBAAqB,GAAGC,2BAA2B,CACvDF,aACJ,CAAC;;IAED;IACA,MAAMG,qBAAqB,GAAG1B,gBAAgB,CAC1CkB,UAAU,EACVK,aACJ,CAAC;;IAED;IACA,MAAMI,gBAAgB,GAAGZ,UAAU,CAC/BE,UAAU,EACVS,qBAAqB,EACrBP,KAAK,EACLC,OACJ,CAAC;;IAED;IACA,MAAM;MAAEQ,IAAI;MAAEC;IAAI,CAAC,GAAG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,CAAC;IAED,OAAO;MAAEV,IAAI;MAAEC;IAAI,CAAC;EACxB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMJ,2BAA2B,GACpCF,aAAmC,IAClC;EACD,OAAQW,MAAc,IAAK;IACvB,MAAMJ,OAAO,GAAG5B,uBAAuB,CAACgC,MAAM,CAAC;IAC/C,MAAMN,IAAI,GAAGL,aAAa,CAACgB,SAAS,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;IACjDjB,aAAa,CAACkB,SAAS,CAACpC,mBAAmB,CAACuB,IAAI,EAAEE,OAAO,CAAC,CAAC;IAC3DI,MAAM,CAACQ,GAAG,GAAGrC,mBAAmB,CAAC6B,MAAM,CAACQ,GAAG,EAAEZ,OAAO,CAAC;IACrD,OAAOI,MAAM;EACjB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASS,uCAAuCA,CAAC;EACpDC,UAAU;EACVd;AAKJ,CAAC,EAAY;EACT,IAAI,CAACA,OAAO,IAAI7B,0BAA0B,CAAC2C,UAAU,CAAC,EAAE;IACpD,OAAOA,UAAU;EACrB;EACA,OAAO,CAAC,GAAG5C,gBAAgB,CAAC4C,UAAU,EAAEzC,mBAAmB,CAAC2B,OAAO,CAAC,CAAC,CAAC;AAC1E","ignoreList":[]}
1
+ {"version":3,"names":["DEBUG_ID_PLACEHOLDER","addDebugIdModule","checkIfDebugIdModuleExists","createDebugIdFromBundle","createDebugIdModule","getDebugIdFromBundleSource","injectDebugIdInCode","injectDebugIdInCodeAndSourceMap","getBaseJSBundleFunction","getBundleToStringFunction","convertSerializerOutput","getMetroBundleWithMap","getSortedModules","getSourceMapStringFunction","createDatadogMetroSerializer","customSerializer","serializer","createDefaultMetroSerializer","entryPoint","preModules","graph","options","transformOptions","hot","platform","debugIdModule","datadogBundleCallback","createDatadogBundleCallback","preModulesWithDebugId","serializerOutput","code","map","debugId","Error","result","baseJSBundle","bundle","bundleToString","sourceMapString","processModuleFilter","shouldAddToIgnoreList","getSource","toString","setSource","pre","unstable_beforeAssetSerializationPlugin","premodules"],"sourceRoot":"../../../../src","sources":["metro/plugin/metroSerializer.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACIA,oBAAoB,EACpBC,gBAAgB,EAChBC,0BAA0B,EAC1BC,uBAAuB,EACvBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,+BAA+B,QAC5B,iBAAiB;AAUxB,SACIC,uBAAuB,EACvBC,yBAAyB,EACzBC,uBAAuB,IAAIC,qBAAqB,EAChDC,gBAAgB,EAChBC,0BAA0B,QACvB,SAAS;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GACrCC,gBAAkC,IACT;EACzB,MAAMC,UAAU,GAAGD,gBAAgB,IAAIE,4BAA4B,CAAC,CAAC;EACrE,OAAO,OAAOC,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,KAAK;IACrD;IACA,IACKD,KAAK,CAACE,gBAAgB,CAASC,GAAG,IACnCH,KAAK,CAACE,gBAAgB,CAACE,QAAQ,KAAK,KAAK,EAC3C;MACE,OAAOR,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,IAAInB,0BAA0B,CAACiB,UAAU,CAAC,EAAE;MACxC,OAAOH,UAAU,CAACE,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,CAAC;IAC7D;;IAEA;IACA,MAAMI,aAAa,GAAGrB,mBAAmB,CAACJ,oBAAoB,CAAC;;IAE/D;IACAqB,OAAO,CAACK,qBAAqB,GAAGC,2BAA2B,CACvDF,aACJ,CAAC;;IAED;IACA,MAAMG,qBAAqB,GAAG3B,gBAAgB,CAC1CkB,UAAU,EACVM,aACJ,CAAC;;IAED;IACA,MAAMI,gBAAgB,GAAGb,UAAU,CAC/BE,UAAU,EACV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ACpD;MACIkB,mBAAmB,EAAElB,OAAO,CAACkB,mBAAmB;MAChDC,qBAAqB,EAAEnB,OAAO,CAACmB;IACnC,CACJ,CAAC;IAED,OAAO;MAAEV,IAAI;MAAEC;IAAI,CAAC;EACxB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMJ,2BAA2B,GACpCF,aAAmC,IAClC;EACD,OAAQW,MAAc,IAAK;IACvB,MAAMJ,OAAO,GAAG7B,uBAAuB,CAACiC,MAAM,CAAC;IAC/C,MAAMN,IAAI,GAAGL,aAAa,CAACgB,SAAS,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;IACjDjB,aAAa,CAACkB,SAAS,CAACrC,mBAAmB,CAACwB,IAAI,EAAEE,OAAO,CAAC,CAAC;IAC3DI,MAAM,CAACQ,GAAG,GAAGtC,mBAAmB,CAAC8B,MAAM,CAACQ,GAAG,EAAEZ,OAAO,CAAC;IACrD,OAAOI,MAAM;EACjB,CAAC;AACL,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASS,uCAAuCA,CAAC;EACpDzB,KAAK;EACL0B,UAAU;EACVd;AAKJ,CAAC,EAAY;EACT,IACIZ,KAAK,CAACE,gBAAgB,CAACE,QAAQ,KAAK,KAAK,IACzC,CAACQ,OAAO,IACR9B,0BAA0B,CAAC4C,UAAU,CAAC,EACxC;IACE,OAAOA,UAAU;EACrB;EACA,OAAO,CAAC,GAAG7C,gBAAgB,CAAC6C,UAAU,EAAE1C,mBAAmB,CAAC4B,OAAO,CAAC,CAAC,CAAC;AAC1E","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '2.14.6';
2
+ export const version = '2.14.7';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debugIdResolver.d.ts","sourceRoot":"","sources":["../../../src/metro/debugIdResolver.ts"],"names":[],"mappings":"AAOA,QAAA,IAAI,OAAO,EAAE,GAAG,GAAG,IAAW,CAAC;AAgC/B,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"debugIdResolver.d.ts","sourceRoot":"","sources":["../../../src/metro/debugIdResolver.ts"],"names":[],"mappings":"AAOA,QAAA,IAAI,OAAO,EAAE,GAAG,GAAG,IAAW,CAAC;AAoC/B,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -21,7 +21,7 @@ export declare const createDatadogBundleCallback: (debugIdModule: DatadogDebugId
21
21
  /**
22
22
  * Adds Debug ID module for runtime injection, used for Expo.
23
23
  */
24
- export declare function unstable_beforeAssetSerializationPlugin({ premodules, debugId }: {
24
+ export declare function unstable_beforeAssetSerializationPlugin({ graph, premodules, debugId }: {
25
25
  graph: ReadOnlyGraph<MixedOutput>;
26
26
  premodules: Module[];
27
27
  debugId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"metroSerializer.d.ts","sourceRoot":"","sources":["../../../../src/metro/plugin/metroSerializer.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACR,MAAM,EACN,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,MAAM,EACN,aAAa,EAChB,MAAM,oBAAoB,CAAC;AAS5B;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,sBAClB,eAAe,KACnC,sBAmDF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAO,eAoC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACrB,oBAAoB,cAEnB,MAAM,WAOzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,uCAAuC,CAAC,EACpD,UAAU,EACV,OAAO,EACV,EAAE;IACC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,EAAE,CAKX"}
1
+ {"version":3,"file":"metroSerializer.d.ts","sourceRoot":"","sources":["../../../../src/metro/plugin/metroSerializer.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACR,MAAM,EACN,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,MAAM,EACN,aAAa,EAChB,MAAM,oBAAoB,CAAC;AAS5B;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,sBAClB,eAAe,KACnC,sBAsDF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAO,eAoC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACrB,oBAAoB,cAEnB,MAAM,WAOzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,uCAAuC,CAAC,EACpD,KAAK,EACL,UAAU,EACV,OAAO,EACV,EAAE;IACC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,EAAE,CASX"}
@@ -1,2 +1,2 @@
1
- export declare const version = "2.14.6";
1
+ export declare const version = "2.14.7";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "2.14.6",
3
+ "version": "2.14.7",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -118,5 +118,5 @@
118
118
  "dependencies": {
119
119
  "big-integer": "^1.6.52"
120
120
  },
121
- "gitHead": "76fdf120176f24955260b0363c81a34b744e00a0"
121
+ "gitHead": "11915759d5e58bb24606e657fef9c31feb3d2d59"
122
122
  }
@@ -32,6 +32,19 @@ describe('Datadog Metro Plugin', () => {
32
32
  });
33
33
 
34
34
  describe('Datadog Metro Serializer', () => {
35
+ test('skips debug ID injection for web platform builds', async () => {
36
+ const serializer = createDatadogMetroSerializer();
37
+ const args = mockSerializerArgsForEmptyModule();
38
+ // Set platform to 'web'
39
+ (args[2] as any).transformOptions.platform = 'web';
40
+
41
+ const bundle = await serializer(...args);
42
+ const { code } = await convertSerializerOutput(bundle);
43
+ // Web builds should not contain debug ID injection
44
+ expect(code).not.toContain('debugId');
45
+ expect(code).not.toContain('_datadogDebugIds');
46
+ });
47
+
35
48
  test('generates bundle and source map with UUID v5 Debug ID', async () => {
36
49
  const codeSnippetHash = createHash('md5');
37
50
  codeSnippetHash.update(DEBUG_ID_CODE_SNIPPET);
@@ -14,10 +14,14 @@ function loadDebugId() {
14
14
  if (typeof globalThis === 'undefined') {
15
15
  return;
16
16
  }
17
+
18
+ const shouldWarn = process.env.NODE_ENV !== 'test' && __DEV__ !== true;
17
19
  try {
18
20
  const debugIds = (globalThis as any)._datadogDebugIds;
19
- if (!debugIds || Object.keys(debugIds).length === 0) {
20
- if (process.env.NODE_ENV !== 'test') {
21
+ const hasDebugId = debugIds && Object.keys(debugIds).length > 0;
22
+
23
+ if (!hasDebugId) {
24
+ if (shouldWarn) {
21
25
  console.warn(
22
26
  '[Datadog SDK] Debug ID not found. Are you using @datadog/mobile-react-native/metro config?'
23
27
  );
@@ -27,7 +31,7 @@ function loadDebugId() {
27
31
 
28
32
  debugId = debugIds[Object.keys(debugIds)[0]];
29
33
  } catch (error) {
30
- if (process.env.NODE_ENV !== 'test') {
34
+ if (shouldWarn) {
31
35
  console.warn(
32
36
  '[Datadog SDK] Error while retrieving Debug ID. Are you using @datadog/mobile-react-native/metro config?'
33
37
  );
@@ -45,8 +45,11 @@ export const createDatadogMetroSerializer = (
45
45
  ): DatadogMetroSerializer => {
46
46
  const serializer = customSerializer || createDefaultMetroSerializer();
47
47
  return async (entryPoint, preModules, graph, options) => {
48
- // Skip for hot reload mode
49
- if ((graph.transformOptions as any).hot) {
48
+ // Skip for hot reload mode and web builds
49
+ if (
50
+ (graph.transformOptions as any).hot ||
51
+ graph.transformOptions.platform === 'web'
52
+ ) {
50
53
  return serializer(entryPoint, preModules, graph, options);
51
54
  }
52
55
 
@@ -158,6 +161,7 @@ export const createDatadogBundleCallback = (
158
161
  * Adds Debug ID module for runtime injection, used for Expo.
159
162
  */
160
163
  export function unstable_beforeAssetSerializationPlugin({
164
+ graph,
161
165
  premodules,
162
166
  debugId
163
167
  }: {
@@ -165,7 +169,11 @@ export function unstable_beforeAssetSerializationPlugin({
165
169
  premodules: Module[];
166
170
  debugId?: string;
167
171
  }): Module[] {
168
- if (!debugId || checkIfDebugIdModuleExists(premodules)) {
172
+ if (
173
+ graph.transformOptions.platform === 'web' ||
174
+ !debugId ||
175
+ checkIfDebugIdModuleExists(premodules)
176
+ ) {
169
177
  return premodules;
170
178
  }
171
179
  return [...addDebugIdModule(premodules, createDebugIdModule(debugId))];
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '2.14.6';
2
+ export const version = '2.14.7';