@datadog/mobile-react-native 1.0.0-rc9 → 1.1.1

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 (112) hide show
  1. package/DatadogSDKReactNative.podspec +2 -1
  2. package/android/build.gradle +73 -3
  3. package/android/gradle.properties +1 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
  6. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
  9. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
  10. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
  11. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
  12. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
  14. package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
  15. package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
  16. package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
  20. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
  21. package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
  22. package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
  23. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
  24. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
  25. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
  26. package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
  27. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
  28. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
  29. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
  30. package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
  31. package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
  32. package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
  33. package/datadog-sourcemaps.gradle +137 -0
  34. package/ios/Sources/AnyEncodable.swift +138 -0
  35. package/ios/Sources/Attributes.swift +101 -0
  36. package/ios/Sources/DdLogs.swift +35 -11
  37. package/ios/Sources/DdRum.m +3 -1
  38. package/ios/Sources/DdRum.swift +184 -22
  39. package/ios/Sources/DdSdk.swift +190 -10
  40. package/ios/Sources/DdSdkConfiguration.swift +51 -0
  41. package/ios/Sources/DdTrace.swift +41 -6
  42. package/ios/Sources/GlobalState.swift +28 -0
  43. package/ios/Sources/QueueHolder.swift +10 -0
  44. package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
  45. package/lib/commonjs/DdSdkReactNative.js +14 -0
  46. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  47. package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
  48. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  49. package/lib/commonjs/foundation.js +36 -2
  50. package/lib/commonjs/foundation.js.map +1 -1
  51. package/lib/commonjs/index.js +14 -0
  52. package/lib/commonjs/index.js.map +1 -1
  53. package/lib/commonjs/nativeModulesTypes.js +36 -0
  54. package/lib/commonjs/nativeModulesTypes.js.map +1 -0
  55. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
  56. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  57. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
  58. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  59. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +7 -2
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
  61. package/lib/commonjs/types.js +26 -1
  62. package/lib/commonjs/types.js.map +1 -1
  63. package/lib/commonjs/version.js +1 -1
  64. package/lib/commonjs/version.js.map +1 -1
  65. package/lib/module/DdSdkReactNative.js +14 -0
  66. package/lib/module/DdSdkReactNative.js.map +1 -1
  67. package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
  68. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  69. package/lib/module/foundation.js +36 -2
  70. package/lib/module/foundation.js.map +1 -1
  71. package/lib/module/index.js +2 -1
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/module/nativeModulesTypes.js +26 -0
  74. package/lib/module/nativeModulesTypes.js.map +1 -0
  75. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
  76. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  77. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
  78. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  79. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +7 -2
  80. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
  81. package/lib/module/types.js +23 -0
  82. package/lib/module/types.js.map +1 -1
  83. package/lib/module/version.js +1 -1
  84. package/lib/module/version.js.map +1 -1
  85. package/lib/typescript/DdSdkReactNative.d.ts +2 -0
  86. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
  87. package/lib/typescript/foundation.d.ts +3 -2
  88. package/lib/typescript/index.d.ts +2 -1
  89. package/lib/typescript/nativeModulesTypes.d.ts +168 -0
  90. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
  91. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +2 -1
  92. package/lib/typescript/types.d.ts +42 -7
  93. package/lib/typescript/version.d.ts +1 -1
  94. package/package.json +5 -4
  95. package/src/DdSdkReactNative.tsx +20 -0
  96. package/src/DdSdkReactNativeConfiguration.tsx +20 -0
  97. package/src/__tests__/DdSdkReactNative.test.tsx +76 -0
  98. package/src/__tests__/foundation.test.ts +79 -0
  99. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +8 -8
  100. package/src/foundation.tsx +40 -11
  101. package/src/index.tsx +3 -0
  102. package/src/nativeModulesTypes.ts +258 -0
  103. package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
  104. package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
  105. package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +22 -0
  106. package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +8 -1
  107. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
  108. package/src/types.tsx +62 -7
  109. package/src/version.ts +1 -1
  110. package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
  111. package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
  112. package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
@@ -1,142 +0,0 @@
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.datadog.android.bridge.DdBridge
10
- import com.datadog.android.bridge.DdRum as SDKDdRum
11
- import com.facebook.react.bridge.Promise
12
- import com.facebook.react.bridge.ReactApplicationContext
13
- import com.facebook.react.bridge.ReactContextBaseJavaModule
14
- import com.facebook.react.bridge.ReactMethod
15
- import com.facebook.react.bridge.ReadableArray
16
- import com.facebook.react.bridge.ReadableMap
17
-
18
- /**
19
- * The entry point to use Datadog's RUM feature.
20
- */
21
- class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
22
-
23
- private val nativeInstance: SDKDdRum = DdBridge.getDdRum(reactContext)
24
-
25
- override fun getName(): String = "DdRum"
26
-
27
- /**
28
- * Start tracking a RUM View.
29
- * @param key The view unique key identifier.
30
- * @param name The view name.
31
- * @param context The additional context to send.
32
- * @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
33
- */
34
- @ReactMethod
35
- fun startView(key: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
36
- nativeInstance.startView(key, name, context.toHashMap(), timestampMs.toLong())
37
- promise.resolve(null)
38
- }
39
-
40
- /**
41
- * Stop tracking a RUM View.
42
- * @param key The view unique key identifier.
43
- * @param context The additional context to send.
44
- * @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
45
- */
46
- @ReactMethod
47
- fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
48
- nativeInstance.stopView(key, context.toHashMap(), timestampMs.toLong())
49
- promise.resolve(null)
50
- }
51
-
52
- /**
53
- * Start tracking a RUM Action.
54
- * @param type The action type (tap, scroll, swipe, click, custom).
55
- * @param name The action name.
56
- * @param context The additional context to send.
57
- * @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
58
- */
59
- @ReactMethod
60
- fun startAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
61
- nativeInstance.startAction(type, name, context.toHashMap(), timestampMs.toLong())
62
- promise.resolve(null)
63
- }
64
-
65
- /**
66
- * Stop tracking the ongoing RUM Action.
67
- * @param context The additional context to send.
68
- * @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
69
- */
70
- @ReactMethod
71
- fun stopAction(context: ReadableMap, timestampMs: Double, promise: Promise) {
72
- nativeInstance.stopAction(context.toHashMap(), timestampMs.toLong())
73
- promise.resolve(null)
74
- }
75
-
76
- /**
77
- * Add a RUM Action.
78
- * @param type The action type (tap, scroll, swipe, click, custom).
79
- * @param name The action name.
80
- * @param context The additional context to send.
81
- * @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
82
- */
83
- @ReactMethod
84
- fun addAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
85
- nativeInstance.addAction(type, name, context.toHashMap(), timestampMs.toLong())
86
- promise.resolve(null)
87
- }
88
-
89
- /**
90
- * Start tracking a RUM Resource.
91
- * @param key The resource unique key identifier.
92
- * @param method The resource method (GET, POST, …).
93
- * @param url The resource url.
94
- * @param context The additional context to send.
95
- * @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
96
- */
97
- @ReactMethod
98
- fun startResource(key: String, method: String, url: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
99
- nativeInstance.startResource(key, method, url, context.toHashMap(), timestampMs.toLong())
100
- promise.resolve(null)
101
- }
102
-
103
- /**
104
- * Stop tracking a RUM Resource.
105
- * @param key The resource unique key identifier.
106
- * @param statusCode The resource status code.
107
- * @param kind The resource's kind (xhr, document, image, css, font, …).
108
- * @param size The resource size in bytes.
109
- * @param context The additional context to send.
110
- * @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
111
- */
112
- @ReactMethod
113
- fun stopResource(key: String, statusCode: Double, kind: String, size: Double, context: ReadableMap, timestampMs: Double, promise: Promise) {
114
- nativeInstance.stopResource(key, statusCode.toLong(), kind, size.toLong(), context.toHashMap(), timestampMs.toLong())
115
- promise.resolve(null)
116
- }
117
-
118
- /**
119
- * Add a RUM Error.
120
- * @param message The error message.
121
- * @param source The error source (network, source, console, logger, …).
122
- * @param stacktrace The error stacktrace.
123
- * @param context The additional context to send.
124
- * @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
125
- */
126
- @ReactMethod
127
- fun addError(message: String, source: String, stacktrace: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
128
- nativeInstance.addError(message, source, stacktrace, context.toHashMap(), timestampMs.toLong())
129
- promise.resolve(null)
130
- }
131
-
132
- /**
133
- * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
134
- * @param name The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
135
- */
136
- @ReactMethod
137
- fun addTiming(name: String, promise: Promise) {
138
- nativeInstance.addTiming(name)
139
- promise.resolve(null)
140
- }
141
-
142
- }
@@ -1,67 +0,0 @@
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.datadog.android.bridge.DdBridge
10
- import com.datadog.android.bridge.DdSdk as SDKDdSdk
11
- import com.facebook.react.bridge.Promise
12
- import com.facebook.react.bridge.ReactApplicationContext
13
- import com.facebook.react.bridge.ReactContextBaseJavaModule
14
- import com.facebook.react.bridge.ReactMethod
15
- import com.facebook.react.bridge.ReadableArray
16
- import com.facebook.react.bridge.ReadableMap
17
-
18
- /**
19
- * The entry point to initialize Datadog's features.
20
- */
21
- class DdSdk(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
22
-
23
- private val nativeInstance: SDKDdSdk = DdBridge.getDdSdk(reactContext)
24
-
25
- override fun getName(): String = "DdSdk"
26
-
27
- /**
28
- * Initializes Datadog's features.
29
- * @param configuration The configuration to use.
30
- */
31
- @ReactMethod
32
- fun initialize(configuration: ReadableMap, promise: Promise) {
33
- nativeInstance.initialize(configuration.asDdSdkConfiguration())
34
- promise.resolve(null)
35
- }
36
-
37
- /**
38
- * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
39
- * @param attributes The global context attributes.
40
- */
41
- @ReactMethod
42
- fun setAttributes(attributes: ReadableMap, promise: Promise) {
43
- nativeInstance.setAttributes(attributes.toHashMap())
44
- promise.resolve(null)
45
- }
46
-
47
- /**
48
- * Set the user information.
49
- * @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
50
- */
51
- @ReactMethod
52
- fun setUser(user: ReadableMap, promise: Promise) {
53
- nativeInstance.setUser(user.toHashMap())
54
- promise.resolve(null)
55
- }
56
-
57
- /**
58
- * Set the tracking consent regarding the data collection.
59
- * @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
60
- */
61
- @ReactMethod
62
- fun setTrackingConsent(trackingConsent: String, promise: Promise) {
63
- nativeInstance.setTrackingConsent(trackingConsent)
64
- promise.resolve(null)
65
- }
66
-
67
- }
@@ -1,51 +0,0 @@
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.datadog.android.bridge.DdBridge
10
- import com.datadog.android.bridge.DdTrace as SDKDdTrace
11
- import com.facebook.react.bridge.Promise
12
- import com.facebook.react.bridge.ReactApplicationContext
13
- import com.facebook.react.bridge.ReactContextBaseJavaModule
14
- import com.facebook.react.bridge.ReactMethod
15
- import com.facebook.react.bridge.ReadableArray
16
- import com.facebook.react.bridge.ReadableMap
17
-
18
- /**
19
- * The entry point to use Datadog's Trace feature.
20
- */
21
- class DdTrace(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
22
-
23
- private val nativeInstance: SDKDdTrace = DdBridge.getDdTrace(reactContext)
24
-
25
- override fun getName(): String = "DdTrace"
26
-
27
- /**
28
- * Start a span, and returns a unique identifier for the span.
29
- * @param operation The operation name of the span.
30
- * @param context The additional context to send.
31
- * @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
32
- */
33
- @ReactMethod
34
- fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
35
- val result = nativeInstance.startSpan(operation, context.toHashMap(), timestampMs.toLong())
36
- promise.resolve(result)
37
- }
38
-
39
- /**
40
- * Finish a started span.
41
- * @param spanId The unique identifier of the span.
42
- * @param context The additional context to send.
43
- * @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
44
- */
45
- @ReactMethod
46
- fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
47
- nativeInstance.finishSpan(spanId, context.toHashMap(), timestampMs.toLong())
48
- promise.resolve(null)
49
- }
50
-
51
- }