@datadog/mobile-react-native 1.0.0-rc8 → 1.1.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 +2 -1
- package/android/build.gradle +73 -3
- package/android/gradle.properties +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
- package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
- package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
- package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/datadog-sourcemaps.gradle +137 -0
- package/ios/Sources/AnyEncodable.swift +138 -0
- package/ios/Sources/Attributes.swift +101 -0
- package/ios/Sources/DdLogs.swift +35 -11
- package/ios/Sources/DdRum.m +3 -1
- package/ios/Sources/DdRum.swift +184 -22
- package/ios/Sources/DdSdk.swift +190 -10
- package/ios/Sources/DdSdkConfiguration.swift +51 -0
- package/ios/Sources/DdTrace.swift +41 -6
- package/ios/Sources/GlobalState.swift +28 -0
- package/ios/Sources/QueueHolder.swift +10 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
- package/lib/commonjs/DdSdkReactNative.js +16 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +36 -2
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +36 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +73 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +40 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +51 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +25 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
- package/lib/commonjs/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +57 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +49 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +45 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{URLHostParser.js → resourceTracking/implementation/URLHostParser.js} +16 -7
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +167 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js +97 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
- package/lib/commonjs/types.js +26 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +15 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +36 -2
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +26 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +61 -0
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
- package/lib/module/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +35 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +34 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +16 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
- package/lib/module/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +50 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +40 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +36 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
- package/{src/rum/instrumentation/URLHostParser.ts → lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js} +15 -8
- package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +151 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js +86 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +2 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
- package/lib/typescript/foundation.d.ts +3 -2
- package/lib/typescript/nativeModulesTypes.d.ts +168 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +15 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +18 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +20 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.d.ts +17 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/URLHostParser.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +25 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +3 -0
- package/lib/typescript/types.d.ts +42 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +7 -5
- package/src/DdSdkReactNative.tsx +21 -1
- package/src/DdSdkReactNativeConfiguration.tsx +20 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +87 -8
- package/src/__tests__/foundation.test.ts +79 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +9 -9
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +1 -1
- package/src/foundation.tsx +40 -11
- package/src/nativeModulesTypes.ts +258 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +67 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +79 -0
- package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/__tests__}/__utils__/XMLHttpRequestMock.ts +0 -0
- package/src/{__tests__/rum/instrumentation/TraceIdentifier.test.tsx → rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts} +1 -1
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +22 -0
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +87 -0
- package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +52 -0
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +15 -0
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +27 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +78 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +83 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +45 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +69 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.ts +50 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.ts +70 -0
- package/src/rum/instrumentation/resourceTracking/implementation/URLHostParser.ts +30 -0
- package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +197 -0
- package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/implementation/__tests__}/URLHostParser.test.ts +3 -3
- package/src/{__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx → rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts} +83 -49
- package/src/rum/instrumentation/resourceTracking/implementation/responseSize.ts +83 -0
- package/src/types.tsx +62 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
- package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +0 -356
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -2
- package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +0 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +0 -331
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
- package/lib/module/rum/instrumentation/DdRumXhr.js +0 -2
- package/lib/module/rum/instrumentation/TraceIdentifier.js.map +0 -1
- package/lib/module/rum/instrumentation/URLHostParser.js +0 -24
- package/lib/module/rum/instrumentation/URLHostParser.js.map +0 -1
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +0 -40
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +0 -23
- package/lib/typescript/rum/instrumentation/TraceIdentifier.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +0 -6
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +0 -426
- package/src/rum/instrumentation/DdRumXhr.tsx +0 -33
- package/src/rum/instrumentation/TraceIdentifier.tsx +0 -34
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
4
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
5
|
+
* Copyright 2019-2020 Datadog, Inc.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
/// Internal attributes, passed to the iOS SDK.
|
|
11
|
+
/// Keep in sync with https://github.com/DataDog/dd-sdk-ios/blob/develop/Sources/Datadog/Core/Attributes/Attributes.swift.
|
|
12
|
+
internal struct CrossPlatformAttributes {
|
|
13
|
+
/// Custom app version passed from CP SDK. Used for all events issued by the SDK (both coming from cross-platform SDK and produced internally, like RUM long tasks).
|
|
14
|
+
/// It should replace the default native `version` read from `Info.plist`.
|
|
15
|
+
/// Expects `String` value (semantic version).
|
|
16
|
+
static let version: String = "_dd.version"
|
|
17
|
+
|
|
18
|
+
/// Custom SDK version passed from bridge SDK. Used for all events issued by the SDK (both coming from cross-platform SDK and produced internally, like RUM long tasks).
|
|
19
|
+
/// It should replace the default native `sdkVersion`.
|
|
20
|
+
/// Expects `String` value (semantic version).
|
|
21
|
+
static let sdkVersion: String = "_dd.sdk_version"
|
|
22
|
+
|
|
23
|
+
/// Custom SDK `source` passed from bridge SDK. Used for all events issued by the SDK (both coming from cross-platform SDK and produced internally, like RUM long tasks).
|
|
24
|
+
/// It should replace the default native `ddsource` value (`"ios"`).
|
|
25
|
+
/// Expects `String` value.
|
|
26
|
+
static let ddsource: String = "_dd.source"
|
|
27
|
+
|
|
28
|
+
/// Event timestamp passed from bridge SDK. Used for all RUM events issued by cross platform SDK.
|
|
29
|
+
/// It should replace event time obtained from `DateProvider` to ensure that events are not skewed due to time difference in native and cross-platform SDKs.
|
|
30
|
+
/// Expects `Int64` value (milliseconds).
|
|
31
|
+
static let timestampInMilliseconds = "_dd.timestamp"
|
|
32
|
+
|
|
33
|
+
/// Custom "source type" of the error passed from bridge SDK. Used in RUM errors reported by cross platform SDK.
|
|
34
|
+
/// It names the language or platform of the RUM error stack trace, so the SCI backend knows how to symbolicate it.
|
|
35
|
+
/// Expects `String` value.
|
|
36
|
+
static let errorSourceType = "_dd.error.source_type"
|
|
37
|
+
|
|
38
|
+
/// Custom attribute of the error passed from bridge SDK. Used in RUM errors reported by cross platform SDK.
|
|
39
|
+
/// It flags the error has being fatal for the host application.
|
|
40
|
+
/// Expects `Bool` value.
|
|
41
|
+
static let errorIsCrash = "_dd.error.is_crash"
|
|
42
|
+
|
|
43
|
+
/// Trace ID passed from bridge SDK. Used in RUM resources created by cross platform SDK.
|
|
44
|
+
/// When cross-platform SDK injects tracing headers to intercepted resource, we pass tracing information through this attribute
|
|
45
|
+
/// and send it within the RUM resource, so the RUM backend can issue corresponding APM span on behalf of the mobile app.
|
|
46
|
+
/// Expects `String` value.
|
|
47
|
+
static let traceID = "_dd.trace_id"
|
|
48
|
+
|
|
49
|
+
/// Span ID passed from bridge SDK. Used in RUM resources created by cross platform SDK.
|
|
50
|
+
/// When cross-platform SDK injects tracing headers to intercepted resource, we pass tracing information through this attribute
|
|
51
|
+
/// and send it within the RUM resource, so the RUM backend can issue corresponding APM span on behalf of the mobile app.
|
|
52
|
+
/// Expects `String` value.
|
|
53
|
+
static let spanID = "_dd.span_id"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// Internal attributes used to configure the proxy.
|
|
57
|
+
internal struct ProxyAttributes {
|
|
58
|
+
/// Expects `String?` value.
|
|
59
|
+
static let address = "_dd.proxy.address"
|
|
60
|
+
|
|
61
|
+
/// Expects `String?` value
|
|
62
|
+
static let username = "_dd.proxy.username"
|
|
63
|
+
|
|
64
|
+
/// Expects `String?` value
|
|
65
|
+
static let password = "_dd.proxy.password"
|
|
66
|
+
|
|
67
|
+
/// Expects `String?` value
|
|
68
|
+
static let type = "_dd.proxy.type"
|
|
69
|
+
|
|
70
|
+
/// Expects `String?` or `Int?` value
|
|
71
|
+
static let port = "_dd.proxy.port"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// Internal attributes used by the bridge only, passed from the javascript.
|
|
75
|
+
internal struct InternalConfigurationAttributes {
|
|
76
|
+
/// Enables native view tracking.
|
|
77
|
+
/// Expects `Bool?` value
|
|
78
|
+
static let nativeViewTracking = "_dd.native_view_tracking"
|
|
79
|
+
|
|
80
|
+
/// Enable overriding the service name.
|
|
81
|
+
/// Expects `String?` value
|
|
82
|
+
static let serviceName = "_dd.service_name"
|
|
83
|
+
|
|
84
|
+
/// Enable overriding the long task threshold for long task detection.
|
|
85
|
+
/// Expects `Double?` value
|
|
86
|
+
static let longTaskThreshold = "_dd.long_task.threshold"
|
|
87
|
+
|
|
88
|
+
/// Specify first party hosts for distributed tracing.
|
|
89
|
+
/// Even if the requests are intercepted at the javascript level, we have to pass this parameter to make sure the headers are
|
|
90
|
+
/// correctly set when sending the traces to the intake.
|
|
91
|
+
/// Expects `[String]?` value
|
|
92
|
+
static let firstPartyHosts = "_dd.first_party_hosts"
|
|
93
|
+
|
|
94
|
+
/// Specify native SDK verbosity
|
|
95
|
+
/// Expects `NSString?` value
|
|
96
|
+
static let sdkVerbosity = "_dd.sdk_verbosity"
|
|
97
|
+
|
|
98
|
+
/// Specify version suffix.
|
|
99
|
+
/// Expects `NSString?` value
|
|
100
|
+
static let versionSuffix = "_dd.version_suffix"
|
|
101
|
+
}
|
package/ios/Sources/DdLogs.swift
CHANGED
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
-
import
|
|
8
|
+
import Datadog
|
|
9
|
+
|
|
10
|
+
extension Logger: NativeLogger { }
|
|
11
|
+
internal protocol NativeLogger {
|
|
12
|
+
func debug(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
13
|
+
func info(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
14
|
+
func warn(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
15
|
+
func error(_ message: String, error: Error?, attributes: [String: Encodable]?)
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
@objc(DdLogs)
|
|
11
19
|
class RNDdLogs: NSObject {
|
|
@@ -15,32 +23,48 @@ class RNDdLogs: NSObject {
|
|
|
15
23
|
return false
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
let nativeInstance: DdLogs = Bridge.getDdLogs()
|
|
19
|
-
|
|
20
26
|
@objc(methodQueue)
|
|
21
27
|
let methodQueue: DispatchQueue = sharedQueue
|
|
22
28
|
|
|
29
|
+
private lazy var logger: NativeLogger = loggerProvider()
|
|
30
|
+
private let loggerProvider: () -> NativeLogger
|
|
31
|
+
|
|
32
|
+
internal init(_ loggerProvider: @escaping () -> NativeLogger) {
|
|
33
|
+
self.loggerProvider = loggerProvider
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override public convenience init() {
|
|
37
|
+
let builder = Logger.builder
|
|
38
|
+
.sendNetworkInfo(true)
|
|
39
|
+
.printLogsToConsole(true)
|
|
40
|
+
self.init { builder.build() }
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
@objc(debug:withContext:withResolver:withRejecter:)
|
|
24
|
-
func debug(message:
|
|
25
|
-
|
|
44
|
+
func debug(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
45
|
+
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
46
|
+
logger.debug(message, error: nil, attributes: attributes)
|
|
26
47
|
resolve(nil)
|
|
27
48
|
}
|
|
28
49
|
|
|
29
50
|
@objc(info:withContext:withResolver:withRejecter:)
|
|
30
|
-
func info(message:
|
|
31
|
-
|
|
51
|
+
func info(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
52
|
+
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
53
|
+
logger.info(message, error: nil, attributes: attributes)
|
|
32
54
|
resolve(nil)
|
|
33
55
|
}
|
|
34
56
|
|
|
35
57
|
@objc(warn:withContext:withResolver:withRejecter:)
|
|
36
|
-
func warn(message:
|
|
37
|
-
|
|
58
|
+
func warn(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
59
|
+
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
60
|
+
logger.warn(message, error: nil, attributes: attributes)
|
|
38
61
|
resolve(nil)
|
|
39
62
|
}
|
|
40
63
|
|
|
41
64
|
@objc(error:withContext:withResolver:withRejecter:)
|
|
42
|
-
func error(message:
|
|
43
|
-
|
|
65
|
+
func error(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
66
|
+
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
|
|
67
|
+
logger.error(message, error: nil, attributes: attributes)
|
|
44
68
|
resolve(nil)
|
|
45
69
|
}
|
|
46
70
|
|
package/ios/Sources/DdRum.m
CHANGED
|
@@ -28,7 +28,9 @@ RCT_EXTERN_METHOD(startAction:(NSString)type
|
|
|
28
28
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
29
29
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
30
30
|
|
|
31
|
-
RCT_EXTERN_METHOD(stopAction:(
|
|
31
|
+
RCT_EXTERN_METHOD(stopAction:(NSString)type
|
|
32
|
+
withName:(NSString)name
|
|
33
|
+
withContext:(NSDictionary)context
|
|
32
34
|
withTimestampms:(NSInteger)timestampMs
|
|
33
35
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
34
36
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
package/ios/Sources/DdRum.swift
CHANGED
|
@@ -5,73 +5,235 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
-
import
|
|
8
|
+
import Datadog
|
|
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 addResourceMetrics(resourceKey: String,
|
|
22
|
+
fetch: (start: Date, end: Date),
|
|
23
|
+
redirection: (start: Date, end: Date)?,
|
|
24
|
+
dns: (start: Date, end: Date)?,
|
|
25
|
+
connect: (start: Date, end: Date)?,
|
|
26
|
+
ssl: (start: Date, end: Date)?,
|
|
27
|
+
firstByte: (start: Date, end: Date)?,
|
|
28
|
+
download: (start: Date, end: Date)?,
|
|
29
|
+
responseSize: Int64?,
|
|
30
|
+
attributes: [AttributeKey: AttributeValue])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private extension RUMUserActionType {
|
|
34
|
+
init(from string: String) {
|
|
35
|
+
switch string.lowercased() {
|
|
36
|
+
case "tap": self = .tap
|
|
37
|
+
case "scroll": self = .scroll
|
|
38
|
+
case "swipe": self = .swipe
|
|
39
|
+
default: self = .custom
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
internal extension RUMErrorSource {
|
|
45
|
+
init(from string: String) {
|
|
46
|
+
switch string.lowercased() {
|
|
47
|
+
case "source": self = .source
|
|
48
|
+
case "network": self = .network
|
|
49
|
+
case "webview": self = .webview
|
|
50
|
+
case "console": self = .console
|
|
51
|
+
default: self = .custom
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private extension RUMResourceType {
|
|
57
|
+
init(from string: String) {
|
|
58
|
+
switch string {
|
|
59
|
+
case "image": self = .image
|
|
60
|
+
case "xhr": self = .xhr
|
|
61
|
+
case "beacon": self = .beacon
|
|
62
|
+
case "css": self = .css
|
|
63
|
+
case "document": self = .document
|
|
64
|
+
case "fetch": self = .fetch
|
|
65
|
+
case "font": self = .font
|
|
66
|
+
case "js": self = .js
|
|
67
|
+
case "media": self = .media
|
|
68
|
+
default: self = .other
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private extension RUMMethod {
|
|
74
|
+
init(from string: String) {
|
|
75
|
+
switch string.uppercased() {
|
|
76
|
+
case "POST": self = .post
|
|
77
|
+
case "GET": self = .get
|
|
78
|
+
case "HEAD": self = .head
|
|
79
|
+
case "PUT": self = .put
|
|
80
|
+
case "DELETE": self = .delete
|
|
81
|
+
case "PATCH": self = .patch
|
|
82
|
+
default: self = .get
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
9
86
|
|
|
10
87
|
@objc(DdRum)
|
|
11
88
|
class RNDdRum: NSObject {
|
|
89
|
+
internal static let timestampKey = "_dd.timestamp"
|
|
90
|
+
internal static let resourceTimingsKey = "_dd.resource_timings"
|
|
91
|
+
|
|
92
|
+
internal static let fetchTimingKey = "fetch"
|
|
93
|
+
internal static let redirectTimingKey = "redirect"
|
|
94
|
+
internal static let dnsTimingKey = "dns"
|
|
95
|
+
internal static let connectTimingKey = "connect"
|
|
96
|
+
internal static let sslTimingKey = "ssl"
|
|
97
|
+
internal static let firstByteTimingKey = "firstByte"
|
|
98
|
+
internal static let downloadTimingKey = "download"
|
|
99
|
+
|
|
100
|
+
internal static let missingResourceSize = -1
|
|
101
|
+
|
|
102
|
+
lazy var nativeRUM: NativeRUM = rumProvider()
|
|
103
|
+
private let rumProvider: () -> NativeRUM
|
|
104
|
+
|
|
105
|
+
private typealias UserAction = (type: RUMUserActionType, name: String?)
|
|
106
|
+
|
|
107
|
+
internal init(_ rumProvider: @escaping () -> NativeRUM) {
|
|
108
|
+
self.rumProvider = rumProvider
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
override convenience init() {
|
|
112
|
+
self.init { Global.rum }
|
|
113
|
+
}
|
|
12
114
|
|
|
13
115
|
@objc(requiresMainQueueSetup)
|
|
14
116
|
static func requiresMainQueueSetup() -> Bool {
|
|
15
117
|
return false
|
|
16
118
|
}
|
|
17
119
|
|
|
18
|
-
let nativeInstance: DdRum = Bridge.getDdRum()
|
|
19
|
-
|
|
20
120
|
@objc(methodQueue)
|
|
21
121
|
let methodQueue: DispatchQueue = sharedQueue
|
|
22
122
|
|
|
23
123
|
@objc(startView:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
24
|
-
func startView(key:
|
|
25
|
-
|
|
124
|
+
func startView(key: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
125
|
+
nativeRUM.startView(key: key, name: name, attributes: attributes(from: context, with: timestampMs))
|
|
26
126
|
resolve(nil)
|
|
27
127
|
}
|
|
28
128
|
|
|
29
129
|
@objc(stopView:withContext:withTimestampms:withResolver:withRejecter:)
|
|
30
|
-
func stopView(key:
|
|
31
|
-
|
|
130
|
+
func stopView(key: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
131
|
+
nativeRUM.stopView(key: key, attributes: attributes(from: context, with: timestampMs))
|
|
32
132
|
resolve(nil)
|
|
33
133
|
}
|
|
34
134
|
|
|
35
135
|
@objc(startAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
36
|
-
func startAction(type:
|
|
37
|
-
|
|
136
|
+
func startAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
137
|
+
nativeRUM.startUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
38
138
|
resolve(nil)
|
|
39
139
|
}
|
|
40
140
|
|
|
41
|
-
@objc(stopAction:withTimestampms:withResolver:withRejecter:)
|
|
42
|
-
func stopAction(context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
43
|
-
|
|
141
|
+
@objc(stopAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
142
|
+
func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
143
|
+
nativeRUM.stopUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
44
144
|
resolve(nil)
|
|
45
145
|
}
|
|
46
146
|
|
|
47
147
|
@objc(addAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
48
|
-
func addAction(type:
|
|
49
|
-
|
|
148
|
+
func addAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
149
|
+
nativeRUM.addUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
|
|
50
150
|
resolve(nil)
|
|
51
151
|
}
|
|
52
152
|
|
|
53
153
|
@objc(startResource:withMethod:withUrl:withContext:withTimestampms:withResolver:withRejecter:)
|
|
54
|
-
func startResource(key:
|
|
55
|
-
|
|
154
|
+
func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
155
|
+
nativeRUM.startResourceLoading(resourceKey: key, httpMethod: RUMMethod(from: method), urlString: url, attributes: attributes(from: context, with: timestampMs))
|
|
56
156
|
resolve(nil)
|
|
57
157
|
}
|
|
58
158
|
|
|
59
159
|
@objc(stopResource:withStatuscode:withKind:withSize:withContext:withTimestampms:withResolver:withRejecter:)
|
|
60
|
-
func stopResource(key:
|
|
61
|
-
|
|
160
|
+
func stopResource(key: String, statusCode: Int64, kind: String, size: Int64, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
161
|
+
let mutableContext = NSMutableDictionary(dictionary: context)
|
|
162
|
+
if let resourceTimings = mutableContext.object(forKey: Self.resourceTimingsKey) as? [String: Any] {
|
|
163
|
+
mutableContext.removeObject(forKey: Self.resourceTimingsKey)
|
|
164
|
+
|
|
165
|
+
addResourceMetrics(key: key, resourceTimings: resourceTimings)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
nativeRUM.stopResourceLoading(
|
|
169
|
+
resourceKey: key,
|
|
170
|
+
statusCode: Int(statusCode),
|
|
171
|
+
kind: RUMResourceType(from: kind),
|
|
172
|
+
size: size == Self.missingResourceSize ? nil : size,
|
|
173
|
+
attributes: attributes(from: mutableContext, with: timestampMs)
|
|
174
|
+
)
|
|
62
175
|
resolve(nil)
|
|
63
176
|
}
|
|
64
177
|
|
|
65
178
|
@objc(addError:withSource:withStacktrace:withContext:withTimestampms:withResolver:withRejecter:)
|
|
66
|
-
func addError(message:
|
|
67
|
-
|
|
179
|
+
func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
180
|
+
nativeRUM.addError(message: message, type: nil, source: RUMErrorSource(from: source), stack: stacktrace, attributes: attributes(from: context, with: timestampMs), file: nil, line: nil)
|
|
68
181
|
resolve(nil)
|
|
69
182
|
}
|
|
70
183
|
|
|
71
184
|
@objc(addTiming:withResolver:withRejecter:)
|
|
72
|
-
func addTiming(name:
|
|
73
|
-
|
|
185
|
+
func addTiming(name: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
186
|
+
nativeRUM.addTiming(name: name)
|
|
74
187
|
resolve(nil)
|
|
75
188
|
}
|
|
76
189
|
|
|
190
|
+
// MARK: - Private methods
|
|
191
|
+
|
|
192
|
+
private func attributes(from context: NSDictionary, with timestampMs: Int64) -> [String: Encodable] {
|
|
193
|
+
var context = context as? [String: Any] ?? [:]
|
|
194
|
+
context[Self.timestampKey] = timestampMs
|
|
195
|
+
return castAttributesToSwift(context)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private func addResourceMetrics(key: String, resourceTimings: [String: Any]) {
|
|
199
|
+
let fetch = timingValue(from: resourceTimings, for: Self.fetchTimingKey)
|
|
200
|
+
let redirect = timingValue(from: resourceTimings, for: Self.redirectTimingKey)
|
|
201
|
+
let dns = timingValue(from: resourceTimings, for: Self.dnsTimingKey)
|
|
202
|
+
let connect = timingValue(from: resourceTimings, for: Self.connectTimingKey)
|
|
203
|
+
let ssl = timingValue(from: resourceTimings, for: Self.sslTimingKey)
|
|
204
|
+
let firstByte = timingValue(from: resourceTimings, for: Self.firstByteTimingKey)
|
|
205
|
+
let download = timingValue(from: resourceTimings, for: Self.downloadTimingKey)
|
|
206
|
+
|
|
207
|
+
if let fetch = fetch {
|
|
208
|
+
nativeRUM.addResourceMetrics(
|
|
209
|
+
resourceKey: key,
|
|
210
|
+
fetch: fetch,
|
|
211
|
+
redirection: redirect,
|
|
212
|
+
dns: dns,
|
|
213
|
+
connect: connect,
|
|
214
|
+
ssl: ssl,
|
|
215
|
+
firstByte: firstByte,
|
|
216
|
+
download: download,
|
|
217
|
+
// no need to define the size here, because if it is missing,
|
|
218
|
+
// it will be taken from the command
|
|
219
|
+
responseSize: nil,
|
|
220
|
+
attributes: [:]
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private func timingValue(from timings: [String: Any], for timingName: String) -> (start: Date, end: Date)? {
|
|
226
|
+
let timing = timings[timingName] as? [String: NSNumber]
|
|
227
|
+
if let startInNs = timing?["startTime"]?.int64Value, let durationInNs = timing?["duration"]?.int64Value {
|
|
228
|
+
return (
|
|
229
|
+
Date(timeIntervalSince1970: TimeInterval(fromNs: startInNs)),
|
|
230
|
+
Date(timeIntervalSince1970: TimeInterval(fromNs: startInNs + durationInNs))
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
return nil
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
internal extension TimeInterval {
|
|
238
|
+
init(fromNs ns: Int64) { self = TimeInterval(Double(ns) / 1_000_000_000) }
|
|
77
239
|
}
|