@datadog/mobile-react-native 3.1.1 → 3.1.2
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.
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +20 -43
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +18 -125
- package/ios/Sources/DdLogsImplementation.swift +13 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/logs/DdLogs.js +14 -44
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +25 -3
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/logs/DdLogs.js +15 -45
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +2 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +25 -3
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/logs/DdLogs.d.ts +0 -5
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +9 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +89 -0
- package/src/logs/DdLogs.ts +25 -58
- package/src/logs/__tests__/DdLogs.test.ts +2 -21
- package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +3 -3
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +25 -3
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +13 -0
- package/src/version.ts +1 -1
|
@@ -16,20 +16,30 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
16
16
|
* The entry point to use Datadog's Logs feature.
|
|
17
17
|
*/
|
|
18
18
|
class DdLogsImplementation(
|
|
19
|
-
|
|
20
|
-
private val
|
|
21
|
-
)
|
|
22
|
-
private val reactNativeLogger: Logger by lazy {
|
|
23
|
-
val bundleLogsWithRum = datadog.bundleLogsWithRum
|
|
24
|
-
val bundleLogsWithTraces = datadog.bundleLogsWithTraces
|
|
25
|
-
|
|
26
|
-
logger ?: Logger.Builder(Datadog.getInstance())
|
|
19
|
+
private val datadog: DatadogWrapper = DatadogSDKWrapper(),
|
|
20
|
+
private val logger: () -> Logger = {
|
|
21
|
+
Logger.Builder(Datadog.getInstance())
|
|
27
22
|
.setLogcatLogsEnabled(true)
|
|
28
|
-
.setBundleWithRumEnabled(bundleLogsWithRum)
|
|
29
|
-
.setBundleWithTraceEnabled(bundleLogsWithTraces)
|
|
23
|
+
.setBundleWithRumEnabled(datadog.bundleLogsWithRum)
|
|
24
|
+
.setBundleWithTraceEnabled(datadog.bundleLogsWithTraces)
|
|
30
25
|
.setName("DdLogs")
|
|
31
26
|
.build()
|
|
32
27
|
}
|
|
28
|
+
) {
|
|
29
|
+
private var loggerInstance: Logger? = null
|
|
30
|
+
private val reactNativeLogger: Logger
|
|
31
|
+
get() {
|
|
32
|
+
if (loggerInstance == null) {
|
|
33
|
+
loggerInstance = logger()
|
|
34
|
+
}
|
|
35
|
+
return loggerInstance!!
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
init {
|
|
39
|
+
DatadogSDKWrapperStorage.addOnInitializedListener {
|
|
40
|
+
loggerInstance = null
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
45
|
* Send a log with Debug level.
|
|
@@ -37,10 +47,6 @@ class DdLogsImplementation(
|
|
|
37
47
|
* @param context The additional context to send.
|
|
38
48
|
*/
|
|
39
49
|
fun debug(message: String, context: ReadableMap, promise: Promise) {
|
|
40
|
-
if (!datadog.isInitialized()) {
|
|
41
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
50
|
reactNativeLogger.d(
|
|
45
51
|
message = message,
|
|
46
52
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -54,10 +60,6 @@ class DdLogsImplementation(
|
|
|
54
60
|
* @param context The additional context to send.
|
|
55
61
|
*/
|
|
56
62
|
fun info(message: String, context: ReadableMap, promise: Promise) {
|
|
57
|
-
if (!datadog.isInitialized()) {
|
|
58
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
63
|
reactNativeLogger.i(
|
|
62
64
|
message = message,
|
|
63
65
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -71,10 +73,6 @@ class DdLogsImplementation(
|
|
|
71
73
|
* @param context The additional context to send.
|
|
72
74
|
*/
|
|
73
75
|
fun warn(message: String, context: ReadableMap, promise: Promise) {
|
|
74
|
-
if (!datadog.isInitialized()) {
|
|
75
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
76
|
reactNativeLogger.w(
|
|
79
77
|
message = message,
|
|
80
78
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -88,10 +86,6 @@ class DdLogsImplementation(
|
|
|
88
86
|
* @param context The additional context to send.
|
|
89
87
|
*/
|
|
90
88
|
fun error(message: String, context: ReadableMap, promise: Promise) {
|
|
91
|
-
if (!datadog.isInitialized()) {
|
|
92
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
89
|
reactNativeLogger.e(
|
|
96
90
|
message = message,
|
|
97
91
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -116,10 +110,6 @@ class DdLogsImplementation(
|
|
|
116
110
|
context: ReadableMap,
|
|
117
111
|
promise: Promise
|
|
118
112
|
) {
|
|
119
|
-
if (!datadog.isInitialized()) {
|
|
120
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
113
|
reactNativeLogger.log(
|
|
124
114
|
priority = AndroidLog.DEBUG,
|
|
125
115
|
message = message,
|
|
@@ -148,10 +138,6 @@ class DdLogsImplementation(
|
|
|
148
138
|
context: ReadableMap,
|
|
149
139
|
promise: Promise
|
|
150
140
|
) {
|
|
151
|
-
if (!datadog.isInitialized()) {
|
|
152
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
141
|
reactNativeLogger.log(
|
|
156
142
|
priority = AndroidLog.INFO,
|
|
157
143
|
message = message,
|
|
@@ -180,10 +166,6 @@ class DdLogsImplementation(
|
|
|
180
166
|
context: ReadableMap,
|
|
181
167
|
promise: Promise
|
|
182
168
|
) {
|
|
183
|
-
if (!datadog.isInitialized()) {
|
|
184
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
169
|
reactNativeLogger.log(
|
|
188
170
|
priority = AndroidLog.WARN,
|
|
189
171
|
message = message,
|
|
@@ -212,10 +194,6 @@ class DdLogsImplementation(
|
|
|
212
194
|
context: ReadableMap,
|
|
213
195
|
promise: Promise
|
|
214
196
|
) {
|
|
215
|
-
if (!datadog.isInitialized()) {
|
|
216
|
-
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
217
|
-
return
|
|
218
|
-
}
|
|
219
197
|
reactNativeLogger.log(
|
|
220
198
|
priority = AndroidLog.ERROR,
|
|
221
199
|
message = message,
|
|
@@ -228,7 +206,6 @@ class DdLogsImplementation(
|
|
|
228
206
|
}
|
|
229
207
|
|
|
230
208
|
internal companion object {
|
|
231
|
-
private const val SDK_NOT_INITIALIZED_MESSAGE = "DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT"
|
|
232
209
|
internal const val NAME = "DdLogs"
|
|
233
210
|
}
|
|
234
211
|
}
|
|
@@ -8,7 +8,6 @@ package com.datadog.reactnative
|
|
|
8
8
|
|
|
9
9
|
import android.util.Log
|
|
10
10
|
import com.datadog.android.log.Logger
|
|
11
|
-
import com.datadog.tools.unit.GenericAssert.Companion.assertThat
|
|
12
11
|
import com.facebook.react.bridge.Promise
|
|
13
12
|
import com.facebook.react.bridge.ReadableMap
|
|
14
13
|
import fr.xgouchet.elmyr.Forge
|
|
@@ -25,11 +24,9 @@ import org.junit.jupiter.api.extension.Extensions
|
|
|
25
24
|
import org.mockito.Mock
|
|
26
25
|
import org.mockito.junit.jupiter.MockitoExtension
|
|
27
26
|
import org.mockito.junit.jupiter.MockitoSettings
|
|
28
|
-
import org.mockito.kotlin.
|
|
29
|
-
import org.mockito.kotlin.doReturn
|
|
27
|
+
import org.mockito.kotlin.mock
|
|
30
28
|
import org.mockito.kotlin.times
|
|
31
29
|
import org.mockito.kotlin.verify
|
|
32
|
-
import org.mockito.kotlin.verifyNoInteractions
|
|
33
30
|
import org.mockito.kotlin.whenever
|
|
34
31
|
import org.mockito.quality.Strictness
|
|
35
32
|
|
|
@@ -71,8 +68,7 @@ internal class DdLogsTest {
|
|
|
71
68
|
|
|
72
69
|
@BeforeEach
|
|
73
70
|
fun `set up`(forge: Forge) {
|
|
74
|
-
|
|
75
|
-
testedLogs = DdLogsImplementation(mockLogger, mockDatadog)
|
|
71
|
+
testedLogs = DdLogsImplementation(datadog = mockDatadog, logger = { mockLogger })
|
|
76
72
|
fakeErrorKind = forge.aNullable { forge.aString() }
|
|
77
73
|
fakeErrorMessage = forge.aNullable { forge.aString() }
|
|
78
74
|
fakeStacktrace = forge.aNullable { forge.aString() }
|
|
@@ -272,129 +268,26 @@ internal class DdLogsTest {
|
|
|
272
268
|
}
|
|
273
269
|
|
|
274
270
|
@Test
|
|
275
|
-
fun `M
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
newTestedLogs.error(fakeMessage, mockContext, mockPromise)
|
|
283
|
-
testedLogs.debugWithError(
|
|
284
|
-
fakeMessage,
|
|
285
|
-
fakeErrorKind,
|
|
286
|
-
fakeErrorMessage,
|
|
287
|
-
fakeStacktrace,
|
|
288
|
-
mockContext,
|
|
289
|
-
mockPromise
|
|
290
|
-
)
|
|
291
|
-
testedLogs.infoWithError(
|
|
292
|
-
fakeMessage,
|
|
293
|
-
fakeErrorKind,
|
|
294
|
-
fakeErrorMessage,
|
|
295
|
-
fakeStacktrace,
|
|
296
|
-
mockContext,
|
|
297
|
-
mockPromise
|
|
298
|
-
)
|
|
299
|
-
testedLogs.warnWithError(
|
|
300
|
-
fakeMessage,
|
|
301
|
-
fakeErrorKind,
|
|
302
|
-
fakeErrorMessage,
|
|
303
|
-
fakeStacktrace,
|
|
304
|
-
mockContext,
|
|
305
|
-
mockPromise
|
|
306
|
-
)
|
|
307
|
-
testedLogs.errorWithError(
|
|
308
|
-
fakeMessage,
|
|
309
|
-
fakeErrorKind,
|
|
310
|
-
fakeErrorMessage,
|
|
311
|
-
fakeStacktrace,
|
|
312
|
-
mockContext,
|
|
313
|
-
mockPromise
|
|
271
|
+
fun `M recreate logger W SDK is initialized`() {
|
|
272
|
+
// Given
|
|
273
|
+
val mockLoggerFactory = mock<() -> Logger>()
|
|
274
|
+
whenever(mockLoggerFactory()).thenReturn(mockLogger)
|
|
275
|
+
val testedLogs = DdLogsImplementation(
|
|
276
|
+
datadog = mockDatadog,
|
|
277
|
+
logger = mockLoggerFactory
|
|
314
278
|
)
|
|
315
279
|
|
|
280
|
+
// When
|
|
281
|
+
testedLogs.debug(fakeMessage, mockContext, mockPromise)
|
|
282
|
+
|
|
316
283
|
// Then
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
.isEqualTo("DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT")
|
|
322
|
-
|
|
323
|
-
// When SDK is finally initialized
|
|
324
|
-
whenever(mockDatadog.isInitialized()) doReturn true
|
|
325
|
-
newTestedLogs.debug(fakeMessage, mockContext, mockPromise)
|
|
326
|
-
newTestedLogs.info(fakeMessage, mockContext, mockPromise)
|
|
327
|
-
newTestedLogs.warn(fakeMessage, mockContext, mockPromise)
|
|
328
|
-
newTestedLogs.error(fakeMessage, mockContext, mockPromise)
|
|
329
|
-
testedLogs.debugWithError(
|
|
330
|
-
fakeMessage,
|
|
331
|
-
fakeErrorKind,
|
|
332
|
-
fakeErrorMessage,
|
|
333
|
-
fakeStacktrace,
|
|
334
|
-
mockContext,
|
|
335
|
-
mockPromise
|
|
336
|
-
)
|
|
337
|
-
testedLogs.infoWithError(
|
|
338
|
-
fakeMessage,
|
|
339
|
-
fakeErrorKind,
|
|
340
|
-
fakeErrorMessage,
|
|
341
|
-
fakeStacktrace,
|
|
342
|
-
mockContext,
|
|
343
|
-
mockPromise
|
|
344
|
-
)
|
|
345
|
-
testedLogs.warnWithError(
|
|
346
|
-
fakeMessage,
|
|
347
|
-
fakeErrorKind,
|
|
348
|
-
fakeErrorMessage,
|
|
349
|
-
fakeStacktrace,
|
|
350
|
-
mockContext,
|
|
351
|
-
mockPromise
|
|
352
|
-
)
|
|
353
|
-
testedLogs.errorWithError(
|
|
354
|
-
fakeMessage,
|
|
355
|
-
fakeErrorKind,
|
|
356
|
-
fakeErrorMessage,
|
|
357
|
-
fakeStacktrace,
|
|
358
|
-
mockContext,
|
|
359
|
-
mockPromise
|
|
360
|
-
)
|
|
284
|
+
verify(mockLoggerFactory, times(1)).invoke()
|
|
285
|
+
|
|
286
|
+
// When
|
|
287
|
+
DatadogSDKWrapperStorage.notifyOnInitializedListeners(mock())
|
|
361
288
|
|
|
362
289
|
// Then
|
|
363
|
-
|
|
364
|
-
verify(
|
|
365
|
-
verify(mockLogger).w(fakeMessage, attributes = mockContext.toHashMap())
|
|
366
|
-
verify(mockLogger).e(fakeMessage, attributes = mockContext.toHashMap())
|
|
367
|
-
verify(mockLogger).log(
|
|
368
|
-
Log.DEBUG,
|
|
369
|
-
fakeMessage,
|
|
370
|
-
fakeErrorKind,
|
|
371
|
-
fakeErrorMessage,
|
|
372
|
-
fakeStacktrace,
|
|
373
|
-
attributes = mockContext.toHashMap()
|
|
374
|
-
)
|
|
375
|
-
verify(mockLogger).log(
|
|
376
|
-
Log.INFO,
|
|
377
|
-
fakeMessage,
|
|
378
|
-
fakeErrorKind,
|
|
379
|
-
fakeErrorMessage,
|
|
380
|
-
fakeStacktrace,
|
|
381
|
-
attributes = mockContext.toHashMap()
|
|
382
|
-
)
|
|
383
|
-
verify(mockLogger).log(
|
|
384
|
-
Log.WARN,
|
|
385
|
-
fakeMessage,
|
|
386
|
-
fakeErrorKind,
|
|
387
|
-
fakeErrorMessage,
|
|
388
|
-
fakeStacktrace,
|
|
389
|
-
attributes = mockContext.toHashMap()
|
|
390
|
-
)
|
|
391
|
-
verify(mockLogger).log(
|
|
392
|
-
Log.ERROR,
|
|
393
|
-
fakeMessage,
|
|
394
|
-
fakeErrorKind,
|
|
395
|
-
fakeErrorMessage,
|
|
396
|
-
fakeStacktrace,
|
|
397
|
-
attributes = mockContext.toHashMap()
|
|
398
|
-
)
|
|
290
|
+
testedLogs.debug(fakeMessage, mockContext, mockPromise)
|
|
291
|
+
verify(mockLoggerFactory, times(2)).invoke()
|
|
399
292
|
}
|
|
400
293
|
}
|
|
@@ -11,11 +11,21 @@ import DatadogCore
|
|
|
11
11
|
|
|
12
12
|
@objc
|
|
13
13
|
public class DdLogsImplementation: NSObject {
|
|
14
|
-
private
|
|
14
|
+
private var loggerInstance: LoggerProtocol?
|
|
15
|
+
private var logger: LoggerProtocol {
|
|
16
|
+
if loggerInstance == nil {
|
|
17
|
+
loggerInstance = loggerProvider()
|
|
18
|
+
}
|
|
19
|
+
return loggerInstance!
|
|
20
|
+
}
|
|
15
21
|
private let loggerProvider: () -> LoggerProtocol
|
|
16
|
-
|
|
22
|
+
|
|
17
23
|
internal init(_ loggerProvider: @escaping () -> LoggerProtocol) {
|
|
18
24
|
self.loggerProvider = loggerProvider
|
|
25
|
+
super.init()
|
|
26
|
+
DatadogSDKWrapper.shared.addOnSdkInitializedListener { [weak self] _ in
|
|
27
|
+
self?.loggerInstance = nil
|
|
28
|
+
}
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
@objc
|
|
@@ -94,4 +104,4 @@ internal extension DatadogLogs.Logger.Configuration {
|
|
|
94
104
|
consoleLogFormat: .short
|
|
95
105
|
)
|
|
96
106
|
}
|
|
97
|
-
}
|
|
107
|
+
}
|
|
@@ -9,6 +9,7 @@ var _InternalLog = require("../InternalLog");
|
|
|
9
9
|
var _SdkVerbosity = require("../config/types/SdkVerbosity");
|
|
10
10
|
var _debugIdResolver = require("../metro/debugIdResolver");
|
|
11
11
|
var _attributesEncoding = require("../sdk/AttributesEncoding/attributesEncoding");
|
|
12
|
+
var _bufferNativeCall = require("../sdk/DatadogProvider/Buffer/bufferNativeCall");
|
|
12
13
|
var _singletonUtils = require("../utils/singletonUtils");
|
|
13
14
|
var _eventMapper = require("./eventMapper");
|
|
14
15
|
/*
|
|
@@ -18,7 +19,6 @@ var _eventMapper = require("./eventMapper");
|
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
const LOGS_MODULE = 'com.datadog.reactnative.logs';
|
|
21
|
-
const SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';
|
|
22
22
|
const generateEmptyPromise = () => new Promise(resolve => resolve());
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -56,16 +56,6 @@ class DdLogsWrapper {
|
|
|
56
56
|
}
|
|
57
57
|
return this.log(args[0], args[1] ?? {}, 'error');
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Since the InternalLog does not have a verbosity set yet in this case,
|
|
62
|
-
* we use console.warn to warn the user in dev mode.
|
|
63
|
-
*/
|
|
64
|
-
printLogDroppedSdkNotInitialized = (message, status) => {
|
|
65
|
-
if (__DEV__) {
|
|
66
|
-
console.warn(`${_InternalLog.DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: "${message}"`);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
59
|
printLogDroppedByMapper = (message, status) => {
|
|
70
60
|
_InternalLog.InternalLog.log(`${status} log dropped by log mapper: "${message}"`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
71
61
|
};
|
|
@@ -83,17 +73,7 @@ class DdLogsWrapper {
|
|
|
83
73
|
return generateEmptyPromise();
|
|
84
74
|
}
|
|
85
75
|
this.printLogTracked(event.message, status);
|
|
86
|
-
|
|
87
|
-
return await this.nativeLogs[status](event.message, (0, _attributesEncoding.encodeAttributes)(event.context));
|
|
88
|
-
} catch (error) {
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {
|
|
92
|
-
this.printLogDroppedSdkNotInitialized(message, status);
|
|
93
|
-
return generateEmptyPromise();
|
|
94
|
-
}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
76
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeLogs[status](event.message, (0, _attributesEncoding.encodeAttributes)(event.context)));
|
|
97
77
|
};
|
|
98
78
|
logWithError = async (message, errorKind, errorMessage, stacktrace, context, status, fingerprint = '', source) => {
|
|
99
79
|
const rawLogEvent = {
|
|
@@ -112,29 +92,19 @@ class DdLogsWrapper {
|
|
|
112
92
|
return generateEmptyPromise();
|
|
113
93
|
}
|
|
114
94
|
this.printLogTracked(mappedEvent.message, status);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
updatedContext[_DdAttributes.DdAttributes.debugId] = _debugId;
|
|
127
|
-
}
|
|
128
|
-
return await this.nativeLogs[`${status}WithError`](mappedEvent.message, mappedEvent.errorKind, mappedEvent.errorMessage, mappedEvent.stacktrace, updatedContext);
|
|
129
|
-
} catch (error) {
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
131
|
-
// @ts-ignore
|
|
132
|
-
if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {
|
|
133
|
-
this.printLogDroppedSdkNotInitialized(message, status);
|
|
134
|
-
return generateEmptyPromise();
|
|
135
|
-
}
|
|
136
|
-
throw error;
|
|
95
|
+
const encodedContext = (0, _attributesEncoding.encodeAttributes)(mappedEvent.context);
|
|
96
|
+
const updatedContext = {
|
|
97
|
+
...encodedContext,
|
|
98
|
+
[_DdAttributes.DdAttributes.errorSourceType]: 'react-native'
|
|
99
|
+
};
|
|
100
|
+
if (fingerprint && fingerprint !== '') {
|
|
101
|
+
updatedContext[_DdAttributes.DdAttributes.errorFingerprint] = fingerprint;
|
|
102
|
+
}
|
|
103
|
+
const _debugId = _debugIdResolver.debugId;
|
|
104
|
+
if (_debugId) {
|
|
105
|
+
updatedContext[_DdAttributes.DdAttributes.debugId] = _debugId;
|
|
137
106
|
}
|
|
107
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeLogs[`${status}WithError`](mappedEvent.message, mappedEvent.errorKind, mappedEvent.errorMessage, mappedEvent.stacktrace, updatedContext));
|
|
138
108
|
};
|
|
139
109
|
registerLogEventMapper(logEventMapper) {
|
|
140
110
|
this.logEventMapper = (0, _eventMapper.generateEventMapper)(logEventMapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DdAttributes","require","_InternalLog","_SdkVerbosity","_debugIdResolver","_attributesEncoding","_singletonUtils","_eventMapper","LOGS_MODULE","
|
|
1
|
+
{"version":3,"names":["_DdAttributes","require","_InternalLog","_SdkVerbosity","_debugIdResolver","_attributesEncoding","_bufferNativeCall","_singletonUtils","_eventMapper","LOGS_MODULE","generateEmptyPromise","Promise","resolve","isLogWithError","args","undefined","DdLogsWrapper","nativeLogs","default","logEventMapper","generateEventMapper","debug","logWithError","log","info","warn","error","printLogDroppedByMapper","message","status","InternalLog","SdkVerbosity","DEBUG","printLogTracked","context","event","applyEventMapper","bufferVoidNativeCall","encodeAttributes","errorKind","errorMessage","stacktrace","fingerprint","source","rawLogEvent","mappedEvent","encodedContext","updatedContext","DdAttributes","errorSourceType","errorFingerprint","_debugId","debugId","registerLogEventMapper","unregisterLogEventMapper","DdLogs","exports","getGlobalInstance"],"sourceRoot":"../../../src","sources":["logs/DdLogs.ts"],"mappings":";;;;;;AAMA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AAEA,IAAAO,YAAA,GAAAP,OAAA;AAhBA;AACA;AACA;AACA;AACA;;AAqBA,MAAMQ,WAAW,GAAG,8BAA8B;AAElD,MAAMC,oBAAoB,GAAGA,CAAA,KAAM,IAAIC,OAAO,CAAOC,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC;;AAE1E;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAChBC,IAA0C,IACV;EAChC,OACI,OAAOA,IA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Label && accessibilityLabel ? accessibilityLabel : null;
|
|
65
65
|
const index = handlerArgs ? handlerArgs.find(x => typeof x === 'number') || 0 : 0;
|
|
66
66
|
|
|
67
|
-
// Order:
|
|
68
|
-
const selectedContent =
|
|
67
|
+
// Order: actionName → actionNameAttribute → accessibilityLabel → content
|
|
68
|
+
const selectedContent = actionName || Object.values(attrs)[0] || getAccessibilityLabel() || tryContent();
|
|
69
69
|
if (!selectedContent) {
|
|
70
70
|
return componentName;
|
|
71
71
|
}
|
package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_NativeDdSdk","_interopRequireDefault","require","_singletonUtils","_DefaultTimeProvider","_constants","_types","e","__esModule","default","BABEL_INTERACTION_TRACKING_MODULE","BabelInteractionTracking","config","trackInteractions","useAccessibilityLabel","timeProvider","DefaultTimeProvider","telemetrySent","ddRum","isInitialized","getInstance","DdBabelInteractionTracking","attachRumInstance","getTelemetryConfig","babel_plugin","enabled","globalThis","__DD_RN_BABEL_PLUGIN_ENABLED__","track_interactions","getTargetName","targetObject","getContent","options","handlerArgs","componentName","actionName","accessibilityLabel","attrs","tryContent","content","length","getAccessibilityLabel","index","find","x","selectedContent","Object","values","output","useNamePrefix","wrapRumAction","func","action","args","DdSdk","sendTelemetryLog","BABEL_PLUGIN_TELEMETRY","onlyOnce","targetName","addAction","ActionSource","BABEL","now","catch","Error","telemetryError","message","stack","exports","getGlobalInstance"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IA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B,kBAAkB,GACrCA,kBAAkB,GAClB,IAAI;IAEd,MAAMM,KAAK,GAAGT,WAAW,GACnBA,WAAW,CAACU,IAAI,CAACC,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,GACjD,CAAC;;IAEP;IACA,MAAMC,eAAe,
|
|
1
|
+
{"version":3,"names":["_NativeDdSdk","_interopRequireDefault","require","_singletonUtils","_DefaultTimeProvider","_constants","_types","e","__esModule","default","BABEL_INTERACTION_TRACKING_MODULE","BabelInteractionTracking","config","trackInteractions","useAccessibilityLabel","timeProvider","DefaultTimeProvider","telemetrySent","ddRum","isInitialized","getInstance","DdBabelInteractionTracking","attachRumInstance","getTelemetryConfig","babel_plugin","enabled","globalThis","__DD_RN_BABEL_PLUGIN_ENABLED__","track_interactions","getTargetName","targetObject","getContent","options","handlerArgs","componentName","actionName","accessibilityLabel","attrs","tryContent","content","length","getAccessibilityLabel","index","find","x","selectedContent","Object","values","output","useNamePrefix","wrapRumAction","func","action","args","DdSdk","sendTelemetryLog","BABEL_PLUGIN_TELEMETRY","onlyOnce","targetName","addAction","ActionSource","BABEL","now","catch","Error","telemetryError","message","stack","exports","getGlobalInstance"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAb3C;AACA;AACA;AACA;AACA;;AAWA,MAAMG,iCAAiC,GACnC,wDAAwD;AAiB5D,MAAMC,wBAAwB,CAAC;EAC3BC,MAAM,GAAgB;IAClBC,iBAAiB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4D,KAAK,IAAI,EAAE,EACb,kBACJ,CAAC;UACL;QACJ,CAAC,CAAC;MACV;MAEA,OAAOhB,IAAI,CAAC,GAAGE,IAAI,CAAC;IACxB,CAAC;EACL;AACJ;AAEO,MAAMhC,0BAA0B,GAAA+C,OAAA,CAAA/C,0BAAA,GAAG,IAAAgD,iCAAiB,EACvD3D,iCAAiC,EACjC,MAAM,IAAIC,wBAAwB,CAAC,CACvC,CAAC","ignoreList":[]}
|
|
@@ -26,12 +26,13 @@ class DdEventsInterceptor {
|
|
|
26
26
|
this.useAccessibilityLabel = options.useAccessibilityLabel ?? true;
|
|
27
27
|
}
|
|
28
28
|
interceptOnPress(...args) {
|
|
29
|
-
|
|
29
|
+
const event = this.resolveNativeEvent(args);
|
|
30
|
+
if (event) {
|
|
30
31
|
const currentTime = Date.now();
|
|
31
32
|
const timestampDifference = Math.abs(Date.now() - this.debouncingStartedTimestamp);
|
|
32
33
|
if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {
|
|
33
|
-
const targetNode =
|
|
34
|
-
this.handleTargetEvent(targetNode,
|
|
34
|
+
const targetNode = event._targetInst;
|
|
35
|
+
this.handleTargetEvent(targetNode, event);
|
|
35
36
|
// we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function
|
|
36
37
|
this.debouncingStartedTimestamp = currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;
|
|
37
38
|
}
|
|
@@ -39,6 +40,27 @@ class DdEventsInterceptor {
|
|
|
39
40
|
_InternalLog.InternalLog.log(DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the native GestureResponderEvent from the onPress arguments.
|
|
46
|
+
*
|
|
47
|
+
* Some third-party libraries (e.g. react-native-ui-lib) wrap the native
|
|
48
|
+
* event inside a props object: `onPress({...componentProps, event})`.
|
|
49
|
+
* This method checks for `_targetInst` on `args[0]` first (standard RN),
|
|
50
|
+
* then falls back to `args[0].event` for the wrapped pattern.
|
|
51
|
+
*/
|
|
52
|
+
resolveNativeEvent(args) {
|
|
53
|
+
if (args.length === 0 || !args[0]) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (args[0]._targetInst) {
|
|
57
|
+
return args[0];
|
|
58
|
+
}
|
|
59
|
+
if (args[0].event && args[0].event._targetInst) {
|
|
60
|
+
return args[0].event;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
42
64
|
handleTargetEvent(targetNode, event) {
|
|
43
65
|
if (targetNode) {
|
|
44
66
|
const resolvedTargetName = this.resolveTargetName(targetNode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_InternalLog","require","_SdkVerbosity","_DdRum","_types","UNKNOWN_TARGET_NAME","exports","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","ACTION_EVENT_DROPPED_DEBUG_MESSAGE","debouncingStartedTimestamp","Number","MIN_VALUE","constructor","options","actionNameAttribute","useAccessibilityLabel","interceptOnPress","args","
|
|
1
|
+
{"version":3,"names":["_InternalLog","require","_SdkVerbosity","_DdRum","_types","UNKNOWN_TARGET_NAME","exports","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","ACTION_EVENT_DROPPED_DEBUG_MESSAGE","debouncingStartedTimestamp","Number","MIN_VALUE","constructor","options","actionNameAttribute","useAccessibilityLabel","interceptOnPress","args","event","resolveNativeEvent","currentTime","Date","now","timestampDifference","Math","abs","targetNode","_targetInst","handleTargetEvent","InternalLog","log","SdkVerbosity","DEBUG","length","resolvedTargetName","resolveTargetName","DdRum","addAction","RumActionType","TAP","undefined","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx"],"mappings":";;;;;;AAQA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAXA;AACA;AACA;AACA;AACA;;AAWO,MAAMI,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,gBAAgB;AACnD,MAAME,8BAA8B,GAAG,EAAE;AACzC,MAAMC,qCAAqC,GAAG,CAAC;AAC/C,MAAMC,mBAAmB,GAAG,gBAAgB;AAarC,MAAMC,mBAAmB,CAA8B;EAC1D,OAAOC,kCAAkC,GACrC,2EAA2E,GAC3E,8DAA8D,GAC9D,iFAAiF,GACjF,4DAA4D,GAC5D,yCAAyC;EAErCC,0BAA0B,GAAGC,MAAM,CAACC,SAAS;EAKrDC,WAAWA,CAACC,OAAmC,GAAG,CAAC,CAAC,EAAE;IAClD,IAAI,CAACC,mBAAmB,GAAGD,OAAO,CAACC,mBAAmB;IACtD,IAAI,CAACC,qBAAqB,GAAGF,OAAO,CAACE,qBAAqB,IAAI,IAAI;EACtE;EAEAC,gBAAgBA,CAAC,GAAGC,IAAW,EAAQ;IACnC,MAAMC,KAAK,GAAG,IAAI,CAACC,kBAAkB,CAACF,IAAI,CAAC;IAC3C,IAAIC,KAAK,EAAE;MACP,MAAME,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;MAC9B,MAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAG,CAChCJ,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACb,0BACtB,CAAC;MACD,IAAIc,mBAAmB,GAAGnB,8BAA8B,EAAE;QACtD,MAAMsB,UAAU,GAAGR,KAAK,CAACS,WAAW;QACpC,IAAI,CAACC,iBA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