@datadog/mobile-react-native 1.0.0-rc3 → 1.0.0-rc6
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 +1 -1
- package/README.md +47 -16
- package/android/build.gradle +2 -3
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +25 -24
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +6 -6
- package/ios/Sources/DdRum.m +10 -9
- package/ios/Sources/DdRum.swift +24 -24
- package/ios/Sources/DdTrace.m +2 -2
- package/ios/Sources/DdTrace.swift +6 -6
- package/lib/commonjs/DdSdkReactNative.js +42 -22
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +17 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +51 -0
- package/lib/commonjs/InternalLog.js.map +1 -0
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/SdkVerbosity.js +26 -0
- package/lib/commonjs/SdkVerbosity.js.map +1 -0
- package/lib/commonjs/TimeProvider.js +72 -0
- package/lib/commonjs/TimeProvider.js.map +1 -0
- package/lib/commonjs/Timer.js +10 -23
- package/lib/commonjs/Timer.js.map +1 -1
- package/lib/commonjs/TrackingConsent.js.map +1 -1
- package/lib/commonjs/foundation.js +62 -40
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +26 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +14 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +14 -5
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +51 -20
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +141 -30
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -7
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +34 -22
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -3
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +46 -0
- package/lib/module/InternalLog.js.map +1 -0
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/SdkVerbosity.js +18 -0
- package/lib/module/SdkVerbosity.js.map +1 -0
- package/lib/module/TimeProvider.js +63 -0
- package/lib/module/TimeProvider.js.map +1 -0
- package/lib/module/Timer.js +14 -23
- package/lib/module/Timer.js.map +1 -1
- package/lib/module/TrackingConsent.js.map +1 -1
- package/lib/module/foundation.js +42 -40
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +2 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +11 -5
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +46 -20
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +133 -29
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +41 -6
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/DdSdkReactNative.d.ts +7 -6
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -4
- package/lib/typescript/InternalLog.d.ts +6 -0
- package/lib/typescript/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/TimeProvider.d.ts +20 -0
- package/lib/typescript/Timer.d.ts +3 -2
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/internal.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +13 -8
- package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
- package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
- package/lib/typescript/types.d.ts +12 -11
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +7 -4
- package/src/DdSdkReactNative.tsx +112 -58
- package/src/DdSdkReactNativeConfiguration.tsx +22 -14
- package/src/InternalLog.tsx +45 -0
- package/src/ProxyConfiguration.tsx +5 -5
- package/src/{NativeSdkVerbosity.tsx → SdkVerbosity.tsx} +6 -6
- package/src/TimeProvider.tsx +64 -0
- package/src/Timer.ts +20 -35
- package/src/TrackingConsent.tsx +3 -3
- package/src/__mocks__/InternalLog.tsx +9 -0
- package/src/__tests__/DdRumWrapper.test.tsx +98 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +699 -500
- package/src/__tests__/InternalLog.test.tsx +379 -0
- package/src/__tests__/TimeProvider.test.tsx +75 -0
- package/src/__tests__/Timer.test.ts +148 -57
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +243 -76
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +723 -403
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
- package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
- package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
- package/src/foundation.tsx +55 -42
- package/src/index.tsx +13 -3
- package/src/internal.tsx +1 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +75 -42
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +312 -166
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -25
- package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
- package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
- package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
- package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
- package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
- package/src/types.tsx +199 -157
- package/src/version.ts +2 -0
- package/lib/commonjs/NativeSdkVerbosity.js +0 -26
- package/lib/commonjs/NativeSdkVerbosity.js.map +0 -1
- package/lib/module/NativeSdkVerbosity.js +0 -18
- package/lib/module/NativeSdkVerbosity.js.map +0 -1
- package/lib/typescript/NativeSdkVerbosity.d.ts +0 -9
|
@@ -25,13 +25,13 @@ class ProxyConfiguration {
|
|
|
25
25
|
* Password for Basic authentication scheme.
|
|
26
26
|
*/
|
|
27
27
|
readonly password?: string
|
|
28
|
-
) {
|
|
28
|
+
) {}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
enum ProxyType {
|
|
32
|
-
HTTP =
|
|
33
|
-
HTTPS =
|
|
34
|
-
SOCKS =
|
|
32
|
+
HTTP = 'http',
|
|
33
|
+
HTTPS = 'https',
|
|
34
|
+
SOCKS = 'socks'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export { ProxyConfiguration, ProxyType }
|
|
37
|
+
export { ProxyConfiguration, ProxyType };
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Enum specifying possible
|
|
8
|
+
* Enum specifying possible log levels for DD SDK.
|
|
9
9
|
*/
|
|
10
|
-
export enum
|
|
11
|
-
DEBUG =
|
|
12
|
-
INFO =
|
|
13
|
-
WARN =
|
|
14
|
-
ERROR =
|
|
10
|
+
export enum SdkVerbosity {
|
|
11
|
+
DEBUG = 'debug',
|
|
12
|
+
INFO = 'info',
|
|
13
|
+
WARN = 'warn',
|
|
14
|
+
ERROR = 'error'
|
|
15
15
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 Timestamp structure holding the
|
|
9
|
+
*/
|
|
10
|
+
export type Timestamp = {
|
|
11
|
+
// Result of Date API. Unix timestamp in ms.
|
|
12
|
+
unix: number;
|
|
13
|
+
// Result of performance.now API. Timestamp in ms (with microsecond precision)
|
|
14
|
+
// since JS context start.
|
|
15
|
+
react_native: number | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Simple class providing timestamps in milliseconds.
|
|
20
|
+
* If available, it will use the `performance.now()` method, and will fallback on `Date.now()` otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export class TimeProvider {
|
|
23
|
+
private canUsePerformanceNow =
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
global.performance && typeof performance.now === 'function';
|
|
27
|
+
|
|
28
|
+
/** Keeps an average offset between the unix time and the provided timestamp. */
|
|
29
|
+
private baseOffset: number;
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
const timestamp = this.getTimestamp();
|
|
33
|
+
if (timestamp.react_native == null) {
|
|
34
|
+
this.baseOffset = 0;
|
|
35
|
+
} else {
|
|
36
|
+
this.baseOffset = timestamp.unix - timestamp.react_native;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getTimestamp(): Timestamp {
|
|
41
|
+
return {
|
|
42
|
+
unix: Date.now(),
|
|
43
|
+
react_native: this.performanceNow()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
now(): number {
|
|
48
|
+
const timestamp = this.getTimestamp();
|
|
49
|
+
if (timestamp.react_native == null) {
|
|
50
|
+
return timestamp.unix;
|
|
51
|
+
} else {
|
|
52
|
+
return this.baseOffset + timestamp.react_native;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private performanceNow(): number | null {
|
|
57
|
+
if (this.canUsePerformanceNow) {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
return performance.now();
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/Timer.ts
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
react_native: number | null
|
|
7
|
-
}
|
|
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
|
+
*/
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import type { Timestamp } from './TimeProvider';
|
|
8
|
+
import { TimeProvider } from './TimeProvider';
|
|
9
|
+
|
|
10
|
+
const START_LABEL = '__start';
|
|
11
|
+
const STOP_LABEL = '__stop';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Simple timer which records time ticks. Shouldn't be re-used once stopped.
|
|
14
15
|
* All timestamps/durations returned are in milliseconds.
|
|
15
16
|
*/
|
|
16
17
|
export default class Timer {
|
|
17
|
-
|
|
18
|
+
private timeProvider: TimeProvider;
|
|
18
19
|
private times: Record<string, Timestamp> = {};
|
|
19
20
|
|
|
21
|
+
constructor(timeProvider: TimeProvider = new TimeProvider()) {
|
|
22
|
+
this.timeProvider = timeProvider;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
get startTime(): number {
|
|
21
|
-
return this.times[START_LABEL].unix
|
|
26
|
+
return this.times[START_LABEL].unix;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
get stopTime(): number {
|
|
25
|
-
return this.startTime + this.durationBetween(START_LABEL, STOP_LABEL)
|
|
30
|
+
return this.startTime + this.durationBetween(START_LABEL, STOP_LABEL);
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
start(): void {
|
|
@@ -30,14 +35,11 @@ export default class Timer {
|
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
stop(): void {
|
|
33
|
-
this.recordTick(STOP_LABEL)
|
|
38
|
+
this.recordTick(STOP_LABEL);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
recordTick(label: string): void {
|
|
37
|
-
this.times[label] =
|
|
38
|
-
unix: Date.now(),
|
|
39
|
-
react_native: this.performanceNow()
|
|
40
|
-
}
|
|
42
|
+
this.times[label] = this.timeProvider.getTimestamp();
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
hasTickFor(label: string): boolean {
|
|
@@ -57,7 +59,7 @@ export default class Timer {
|
|
|
57
59
|
timeAt(label: string): number {
|
|
58
60
|
this.checkLabelExists(label);
|
|
59
61
|
|
|
60
|
-
return this.startTime + this.durationBetween(START_LABEL, label)
|
|
62
|
+
return this.startTime + this.durationBetween(START_LABEL, label);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
reset(): void {
|
|
@@ -71,26 +73,9 @@ export default class Timer {
|
|
|
71
73
|
return end.unix - start.unix;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
private performanceNow(): number | null {
|
|
76
|
-
if (this.canUsePerformanceNow()) {
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
return performance.now();
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private canUsePerformanceNow(): boolean {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
return global.performance && typeof performance.now === 'function';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
76
|
private checkLabelExists(label: string) {
|
|
91
77
|
if (!this.hasTickFor(label)) {
|
|
92
78
|
throw new Error(`Label ${label} is not registered`);
|
|
93
79
|
}
|
|
94
80
|
}
|
|
95
|
-
|
|
96
81
|
}
|
package/src/TrackingConsent.tsx
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export const InternalLog = {
|
|
8
|
+
log: jest.fn()
|
|
9
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
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('react-native', () => {
|
|
12
|
+
return {
|
|
13
|
+
NativeModules: {
|
|
14
|
+
DdRum: {
|
|
15
|
+
startView: jest.fn().mockImplementation(() => {}),
|
|
16
|
+
stopView: jest.fn().mockImplementation(() => {}),
|
|
17
|
+
startAction: jest.fn().mockImplementation(() => {}),
|
|
18
|
+
stopAction: jest.fn().mockImplementation(() => {}),
|
|
19
|
+
addAction: jest.fn().mockImplementation(() => {}),
|
|
20
|
+
startResource: jest.fn().mockImplementation(() => {}),
|
|
21
|
+
stopResource: jest.fn().mockImplementation(() => {}),
|
|
22
|
+
addError: jest.fn().mockImplementation(() => {}),
|
|
23
|
+
addTiming: jest.fn().mockImplementation(() => {})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
NativeModules.DdRum.startView.mockClear();
|
|
31
|
+
NativeModules.DdRum.stopView.mockClear();
|
|
32
|
+
NativeModules.DdRum.startAction.mockClear();
|
|
33
|
+
NativeModules.DdRum.stopAction.mockClear();
|
|
34
|
+
NativeModules.DdRum.addAction.mockClear();
|
|
35
|
+
NativeModules.DdRum.startResource.mockClear();
|
|
36
|
+
NativeModules.DdRum.stopResource.mockClear();
|
|
37
|
+
NativeModules.DdRum.addError.mockClear();
|
|
38
|
+
NativeModules.DdRum.addTiming.mockClear();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('M add error source type W addError()', async () => {
|
|
42
|
+
// Given
|
|
43
|
+
const message = 'Oops I did it again!';
|
|
44
|
+
const source = 'SOURCE';
|
|
45
|
+
const stacktrace = 'doSomething() at ./path/to/file.js:67:3';
|
|
46
|
+
const before = Date.now();
|
|
47
|
+
|
|
48
|
+
// When
|
|
49
|
+
DdRum.addError(message, source, stacktrace);
|
|
50
|
+
|
|
51
|
+
// Then
|
|
52
|
+
const after = Date.now();
|
|
53
|
+
expect(NativeModules.DdRum.addError.mock.calls.length).toBe(1);
|
|
54
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][0]).toBe(message);
|
|
55
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][1]).toBe(source);
|
|
56
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][2]).toBe(stacktrace);
|
|
57
|
+
expect(
|
|
58
|
+
NativeModules.DdRum.addError.mock.calls[0][4]
|
|
59
|
+
).toBeGreaterThanOrEqual(before);
|
|
60
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][4]).toBeLessThanOrEqual(
|
|
61
|
+
after
|
|
62
|
+
);
|
|
63
|
+
const context = NativeModules.DdRum.addError.mock.calls[0][3];
|
|
64
|
+
expect(context['_dd.error.source_type']).toStrictEqual('react-native');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('M add error source type W addError() {with custom attributes}', async () => {
|
|
68
|
+
// Given
|
|
69
|
+
const message = 'Oops I did it again!';
|
|
70
|
+
const source = 'SOURCE';
|
|
71
|
+
const stacktrace = 'doSomething() at ./path/to/file.js:67:3';
|
|
72
|
+
const random = Math.random();
|
|
73
|
+
const attributes = {
|
|
74
|
+
foo: 'bar',
|
|
75
|
+
spam: random
|
|
76
|
+
};
|
|
77
|
+
const before = Date.now();
|
|
78
|
+
|
|
79
|
+
// When
|
|
80
|
+
DdRum.addError(message, source, stacktrace, attributes);
|
|
81
|
+
|
|
82
|
+
// Then
|
|
83
|
+
const after = Date.now();
|
|
84
|
+
expect(NativeModules.DdRum.addError.mock.calls.length).toBe(1);
|
|
85
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][0]).toBe(message);
|
|
86
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][1]).toBe(source);
|
|
87
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][2]).toBe(stacktrace);
|
|
88
|
+
expect(
|
|
89
|
+
NativeModules.DdRum.addError.mock.calls[0][4]
|
|
90
|
+
).toBeGreaterThanOrEqual(before);
|
|
91
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][4]).toBeLessThanOrEqual(
|
|
92
|
+
after
|
|
93
|
+
);
|
|
94
|
+
const context = NativeModules.DdRum.addError.mock.calls[0][3];
|
|
95
|
+
expect(context['_dd.error.source_type']).toStrictEqual('react-native');
|
|
96
|
+
expect(context['foo']).toStrictEqual('bar');
|
|
97
|
+
expect(context['spam']).toStrictEqual(random);
|
|
98
|
+
});
|