@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
|
@@ -13,8 +13,8 @@ import { SdkVerbosity } from '../SdkVerbosity';
|
|
|
13
13
|
import { TrackingConsent } from '../TrackingConsent';
|
|
14
14
|
import { DdSdk } from '../foundation';
|
|
15
15
|
import { DdRumErrorTracking } from '../rum/instrumentation/DdRumErrorTracking';
|
|
16
|
-
import { DdRumResourceTracking } from '../rum/instrumentation/DdRumResourceTracking';
|
|
17
16
|
import { DdRumUserInteractionTracking } from '../rum/instrumentation/DdRumUserInteractionTracking';
|
|
17
|
+
import { DdRumResourceTracking } from '../rum/instrumentation/resourceTracking/DdRumResourceTracking';
|
|
18
18
|
import type { DdSdkConfiguration } from '../types';
|
|
19
19
|
import { version as sdkVersion } from '../version';
|
|
20
20
|
|
|
@@ -28,13 +28,16 @@ jest.mock('../rum/instrumentation/DdRumUserInteractionTracking', () => {
|
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
jest.mock(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
31
|
+
jest.mock(
|
|
32
|
+
'../rum/instrumentation/resourceTracking/DdRumResourceTracking',
|
|
33
|
+
() => {
|
|
34
|
+
return {
|
|
35
|
+
DdRumResourceTracking: {
|
|
36
|
+
startTracking: jest.fn().mockImplementation(() => {})
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
);
|
|
38
41
|
|
|
39
42
|
jest.mock('../rum/instrumentation/DdRumErrorTracking', () => {
|
|
40
43
|
return {
|
|
@@ -344,6 +347,82 @@ describe('DdSdkReactNative', () => {
|
|
|
344
347
|
})
|
|
345
348
|
);
|
|
346
349
|
});
|
|
350
|
+
|
|
351
|
+
it('initializes with the version when a version is specified', async () => {
|
|
352
|
+
// GIVEN
|
|
353
|
+
const fakeAppId = '1';
|
|
354
|
+
const fakeClientToken = '2';
|
|
355
|
+
const fakeEnvName = 'env';
|
|
356
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
357
|
+
fakeClientToken,
|
|
358
|
+
fakeEnvName,
|
|
359
|
+
fakeAppId
|
|
360
|
+
);
|
|
361
|
+
configuration.version = '2.0.0';
|
|
362
|
+
|
|
363
|
+
// WHEN
|
|
364
|
+
await DdSdkReactNative.initialize(configuration);
|
|
365
|
+
|
|
366
|
+
// THEN
|
|
367
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
368
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
369
|
+
expect(ddSdkConfiguration.additionalConfig['_dd.version']).toBe(
|
|
370
|
+
'2.0.0'
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it('initialized with a version suffix when a version suffix is specified', async () => {
|
|
375
|
+
// GIVEN
|
|
376
|
+
const fakeAppId = '1';
|
|
377
|
+
const fakeClientToken = '2';
|
|
378
|
+
const fakeEnvName = 'env';
|
|
379
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
380
|
+
fakeClientToken,
|
|
381
|
+
fakeEnvName,
|
|
382
|
+
fakeAppId
|
|
383
|
+
);
|
|
384
|
+
configuration.versionSuffix = 'codepush-3';
|
|
385
|
+
|
|
386
|
+
// WHEN
|
|
387
|
+
await DdSdkReactNative.initialize(configuration);
|
|
388
|
+
|
|
389
|
+
// THEN
|
|
390
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
391
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
392
|
+
expect(
|
|
393
|
+
ddSdkConfiguration.additionalConfig['_dd.version']
|
|
394
|
+
).toBeUndefined();
|
|
395
|
+
expect(
|
|
396
|
+
ddSdkConfiguration.additionalConfig['_dd.version_suffix']
|
|
397
|
+
).toBe('-codepush-3');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('initializes with the version when a version and version suffix are specified', async () => {
|
|
401
|
+
// GIVEN
|
|
402
|
+
const fakeAppId = '1';
|
|
403
|
+
const fakeClientToken = '2';
|
|
404
|
+
const fakeEnvName = 'env';
|
|
405
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
406
|
+
fakeClientToken,
|
|
407
|
+
fakeEnvName,
|
|
408
|
+
fakeAppId
|
|
409
|
+
);
|
|
410
|
+
configuration.version = '2.0.0';
|
|
411
|
+
configuration.versionSuffix = 'codepush-3';
|
|
412
|
+
|
|
413
|
+
// WHEN
|
|
414
|
+
await DdSdkReactNative.initialize(configuration);
|
|
415
|
+
|
|
416
|
+
// THEN
|
|
417
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
418
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
419
|
+
expect(ddSdkConfiguration.additionalConfig['_dd.version']).toBe(
|
|
420
|
+
'2.0.0-codepush-3'
|
|
421
|
+
);
|
|
422
|
+
expect(
|
|
423
|
+
ddSdkConfiguration.additionalConfig['_dd.version_suffix']
|
|
424
|
+
).toBeUndefined();
|
|
425
|
+
});
|
|
347
426
|
});
|
|
348
427
|
|
|
349
428
|
describe('feature enablement', () => {
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { NativeModules } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { DdRum } from '../foundation';
|
|
10
|
+
|
|
11
|
+
jest.mock('../TimeProvider', () => {
|
|
12
|
+
return {
|
|
13
|
+
TimeProvider: jest.fn().mockImplementation(() => {
|
|
14
|
+
return { now: jest.fn().mockReturnValue(456) };
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('foundation', () => {
|
|
20
|
+
describe('DdRum.stopAction', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('calls the native SDK when called with new API', async () => {
|
|
26
|
+
await DdRum.stopAction('scroll', 'page', { user: 'me' }, 123);
|
|
27
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
28
|
+
'scroll',
|
|
29
|
+
'page',
|
|
30
|
+
{ user: 'me' },
|
|
31
|
+
123
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('calls the native SDK when called with new API with default values', async () => {
|
|
36
|
+
await DdRum.stopAction('scroll', 'page');
|
|
37
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
38
|
+
'scroll',
|
|
39
|
+
'page',
|
|
40
|
+
{},
|
|
41
|
+
456
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('does not call the native SDK when sartAction has not been called before and using old API', async () => {
|
|
46
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
47
|
+
expect(NativeModules.DdRum.stopAction).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('calls the native SDK when called with old API', async () => {
|
|
51
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
52
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
53
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
54
|
+
'scroll',
|
|
55
|
+
'page_old_api',
|
|
56
|
+
{ user: 'me' },
|
|
57
|
+
789
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('calls the native SDK when called with old API with default values', async () => {
|
|
62
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
63
|
+
await DdRum.stopAction();
|
|
64
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
65
|
+
'scroll',
|
|
66
|
+
'page_old_api',
|
|
67
|
+
{},
|
|
68
|
+
456
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('cleans the action data when stopAction is called', async () => {
|
|
73
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
74
|
+
await DdRum.stopAction();
|
|
75
|
+
await DdRum.stopAction();
|
|
76
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -9,9 +9,9 @@ import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
|
9
9
|
import { DdRum } from '../../../index';
|
|
10
10
|
import {
|
|
11
11
|
DdEventsInterceptor,
|
|
12
|
-
RumActionType,
|
|
13
12
|
UNKNOWN_TARGET_NAME
|
|
14
13
|
} from '../../../rum/instrumentation/DdEventsInterceptor';
|
|
14
|
+
import { RumActionType } from '../../../types';
|
|
15
15
|
|
|
16
16
|
jest.mock('../../../foundation', () => {
|
|
17
17
|
return {
|
|
@@ -31,7 +31,7 @@ jest.mock('../../../InternalLog', () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
|
|
34
|
-
jest.mock('react-native/Libraries/Animated/
|
|
34
|
+
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
35
35
|
jest.useFakeTimers();
|
|
36
36
|
|
|
37
37
|
let testedEventsInterceptor: DdEventsInterceptor;
|
|
@@ -61,7 +61,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
|
|
|
61
61
|
|
|
62
62
|
// THEN
|
|
63
63
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
64
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
64
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
65
65
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -88,7 +88,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
|
|
|
88
88
|
|
|
89
89
|
// THEN
|
|
90
90
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
91
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
91
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
92
92
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -106,7 +106,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with accessibilityL
|
|
|
106
106
|
|
|
107
107
|
// THEN
|
|
108
108
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
109
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
109
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
110
110
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
|
|
111
111
|
});
|
|
112
112
|
|
|
@@ -127,7 +127,7 @@ it('M send only one RUM Action event W interceptOnPress { called multiple times
|
|
|
127
127
|
|
|
128
128
|
// THEN
|
|
129
129
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
130
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
130
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
131
131
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
|
|
132
132
|
});
|
|
133
133
|
|
|
@@ -141,7 +141,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel argumen
|
|
|
141
141
|
|
|
142
142
|
// THEN
|
|
143
143
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
144
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
144
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
145
145
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -157,7 +157,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel argumen
|
|
|
157
157
|
|
|
158
158
|
// THEN
|
|
159
159
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
160
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
160
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
161
161
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -170,7 +170,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel, no ele
|
|
|
170
170
|
|
|
171
171
|
// THEN
|
|
172
172
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
173
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
173
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
174
174
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(UNKNOWN_TARGET_NAME);
|
|
175
175
|
});
|
|
176
176
|
|
|
@@ -31,7 +31,7 @@ const styles = StyleSheet.create({
|
|
|
31
31
|
jest.mock('../../../rum/instrumentation/DdEventsInterceptor');
|
|
32
32
|
|
|
33
33
|
// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
|
|
34
|
-
jest.mock('react-native/Libraries/Animated/
|
|
34
|
+
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
35
35
|
jest.useFakeTimers();
|
|
36
36
|
|
|
37
37
|
let originalMethod: typeof React.createElement;
|
package/src/foundation.tsx
CHANGED
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
|
-
import { DdSdkConfiguration,
|
|
8
|
+
import { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';
|
|
9
9
|
import {InternalLog} from "./InternalLog"
|
|
10
10
|
import {SdkVerbosity} from "./SdkVerbosity";
|
|
11
11
|
import {TimeProvider} from "./TimeProvider";
|
|
12
|
+
import type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';
|
|
12
13
|
|
|
13
14
|
const timeProvider = new TimeProvider();
|
|
14
15
|
|
|
15
16
|
class DdLogsWrapper implements DdLogsType {
|
|
16
17
|
|
|
17
|
-
private nativeLogs:
|
|
18
|
+
private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;
|
|
18
19
|
|
|
19
20
|
debug(message: string, context: object = {}): Promise<void> {
|
|
20
21
|
InternalLog.log("Tracking debug log “" + message + "”", SdkVerbosity.DEBUG);
|
|
@@ -40,7 +41,7 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
40
41
|
|
|
41
42
|
class DdTraceWrapper implements DdTraceType {
|
|
42
43
|
|
|
43
|
-
private nativeTrace:
|
|
44
|
+
private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;
|
|
44
45
|
|
|
45
46
|
startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {
|
|
46
47
|
let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
|
|
@@ -54,9 +55,18 @@ class DdTraceWrapper implements DdTraceType {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
const isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {
|
|
59
|
+
return typeof args[0] === 'string'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {
|
|
63
|
+
return typeof args[0] === 'object' || typeof args[0] === 'undefined'
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
class DdRumWrapper implements DdRumType {
|
|
58
67
|
|
|
59
|
-
private nativeRum:
|
|
68
|
+
private nativeRum: DdNativeRumType = NativeModules.DdRum;
|
|
69
|
+
private lastActionData?: {type: RumActionType, name: string}
|
|
60
70
|
|
|
61
71
|
startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {
|
|
62
72
|
InternalLog.log("Starting RUM View “" + name + "” #" + key, SdkVerbosity.DEBUG);
|
|
@@ -68,17 +78,36 @@ class DdRumWrapper implements DdRumType {
|
|
|
68
78
|
return this.nativeRum.stopView(key, context, timestampMs);
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
startAction(type:
|
|
81
|
+
startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {
|
|
72
82
|
InternalLog.log("Starting RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
|
|
83
|
+
this.lastActionData={type, name}
|
|
73
84
|
return this.nativeRum.startAction(type, name, context, timestampMs);
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
stopAction(
|
|
87
|
+
stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {
|
|
77
88
|
InternalLog.log("Stopping current RUM Action", SdkVerbosity.DEBUG);
|
|
78
|
-
|
|
89
|
+
let returnPromise = this.getStopActionNativeCall(args)
|
|
90
|
+
this.lastActionData = undefined
|
|
91
|
+
return returnPromise
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {
|
|
95
|
+
if (isNewStopActionAPI(args)) {
|
|
96
|
+
return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())
|
|
97
|
+
}
|
|
98
|
+
if (isOldStopActionAPI(args)) {
|
|
99
|
+
if (this.lastActionData) {
|
|
100
|
+
return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
|
|
101
|
+
}
|
|
102
|
+
InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", SdkVerbosity.WARN);
|
|
103
|
+
} else {
|
|
104
|
+
InternalLog.log("DdRum.stopAction was called with wrong arguments", SdkVerbosity.WARN);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return new Promise<void>(resolve => resolve())
|
|
79
108
|
}
|
|
80
109
|
|
|
81
|
-
addAction(type:
|
|
110
|
+
addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {
|
|
82
111
|
InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
|
|
83
112
|
return this.nativeRum.addAction(type, name, context, timestampMs);
|
|
84
113
|
}
|
|
@@ -88,12 +117,12 @@ class DdRumWrapper implements DdRumType {
|
|
|
88
117
|
return this.nativeRum.startResource(key, method, url, context, timestampMs);
|
|
89
118
|
}
|
|
90
119
|
|
|
91
|
-
stopResource(key: string, statusCode: number, kind:
|
|
120
|
+
stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {
|
|
92
121
|
InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, SdkVerbosity.DEBUG);
|
|
93
122
|
return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
|
|
94
123
|
}
|
|
95
124
|
|
|
96
|
-
addError(message: string, source:
|
|
125
|
+
addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {
|
|
97
126
|
InternalLog.log("Adding RUM Error “" + message + "”", SdkVerbosity.DEBUG);
|
|
98
127
|
let updatedContext: any = context;
|
|
99
128
|
updatedContext["_dd.error.source_type"] = "react-native";
|
|
@@ -106,7 +135,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
106
135
|
}
|
|
107
136
|
}
|
|
108
137
|
|
|
109
|
-
const DdSdk:
|
|
138
|
+
const DdSdk: DdNativeSdkType = NativeModules.DdSdk;
|
|
110
139
|
const DdLogs: DdLogsType = new DdLogsWrapper();
|
|
111
140
|
const DdTrace: DdTraceType = new DdTraceWrapper();
|
|
112
141
|
const DdRum: DdRumType = new DdRumWrapper();
|
|
@@ -0,0 +1,258 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* A configuration object to initialize Datadog's features.
|
|
9
|
+
*/
|
|
10
|
+
export class DdNativeSdkConfiguration {
|
|
11
|
+
constructor(
|
|
12
|
+
readonly clientToken: string,
|
|
13
|
+
readonly env: string,
|
|
14
|
+
readonly applicationId: string,
|
|
15
|
+
readonly nativeCrashReportEnabled: boolean,
|
|
16
|
+
readonly sampleRate: number,
|
|
17
|
+
readonly site: string,
|
|
18
|
+
readonly trackingConsent: string,
|
|
19
|
+
readonly additionalConfig: object
|
|
20
|
+
) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The entry point to initialize Datadog's features.
|
|
25
|
+
*/
|
|
26
|
+
export type DdNativeSdkType = {
|
|
27
|
+
/**
|
|
28
|
+
* Initializes Datadog's features.
|
|
29
|
+
* @param configuration: The configuration to use.
|
|
30
|
+
*/
|
|
31
|
+
initialize(configuration: DdNativeSdkConfiguration): Promise<void>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
35
|
+
* @param attributes: The global context attributes.
|
|
36
|
+
*/
|
|
37
|
+
setAttributes(attributes: object): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Set the user information.
|
|
41
|
+
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
42
|
+
*/
|
|
43
|
+
setUser(user: object): Promise<void>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set the tracking consent regarding the data collection.
|
|
47
|
+
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
48
|
+
*/
|
|
49
|
+
setTrackingConsent(trackingConsent: string): Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The entry point to use Datadog's Logs feature.
|
|
54
|
+
*/
|
|
55
|
+
export type DdNativeLogsType = {
|
|
56
|
+
/**
|
|
57
|
+
* Send a log with level debug.
|
|
58
|
+
* @param message: The message to send.
|
|
59
|
+
* @param context: The additional context to send.
|
|
60
|
+
*/
|
|
61
|
+
debug(message: string, context?: object): Promise<void>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Send a log with level info.
|
|
65
|
+
* @param message: The message to send.
|
|
66
|
+
* @param context: The additional context to send.
|
|
67
|
+
*/
|
|
68
|
+
info(message: string, context?: object): Promise<void>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Send a log with level warn.
|
|
72
|
+
* @param message: The message to send.
|
|
73
|
+
* @param context: The additional context to send.
|
|
74
|
+
*/
|
|
75
|
+
warn(message: string, context?: object): Promise<void>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Send a log with level error.
|
|
79
|
+
* @param message: The message to send.
|
|
80
|
+
* @param context: The additional context to send.
|
|
81
|
+
*/
|
|
82
|
+
error(message: string, context?: object): Promise<void>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The entry point to use Datadog's Trace feature.
|
|
87
|
+
*/
|
|
88
|
+
export type DdNativeTraceType = {
|
|
89
|
+
/**
|
|
90
|
+
* Start a span, and returns a unique identifier for the span.
|
|
91
|
+
* @param operation: The operation name of the span.
|
|
92
|
+
* @param context: The additional context to send.
|
|
93
|
+
* @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
|
|
94
|
+
*/
|
|
95
|
+
startSpan(
|
|
96
|
+
operation: string,
|
|
97
|
+
context?: object,
|
|
98
|
+
timestampMs?: number
|
|
99
|
+
): Promise<string>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Finish a started span.
|
|
103
|
+
* @param spanId: The unique identifier of the span.
|
|
104
|
+
* @param context: The additional context to send.
|
|
105
|
+
* @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
106
|
+
*/
|
|
107
|
+
finishSpan(
|
|
108
|
+
spanId: string,
|
|
109
|
+
context?: object,
|
|
110
|
+
timestampMs?: number
|
|
111
|
+
): Promise<void>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The entry point to use Datadog's RUM feature.
|
|
116
|
+
*/
|
|
117
|
+
export type DdNativeRumType = {
|
|
118
|
+
/**
|
|
119
|
+
* Start tracking a RUM View.
|
|
120
|
+
* @param key: The view unique key identifier.
|
|
121
|
+
* @param name: The view name.
|
|
122
|
+
* @param context: The additional context to send.
|
|
123
|
+
* @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
124
|
+
*/
|
|
125
|
+
startView(
|
|
126
|
+
key: string,
|
|
127
|
+
name: string,
|
|
128
|
+
context?: object,
|
|
129
|
+
timestampMs?: number
|
|
130
|
+
): Promise<void>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Stop tracking a RUM View.
|
|
134
|
+
* @param key: The view unique key identifier.
|
|
135
|
+
* @param context: The additional context to send.
|
|
136
|
+
* @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
137
|
+
*/
|
|
138
|
+
stopView(
|
|
139
|
+
key: string,
|
|
140
|
+
context?: object,
|
|
141
|
+
timestampMs?: number
|
|
142
|
+
): Promise<void>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Start tracking a RUM Action.
|
|
146
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
147
|
+
* @param name: The action name.
|
|
148
|
+
* @param context: The additional context to send.
|
|
149
|
+
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
150
|
+
*/
|
|
151
|
+
startAction(
|
|
152
|
+
type: ActionType,
|
|
153
|
+
name: string,
|
|
154
|
+
context?: object,
|
|
155
|
+
timestampMs?: number
|
|
156
|
+
): Promise<void>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
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: ActionType,
|
|
167
|
+
name: string,
|
|
168
|
+
context?: object,
|
|
169
|
+
timestampMs?: number
|
|
170
|
+
): Promise<void>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Add a RUM Action.
|
|
174
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
175
|
+
* @param name: The action name.
|
|
176
|
+
* @param context: The additional context to send.
|
|
177
|
+
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
178
|
+
*/
|
|
179
|
+
addAction(
|
|
180
|
+
type: ActionType,
|
|
181
|
+
name: string,
|
|
182
|
+
context?: object,
|
|
183
|
+
timestampMs?: number
|
|
184
|
+
): Promise<void>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Start tracking a RUM Resource.
|
|
188
|
+
* @param key: The resource unique key identifier.
|
|
189
|
+
* @param method: The resource method (GET, POST, …).
|
|
190
|
+
* @param url: The resource url.
|
|
191
|
+
* @param context: The additional context to send.
|
|
192
|
+
* @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
193
|
+
*/
|
|
194
|
+
startResource(
|
|
195
|
+
key: string,
|
|
196
|
+
method: string,
|
|
197
|
+
url: string,
|
|
198
|
+
context?: object,
|
|
199
|
+
timestampMs?: number
|
|
200
|
+
): Promise<void>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Stop tracking a RUM Resource.
|
|
204
|
+
* @param key: The resource unique key identifier.
|
|
205
|
+
* @param statusCode: The resource status code.
|
|
206
|
+
* @param kind: The resource's kind (xhr, document, image, css, font, …).
|
|
207
|
+
* @param size: The resource size in bytes. If size is unknown, use -1.
|
|
208
|
+
* @param context: The additional context to send.
|
|
209
|
+
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
210
|
+
*/
|
|
211
|
+
stopResource(
|
|
212
|
+
key: string,
|
|
213
|
+
statusCode: number,
|
|
214
|
+
kind: ResourceKind,
|
|
215
|
+
size?: number,
|
|
216
|
+
context?: object,
|
|
217
|
+
timestampMs?: number
|
|
218
|
+
): Promise<void>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Add a RUM Error.
|
|
222
|
+
* @param message: The error message.
|
|
223
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
224
|
+
* @param stacktrace: The error stacktrace.
|
|
225
|
+
* @param context: The additional context to send.
|
|
226
|
+
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
227
|
+
*/
|
|
228
|
+
addError(
|
|
229
|
+
message: string,
|
|
230
|
+
source: ErrorSource,
|
|
231
|
+
stacktrace: string,
|
|
232
|
+
context?: object,
|
|
233
|
+
timestampMs?: number
|
|
234
|
+
): Promise<void>;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 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.
|
|
238
|
+
* @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.
|
|
239
|
+
*/
|
|
240
|
+
addTiming(name: string): Promise<void>;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
|
|
244
|
+
|
|
245
|
+
type ResourceKind =
|
|
246
|
+
| 'image'
|
|
247
|
+
| 'xhr'
|
|
248
|
+
| 'beacon'
|
|
249
|
+
| 'css'
|
|
250
|
+
| 'document'
|
|
251
|
+
| 'fetch'
|
|
252
|
+
| 'font'
|
|
253
|
+
| 'js'
|
|
254
|
+
| 'media'
|
|
255
|
+
| 'other'
|
|
256
|
+
| 'native';
|
|
257
|
+
|
|
258
|
+
type ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';
|