@datadog/mobile-react-native 1.7.0 → 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 +6 -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,199 @@
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.ReactMethod
12
+ import com.facebook.react.bridge.ReadableMap
13
+
14
+ /**
15
+ * The entry point to use Datadog's RUM feature.
16
+ */
17
+ @Suppress("TooManyFunctions")
18
+ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContext) {
19
+
20
+ private val implementation = DdRumImplementation()
21
+
22
+ override fun getName(): String = DdRumImplementation.NAME
23
+
24
+ /**
25
+ * Start tracking a RUM View.
26
+ * @param key The view unique key identifier.
27
+ * @param name The view name.
28
+ * @param context The additional context to send.
29
+ * @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
30
+ */
31
+ @ReactMethod
32
+ override fun startView(
33
+ key: String,
34
+ name: String,
35
+ context: ReadableMap,
36
+ timestampMs: Double,
37
+ promise: Promise
38
+ ) {
39
+ implementation.startView(key, name, context, timestampMs, promise)
40
+ }
41
+
42
+ /**
43
+ * Stop tracking a RUM View.
44
+ * @param key The view unique key identifier.
45
+ * @param context The additional context to send.
46
+ * @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
47
+ */
48
+ @ReactMethod
49
+ override fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
50
+ implementation.stopView(key, context, timestampMs, promise)
51
+ }
52
+
53
+ /**
54
+ * Start tracking a RUM Action.
55
+ * @param type The action type (tap, scroll, swipe, click, custom).
56
+ * @param name The action name.
57
+ * @param context The additional context to send.
58
+ * @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
59
+ */
60
+ @ReactMethod
61
+ override fun startAction(
62
+ type: String,
63
+ name: String,
64
+ context: ReadableMap,
65
+ timestampMs: Double,
66
+ promise: Promise
67
+ ) {
68
+ implementation.startAction(type, name, context, timestampMs, promise)
69
+ }
70
+
71
+ /**
72
+ * Stop tracking the ongoing RUM Action.
73
+ * @param type The action type (tap, scroll, swipe, click, custom).
74
+ * @param name The action name.
75
+ * @param context The additional context to send.
76
+ * @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
77
+ */
78
+ @ReactMethod
79
+ override fun stopAction(
80
+ type: String,
81
+ name: String,
82
+ context: ReadableMap,
83
+ timestampMs: Double,
84
+ promise: Promise
85
+ ) {
86
+ implementation.stopAction(type, name, context, timestampMs, promise)
87
+ }
88
+
89
+ /**
90
+ * Add a RUM Action.
91
+ * @param type The action type (tap, scroll, swipe, click, custom).
92
+ * @param name The action name.
93
+ * @param context The additional context to send.
94
+ * @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
95
+ */
96
+ @ReactMethod
97
+ override fun addAction(
98
+ type: String,
99
+ name: String,
100
+ context: ReadableMap,
101
+ timestampMs: Double,
102
+ promise: Promise
103
+ ) {
104
+ implementation.addAction(type, name, context, timestampMs, promise)
105
+ }
106
+
107
+ /**
108
+ * Start tracking a RUM Resource.
109
+ * @param key The resource unique key identifier.
110
+ * @param method The resource method (GET, POST, …).
111
+ * @param url The resource url.
112
+ * @param context The additional context to send.
113
+ * @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
114
+ */
115
+ @Suppress("LongParameterList")
116
+ @ReactMethod
117
+ override fun startResource(
118
+ key: String,
119
+ method: String,
120
+ url: String,
121
+ context: ReadableMap,
122
+ timestampMs: Double,
123
+ promise: Promise
124
+ ) {
125
+ implementation.startResource(key, method, url, context, timestampMs, promise)
126
+ }
127
+
128
+ /**
129
+ * Stop tracking a RUM Resource.
130
+ * @param key The resource unique key identifier.
131
+ * @param statusCode The resource status code.
132
+ * @param kind The resource's kind (xhr, document, image, css, font, …).
133
+ * @param size The resource size in bytes.
134
+ * @param context The additional context to send.
135
+ * @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
136
+ */
137
+ @Suppress("LongParameterList")
138
+ @ReactMethod
139
+ override fun stopResource(
140
+ key: String,
141
+ statusCode: Double,
142
+ kind: String,
143
+ size: Double,
144
+ context: ReadableMap,
145
+ timestampMs: Double,
146
+ promise: Promise
147
+ ) {
148
+ implementation.stopResource(key, statusCode, kind, size, context, timestampMs, promise)
149
+ }
150
+
151
+ /**
152
+ * Add a RUM Error.
153
+ * @param message The error message.
154
+ * @param source The error source (network, source, console, logger, …).
155
+ * @param stacktrace The error stacktrace.
156
+ * @param context The additional context to send.
157
+ * @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
158
+ */
159
+ @Suppress("LongParameterList")
160
+ @ReactMethod
161
+ override fun addError(
162
+ message: String,
163
+ source: String,
164
+ stacktrace: String,
165
+ context: ReadableMap,
166
+ timestampMs: Double,
167
+ promise: Promise
168
+ ) {
169
+ implementation.addError(message, source, stacktrace, context, timestampMs, promise)
170
+ }
171
+
172
+ /**
173
+ * 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.
174
+ * @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.
175
+ */
176
+ @ReactMethod
177
+ override fun addTiming(name: String, promise: Promise) {
178
+ implementation.addTiming(name, promise)
179
+ }
180
+
181
+ /**
182
+ * Stops the current RUM Session.
183
+ */
184
+ @ReactMethod
185
+ override fun stopSession(promise: Promise) {
186
+ implementation.stopSession(promise)
187
+ }
188
+
189
+ /**
190
+ * Adds result of evaluating a feature flag to the view.
191
+ * Feature flag evaluations are local to the active view and are cleared when the view is stopped.
192
+ * @param name The name of the feature flag
193
+ * @param value The value the feature flag evaluated to, encapsulated in a Map
194
+ */
195
+ @ReactMethod
196
+ override fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
197
+ implementation.addFeatureFlagEvaluation(name, value, promise)
198
+ }
199
+ }
@@ -0,0 +1,90 @@
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.ReactMethod
12
+ import com.facebook.react.bridge.ReadableMap
13
+
14
+ /** The entry point to initialize Datadog's features. */
15
+ class DdSdk(
16
+ reactContext: ReactApplicationContext
17
+ ) : NativeDdSdkSpec(reactContext) {
18
+
19
+ private val implementation = DdSdkImplementation(reactContext)
20
+
21
+ override fun getName(): String = DdSdkImplementation.NAME
22
+
23
+ /**
24
+ * Initializes Datadog's features.
25
+ * @param configuration The configuration to use.
26
+ */
27
+ @ReactMethod
28
+ override fun initialize(configuration: ReadableMap, promise: Promise) {
29
+ implementation.initialize(configuration, promise)
30
+ }
31
+
32
+ /**
33
+ * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM
34
+ * events.
35
+ * @param attributes The global context attributes.
36
+ */
37
+ @ReactMethod
38
+ override fun setAttributes(attributes: ReadableMap, promise: Promise) {
39
+ implementation.setAttributes(attributes, promise)
40
+ }
41
+
42
+ /**
43
+ * Set the user information.
44
+ * @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
45
+ * attribute).
46
+ */
47
+ @ReactMethod
48
+ override fun setUser(user: ReadableMap, promise: Promise) {
49
+ implementation.setUser(user, promise)
50
+ }
51
+
52
+ /**
53
+ * Set the tracking consent regarding the data collection.
54
+ * @param trackingConsent Consent, which can take one of the following values: 'pending',
55
+ * 'granted', 'not_granted'.
56
+ */
57
+ @ReactMethod
58
+ override fun setTrackingConsent(trackingConsent: String, promise: Promise) {
59
+ implementation.setTrackingConsent(trackingConsent, promise)
60
+ }
61
+
62
+ /**
63
+ * Sends a telemetry debug event.
64
+ * @param message Debug message.
65
+ */
66
+ @ReactMethod
67
+ override fun telemetryDebug(message: String, promise: Promise) {
68
+ implementation.telemetryDebug(message, promise)
69
+ }
70
+
71
+ /**
72
+ * Sends a telemetry error event.
73
+ * @param message Error message.
74
+ * @param stack Error stack.
75
+ * @param kind Error kind.
76
+ */
77
+ @ReactMethod
78
+ override fun telemetryError(message: String, stack: String, kind: String, promise: Promise) {
79
+ implementation.telemetryError(message, stack, kind, promise)
80
+ }
81
+
82
+ /**
83
+ * Sends WebView Events.
84
+ * @param message User action.
85
+ */
86
+ @ReactMethod
87
+ override fun consumeWebviewEvent(message: String, promise: Promise) {
88
+ implementation.consumeWebviewEvent(message, promise)
89
+ }
90
+ }
@@ -0,0 +1,46 @@
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.ReactMethod
12
+ import com.facebook.react.bridge.ReadableMap
13
+
14
+ /**
15
+ * The entry point to use Datadog's Trace feature.
16
+ */
17
+ class DdTrace(
18
+ reactContext: ReactApplicationContext,
19
+ ) : NativeDdTraceSpec(reactContext) {
20
+
21
+ private val implementation = DdTraceImplementation()
22
+
23
+ override fun getName(): String = DdTraceImplementation.NAME
24
+
25
+ /**
26
+ * Start a span, and returns a unique identifier for the span.
27
+ * @param operation The operation name of the span.
28
+ * @param context The additional context to send.
29
+ * @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
30
+ */
31
+ @ReactMethod
32
+ override fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
33
+ implementation.startSpan(operation, context, timestampMs, promise)
34
+ }
35
+
36
+ /**
37
+ * Finish a started span.
38
+ * @param spanId The unique identifier of the span.
39
+ * @param context The additional context to send.
40
+ * @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
41
+ */
42
+ @ReactMethod
43
+ override fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
44
+ implementation.finishSpan(spanId, context, timestampMs, promise)
45
+ }
46
+ }
@@ -0,0 +1,163 @@
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 Logs feature.
17
+ */
18
+ class DdLogs(
19
+ reactContext: ReactApplicationContext
20
+ ) : ReactContextBaseJavaModule(reactContext) {
21
+
22
+ private val implementation = DdLogsImplementation()
23
+
24
+ override fun getName(): String = DdLogsImplementation.NAME
25
+
26
+ /**
27
+ * Send a log with Debug level.
28
+ * @param message The message to send.
29
+ * @param context The additional context to send.
30
+ */
31
+ @ReactMethod
32
+ fun debug(message: String, context: ReadableMap, promise: Promise) {
33
+ implementation.debug(message, context, promise)
34
+ }
35
+
36
+ /**
37
+ * Send a log with Info level.
38
+ * @param message The message to send.
39
+ * @param context The additional context to send.
40
+ */
41
+ @ReactMethod
42
+ fun info(message: String, context: ReadableMap, promise: Promise) {
43
+ implementation.info(message, context, promise)
44
+ }
45
+
46
+ /**
47
+ * Send a log with Warn level.
48
+ * @param message The message to send.
49
+ * @param context The additional context to send.
50
+ */
51
+ @ReactMethod
52
+ fun warn(message: String, context: ReadableMap, promise: Promise) {
53
+ implementation.warn(message, context, promise)
54
+ }
55
+
56
+ /**
57
+ * Send a log with Error level.
58
+ * @param message The message to send.
59
+ * @param context The additional context to send.
60
+ */
61
+ @ReactMethod
62
+ fun error(message: String, context: ReadableMap, promise: Promise) {
63
+ implementation.error(message, context, promise)
64
+ }
65
+
66
+ /**
67
+ * Send a log containing an error with Debug level.
68
+ * @param message The message to send.
69
+ * @param errorKind The error kind to send.
70
+ * @param errorMessage The error message to send.
71
+ * @param stacktrace The error stacktrace to send.
72
+ * @param context The additional context to send.
73
+ */
74
+ @Suppress("LongParameterList")
75
+ @ReactMethod
76
+ fun debugWithError(
77
+ message: String,
78
+ errorKind: String?,
79
+ errorMessage: String?,
80
+ stacktrace: String?,
81
+ context: ReadableMap,
82
+ promise: Promise
83
+ ) {
84
+ implementation.debugWithError(
85
+ message,
86
+ errorKind,
87
+ errorMessage,
88
+ stacktrace,
89
+ context,
90
+ promise
91
+ )
92
+ }
93
+
94
+ /**
95
+ * Send a log with containing an error with Info level.
96
+ * @param message The message to send.
97
+ * @param errorKind The error kind to send.
98
+ * @param errorMessage The error message to send.
99
+ * @param stacktrace The error stacktrace to send.
100
+ * @param context The additional context to send.
101
+ */
102
+ @Suppress("LongParameterList")
103
+ @ReactMethod
104
+ fun infoWithError(
105
+ message: String,
106
+ errorKind: String?,
107
+ errorMessage: String?,
108
+ stacktrace: String?,
109
+ context: ReadableMap,
110
+ promise: Promise
111
+ ) {
112
+ implementation.infoWithError(message, errorKind, errorMessage, stacktrace, context, promise)
113
+ }
114
+
115
+ /**
116
+ * Send a log containing an error with Warn level.
117
+ * @param message The message to send.
118
+ * @param errorKind The error kind to send.
119
+ * @param errorMessage The error message to send.
120
+ * @param stacktrace The error stacktrace to send.
121
+ * @param context The additional context to send.
122
+ */
123
+ @Suppress("LongParameterList")
124
+ @ReactMethod
125
+ fun warnWithError(
126
+ message: String,
127
+ errorKind: String?,
128
+ errorMessage: String?,
129
+ stacktrace: String?,
130
+ context: ReadableMap,
131
+ promise: Promise
132
+ ) {
133
+ implementation.warnWithError(message, errorKind, errorMessage, stacktrace, context, promise)
134
+ }
135
+
136
+ /**
137
+ * Send a log containing an error with Error level.
138
+ * @param message The message to send.
139
+ * @param errorKind The error kind to send.
140
+ * @param errorMessage The error message to send.
141
+ * @param stacktrace The error stacktrace to send.
142
+ * @param context The additional context to send.
143
+ */
144
+ @Suppress("LongParameterList")
145
+ @ReactMethod
146
+ fun errorWithError(
147
+ message: String,
148
+ errorKind: String?,
149
+ errorMessage: String?,
150
+ stacktrace: String?,
151
+ context: ReadableMap,
152
+ promise: Promise
153
+ ) {
154
+ implementation.errorWithError(
155
+ message,
156
+ errorKind,
157
+ errorMessage,
158
+ stacktrace,
159
+ context,
160
+ promise
161
+ )
162
+ }
163
+ }
@@ -0,0 +1,200 @@
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 RUM feature.
17
+ */
18
+ @Suppress("TooManyFunctions")
19
+ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
20
+
21
+ private val implementation = DdRumImplementation()
22
+
23
+ override fun getName(): String = DdRumImplementation.NAME
24
+
25
+ /**
26
+ * Start tracking a RUM View.
27
+ * @param key The view unique key identifier.
28
+ * @param name The view name.
29
+ * @param context The additional context to send.
30
+ * @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
31
+ */
32
+ @ReactMethod
33
+ fun startView(
34
+ key: String,
35
+ name: String,
36
+ context: ReadableMap,
37
+ timestampMs: Double,
38
+ promise: Promise
39
+ ) {
40
+ implementation.startView(key, name, context, timestampMs, promise)
41
+ }
42
+
43
+ /**
44
+ * Stop tracking a RUM View.
45
+ * @param key The view unique key identifier.
46
+ * @param context The additional context to send.
47
+ * @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
48
+ */
49
+ @ReactMethod
50
+ fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
51
+ implementation.stopView(key, context, timestampMs, promise)
52
+ }
53
+
54
+ /**
55
+ * Start tracking a RUM Action.
56
+ * @param type The action type (tap, scroll, swipe, click, custom).
57
+ * @param name The action name.
58
+ * @param context The additional context to send.
59
+ * @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
60
+ */
61
+ @ReactMethod
62
+ fun startAction(
63
+ type: String,
64
+ name: String,
65
+ context: ReadableMap,
66
+ timestampMs: Double,
67
+ promise: Promise
68
+ ) {
69
+ implementation.startAction(type, name, context, timestampMs, promise)
70
+ }
71
+
72
+ /**
73
+ * Stop tracking the ongoing RUM Action.
74
+ * @param type The action type (tap, scroll, swipe, click, custom).
75
+ * @param name The action name.
76
+ * @param context The additional context to send.
77
+ * @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
78
+ */
79
+ @ReactMethod
80
+ fun stopAction(
81
+ type: String,
82
+ name: String,
83
+ context: ReadableMap,
84
+ timestampMs: Double,
85
+ promise: Promise
86
+ ) {
87
+ implementation.stopAction(type, name, context, timestampMs, promise)
88
+ }
89
+
90
+ /**
91
+ * Add a RUM Action.
92
+ * @param type The action type (tap, scroll, swipe, click, custom).
93
+ * @param name The action name.
94
+ * @param context The additional context to send.
95
+ * @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
96
+ */
97
+ @ReactMethod
98
+ fun addAction(
99
+ type: String,
100
+ name: String,
101
+ context: ReadableMap,
102
+ timestampMs: Double,
103
+ promise: Promise
104
+ ) {
105
+ implementation.addAction(type, name, context, timestampMs, promise)
106
+ }
107
+
108
+ /**
109
+ * Start tracking a RUM Resource.
110
+ * @param key The resource unique key identifier.
111
+ * @param method The resource method (GET, POST, …).
112
+ * @param url The resource url.
113
+ * @param context The additional context to send.
114
+ * @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
115
+ */
116
+ @Suppress("LongParameterList")
117
+ @ReactMethod
118
+ fun startResource(
119
+ key: String,
120
+ method: String,
121
+ url: String,
122
+ context: ReadableMap,
123
+ timestampMs: Double,
124
+ promise: Promise
125
+ ) {
126
+ implementation.startResource(key, method, url, context, timestampMs, promise)
127
+ }
128
+
129
+ /**
130
+ * Stop tracking a RUM Resource.
131
+ * @param key The resource unique key identifier.
132
+ * @param statusCode The resource status code.
133
+ * @param kind The resource's kind (xhr, document, image, css, font, …).
134
+ * @param size The resource size in bytes.
135
+ * @param context The additional context to send.
136
+ * @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
137
+ */
138
+ @Suppress("LongParameterList")
139
+ @ReactMethod
140
+ fun stopResource(
141
+ key: String,
142
+ statusCode: Double,
143
+ kind: String,
144
+ size: Double,
145
+ context: ReadableMap,
146
+ timestampMs: Double,
147
+ promise: Promise
148
+ ) {
149
+ implementation.stopResource(key, statusCode, kind, size, context, timestampMs, promise)
150
+ }
151
+
152
+ /**
153
+ * Add a RUM Error.
154
+ * @param message The error message.
155
+ * @param source The error source (network, source, console, logger, …).
156
+ * @param stacktrace The error stacktrace.
157
+ * @param context The additional context to send.
158
+ * @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
159
+ */
160
+ @Suppress("LongParameterList")
161
+ @ReactMethod
162
+ fun addError(
163
+ message: String,
164
+ source: String,
165
+ stacktrace: String,
166
+ context: ReadableMap,
167
+ timestampMs: Double,
168
+ promise: Promise
169
+ ) {
170
+ implementation.addError(message, source, stacktrace, context, timestampMs, promise)
171
+ }
172
+
173
+ /**
174
+ * 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.
175
+ * @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.
176
+ */
177
+ @ReactMethod
178
+ fun addTiming(name: String, promise: Promise) {
179
+ implementation.addTiming(name, promise)
180
+ }
181
+
182
+ /**
183
+ * Stops the current RUM Session.
184
+ */
185
+ @ReactMethod
186
+ fun stopSession(promise: Promise) {
187
+ implementation.stopSession(promise)
188
+ }
189
+
190
+ /**
191
+ * Adds result of evaluating a feature flag to the view.
192
+ * Feature flag evaluations are local to the active view and are cleared when the view is stopped.
193
+ * @param name The name of the feature flag
194
+ * @param value The value the feature flag evaluated to, encapsulated in a Map
195
+ */
196
+ @ReactMethod
197
+ fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
198
+ implementation.addFeatureFlagEvaluation(name, value, promise)
199
+ }
200
+ }