@datadog/mobile-react-native 1.7.1 → 1.8.0-rc0

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 (131) hide show
  1. package/DatadogSDKReactNative.podspec +14 -1
  2. package/android/build.gradle +20 -7
  3. package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
  4. package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
  5. package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
  7. package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
  9. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
  11. package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
  12. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
  13. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
  14. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
  15. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
  16. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
  20. package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
  21. package/ios/Sources/DdLogs.h +24 -0
  22. package/ios/Sources/DdLogs.mm +149 -0
  23. package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
  24. package/ios/Sources/DdRum.h +24 -0
  25. package/ios/Sources/DdRum.mm +188 -0
  26. package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
  27. package/ios/Sources/DdSdk.h +24 -0
  28. package/ios/Sources/DdSdk.mm +119 -0
  29. package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
  30. package/ios/Sources/DdTrace.h +24 -0
  31. package/ios/Sources/DdTrace.mm +66 -0
  32. package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
  33. package/ios/Sources/QueueHolder.swift +8 -0
  34. package/jest/mock.js +3 -1
  35. package/lib/commonjs/DdSdkReactNative.js +32 -49
  36. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  37. package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
  38. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  39. package/lib/commonjs/logs/DdLogs.js +33 -40
  40. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  41. package/lib/commonjs/nativeModulesTypes.js +13 -0
  42. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  43. package/lib/commonjs/rum/DdRum.js +104 -106
  44. package/lib/commonjs/rum/DdRum.js.map +1 -1
  45. package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
  46. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  47. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  48. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  49. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  50. package/lib/commonjs/sdk/DdSdk.js +3 -3
  51. package/lib/commonjs/sdk/DdSdk.js.map +1 -1
  52. package/lib/commonjs/specs/NativeDdLogs.js +20 -0
  53. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
  54. package/lib/commonjs/specs/NativeDdRum.js +20 -0
  55. package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
  56. package/lib/commonjs/specs/NativeDdSdk.js +20 -0
  57. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
  58. package/lib/commonjs/specs/NativeDdTrace.js +20 -0
  59. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
  60. package/lib/commonjs/trace/DdTrace.js +10 -12
  61. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  62. package/lib/commonjs/version.js +1 -1
  63. package/lib/commonjs/version.js.map +1 -1
  64. package/lib/module/DdSdkReactNative.js +27 -44
  65. package/lib/module/DdSdkReactNative.js.map +1 -1
  66. package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
  67. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  68. package/lib/module/logs/DdLogs.js +33 -39
  69. package/lib/module/logs/DdLogs.js.map +1 -1
  70. package/lib/module/nativeModulesTypes.js +13 -0
  71. package/lib/module/nativeModulesTypes.js.map +1 -1
  72. package/lib/module/rum/DdRum.js +100 -101
  73. package/lib/module/rum/DdRum.js.map +1 -1
  74. package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
  75. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  76. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  77. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  78. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  79. package/lib/module/sdk/DdSdk.js +3 -2
  80. package/lib/module/sdk/DdSdk.js.map +1 -1
  81. package/lib/module/specs/NativeDdLogs.js +14 -0
  82. package/lib/module/specs/NativeDdLogs.js.map +1 -0
  83. package/lib/module/specs/NativeDdRum.js +14 -0
  84. package/lib/module/specs/NativeDdRum.js.map +1 -0
  85. package/lib/module/specs/NativeDdSdk.js +14 -0
  86. package/lib/module/specs/NativeDdSdk.js.map +1 -0
  87. package/lib/module/specs/NativeDdTrace.js +14 -0
  88. package/lib/module/specs/NativeDdTrace.js.map +1 -0
  89. package/lib/module/trace/DdTrace.js +10 -11
  90. package/lib/module/trace/DdTrace.js.map +1 -1
  91. package/lib/module/version.js +1 -1
  92. package/lib/module/version.js.map +1 -1
  93. package/lib/typescript/DdSdkReactNative.d.ts +4 -4
  94. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
  95. package/lib/typescript/logs/DdLogs.d.ts +4 -4
  96. package/lib/typescript/nativeModulesTypes.d.ts +28 -168
  97. package/lib/typescript/rum/DdRum.d.ts +12 -12
  98. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
  99. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
  100. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
  101. package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
  102. package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
  103. package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
  104. package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
  105. package/lib/typescript/version.d.ts +1 -1
  106. package/package.json +10 -2
  107. package/src/DdSdkReactNative.tsx +12 -10
  108. package/src/DdSdkReactNativeConfiguration.tsx +22 -0
  109. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
  110. package/src/__tests__/longTasksUtils.test.ts +5 -0
  111. package/src/__tests__/mock.test.ts +89 -0
  112. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
  113. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
  114. package/src/logs/DdLogs.ts +11 -11
  115. package/src/logs/__tests__/DdLogs.test.ts +1 -1
  116. package/src/nativeModulesTypes.ts +49 -254
  117. package/src/rum/DdRum.ts +36 -32
  118. package/src/rum/eventMappers/errorEventMapper.ts +4 -4
  119. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
  120. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
  121. package/src/sdk/DdSdk.ts +2 -3
  122. package/src/specs/NativeDdLogs.ts +110 -0
  123. package/src/specs/NativeDdRum.ts +151 -0
  124. package/src/specs/NativeDdSdk.ts +62 -0
  125. package/src/specs/NativeDdTrace.ts +42 -0
  126. package/src/trace/DdTrace.ts +9 -9
  127. package/src/version.ts +1 -1
  128. package/ios/Sources/DdLogs.m +0 -62
  129. package/ios/Sources/DdRum.m +0 -82
  130. package/ios/Sources/DdSdk.m +0 -41
  131. package/ios/Sources/DdTrace.m +0 -23
@@ -0,0 +1,91 @@
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
+ package com.datadog.reactnative
8
+
9
+ import com.facebook.react.bridge.Promise
10
+ import com.facebook.react.bridge.ReactApplicationContext
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
12
+ import com.facebook.react.bridge.ReactMethod
13
+ import com.facebook.react.bridge.ReadableMap
14
+
15
+ /** The entry point to initialize Datadog's features. */
16
+ class DdSdk(
17
+ reactContext: ReactApplicationContext
18
+ ) : ReactContextBaseJavaModule(reactContext) {
19
+
20
+ private val implementation = DdSdkImplementation(reactContext)
21
+
22
+ override fun getName(): String = DdSdkImplementation.NAME
23
+
24
+ /**
25
+ * Initializes Datadog's features.
26
+ * @param configuration The configuration to use.
27
+ */
28
+ @ReactMethod
29
+ fun initialize(configuration: ReadableMap, promise: Promise) {
30
+ implementation.initialize(configuration, promise)
31
+ }
32
+
33
+ /**
34
+ * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM
35
+ * events.
36
+ * @param attributes The global context attributes.
37
+ */
38
+ @ReactMethod
39
+ fun setAttributes(attributes: ReadableMap, promise: Promise) {
40
+ implementation.setAttributes(attributes, promise)
41
+ }
42
+
43
+ /**
44
+ * Set the user information.
45
+ * @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
46
+ * attribute).
47
+ */
48
+ @ReactMethod
49
+ fun setUser(user: ReadableMap, promise: Promise) {
50
+ implementation.setUser(user, promise)
51
+ }
52
+
53
+ /**
54
+ * Set the tracking consent regarding the data collection.
55
+ * @param trackingConsent Consent, which can take one of the following values: 'pending',
56
+ * 'granted', 'not_granted'.
57
+ */
58
+ @ReactMethod
59
+ fun setTrackingConsent(trackingConsent: String, promise: Promise) {
60
+ implementation.setTrackingConsent(trackingConsent, promise)
61
+ }
62
+
63
+ /**
64
+ * Sends a telemetry debug event.
65
+ * @param message Debug message.
66
+ */
67
+ @ReactMethod
68
+ fun telemetryDebug(message: String, promise: Promise) {
69
+ implementation.telemetryDebug(message, promise)
70
+ }
71
+
72
+ /**
73
+ * Sends a telemetry error event.
74
+ * @param message Error message.
75
+ * @param stack Error stack.
76
+ * @param kind Error kind.
77
+ */
78
+ @ReactMethod
79
+ fun telemetryError(message: String, stack: String, kind: String, promise: Promise) {
80
+ implementation.telemetryError(message, stack, kind, promise)
81
+ }
82
+
83
+ /**
84
+ * Sends WebView Events.
85
+ * @param message User action.
86
+ */
87
+ @ReactMethod
88
+ fun consumeWebviewEvent(message: String, promise: Promise) {
89
+ implementation.consumeWebviewEvent(message, promise)
90
+ }
91
+ }
@@ -0,0 +1,47 @@
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
+ package com.datadog.reactnative
8
+
9
+ import com.facebook.react.bridge.Promise
10
+ import com.facebook.react.bridge.ReactApplicationContext
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
12
+ import com.facebook.react.bridge.ReactMethod
13
+ import com.facebook.react.bridge.ReadableMap
14
+
15
+ /**
16
+ * The entry point to use Datadog's Trace feature.
17
+ */
18
+ class DdTrace(
19
+ reactContext: ReactApplicationContext,
20
+ ) : ReactContextBaseJavaModule(reactContext) {
21
+
22
+ private val implementation = DdTraceImplementation()
23
+
24
+ override fun getName(): String = DdTraceImplementation.NAME
25
+
26
+ /**
27
+ * Start a span, and returns a unique identifier for the span.
28
+ * @param operation The operation name of the span.
29
+ * @param context The additional context to send.
30
+ * @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
31
+ */
32
+ @ReactMethod
33
+ fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
34
+ implementation.startSpan(operation, context, timestampMs, promise)
35
+ }
36
+
37
+ /**
38
+ * Finish a started span.
39
+ * @param spanId The unique identifier of the span.
40
+ * @param context The additional context to send.
41
+ * @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
42
+ */
43
+ @ReactMethod
44
+ fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
45
+ implementation.finishSpan(spanId, context, timestampMs, promise)
46
+ }
47
+ }
@@ -10,7 +10,6 @@ import android.util.Log
10
10
  import com.datadog.android.log.Logger
11
11
  import com.datadog.tools.unit.GenericAssert.Companion.assertThat
12
12
  import com.facebook.react.bridge.Promise
13
- import com.facebook.react.bridge.ReactApplicationContext
14
13
  import com.facebook.react.bridge.ReadableMap
15
14
  import com.nhaarman.mockitokotlin2.argumentCaptor
16
15
  import com.nhaarman.mockitokotlin2.doReturn
@@ -41,7 +40,7 @@ import org.mockito.quality.Strictness
41
40
  @MockitoSettings(strictness = Strictness.LENIENT)
42
41
  internal class DdLogsTest {
43
42
 
44
- lateinit var testedLogs: DdLogs
43
+ lateinit var testedLogs: DdLogsImplementation
45
44
 
46
45
  @Mock
47
46
  lateinit var mockLogger: Logger
@@ -61,15 +60,6 @@ internal class DdLogsTest {
61
60
  @Mock
62
61
  lateinit var mockDatadog: DatadogWrapper
63
62
 
64
- @Mock
65
- lateinit var mockReactContext: ReactApplicationContext
66
-
67
- @MapForgery(
68
- key = AdvancedForgery(string = [StringForgery()]),
69
- value = AdvancedForgery(string = [StringForgery(StringForgeryType.HEXADECIMAL)])
70
- )
71
- lateinit var fakeContext: Map<String, String>
72
-
73
63
  @Mock
74
64
  lateinit var mockContext: ReadableMap
75
65
 
@@ -82,7 +72,7 @@ internal class DdLogsTest {
82
72
  @BeforeEach
83
73
  fun `set up`(forge: Forge) {
84
74
  whenever(mockDatadog.isInitialized()) doReturn true
85
- testedLogs = DdLogs(mockReactContext, mockLogger, mockDatadog)
75
+ testedLogs = DdLogsImplementation(mockLogger, mockDatadog)
86
76
  fakeErrorKind = forge.aNullable { forge.aString() }
87
77
  fakeErrorMessage = forge.aNullable { forge.aString() }
88
78
  fakeStacktrace = forge.aNullable { forge.aString() }
@@ -285,7 +275,7 @@ internal class DdLogsTest {
285
275
  fun `M not forward logs W SDK is not initialized`() {
286
276
  // When
287
277
  whenever(mockDatadog.isInitialized()) doReturn false
288
- var newTestedLogs = DdLogs(mockReactContext, mockLogger, mockDatadog)
278
+ var newTestedLogs = DdLogsImplementation(mockLogger, mockDatadog)
289
279
  newTestedLogs.debug(fakeMessage, mockContext, mockPromise)
290
280
  newTestedLogs.info(fakeMessage, mockContext, mockPromise)
291
281
  newTestedLogs.warn(fakeMessage, mockContext, mockPromise)
@@ -17,7 +17,6 @@ import com.datadog.tools.unit.getStaticValue
17
17
  import com.datadog.tools.unit.setStaticValue
18
18
  import com.datadog.tools.unit.toReadableMap
19
19
  import com.facebook.react.bridge.Promise
20
- import com.facebook.react.bridge.ReactApplicationContext
21
20
  import com.nhaarman.mockitokotlin2.mock
22
21
  import com.nhaarman.mockitokotlin2.verify
23
22
  import fr.xgouchet.elmyr.Forge
@@ -51,14 +50,11 @@ internal class DdRumTest {
51
50
 
52
51
  // TODO: 14/12/2020 RUMM-925 Add the relevant unit tests after merging the feature/bridge branch
53
52
 
54
- lateinit var testedDdRum: DdRum
53
+ lateinit var testedDdRum: DdRumImplementation
55
54
 
56
55
  @Mock
57
56
  lateinit var mockRumMonitor: RumMonitor
58
57
 
59
- @Mock
60
- lateinit var mockReactContext: ReactApplicationContext
61
-
62
58
  @Mock
63
59
  lateinit var mockPromise: Promise
64
60
 
@@ -83,7 +79,7 @@ internal class DdRumTest {
83
79
  }
84
80
  }
85
81
 
86
- testedDdRum = DdRum(mockReactContext)
82
+ testedDdRum = DdRumImplementation()
87
83
  }
88
84
 
89
85
  @AfterEach
@@ -102,7 +102,7 @@ fun mockChoreographerInstance(mock: Choreographer = mock()) {
102
102
  @ForgeConfiguration(BaseConfigurator::class)
103
103
  internal class DdSdkTest {
104
104
 
105
- lateinit var testedBridgeSdk: DdSdk
105
+ lateinit var testedBridgeSdk: DdSdkImplementation
106
106
 
107
107
  @Mock(answer = Answers.RETURNS_DEEP_STUBS)
108
108
  lateinit var mockReactContext: ReactApplicationContext
@@ -150,7 +150,7 @@ internal class DdSdkTest {
150
150
  answer.getArgument<Runnable>(0).run()
151
151
  true
152
152
  }
153
- testedBridgeSdk = DdSdk(mockReactContext, mockDatadog)
153
+ testedBridgeSdk = DdSdkImplementation(mockReactContext, mockDatadog)
154
154
  }
155
155
 
156
156
  @AfterEach
@@ -1018,7 +1018,7 @@ internal class DdSdkTest {
1018
1018
  // Given
1019
1019
  val bridgeConfiguration = configuration.copy(
1020
1020
  additionalConfig = mapOf(
1021
- DdSdk.DD_NATIVE_VIEW_TRACKING to false
1021
+ DdSdkImplementation.DD_NATIVE_VIEW_TRACKING to false
1022
1022
  )
1023
1023
  )
1024
1024
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1050,7 +1050,7 @@ internal class DdSdkTest {
1050
1050
  // Given
1051
1051
  val bridgeConfiguration = configuration.copy(
1052
1052
  additionalConfig = mapOf(
1053
- DdSdk.DD_NATIVE_VIEW_TRACKING to true
1053
+ DdSdkImplementation.DD_NATIVE_VIEW_TRACKING to true
1054
1054
  )
1055
1055
  )
1056
1056
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1082,7 +1082,7 @@ internal class DdSdkTest {
1082
1082
  // Given
1083
1083
  val bridgeConfiguration = configuration.copy(
1084
1084
  additionalConfig = mapOf(
1085
- DdSdk.DD_NATIVE_INTERACTION_TRACKING to false
1085
+ DdSdkImplementation.DD_NATIVE_INTERACTION_TRACKING to false
1086
1086
  )
1087
1087
  )
1088
1088
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1183,7 +1183,7 @@ internal class DdSdkTest {
1183
1183
  // Given
1184
1184
  val bridgeConfiguration = configuration.copy(
1185
1185
  additionalConfig = mapOf(
1186
- DdSdk.DD_NATIVE_INTERACTION_TRACKING to true
1186
+ DdSdkImplementation.DD_NATIVE_INTERACTION_TRACKING to true
1187
1187
  )
1188
1188
  )
1189
1189
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1219,7 +1219,7 @@ internal class DdSdkTest {
1219
1219
  // Given
1220
1220
  val bridgeConfiguration = configuration.copy(
1221
1221
  additionalConfig = mapOf(
1222
- DdSdk.DD_NATIVE_INTERACTION_TRACKING to null
1222
+ DdSdkImplementation.DD_NATIVE_INTERACTION_TRACKING to null
1223
1223
  )
1224
1224
  )
1225
1225
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1262,7 +1262,7 @@ internal class DdSdkTest {
1262
1262
  }
1263
1263
  val bridgeConfiguration = configuration.copy(
1264
1264
  additionalConfig = mapOf(
1265
- DdSdk.DD_SDK_VERBOSITY to verbosityName
1265
+ DdSdkImplementation.DD_SDK_VERBOSITY to verbosityName
1266
1266
  )
1267
1267
  )
1268
1268
 
@@ -1281,7 +1281,7 @@ internal class DdSdkTest {
1281
1281
  // Given
1282
1282
  val bridgeConfiguration = configuration.copy(
1283
1283
  additionalConfig = mapOf(
1284
- DdSdk.DD_SDK_VERBOSITY to verbosity
1284
+ DdSdkImplementation.DD_SDK_VERBOSITY to verbosity
1285
1285
  )
1286
1286
  )
1287
1287
 
@@ -1300,7 +1300,7 @@ internal class DdSdkTest {
1300
1300
  // Given
1301
1301
  val bridgeConfiguration = configuration.copy(
1302
1302
  additionalConfig = mapOf(
1303
- DdSdk.DD_SERVICE_NAME to serviceName
1303
+ DdSdkImplementation.DD_SERVICE_NAME to serviceName
1304
1304
  )
1305
1305
  )
1306
1306
  val credentialCaptor = argumentCaptor<Credentials>()
@@ -1419,7 +1419,7 @@ internal class DdSdkTest {
1419
1419
  // Given
1420
1420
  val bridgeConfiguration = configuration.copy(
1421
1421
  additionalConfig = mapOf(
1422
- DdSdk.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1422
+ DdSdkImplementation.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1423
1423
  )
1424
1424
  )
1425
1425
  val configCaptor = argumentCaptor<Configuration>()
@@ -1473,7 +1473,7 @@ internal class DdSdkTest {
1473
1473
  // Given
1474
1474
  val bridgeConfiguration = configuration.copy(
1475
1475
  additionalConfig = mapOf(
1476
- DdSdk.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1476
+ DdSdkImplementation.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1477
1477
  )
1478
1478
  )
1479
1479
  val configCaptor = argumentCaptor<Configuration>()
@@ -1534,7 +1534,7 @@ internal class DdSdkTest {
1534
1534
  // Given
1535
1535
  val bridgeConfiguration = configuration.copy(
1536
1536
  additionalConfig = mapOf(
1537
- DdSdk.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1537
+ DdSdkImplementation.DD_FIRST_PARTY_HOSTS to firstPartyHosts.toReadableArray()
1538
1538
  )
1539
1539
  )
1540
1540
  val configCaptor = argumentCaptor<Configuration>()
@@ -1863,7 +1863,7 @@ internal class DdSdkTest {
1863
1863
  // Given
1864
1864
  val bridgeConfiguration = configuration.copy(
1865
1865
  additionalConfig = mapOf(
1866
- DdSdk.DD_VERSION_SUFFIX to versionSuffix
1866
+ DdSdkImplementation.DD_VERSION_SUFFIX to versionSuffix
1867
1867
  )
1868
1868
  )
1869
1869
  val configCaptor = argumentCaptor<Configuration>()
@@ -1882,8 +1882,8 @@ internal class DdSdkTest {
1882
1882
  .hasFieldEqualTo(
1883
1883
  "additionalConfig",
1884
1884
  mapOf(
1885
- DdSdk.DD_VERSION_SUFFIX to versionSuffix,
1886
- DdSdk.DD_VERSION to mockPackageInfo.versionName + versionSuffix
1885
+ DdSdkImplementation.DD_VERSION_SUFFIX to versionSuffix,
1886
+ DdSdkImplementation.DD_VERSION to mockPackageInfo.versionName + versionSuffix
1887
1887
  )
1888
1888
  )
1889
1889
  }
@@ -2347,8 +2347,8 @@ internal class DdSdkTest {
2347
2347
  ) {
2348
2348
  // Given
2349
2349
  val additionalConfig = mapOf(
2350
- DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
2351
- DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2350
+ DdSdkImplementation.DD_PROXY_ADDRESS to "1.1.1.1",
2351
+ DdSdkImplementation.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2352
2352
  )
2353
2353
  val config = configuration.copy(additionalConfig = additionalConfig)
2354
2354
 
@@ -2370,9 +2370,9 @@ internal class DdSdkTest {
2370
2370
  assumeTrue(proxyType.lowercase(Locale.US) !in arrayOf("http", "https", "socks"))
2371
2371
 
2372
2372
  val additionalConfig = mapOf(
2373
- DdSdk.DD_PROXY_TYPE to proxyType,
2374
- DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
2375
- DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2373
+ DdSdkImplementation.DD_PROXY_TYPE to proxyType,
2374
+ DdSdkImplementation.DD_PROXY_ADDRESS to "1.1.1.1",
2375
+ DdSdkImplementation.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2376
2376
  )
2377
2377
  val config = configuration.copy(additionalConfig = additionalConfig)
2378
2378
 
@@ -2390,8 +2390,8 @@ internal class DdSdkTest {
2390
2390
  ) {
2391
2391
  // Given
2392
2392
  val additionalConfig = mapOf(
2393
- DdSdk.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
2394
- DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2393
+ DdSdkImplementation.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
2394
+ DdSdkImplementation.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2395
2395
  )
2396
2396
  val config = configuration.copy(additionalConfig = additionalConfig)
2397
2397
 
@@ -2409,8 +2409,8 @@ internal class DdSdkTest {
2409
2409
  ) {
2410
2410
  // Given
2411
2411
  val additionalConfig = mapOf(
2412
- DdSdk.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
2413
- DdSdk.DD_PROXY_ADDRESS to "1.1.1.1"
2412
+ DdSdkImplementation.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
2413
+ DdSdkImplementation.DD_PROXY_ADDRESS to "1.1.1.1"
2414
2414
  )
2415
2415
  val config = configuration.copy(additionalConfig = additionalConfig)
2416
2416
 
@@ -2430,9 +2430,9 @@ internal class DdSdkTest {
2430
2430
  val proxyType = forge.anElementFrom("http", "https", "socks")
2431
2431
 
2432
2432
  val additionalConfig = mapOf(
2433
- DdSdk.DD_PROXY_TYPE to proxyType,
2434
- DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
2435
- DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2433
+ DdSdkImplementation.DD_PROXY_TYPE to proxyType,
2434
+ DdSdkImplementation.DD_PROXY_ADDRESS to "1.1.1.1",
2435
+ DdSdkImplementation.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
2436
2436
  )
2437
2437
  val config = configuration.copy(additionalConfig = additionalConfig)
2438
2438
 
@@ -2465,11 +2465,11 @@ internal class DdSdkTest {
2465
2465
  val proxyAddress = "1.1.1.1"
2466
2466
 
2467
2467
  val additionalConfig = mapOf(
2468
- DdSdk.DD_PROXY_TYPE to proxyType,
2469
- DdSdk.DD_PROXY_ADDRESS to proxyAddress,
2470
- DdSdk.DD_PROXY_PORT to proxyPort,
2471
- DdSdk.DD_PROXY_USERNAME to proxyUsername,
2472
- DdSdk.DD_PROXY_PASSWORD to proxyPassword
2468
+ DdSdkImplementation.DD_PROXY_TYPE to proxyType,
2469
+ DdSdkImplementation.DD_PROXY_ADDRESS to proxyAddress,
2470
+ DdSdkImplementation.DD_PROXY_PORT to proxyPort,
2471
+ DdSdkImplementation.DD_PROXY_USERNAME to proxyUsername,
2472
+ DdSdkImplementation.DD_PROXY_PASSWORD to proxyPassword
2473
2473
  )
2474
2474
  val config = configuration.copy(additionalConfig = additionalConfig)
2475
2475
 
@@ -8,7 +8,6 @@ package com.datadog.reactnative
8
8
 
9
9
  import com.datadog.tools.unit.toReadableMap
10
10
  import com.facebook.react.bridge.Promise
11
- import com.facebook.react.bridge.ReactApplicationContext
12
11
  import com.nhaarman.mockitokotlin2.any
13
12
  import com.nhaarman.mockitokotlin2.doAnswer
14
13
  import com.nhaarman.mockitokotlin2.doReturn
@@ -47,7 +46,7 @@ import org.mockito.quality.Strictness
47
46
  @MockitoSettings(strictness = Strictness.LENIENT)
48
47
  internal class DdTraceTest {
49
48
 
50
- lateinit var testedTrace: DdTrace
49
+ lateinit var testedTrace: DdTraceImplementation
51
50
 
52
51
  @Mock
53
52
  lateinit var mockTracer: Tracer
@@ -92,9 +91,6 @@ internal class DdTraceTest {
92
91
  }
93
92
  }
94
93
 
95
- @Mock
96
- lateinit var mockReactContext: ReactApplicationContext
97
-
98
94
  @BeforeEach
99
95
  fun `set up`() {
100
96
  whenever(mockTracer.buildSpan(fakeOperation)) doReturn mockSpanBuilder
@@ -108,7 +104,7 @@ internal class DdTraceTest {
108
104
  whenever(mockSpanContext.toSpanId()) doReturn fakeSpanId
109
105
  whenever(mockSpanContext.toTraceId()) doReturn fakeTraceId
110
106
 
111
- testedTrace = DdTrace(mockReactContext, tracerProvider = { mockTracer })
107
+ testedTrace = DdTraceImplementation(tracerProvider = { mockTracer })
112
108
  }
113
109
 
114
110
  @AfterEach
@@ -4,4 +4,5 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- #import <React/RCTBridgeModule.h>
7
+ // This file is imported in the auto-generated DatadogSDKReactNative-Swift.h header file.
8
+ // Deleting it could result in iOS builds failing.
@@ -0,0 +1,24 @@
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/Foundation.h>
8
+ @class DdLogsImplementation;
9
+
10
+ #ifdef RCT_NEW_ARCH_ENABLED
11
+
12
+ #import <DdSdkReactNative/DdSdkReactNative.h>
13
+ @interface DdLogs: NSObject <NativeDdLogsSpec>
14
+
15
+ #else
16
+
17
+ #import <React/RCTBridgeModule.h>
18
+ @interface DdLogs : NSObject <RCTBridgeModule>
19
+
20
+ #endif
21
+
22
+ @property (nonatomic, strong) DdLogsImplementation* ddLogsImplementation;
23
+
24
+ @end
@@ -0,0 +1,149 @@
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
+ // Import this first to prevent require cycles
7
+ #import <DatadogSDKReactNative-Swift.h>
8
+ #import "DdLogs.h"
9
+
10
+
11
+ @implementation DdLogs
12
+
13
+ RCT_EXPORT_MODULE()
14
+
15
+ RCT_REMAP_METHOD(debug, withDebugMessage:(NSString*)message
16
+ withContext:(NSDictionary*)context
17
+ withResolver:(RCTPromiseResolveBlock)resolve
18
+ withRejecter:(RCTPromiseRejectBlock)reject)
19
+ {
20
+ [self debug:message context:context resolve:resolve reject:reject];
21
+ }
22
+
23
+ RCT_REMAP_METHOD(info, withInfoMessage:(NSString*)message
24
+ withContext:(NSDictionary*)context
25
+ withResolver:(RCTPromiseResolveBlock)resolve
26
+ withRejecter:(RCTPromiseRejectBlock)reject)
27
+ {
28
+ [self info:message context:context resolve:resolve reject:reject];
29
+ }
30
+
31
+ RCT_REMAP_METHOD(warn, withWarnMessage:(NSString*)message
32
+ withContext:(NSDictionary*)context
33
+ withResolver:(RCTPromiseResolveBlock)resolve
34
+ withRejecter:(RCTPromiseRejectBlock)reject)
35
+ {
36
+ [self warn:message context:context resolve:resolve reject:reject];
37
+ }
38
+
39
+ RCT_REMAP_METHOD(error, withMessage:(NSString*)message
40
+ withContext:(NSDictionary*)context
41
+ withResolver:(RCTPromiseResolveBlock)resolve
42
+ withRejecter:(RCTPromiseRejectBlock)reject)
43
+ {
44
+ [self error:message context:context resolve:resolve reject:reject];
45
+ }
46
+
47
+ RCT_REMAP_METHOD(debugWithError, withDebugMessage:(NSString*)message
48
+ withErrorKind:(NSString*)errorKind
49
+ withErrorMessage:(NSString*)errorMessage
50
+ withStacktrace:(NSString*)stacktrace
51
+ withContext:(NSDictionary*)context
52
+ withResolver:(RCTPromiseResolveBlock)resolve
53
+ withRejecter:(RCTPromiseRejectBlock)reject)
54
+ {
55
+ [self debugWithError:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
56
+ }
57
+
58
+ RCT_REMAP_METHOD(infoWithError, withInfoMessage:(NSString*)message
59
+ withErrorKind:(NSString*)errorKind
60
+ withErrorMessage:(NSString*)errorMessage
61
+ withStacktrace:(NSString*)stacktrace
62
+ withContext:(NSDictionary*)context
63
+ withResolver:(RCTPromiseResolveBlock)resolve
64
+ withRejecter:(RCTPromiseRejectBlock)reject)
65
+ {
66
+ [self infoWithError:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
67
+ }
68
+
69
+ RCT_REMAP_METHOD(warnWithError, withWarnMessage:(NSString*)message
70
+ withErrorKind:(NSString*)errorKind
71
+ withErrorMessage:(NSString*)errorMessage
72
+ withStacktrace:(NSString*)stacktrace
73
+ withContext:(NSDictionary*)context
74
+ withResolver:(RCTPromiseResolveBlock)resolve
75
+ withRejecter:(RCTPromiseRejectBlock)reject)
76
+ {
77
+ [self warnWithError:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
78
+ }
79
+
80
+ RCT_REMAP_METHOD(errorWithError, withMessage:(NSString*)message
81
+ withErrorKind:(NSString*)errorKind
82
+ withErrorMessage:(NSString*)errorMessage
83
+ withStacktrace:(NSString*)stacktrace
84
+ withContext:(NSDictionary*)context
85
+ withResolver:(RCTPromiseResolveBlock)resolve
86
+ withRejecter:(RCTPromiseRejectBlock)reject)
87
+ {
88
+ [self errorWithError:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
89
+ }
90
+
91
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
92
+ #ifdef RCT_NEW_ARCH_ENABLED
93
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
94
+ (const facebook::react::ObjCTurboModule::InitParams &)params
95
+ {
96
+ return std::make_shared<facebook::react::NativeDdLogsSpecJSI>(params);
97
+ }
98
+ #endif
99
+
100
+ - (DdLogsImplementation*)ddLogsImplementation
101
+ {
102
+ if (_ddLogsImplementation == nil) {
103
+ _ddLogsImplementation = [[DdLogsImplementation alloc] init];
104
+ }
105
+ return _ddLogsImplementation;
106
+ }
107
+
108
+ + (BOOL)requiresMainQueueSetup {
109
+ return NO;
110
+ }
111
+
112
+ - (dispatch_queue_t)methodQueue {
113
+ return [RNQueue getSharedQueue];
114
+ }
115
+
116
+
117
+ - (void)debug:(NSString *)message context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
118
+ [self.ddLogsImplementation debugWithMessage:message context:context resolve:resolve reject:reject];
119
+ }
120
+
121
+ - (void)debugWithError:(NSString *)message errorKind:(NSString *)errorKind errorMessage:(NSString *)errorMessage stacktrace:(NSString *)stacktrace context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
122
+ [self.ddLogsImplementation debugWithErrorWithMessage:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
123
+ }
124
+
125
+ - (void)error:(NSString *)message context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
126
+ [self.ddLogsImplementation errorWithMessage:message context:context resolve:resolve reject:reject];
127
+ }
128
+
129
+ - (void)errorWithError:(NSString *)message errorKind:(NSString *)errorKind errorMessage:(NSString *)errorMessage stacktrace:(NSString *)stacktrace context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
130
+ [self.ddLogsImplementation errorWithErrorWithMessage:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
131
+ }
132
+
133
+ - (void)info:(NSString *)message context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
134
+ [self.ddLogsImplementation infoWithMessage:message context:context resolve:resolve reject:reject];
135
+ }
136
+
137
+ - (void)infoWithError:(NSString *)message errorKind:(NSString *)errorKind errorMessage:(NSString *)errorMessage stacktrace:(NSString *)stacktrace context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
138
+ [self.ddLogsImplementation infoWithErrorWithMessage:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
139
+ }
140
+
141
+ - (void)warn:(NSString *)message context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
142
+ [self.ddLogsImplementation warnWithMessage:message context:context resolve:resolve reject:reject];
143
+ }
144
+
145
+ - (void)warnWithError:(NSString *)message errorKind:(NSString *)errorKind errorMessage:(NSString *)errorMessage stacktrace:(NSString *)stacktrace context:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
146
+ [self.ddLogsImplementation warnWithErrorWithMessage:message errorKind:errorKind errorMessage:errorMessage stacktrace:stacktrace context:context resolve:resolve reject:reject];
147
+ }
148
+
149
+ @end