@datadog/mobile-react-native 1.8.5 → 2.0.0-rc.0
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/DatadogSDKReactNative.podspec +8 -2
- package/android/build.gradle +17 -5
- package/android/gradle.properties +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -13
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +36 -9
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +1 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +37 -17
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +3 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +71 -70
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -2
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +2 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +48 -30
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +648 -641
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +122 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +0 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ActionEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +3 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ResourceEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +4 -0
- package/ios/Sources/DdLogsImplementation.swift +10 -38
- package/ios/Sources/DdRumImplementation.swift +26 -39
- package/ios/Sources/DdSdkConfiguration.swift +55 -8
- package/ios/Sources/DdSdkImplementation.swift +141 -143
- package/ios/Sources/DdTraceImplementation.swift +4 -5
- package/ios/Sources/RNDdSdkConfiguration.swift +4 -2
- package/ios/Sources/RUMMonitorInternalProtocol.swift +40 -0
- package/jest/mock.js +1 -0
- package/lib/commonjs/DdSdkReactNative.js +2 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +2 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +10 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +26 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +37 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +2 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/jsUtils.js +26 -0
- package/lib/commonjs/utils/jsUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +1 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/DdRum.js +1 -1
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +8 -3
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +13 -0
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +36 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/trace/DdTrace.js +1 -1
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/jsUtils.js +17 -0
- package/lib/module/utils/jsUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +6 -0
- package/lib/typescript/utils/jsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -3
- package/src/DdSdkReactNative.tsx +1 -1
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -0
- package/src/index.tsx +9 -1
- package/src/rum/DdRum.ts +1 -1
- package/src/rum/__tests__/DdRum.test.ts +1 -1
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +13 -4
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +1 -1
- package/src/rum/instrumentation/resourceTracking/graphql/__tests__/graphqlHeaders.test.ts +28 -0
- package/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts +15 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +35 -20
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +48 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +178 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +7 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +1 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -2
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +2 -2
- package/src/trace/DdTrace.ts +1 -1
- package/src/utils/__mocks__/jsUtils.ts +21 -0
- package/src/utils/jsUtils.ts +20 -0
- package/src/version.ts +1 -1
- /package/lib/commonjs/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/commonjs/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/commonjs/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/commonjs/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/commonjs/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/commonjs/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/commonjs/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/commonjs/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/module/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/module/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/module/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/module/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/module/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/module/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/module/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/module/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/typescript/{TimeProvider.d.ts → utils/TimeProvider.d.ts} +0 -0
- /package/lib/typescript/{Timer.d.ts → utils/Timer.d.ts} +0 -0
- /package/lib/typescript/{errorUtils.d.ts → utils/errorUtils.d.ts} +0 -0
- /package/lib/typescript/{longTasksUtils.d.ts → utils/longTasksUtils.d.ts} +0 -0
- /package/src/{TimeProvider.tsx → utils/TimeProvider.tsx} +0 -0
- /package/src/{Timer.ts → utils/Timer.ts} +0 -0
- /package/src/{__tests__ → utils/__tests__}/TimeProvider.test.tsx +0 -0
- /package/src/{__tests__ → utils/__tests__}/Timer.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/errorUtils.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/longTasksUtils.test.ts +0 -0
- /package/src/{errorUtils.ts → utils/errorUtils.ts} +0 -0
- /package/src/{longTasksUtils.ts → utils/longTasksUtils.ts} +0 -0
|
@@ -8,7 +8,7 @@ package com.datadog.tools.unit
|
|
|
8
8
|
|
|
9
9
|
import com.datadog.android.core.configuration.BatchSize
|
|
10
10
|
import com.datadog.android.core.configuration.UploadFrequency
|
|
11
|
-
import com.datadog.android.
|
|
11
|
+
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
12
12
|
import com.datadog.reactnative.ConfigurationForTelemetry
|
|
13
13
|
import com.datadog.reactnative.DdSdkConfiguration
|
|
14
14
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -0,0 +1,122 @@
|
|
|
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.tools.unit
|
|
8
|
+
|
|
9
|
+
import com.datadog.android.rum.RumActionType
|
|
10
|
+
import com.datadog.android.rum.RumErrorSource
|
|
11
|
+
import com.datadog.android.rum.RumMonitor
|
|
12
|
+
import com.datadog.android.rum.RumResourceKind
|
|
13
|
+
import com.datadog.android.rum.RumResourceMethod
|
|
14
|
+
import com.datadog.android.rum._RumInternalProxy
|
|
15
|
+
|
|
16
|
+
class MockRumMonitor : RumMonitor {
|
|
17
|
+
override var debug = false
|
|
18
|
+
|
|
19
|
+
override fun _getInternal(): _RumInternalProxy? {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun addAction(
|
|
24
|
+
type: RumActionType,
|
|
25
|
+
name: String,
|
|
26
|
+
attributes: Map<String, Any?>
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
override fun addAttribute(key: String, value: Any?) {}
|
|
30
|
+
|
|
31
|
+
override fun addError(
|
|
32
|
+
message: String,
|
|
33
|
+
source: RumErrorSource,
|
|
34
|
+
throwable: Throwable?,
|
|
35
|
+
attributes: Map<String, Any?>
|
|
36
|
+
) {}
|
|
37
|
+
|
|
38
|
+
override fun addErrorWithStacktrace(
|
|
39
|
+
message: String,
|
|
40
|
+
source: RumErrorSource,
|
|
41
|
+
stacktrace: String?,
|
|
42
|
+
attributes: Map<String, Any?>
|
|
43
|
+
) {}
|
|
44
|
+
|
|
45
|
+
override fun addFeatureFlagEvaluation(name: String, value: Any) {}
|
|
46
|
+
|
|
47
|
+
override fun addTiming(name: String) {}
|
|
48
|
+
|
|
49
|
+
override fun clearAttributes() {}
|
|
50
|
+
|
|
51
|
+
override fun getAttributes(): Map<String, Any?> {
|
|
52
|
+
return mapOf()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override fun removeAttribute(key: String) {}
|
|
56
|
+
|
|
57
|
+
override fun startAction(
|
|
58
|
+
type: RumActionType,
|
|
59
|
+
name: String,
|
|
60
|
+
attributes: Map<String, Any?>
|
|
61
|
+
) {}
|
|
62
|
+
|
|
63
|
+
override fun startResource(
|
|
64
|
+
key: String,
|
|
65
|
+
method: RumResourceMethod,
|
|
66
|
+
url: String,
|
|
67
|
+
attributes: Map<String, Any?>
|
|
68
|
+
) {}
|
|
69
|
+
|
|
70
|
+
override fun startResource(
|
|
71
|
+
key: String,
|
|
72
|
+
method: String,
|
|
73
|
+
url: String,
|
|
74
|
+
attributes: Map<String, Any?>
|
|
75
|
+
) {}
|
|
76
|
+
|
|
77
|
+
override fun startView(
|
|
78
|
+
key: Any,
|
|
79
|
+
name: String,
|
|
80
|
+
attributes: Map<String, Any?>
|
|
81
|
+
) {}
|
|
82
|
+
|
|
83
|
+
override fun stopAction(
|
|
84
|
+
type: RumActionType,
|
|
85
|
+
name: String,
|
|
86
|
+
attributes: Map<String, Any?>
|
|
87
|
+
) {}
|
|
88
|
+
|
|
89
|
+
override fun stopResource(
|
|
90
|
+
key: String,
|
|
91
|
+
statusCode: Int?,
|
|
92
|
+
size: Long?,
|
|
93
|
+
kind: RumResourceKind,
|
|
94
|
+
attributes: Map<String, Any?>
|
|
95
|
+
) {}
|
|
96
|
+
|
|
97
|
+
override fun stopResourceWithError(
|
|
98
|
+
key: String,
|
|
99
|
+
statusCode: Int?,
|
|
100
|
+
message: String,
|
|
101
|
+
source: RumErrorSource,
|
|
102
|
+
stackTrace: String,
|
|
103
|
+
errorType: String?,
|
|
104
|
+
attributes: Map<String, Any?>
|
|
105
|
+
) {}
|
|
106
|
+
|
|
107
|
+
override fun stopResourceWithError(
|
|
108
|
+
key: String,
|
|
109
|
+
statusCode: Int?,
|
|
110
|
+
message: String,
|
|
111
|
+
source: RumErrorSource,
|
|
112
|
+
throwable: Throwable,
|
|
113
|
+
attributes: Map<String, Any?>
|
|
114
|
+
) {}
|
|
115
|
+
|
|
116
|
+
override fun stopSession() {}
|
|
117
|
+
|
|
118
|
+
override fun stopView(
|
|
119
|
+
key: Any,
|
|
120
|
+
attributes: Map<String, Any?>
|
|
121
|
+
) {}
|
|
122
|
+
}
|
|
@@ -92,7 +92,7 @@ internal class ActionEventForgeryFactory :
|
|
|
92
92
|
name = forge.anAlphabeticalString(),
|
|
93
93
|
model = forge.anAlphabeticalString(),
|
|
94
94
|
brand = forge.anAlphabeticalString(),
|
|
95
|
-
type = forge.aValueFrom(ActionEvent.DeviceType::class.java)
|
|
95
|
+
type = forge.aValueFrom(ActionEvent.DeviceType::class.java)
|
|
96
96
|
),
|
|
97
97
|
context = ActionEvent.Context(
|
|
98
98
|
additionalProperties = mutableMapOf()
|
package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt
CHANGED
|
@@ -17,7 +17,7 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
|
|
|
17
17
|
return DdSdkConfiguration(
|
|
18
18
|
clientToken = forge.aStringMatching("pub[a-f0-9]{32}"),
|
|
19
19
|
env = forge.anAlphabeticalString(),
|
|
20
|
-
applicationId = forge.
|
|
20
|
+
applicationId = forge.getForgery<UUID>().toString(),
|
|
21
21
|
nativeCrashReportEnabled = forge.aNullable { aBool() },
|
|
22
22
|
nativeLongTaskThresholdMs = forge.aNullable { aDouble(100.0, 5000.0) },
|
|
23
23
|
longTaskThresholdMs = forge.aDouble(0.0, 100.0),
|
|
@@ -63,9 +63,9 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
|
|
|
63
63
|
trackInteractions = forge.aBool(),
|
|
64
64
|
trackNetworkRequests = forge.aBool(),
|
|
65
65
|
reactVersion = forge.aString(),
|
|
66
|
-
reactNativeVersion = forge.aString()
|
|
66
|
+
reactNativeVersion = forge.aString()
|
|
67
67
|
),
|
|
68
|
-
trackFrustrations = forge.aNullable { aBool() }
|
|
68
|
+
trackFrustrations = forge.aNullable { aBool() }
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -100,7 +100,7 @@ internal class ResourceEventForgeryFactory :
|
|
|
100
100
|
name = forge.anAlphabeticalString(),
|
|
101
101
|
model = forge.anAlphabeticalString(),
|
|
102
102
|
brand = forge.anAlphabeticalString(),
|
|
103
|
-
type = forge.aValueFrom(ResourceEvent.DeviceType::class.java)
|
|
103
|
+
type = forge.aValueFrom(ResourceEvent.DeviceType::class.java)
|
|
104
104
|
),
|
|
105
105
|
context = ResourceEvent.Context(
|
|
106
106
|
additionalProperties = mutableMapOf()
|
|
@@ -59,6 +59,9 @@ internal class TelemetryConfigurationEventForgeryFactory :
|
|
|
59
59
|
forge.aNullable { aBool() },
|
|
60
60
|
forge.aNullable { aBool() },
|
|
61
61
|
forge.aNullable { aBool() },
|
|
62
|
+
forge.aNullable { aBool() },
|
|
63
|
+
forge.aNullable { aBool() },
|
|
64
|
+
forge.aNullable { aBool() },
|
|
62
65
|
forge.aNullable { aString() },
|
|
63
66
|
forge.aNullable { aBool() },
|
|
64
67
|
forge.aNullable { aBool() },
|
|
@@ -76,6 +79,7 @@ internal class TelemetryConfigurationEventForgeryFactory :
|
|
|
76
79
|
forge.aNullable { aBool() },
|
|
77
80
|
forge.aNullable { aBool() },
|
|
78
81
|
|
|
82
|
+
forge.aNullable { aBool() },
|
|
79
83
|
forge.aNullable { aBool() },
|
|
80
84
|
forge.aNullable { aList { aString() } },
|
|
81
85
|
forge.aNullable { aList { aString() } },
|
|
@@ -5,51 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
extension DDLogger: NativeLogger {
|
|
11
|
-
// Adding stubs until they are added to the the LoggerProtocol extension
|
|
12
|
-
func debug(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String : Encodable]?) {
|
|
13
|
-
log(level: .debug, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stackTrace, attributes: attributes)
|
|
14
|
-
}
|
|
15
|
-
func info(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String : Encodable]?) {
|
|
16
|
-
log(level: .info, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stackTrace, attributes: attributes)
|
|
17
|
-
}
|
|
18
|
-
func warn(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String : Encodable]?) {
|
|
19
|
-
log(level: .warn, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stackTrace, attributes: attributes)
|
|
20
|
-
}
|
|
21
|
-
func error(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String : Encodable]?) {
|
|
22
|
-
log(level: .error, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stackTrace, attributes: attributes)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
internal protocol NativeLogger {
|
|
26
|
-
func debug(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
27
|
-
func debug(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String: Encodable]?)
|
|
28
|
-
func info(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
29
|
-
func info(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String: Encodable]?)
|
|
30
|
-
func warn(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
31
|
-
func warn(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String: Encodable]?)
|
|
32
|
-
func error(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
33
|
-
func error(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String: Encodable]?)
|
|
34
|
-
}
|
|
8
|
+
import DatadogLogs
|
|
9
|
+
import DatadogCore
|
|
35
10
|
|
|
36
11
|
@objc
|
|
37
12
|
public class DdLogsImplementation: NSObject {
|
|
38
|
-
private lazy var logger:
|
|
39
|
-
private let loggerProvider: () ->
|
|
13
|
+
private lazy var logger: LoggerProtocol = loggerProvider()
|
|
14
|
+
private let loggerProvider: () -> LoggerProtocol
|
|
40
15
|
private let isSDKInitialized: () -> Bool
|
|
41
16
|
|
|
42
|
-
internal init(_ loggerProvider: @escaping () ->
|
|
17
|
+
internal init(_ loggerProvider: @escaping () -> LoggerProtocol, _ isSDKInitialized: @escaping () -> Bool) {
|
|
43
18
|
self.loggerProvider = loggerProvider
|
|
44
19
|
self.isSDKInitialized = isSDKInitialized
|
|
45
20
|
}
|
|
46
21
|
|
|
47
22
|
@objc
|
|
48
23
|
public override convenience init() {
|
|
49
|
-
|
|
50
|
-
.sendNetworkInfo(true)
|
|
51
|
-
.printLogsToConsole(true)
|
|
52
|
-
self.init({ builder.build() }, { Datadog.isInitialized })
|
|
24
|
+
self.init({ Logger.create(with: Logger.Configuration(networkInfoEnabled: true, consoleLogFormat: .short)) }, { Datadog.isInitialized() })
|
|
53
25
|
}
|
|
54
26
|
|
|
55
27
|
@objc
|
|
@@ -103,7 +75,7 @@ public class DdLogsImplementation: NSObject {
|
|
|
103
75
|
return
|
|
104
76
|
}
|
|
105
77
|
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
106
|
-
logger.debug
|
|
78
|
+
logger._internal.log(level: .debug, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
|
|
107
79
|
resolve(nil)
|
|
108
80
|
}
|
|
109
81
|
|
|
@@ -114,7 +86,7 @@ public class DdLogsImplementation: NSObject {
|
|
|
114
86
|
return
|
|
115
87
|
}
|
|
116
88
|
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
117
|
-
logger.info
|
|
89
|
+
logger._internal.log(level: .info, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
|
|
118
90
|
resolve(nil)
|
|
119
91
|
}
|
|
120
92
|
|
|
@@ -125,7 +97,7 @@ public class DdLogsImplementation: NSObject {
|
|
|
125
97
|
return
|
|
126
98
|
}
|
|
127
99
|
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
128
|
-
logger.warn
|
|
100
|
+
logger._internal.log(level: .warn, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
|
|
129
101
|
resolve(nil)
|
|
130
102
|
}
|
|
131
103
|
|
|
@@ -136,7 +108,7 @@ public class DdLogsImplementation: NSObject {
|
|
|
136
108
|
return
|
|
137
109
|
}
|
|
138
110
|
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
139
|
-
logger.error
|
|
111
|
+
logger._internal.log(level: .error, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
|
|
140
112
|
resolve(nil)
|
|
141
113
|
}
|
|
142
114
|
}
|
|
@@ -5,34 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
extension DDRUMMonitor: NativeRUM { }
|
|
11
|
-
internal protocol NativeRUM {
|
|
12
|
-
func startView(key: String, name: String?, attributes: [String: Encodable])
|
|
13
|
-
func stopView(key: String, attributes: [String: Encodable])
|
|
14
|
-
func addError(message: String, type: String?, source: RUMErrorSource, stack: String?, attributes: [String: Encodable], file: StaticString?, line: UInt?)
|
|
15
|
-
func startResourceLoading(resourceKey: String, httpMethod: RUMMethod, urlString: String, attributes: [String: Encodable])
|
|
16
|
-
func stopResourceLoading(resourceKey: String, statusCode: Int?, kind: RUMResourceType, size: Int64?, attributes: [String: Encodable])
|
|
17
|
-
func startUserAction(type: RUMUserActionType, name: String, attributes: [String: Encodable])
|
|
18
|
-
func stopUserAction(type: RUMUserActionType, name: String?, attributes: [String: Encodable])
|
|
19
|
-
func addUserAction(type: RUMUserActionType, name: String, attributes: [String: Encodable])
|
|
20
|
-
func addTiming(name: String)
|
|
21
|
-
func stopSession()
|
|
22
|
-
func addResourceMetrics(resourceKey: String,
|
|
23
|
-
fetch: (start: Date, end: Date),
|
|
24
|
-
redirection: (start: Date, end: Date)?,
|
|
25
|
-
dns: (start: Date, end: Date)?,
|
|
26
|
-
connect: (start: Date, end: Date)?,
|
|
27
|
-
ssl: (start: Date, end: Date)?,
|
|
28
|
-
firstByte: (start: Date, end: Date)?,
|
|
29
|
-
download: (start: Date, end: Date)?,
|
|
30
|
-
responseSize: Int64?,
|
|
31
|
-
attributes: [AttributeKey: AttributeValue])
|
|
32
|
-
func addFeatureFlagEvaluation(name: String, value: Encodable)
|
|
33
|
-
}
|
|
8
|
+
import DatadogRUM
|
|
9
|
+
import DatadogInternal
|
|
34
10
|
|
|
35
|
-
private extension
|
|
11
|
+
private extension RUMActionType {
|
|
36
12
|
init(from string: String) {
|
|
37
13
|
switch string.lowercased() {
|
|
38
14
|
case "tap": self = .tap
|
|
@@ -101,18 +77,27 @@ public class DdRumImplementation: NSObject {
|
|
|
101
77
|
|
|
102
78
|
internal static let missingResourceSize = -1
|
|
103
79
|
|
|
104
|
-
lazy var nativeRUM:
|
|
105
|
-
|
|
80
|
+
lazy var nativeRUM: RUMMonitorProtocol = rumProvider()
|
|
81
|
+
lazy var rumInternal: RUMMonitorInternalProtocol? = rumInternalProvider()
|
|
82
|
+
private let rumProvider: () -> RUMMonitorProtocol
|
|
83
|
+
private let rumInternalProvider: () -> RUMMonitorInternalProtocol?
|
|
106
84
|
|
|
107
|
-
private typealias UserAction = (type:
|
|
85
|
+
private typealias UserAction = (type: RUMActionType, name: String?)
|
|
108
86
|
|
|
109
|
-
internal init(
|
|
87
|
+
internal init(
|
|
88
|
+
_ rumProvider: @escaping () -> RUMMonitorProtocol,
|
|
89
|
+
_ rumInternalProvider: @escaping () -> RUMMonitorInternalProtocol?
|
|
90
|
+
) {
|
|
110
91
|
self.rumProvider = rumProvider
|
|
92
|
+
self.rumInternalProvider = rumInternalProvider
|
|
111
93
|
}
|
|
112
94
|
|
|
113
95
|
@objc
|
|
114
96
|
public override convenience init() {
|
|
115
|
-
self.init
|
|
97
|
+
self.init(
|
|
98
|
+
{ RUMMonitor.shared() },
|
|
99
|
+
{ RUMMonitor.shared()._internal }
|
|
100
|
+
)
|
|
116
101
|
}
|
|
117
102
|
|
|
118
103
|
@objc
|
|
@@ -129,25 +114,25 @@ public class DdRumImplementation: NSObject {
|
|
|
129
114
|
|
|
130
115
|
@objc
|
|
131
116
|
public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
132
|
-
nativeRUM.
|
|
117
|
+
nativeRUM.startAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
133
118
|
resolve(nil)
|
|
134
119
|
}
|
|
135
120
|
|
|
136
121
|
@objc
|
|
137
122
|
public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
138
|
-
nativeRUM.
|
|
123
|
+
nativeRUM.stopAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
139
124
|
resolve(nil)
|
|
140
125
|
}
|
|
141
126
|
|
|
142
127
|
@objc
|
|
143
128
|
public func addAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
144
|
-
nativeRUM.
|
|
129
|
+
nativeRUM.addAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
145
130
|
resolve(nil)
|
|
146
131
|
}
|
|
147
132
|
|
|
148
133
|
@objc
|
|
149
134
|
public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
150
|
-
nativeRUM.
|
|
135
|
+
nativeRUM.startResource(resourceKey: key, httpMethod: RUMMethod(from: method), urlString: url, attributes: attributes(from: context, with: timestampMs))
|
|
151
136
|
resolve(nil)
|
|
152
137
|
}
|
|
153
138
|
|
|
@@ -160,7 +145,7 @@ public class DdRumImplementation: NSObject {
|
|
|
160
145
|
addResourceMetrics(key: key, resourceTimings: resourceTimings)
|
|
161
146
|
}
|
|
162
147
|
|
|
163
|
-
nativeRUM.
|
|
148
|
+
nativeRUM.stopResource(
|
|
164
149
|
resourceKey: key,
|
|
165
150
|
statusCode: Int(statusCode),
|
|
166
151
|
kind: RUMResourceType(from: kind),
|
|
@@ -172,7 +157,7 @@ public class DdRumImplementation: NSObject {
|
|
|
172
157
|
|
|
173
158
|
@objc
|
|
174
159
|
public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
175
|
-
nativeRUM.addError(message: message, type: nil, source: RUMErrorSource(from: source),
|
|
160
|
+
nativeRUM.addError(message: message, type: nil, stack: stacktrace, source: RUMErrorSource(from: source), attributes: attributes(from: context, with: timestampMs), file: nil, line: nil)
|
|
176
161
|
resolve(nil)
|
|
177
162
|
}
|
|
178
163
|
|
|
@@ -214,8 +199,10 @@ public class DdRumImplementation: NSObject {
|
|
|
214
199
|
let firstByte = timingValue(from: resourceTimings, for: Self.firstByteTimingKey)
|
|
215
200
|
let download = timingValue(from: resourceTimings, for: Self.downloadTimingKey)
|
|
216
201
|
|
|
202
|
+
|
|
217
203
|
if let fetch = fetch {
|
|
218
|
-
|
|
204
|
+
rumInternal?.addResourceMetrics(
|
|
205
|
+
at: Date.init(),
|
|
219
206
|
resourceKey: key,
|
|
220
207
|
fetch: fetch,
|
|
221
208
|
redirection: redirect,
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
+
import DatadogCore
|
|
9
|
+
import DatadogInternal
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
A configuration object to initialize Datadog's features.
|
|
@@ -31,18 +33,18 @@ import Foundation
|
|
|
31
33
|
public class DdSdkConfiguration: NSObject {
|
|
32
34
|
public var clientToken: String = ""
|
|
33
35
|
public var env: String = ""
|
|
34
|
-
public var applicationId: String
|
|
36
|
+
public var applicationId: String = ""
|
|
35
37
|
public var nativeCrashReportEnabled: Bool? = nil
|
|
36
38
|
public var nativeLongTaskThresholdMs: Double? = nil
|
|
37
39
|
public var longTaskThresholdMs: Double = 0.0
|
|
38
40
|
public var sampleRate: Double? = nil
|
|
39
|
-
public var site:
|
|
41
|
+
public var site: DatadogSite
|
|
40
42
|
public var trackingConsent: NSString? = nil
|
|
41
43
|
public var telemetrySampleRate: Double? = nil
|
|
42
44
|
public var vitalsUpdateFrequency: NSString? = nil
|
|
43
45
|
public var trackFrustrations: Bool? = nil
|
|
44
|
-
public var uploadFrequency:
|
|
45
|
-
public var batchSize:
|
|
46
|
+
public var uploadFrequency: Datadog.Configuration.UploadFrequency
|
|
47
|
+
public var batchSize: Datadog.Configuration.BatchSize
|
|
46
48
|
public var trackBackgroundEvents: Bool? = nil
|
|
47
49
|
public var additionalConfig: NSDictionary? = nil
|
|
48
50
|
public var configurationForTelemetry: ConfigurationForTelemetry? = nil
|
|
@@ -50,7 +52,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
50
52
|
public init(
|
|
51
53
|
clientToken: String,
|
|
52
54
|
env: String,
|
|
53
|
-
applicationId: String
|
|
55
|
+
applicationId: String,
|
|
54
56
|
nativeCrashReportEnabled: Bool?,
|
|
55
57
|
nativeLongTaskThresholdMs: Double?,
|
|
56
58
|
longTaskThresholdMs: Double,
|
|
@@ -73,17 +75,62 @@ public class DdSdkConfiguration: NSObject {
|
|
|
73
75
|
self.nativeLongTaskThresholdMs = nativeLongTaskThresholdMs
|
|
74
76
|
self.longTaskThresholdMs = longTaskThresholdMs
|
|
75
77
|
self.sampleRate = sampleRate
|
|
76
|
-
self.site = site
|
|
78
|
+
self.site = DdSdkConfiguration.buildSite(site: site)
|
|
77
79
|
self.trackingConsent = trackingConsent
|
|
78
80
|
self.telemetrySampleRate = telemetrySampleRate
|
|
79
81
|
self.vitalsUpdateFrequency = vitalsUpdateFrequency
|
|
80
82
|
self.trackFrustrations = trackFrustrations
|
|
81
|
-
self.uploadFrequency = uploadFrequency
|
|
82
|
-
self.batchSize = batchSize
|
|
83
|
+
self.uploadFrequency = DdSdkConfiguration.buildUploadFrequency(uploadFrequency: uploadFrequency)
|
|
84
|
+
self.batchSize = DdSdkConfiguration.buildBatchSize(batchSize: batchSize)
|
|
83
85
|
self.trackBackgroundEvents = trackBackgroundEvents
|
|
84
86
|
self.additionalConfig = additionalConfig
|
|
85
87
|
self.configurationForTelemetry = configurationForTelemetry
|
|
86
88
|
}
|
|
89
|
+
|
|
90
|
+
static func buildSite(site: NSString?) -> DatadogSite {
|
|
91
|
+
switch site?.lowercased ?? "us" {
|
|
92
|
+
case "us1", "us":
|
|
93
|
+
return .us1
|
|
94
|
+
case "eu1", "eu":
|
|
95
|
+
return .eu1
|
|
96
|
+
case "us3":
|
|
97
|
+
return .us3
|
|
98
|
+
case "us5":
|
|
99
|
+
return .us5
|
|
100
|
+
case "us1_fed", "gov":
|
|
101
|
+
return .us1_fed
|
|
102
|
+
case "ap1":
|
|
103
|
+
return .ap1
|
|
104
|
+
default:
|
|
105
|
+
return .us1
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static func buildBatchSize(batchSize: NSString?) -> Datadog.Configuration.BatchSize {
|
|
110
|
+
switch batchSize?.lowercased ?? "" {
|
|
111
|
+
case "small":
|
|
112
|
+
return .small
|
|
113
|
+
case "medium":
|
|
114
|
+
return .medium
|
|
115
|
+
case "large":
|
|
116
|
+
return .large
|
|
117
|
+
default:
|
|
118
|
+
return .medium
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static func buildUploadFrequency(uploadFrequency: NSString?) -> Datadog.Configuration.UploadFrequency {
|
|
123
|
+
switch uploadFrequency?.lowercased ?? "" {
|
|
124
|
+
case "rare":
|
|
125
|
+
return .rare
|
|
126
|
+
case "average":
|
|
127
|
+
return .average
|
|
128
|
+
case "frequent":
|
|
129
|
+
return .frequent
|
|
130
|
+
default:
|
|
131
|
+
return .average
|
|
132
|
+
}
|
|
133
|
+
}
|
|
87
134
|
}
|
|
88
135
|
|
|
89
136
|
public class ConfigurationForTelemetry: NSObject {
|