@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
|
@@ -6,23 +6,26 @@
|
|
|
6
6
|
|
|
7
7
|
import { Platform, NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
|
-
import { InternalLog } from '
|
|
10
|
-
import { SdkVerbosity } from '
|
|
9
|
+
import { InternalLog } from '../../../../../InternalLog';
|
|
10
|
+
import { SdkVerbosity } from '../../../../../SdkVerbosity';
|
|
11
|
+
import { XMLHttpRequestMock } from '../../__tests__/__utils__/XMLHttpRequestMock';
|
|
12
|
+
import { firstPartyHostsRegexBuilder } from '../../domain/firstPartyHosts';
|
|
13
|
+
import { ResourceReporter } from '../DatadogRumResource/ResourceReporter';
|
|
11
14
|
import {
|
|
12
|
-
DdRumResourceTracking,
|
|
13
15
|
PARENT_ID_HEADER_KEY,
|
|
14
16
|
TRACE_ID_HEADER_KEY,
|
|
15
17
|
ORIGIN_RUM,
|
|
16
18
|
ORIGIN_HEADER_KEY,
|
|
17
19
|
SAMPLING_PRIORITY_HEADER_KEY,
|
|
20
|
+
XHRProxy
|
|
21
|
+
} from '../XHRProxy';
|
|
22
|
+
import {
|
|
18
23
|
calculateResponseSize,
|
|
19
24
|
RESOURCE_SIZE_ERROR_MESSAGE
|
|
20
|
-
} from '
|
|
21
|
-
|
|
22
|
-
import { XMLHttpRequestMock } from './__utils__/XMLHttpRequestMock';
|
|
25
|
+
} from '../responseSize';
|
|
23
26
|
|
|
24
27
|
jest.useFakeTimers();
|
|
25
|
-
jest.mock('
|
|
28
|
+
jest.mock('../../../../../InternalLog');
|
|
26
29
|
const mockedInternalLog = (InternalLog as unknown) as {
|
|
27
30
|
log: jest.MockedFunction<typeof InternalLog.log>;
|
|
28
31
|
};
|
|
@@ -35,10 +38,15 @@ function randomInt(max: number): number {
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
const flushPromises = () => new Promise(setImmediate);
|
|
41
|
+
let xhrProxy;
|
|
38
42
|
|
|
39
43
|
beforeEach(() => {
|
|
40
44
|
DdRum.startResource.mockClear();
|
|
41
45
|
DdRum.stopResource.mockClear();
|
|
46
|
+
xhrProxy = new XHRProxy({
|
|
47
|
+
xhrType: XMLHttpRequestMock,
|
|
48
|
+
resourceReporter: new ResourceReporter([])
|
|
49
|
+
});
|
|
42
50
|
|
|
43
51
|
// we need this because with ms precision between Date.now() calls we can get 0, so we advance
|
|
44
52
|
// it manually with each call
|
|
@@ -52,20 +60,20 @@ beforeEach(() => {
|
|
|
52
60
|
});
|
|
53
61
|
|
|
54
62
|
afterEach(() => {
|
|
55
|
-
|
|
63
|
+
xhrProxy.onTrackingStop();
|
|
56
64
|
(Date.now as jest.MockedFunction<typeof Date.now>).mockClear();
|
|
57
65
|
jest.spyOn(global.Math, 'random').mockRestore();
|
|
58
66
|
});
|
|
59
67
|
|
|
60
|
-
describe('
|
|
68
|
+
describe('XHRPr', () => {
|
|
61
69
|
describe('resource interception', () => {
|
|
62
70
|
it('intercepts XHR request when startTracking() + XHR.open() + XHR.send()', async () => {
|
|
63
71
|
// GIVEN
|
|
64
72
|
const method = 'GET';
|
|
65
73
|
const url = 'https://api.example.com/v2/user';
|
|
66
|
-
|
|
74
|
+
xhrProxy.onTrackingStart({
|
|
67
75
|
tracingSamplingRate: 100,
|
|
68
|
-
|
|
76
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
69
77
|
});
|
|
70
78
|
|
|
71
79
|
// WHEN
|
|
@@ -98,9 +106,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
98
106
|
// GIVEN
|
|
99
107
|
const method = 'GET';
|
|
100
108
|
const url = 'https://api.example.com/v2/user';
|
|
101
|
-
|
|
109
|
+
xhrProxy.onTrackingStart({
|
|
102
110
|
tracingSamplingRate: 100,
|
|
103
|
-
|
|
111
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
104
112
|
});
|
|
105
113
|
|
|
106
114
|
// WHEN
|
|
@@ -133,9 +141,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
133
141
|
// GIVEN
|
|
134
142
|
const method = 'GET';
|
|
135
143
|
const url = 'https://api.example.com/v2/user';
|
|
136
|
-
|
|
144
|
+
xhrProxy.onTrackingStart({
|
|
137
145
|
tracingSamplingRate: 100,
|
|
138
|
-
|
|
146
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
139
147
|
});
|
|
140
148
|
|
|
141
149
|
// WHEN
|
|
@@ -170,9 +178,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
170
178
|
// GIVEN
|
|
171
179
|
const method = 'GET';
|
|
172
180
|
const url = 'https://api.example.com/v2/user';
|
|
173
|
-
|
|
181
|
+
xhrProxy.onTrackingStart({
|
|
174
182
|
tracingSamplingRate: 100,
|
|
175
|
-
|
|
183
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
184
|
+
'api.example.com'
|
|
185
|
+
])
|
|
176
186
|
});
|
|
177
187
|
|
|
178
188
|
// WHEN
|
|
@@ -193,9 +203,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
193
203
|
// GIVEN
|
|
194
204
|
const method = 'GET';
|
|
195
205
|
const url = 'https://api.example.com/v2/user';
|
|
196
|
-
|
|
206
|
+
xhrProxy.onTrackingStart({
|
|
197
207
|
tracingSamplingRate: 100,
|
|
198
|
-
|
|
208
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
209
|
+
'api.example.com'
|
|
210
|
+
])
|
|
199
211
|
});
|
|
200
212
|
|
|
201
213
|
// WHEN
|
|
@@ -216,9 +228,12 @@ describe('DdRumResourceTracking', () => {
|
|
|
216
228
|
// GIVEN
|
|
217
229
|
const method = 'GET';
|
|
218
230
|
const url = 'https://api.example.com:443/v2/user';
|
|
219
|
-
|
|
231
|
+
xhrProxy.onTrackingStart({
|
|
220
232
|
tracingSamplingRate: 100,
|
|
221
|
-
|
|
233
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
234
|
+
'something.fr',
|
|
235
|
+
'example.com'
|
|
236
|
+
])
|
|
222
237
|
});
|
|
223
238
|
|
|
224
239
|
// WHEN
|
|
@@ -239,9 +254,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
239
254
|
// GIVEN
|
|
240
255
|
const method = 'GET';
|
|
241
256
|
const url = 'https://api.example.com/v2/user';
|
|
242
|
-
|
|
257
|
+
xhrProxy.onTrackingStart({
|
|
243
258
|
tracingSamplingRate: 100,
|
|
244
|
-
|
|
259
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
245
260
|
});
|
|
246
261
|
|
|
247
262
|
// WHEN
|
|
@@ -261,9 +276,12 @@ describe('DdRumResourceTracking', () => {
|
|
|
261
276
|
// GIVEN
|
|
262
277
|
const method = 'GET';
|
|
263
278
|
const url = 'https://api.example.com/v2/user';
|
|
264
|
-
|
|
279
|
+
xhrProxy.onTrackingStart({
|
|
265
280
|
tracingSamplingRate: 100,
|
|
266
|
-
|
|
281
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
282
|
+
'google.com',
|
|
283
|
+
'api.example.co'
|
|
284
|
+
])
|
|
267
285
|
});
|
|
268
286
|
|
|
269
287
|
// WHEN
|
|
@@ -283,9 +301,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
283
301
|
// GIVEN
|
|
284
302
|
const method = 'GET';
|
|
285
303
|
const url = 'crash';
|
|
286
|
-
|
|
304
|
+
xhrProxy.onTrackingStart({
|
|
287
305
|
tracingSamplingRate: 100,
|
|
288
|
-
|
|
306
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
307
|
+
'example.com'
|
|
308
|
+
])
|
|
289
309
|
});
|
|
290
310
|
|
|
291
311
|
// WHEN
|
|
@@ -305,9 +325,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
305
325
|
// GIVEN
|
|
306
326
|
const method = 'GET';
|
|
307
327
|
const url = 'https://api.example.com/v2/user';
|
|
308
|
-
|
|
328
|
+
xhrProxy.onTrackingStart({
|
|
309
329
|
tracingSamplingRate: 50,
|
|
310
|
-
|
|
330
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
331
|
+
'api.example.com'
|
|
332
|
+
])
|
|
311
333
|
});
|
|
312
334
|
jest.spyOn(global.Math, 'random').mockReturnValue(0.7);
|
|
313
335
|
|
|
@@ -328,9 +350,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
328
350
|
// GIVEN
|
|
329
351
|
const method = 'GET';
|
|
330
352
|
const url = 'https://api.example.com/v2/user';
|
|
331
|
-
|
|
353
|
+
xhrProxy.onTrackingStart({
|
|
332
354
|
tracingSamplingRate: 100,
|
|
333
|
-
|
|
355
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
334
356
|
});
|
|
335
357
|
|
|
336
358
|
// WHEN
|
|
@@ -349,9 +371,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
349
371
|
// GIVEN
|
|
350
372
|
const method = 'GET';
|
|
351
373
|
const url = 'https://api.example.com/v2/user';
|
|
352
|
-
|
|
374
|
+
xhrProxy.onTrackingStart({
|
|
353
375
|
tracingSamplingRate: 100,
|
|
354
|
-
|
|
376
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
377
|
+
'api.example.com'
|
|
378
|
+
])
|
|
355
379
|
});
|
|
356
380
|
|
|
357
381
|
// WHEN
|
|
@@ -370,9 +394,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
370
394
|
// GIVEN
|
|
371
395
|
const method = 'GET';
|
|
372
396
|
const url = 'https://api.example.com/v2/user';
|
|
373
|
-
|
|
397
|
+
xhrProxy.onTrackingStart({
|
|
374
398
|
tracingSamplingRate: 50,
|
|
375
|
-
|
|
399
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
400
|
+
'api.example.com'
|
|
401
|
+
])
|
|
376
402
|
});
|
|
377
403
|
jest.spyOn(global.Math, 'random').mockReturnValue(0.7);
|
|
378
404
|
|
|
@@ -394,9 +420,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
394
420
|
// GIVEN
|
|
395
421
|
const method = 'GET';
|
|
396
422
|
const url = 'https://api.example.com/v2/user';
|
|
397
|
-
|
|
423
|
+
xhrProxy.onTrackingStart({
|
|
398
424
|
tracingSamplingRate: 100,
|
|
399
|
-
|
|
425
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
426
|
+
'api.example.com'
|
|
427
|
+
])
|
|
400
428
|
});
|
|
401
429
|
|
|
402
430
|
// WHEN
|
|
@@ -417,9 +445,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
417
445
|
// GIVEN
|
|
418
446
|
const method = 'GET';
|
|
419
447
|
const url = 'https://api.example.com/v2/user';
|
|
420
|
-
|
|
448
|
+
xhrProxy.onTrackingStart({
|
|
421
449
|
tracingSamplingRate: 100,
|
|
422
|
-
|
|
450
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
451
|
+
'api.example.com'
|
|
452
|
+
])
|
|
423
453
|
});
|
|
424
454
|
|
|
425
455
|
// WHEN
|
|
@@ -441,9 +471,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
441
471
|
// GIVEN
|
|
442
472
|
const method = 'GET';
|
|
443
473
|
const url = 'https://api.example.com/v2/user';
|
|
444
|
-
|
|
474
|
+
xhrProxy.onTrackingStart({
|
|
445
475
|
tracingSamplingRate: 100,
|
|
446
|
-
|
|
476
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
477
|
+
'api.example.com'
|
|
478
|
+
])
|
|
447
479
|
});
|
|
448
480
|
|
|
449
481
|
// WHEN
|
|
@@ -465,9 +497,11 @@ describe('DdRumResourceTracking', () => {
|
|
|
465
497
|
// GIVEN
|
|
466
498
|
const method = 'GET';
|
|
467
499
|
const url = 'https://api.example.com/v2/user';
|
|
468
|
-
|
|
500
|
+
xhrProxy.onTrackingStart({
|
|
469
501
|
tracingSamplingRate: 50,
|
|
470
|
-
|
|
502
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([
|
|
503
|
+
'api.example.com'
|
|
504
|
+
])
|
|
471
505
|
});
|
|
472
506
|
jest.spyOn(global.Math, 'random').mockReturnValue(0.7);
|
|
473
507
|
|
|
@@ -498,9 +532,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
498
532
|
// GIVEN
|
|
499
533
|
const method = 'GET';
|
|
500
534
|
const url = 'https://api.example.com/v2/user';
|
|
501
|
-
|
|
535
|
+
xhrProxy.onTrackingStart({
|
|
502
536
|
tracingSamplingRate: 100,
|
|
503
|
-
|
|
537
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
504
538
|
});
|
|
505
539
|
|
|
506
540
|
jest.doMock('react-native/Libraries/Utilities/Platform', () => ({
|
|
@@ -541,9 +575,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
541
575
|
// GIVEN
|
|
542
576
|
const method = 'GET';
|
|
543
577
|
const url = 'https://api.example.com/v2/user';
|
|
544
|
-
|
|
578
|
+
xhrProxy.onTrackingStart({
|
|
545
579
|
tracingSamplingRate: 100,
|
|
546
|
-
|
|
580
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
547
581
|
});
|
|
548
582
|
|
|
549
583
|
jest.doMock('react-native/Libraries/Utilities/Platform', () => ({
|
|
@@ -587,9 +621,9 @@ describe('DdRumResourceTracking', () => {
|
|
|
587
621
|
// GIVEN
|
|
588
622
|
const method = 'GET';
|
|
589
623
|
const url = 'https://api.example.com/v2/user';
|
|
590
|
-
|
|
624
|
+
xhrProxy.onTrackingStart({
|
|
591
625
|
tracingSamplingRate: 100,
|
|
592
|
-
|
|
626
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
593
627
|
});
|
|
594
628
|
|
|
595
629
|
// WHEN
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import { InternalLog } from '../../../../InternalLog';
|
|
8
|
+
import { SdkVerbosity } from '../../../../SdkVerbosity';
|
|
9
|
+
|
|
10
|
+
const MISSING_RESOURCE_SIZE = -1;
|
|
11
|
+
export const RESOURCE_SIZE_ERROR_MESSAGE =
|
|
12
|
+
"Couldn't get resource size, because an error occured: ";
|
|
13
|
+
|
|
14
|
+
function byteLength(str: string): number {
|
|
15
|
+
// This is a weird trick, but it works.
|
|
16
|
+
// Output is the same as TextEncoder.encode(...).length
|
|
17
|
+
return unescape(encodeURI(str)).length;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getResponseContentLengthFromHeader(
|
|
21
|
+
xhr: XMLHttpRequest
|
|
22
|
+
): number | null {
|
|
23
|
+
const contentLengthHeader = parseInt(
|
|
24
|
+
xhr.getResponseHeader('Content-Length') ?? '',
|
|
25
|
+
10
|
|
26
|
+
);
|
|
27
|
+
if (!isNaN(contentLengthHeader)) {
|
|
28
|
+
return contentLengthHeader;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function calculateResponseSize(xhr: XMLHttpRequest): number {
|
|
34
|
+
const contentLengthHeader = getResponseContentLengthFromHeader(xhr);
|
|
35
|
+
if (contentLengthHeader != null) {
|
|
36
|
+
return contentLengthHeader as number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const response = xhr.response;
|
|
40
|
+
if (!response) {
|
|
41
|
+
return MISSING_RESOURCE_SIZE;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let size;
|
|
45
|
+
try {
|
|
46
|
+
switch (xhr.responseType) {
|
|
47
|
+
case '':
|
|
48
|
+
case 'text':
|
|
49
|
+
// String
|
|
50
|
+
size = byteLength(response);
|
|
51
|
+
break;
|
|
52
|
+
case 'blob':
|
|
53
|
+
size = response.size;
|
|
54
|
+
break;
|
|
55
|
+
case 'arraybuffer':
|
|
56
|
+
size = response.byteLength;
|
|
57
|
+
break;
|
|
58
|
+
case 'document':
|
|
59
|
+
// currently not supported by RN as of 0.66
|
|
60
|
+
// HTML Document or XML Document
|
|
61
|
+
break;
|
|
62
|
+
case 'json':
|
|
63
|
+
// plain JS object
|
|
64
|
+
// original size was lost, because this is the object which was parsed.
|
|
65
|
+
// We can only convert back to the string and calculate the size,
|
|
66
|
+
// which will roughly match original.
|
|
67
|
+
size = byteLength(JSON.stringify(response));
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
InternalLog.log(
|
|
74
|
+
`${RESOURCE_SIZE_ERROR_MESSAGE}${e}`,
|
|
75
|
+
SdkVerbosity.ERROR
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (typeof size !== 'number') {
|
|
80
|
+
return MISSING_RESOURCE_SIZE;
|
|
81
|
+
}
|
|
82
|
+
return size;
|
|
83
|
+
}
|
package/src/types.tsx
CHANGED
|
@@ -143,13 +143,13 @@ export type DdRumType = {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Start tracking a RUM Action.
|
|
146
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
146
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
147
147
|
* @param name: The action name.
|
|
148
148
|
* @param context: The additional context to send.
|
|
149
149
|
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
150
150
|
*/
|
|
151
151
|
startAction(
|
|
152
|
-
type:
|
|
152
|
+
type: RumActionType,
|
|
153
153
|
name: string,
|
|
154
154
|
context?: object,
|
|
155
155
|
timestampMs?: number
|
|
@@ -157,6 +157,24 @@ export type DdRumType = {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Stop tracking the ongoing RUM Action.
|
|
160
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
161
|
+
* @param name: The action name.
|
|
162
|
+
* @param context: The additional context to send.
|
|
163
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
164
|
+
*/
|
|
165
|
+
stopAction(
|
|
166
|
+
type: RumActionType,
|
|
167
|
+
name: string,
|
|
168
|
+
context?: object,
|
|
169
|
+
timestampMs?: number
|
|
170
|
+
): Promise<void>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Stop tracking the ongoing RUM Action.
|
|
174
|
+
*
|
|
175
|
+
* Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.
|
|
176
|
+
*
|
|
177
|
+
* @deprecated add the `type` and `name` of the action as first two arguments.
|
|
160
178
|
* @param context: The additional context to send.
|
|
161
179
|
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
162
180
|
*/
|
|
@@ -164,13 +182,13 @@ export type DdRumType = {
|
|
|
164
182
|
|
|
165
183
|
/**
|
|
166
184
|
* Add a RUM Action.
|
|
167
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
185
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
168
186
|
* @param name: The action name.
|
|
169
187
|
* @param context: The additional context to send.
|
|
170
188
|
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
171
189
|
*/
|
|
172
190
|
addAction(
|
|
173
|
-
type:
|
|
191
|
+
type: RumActionType,
|
|
174
192
|
name: string,
|
|
175
193
|
context?: object,
|
|
176
194
|
timestampMs?: number
|
|
@@ -204,7 +222,7 @@ export type DdRumType = {
|
|
|
204
222
|
stopResource(
|
|
205
223
|
key: string,
|
|
206
224
|
statusCode: number,
|
|
207
|
-
kind:
|
|
225
|
+
kind: ResourceKind,
|
|
208
226
|
size?: number,
|
|
209
227
|
context?: object,
|
|
210
228
|
timestampMs?: number
|
|
@@ -213,14 +231,14 @@ export type DdRumType = {
|
|
|
213
231
|
/**
|
|
214
232
|
* Add a RUM Error.
|
|
215
233
|
* @param message: The error message.
|
|
216
|
-
* @param source: The error source (network, source, console,
|
|
234
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
217
235
|
* @param stacktrace: The error stacktrace.
|
|
218
236
|
* @param context: The additional context to send.
|
|
219
237
|
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
220
238
|
*/
|
|
221
239
|
addError(
|
|
222
240
|
message: string,
|
|
223
|
-
source:
|
|
241
|
+
source: ErrorSource,
|
|
224
242
|
stacktrace: string,
|
|
225
243
|
context?: object,
|
|
226
244
|
timestampMs?: number
|
|
@@ -232,3 +250,40 @@ export type DdRumType = {
|
|
|
232
250
|
*/
|
|
233
251
|
addTiming(name: string): Promise<void>;
|
|
234
252
|
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Describe the type of a RUM Action.
|
|
256
|
+
*/
|
|
257
|
+
export enum RumActionType {
|
|
258
|
+
/** User tapped on a widget. */
|
|
259
|
+
TAP = 'TAP',
|
|
260
|
+
/** User scrolled a view. */
|
|
261
|
+
SCROLL = 'SCROLL',
|
|
262
|
+
/** User swiped on a view. */
|
|
263
|
+
SWIPE = 'SWIPE',
|
|
264
|
+
/** User pressed hardware back button (Android only). */
|
|
265
|
+
BACK = 'BACK',
|
|
266
|
+
/** A custom action. */
|
|
267
|
+
CUSTOM = 'CUSTOM'
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export type ResourceKind =
|
|
271
|
+
| 'image'
|
|
272
|
+
| 'xhr'
|
|
273
|
+
| 'beacon'
|
|
274
|
+
| 'css'
|
|
275
|
+
| 'document'
|
|
276
|
+
| 'fetch'
|
|
277
|
+
| 'font'
|
|
278
|
+
| 'js'
|
|
279
|
+
| 'media'
|
|
280
|
+
| 'other'
|
|
281
|
+
| 'native';
|
|
282
|
+
|
|
283
|
+
export enum ErrorSource {
|
|
284
|
+
NETWORK = 'NETWORK',
|
|
285
|
+
SOURCE = 'SOURCE',
|
|
286
|
+
CONSOLE = 'CONSOLE',
|
|
287
|
+
WEBVIEW = 'WEBVIEW',
|
|
288
|
+
CUSTOM = 'CUSTOM'
|
|
289
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.1.0';
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
-
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
-
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
package com.datadog.reactnative
|
|
8
|
-
|
|
9
|
-
import com.datadog.android.bridge.DdBridge
|
|
10
|
-
import com.datadog.android.bridge.DdRum as SDKDdRum
|
|
11
|
-
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
-
import com.facebook.react.bridge.ReactMethod
|
|
15
|
-
import com.facebook.react.bridge.ReadableArray
|
|
16
|
-
import com.facebook.react.bridge.ReadableMap
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The entry point to use Datadog's RUM feature.
|
|
20
|
-
*/
|
|
21
|
-
class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
|
-
|
|
23
|
-
private val nativeInstance: SDKDdRum = DdBridge.getDdRum(reactContext)
|
|
24
|
-
|
|
25
|
-
override fun getName(): String = "DdRum"
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Start tracking a RUM View.
|
|
29
|
-
* @param key The view unique key identifier.
|
|
30
|
-
* @param name The view name.
|
|
31
|
-
* @param context The additional context to send.
|
|
32
|
-
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
33
|
-
*/
|
|
34
|
-
@ReactMethod
|
|
35
|
-
fun startView(key: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
36
|
-
nativeInstance.startView(key, name, context.toHashMap(), timestampMs.toLong())
|
|
37
|
-
promise.resolve(null)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Stop tracking a RUM View.
|
|
42
|
-
* @param key The view unique key identifier.
|
|
43
|
-
* @param context The additional context to send.
|
|
44
|
-
* @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
45
|
-
*/
|
|
46
|
-
@ReactMethod
|
|
47
|
-
fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
48
|
-
nativeInstance.stopView(key, context.toHashMap(), timestampMs.toLong())
|
|
49
|
-
promise.resolve(null)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Start tracking a RUM Action.
|
|
54
|
-
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
55
|
-
* @param name The action name.
|
|
56
|
-
* @param context The additional context to send.
|
|
57
|
-
* @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
58
|
-
*/
|
|
59
|
-
@ReactMethod
|
|
60
|
-
fun startAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
61
|
-
nativeInstance.startAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
62
|
-
promise.resolve(null)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Stop tracking the ongoing RUM Action.
|
|
67
|
-
* @param context The additional context to send.
|
|
68
|
-
* @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
69
|
-
*/
|
|
70
|
-
@ReactMethod
|
|
71
|
-
fun stopAction(context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
72
|
-
nativeInstance.stopAction(context.toHashMap(), timestampMs.toLong())
|
|
73
|
-
promise.resolve(null)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Add a RUM Action.
|
|
78
|
-
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
79
|
-
* @param name The action name.
|
|
80
|
-
* @param context The additional context to send.
|
|
81
|
-
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
82
|
-
*/
|
|
83
|
-
@ReactMethod
|
|
84
|
-
fun addAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
85
|
-
nativeInstance.addAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
86
|
-
promise.resolve(null)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Start tracking a RUM Resource.
|
|
91
|
-
* @param key The resource unique key identifier.
|
|
92
|
-
* @param method The resource method (GET, POST, …).
|
|
93
|
-
* @param url The resource url.
|
|
94
|
-
* @param context The additional context to send.
|
|
95
|
-
* @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
96
|
-
*/
|
|
97
|
-
@ReactMethod
|
|
98
|
-
fun startResource(key: String, method: String, url: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
99
|
-
nativeInstance.startResource(key, method, url, context.toHashMap(), timestampMs.toLong())
|
|
100
|
-
promise.resolve(null)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Stop tracking a RUM Resource.
|
|
105
|
-
* @param key The resource unique key identifier.
|
|
106
|
-
* @param statusCode The resource status code.
|
|
107
|
-
* @param kind The resource's kind (xhr, document, image, css, font, …).
|
|
108
|
-
* @param size The resource size in bytes.
|
|
109
|
-
* @param context The additional context to send.
|
|
110
|
-
* @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
111
|
-
*/
|
|
112
|
-
@ReactMethod
|
|
113
|
-
fun stopResource(key: String, statusCode: Double, kind: String, size: Double, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
114
|
-
nativeInstance.stopResource(key, statusCode.toLong(), kind, size.toLong(), context.toHashMap(), timestampMs.toLong())
|
|
115
|
-
promise.resolve(null)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Add a RUM Error.
|
|
120
|
-
* @param message The error message.
|
|
121
|
-
* @param source The error source (network, source, console, logger, …).
|
|
122
|
-
* @param stacktrace The error stacktrace.
|
|
123
|
-
* @param context The additional context to send.
|
|
124
|
-
* @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
125
|
-
*/
|
|
126
|
-
@ReactMethod
|
|
127
|
-
fun addError(message: String, source: String, stacktrace: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
128
|
-
nativeInstance.addError(message, source, stacktrace, context.toHashMap(), timestampMs.toLong())
|
|
129
|
-
promise.resolve(null)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
134
|
-
* @param name The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
135
|
-
*/
|
|
136
|
-
@ReactMethod
|
|
137
|
-
fun addTiming(name: String, promise: Promise) {
|
|
138
|
-
nativeInstance.addTiming(name)
|
|
139
|
-
promise.resolve(null)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|