@datadog/mobile-react-native 1.0.0-rc5 → 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/README.md +46 -17
- package/android/gradle.properties +4 -4
- package/lib/commonjs/DdSdkReactNative.js +31 -31
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -7
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +5 -5
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/SdkVerbosity.js.map +1 -1
- 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 +19 -54
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +21 -21
- 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 +16 -11
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +19 -23
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +60 -42
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -19
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -4
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js +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 +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +29 -29
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +19 -8
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +5 -5
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/SdkVerbosity.js.map +1 -1
- 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 +16 -39
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +2 -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 +12 -10
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +19 -23
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +57 -38
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +44 -17
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumXhr.js +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js +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 +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +6 -6
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -3
- package/lib/typescript/TimeProvider.d.ts +20 -0
- package/lib/typescript/Timer.d.ts +3 -2
- package/lib/typescript/index.d.ts +2 -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 +2 -2
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +10 -9
- 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/version.d.ts +1 -1
- package/package.json +6 -3
- package/src/DdSdkReactNative.tsx +112 -70
- package/src/DdSdkReactNativeConfiguration.tsx +21 -13
- package/src/InternalLog.tsx +13 -16
- package/src/ProxyConfiguration.tsx +5 -5
- package/src/SdkVerbosity.tsx +4 -4
- 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 +40 -33
- package/src/__tests__/DdSdkReactNative.test.tsx +697 -513
- package/src/__tests__/InternalLog.test.tsx +114 -117
- 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 +168 -116
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +714 -644
- 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 +13 -10
- package/src/index.tsx +13 -4
- package/src/internal.tsx +1 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +49 -44
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +308 -238
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -29
- 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 -158
- package/src/version.ts +1 -1
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import { DdRumErrorTracking } from '../../../rum/instrumentation/DdRumErrorTracking'
|
|
6
|
+
|
|
8
7
|
import { DdRum } from '../../../index';
|
|
8
|
+
import { DdRumErrorTracking } from '../../../rum/instrumentation/DdRumErrorTracking';
|
|
9
9
|
|
|
10
|
-
jest.useFakeTimers()
|
|
10
|
+
jest.useFakeTimers();
|
|
11
11
|
|
|
12
12
|
jest.mock('../../../foundation', () => {
|
|
13
13
|
return {
|
|
@@ -16,22 +16,21 @@ jest.mock('../../../foundation', () => {
|
|
|
16
16
|
addError: jest.fn().mockImplementation(() => {
|
|
17
17
|
return Promise.resolve();
|
|
18
18
|
})
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
let baseErrorHandlerCalled = false;
|
|
25
|
-
|
|
26
|
-
baseErrorHandlerCalled = true
|
|
24
|
+
const baseErrorHandler = (error: any, isFatal?: boolean) => {
|
|
25
|
+
baseErrorHandlerCalled = true;
|
|
27
26
|
};
|
|
28
|
-
let originalErrorHandler
|
|
27
|
+
let originalErrorHandler;
|
|
29
28
|
|
|
30
29
|
let baseConsoleErrorCalled = false;
|
|
31
|
-
|
|
32
|
-
baseConsoleErrorCalled = true
|
|
33
|
-
}
|
|
34
|
-
let originalConsoleError
|
|
30
|
+
const baseConsoleError = (...params: unknown) => {
|
|
31
|
+
baseConsoleErrorCalled = true;
|
|
32
|
+
};
|
|
33
|
+
let originalConsoleError;
|
|
35
34
|
|
|
36
35
|
const flushPromises = () => new Promise(setImmediate);
|
|
37
36
|
|
|
@@ -42,21 +41,21 @@ beforeEach(() => {
|
|
|
42
41
|
ErrorUtils.setGlobalHandler(baseErrorHandler);
|
|
43
42
|
originalConsoleError = console.error;
|
|
44
43
|
console.error = baseConsoleError;
|
|
45
|
-
jest.setTimeout(20000)
|
|
46
|
-
})
|
|
44
|
+
jest.setTimeout(20000);
|
|
45
|
+
});
|
|
47
46
|
|
|
48
47
|
afterEach(() => {
|
|
49
|
-
DdRumErrorTracking['isTracking'] = false
|
|
50
|
-
ErrorUtils.setGlobalHandler(originalErrorHandler)
|
|
51
|
-
console.error = originalConsoleError
|
|
52
|
-
})
|
|
48
|
+
DdRumErrorTracking['isTracking'] = false;
|
|
49
|
+
ErrorUtils.setGlobalHandler(originalErrorHandler);
|
|
50
|
+
console.error = originalConsoleError;
|
|
51
|
+
});
|
|
53
52
|
|
|
54
53
|
it('M intercept and send a RUM event W onGlobalError() {no message}', async () => {
|
|
55
54
|
// GIVEN
|
|
56
55
|
DdRumErrorTracking.startTracking();
|
|
57
56
|
const is_fatal = Math.random() < 0.5;
|
|
58
57
|
const error = {
|
|
59
|
-
|
|
58
|
+
stack: ['doSomething() at ./path/to/file.js:67:3']
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
// WHEN
|
|
@@ -66,20 +65,22 @@ it('M intercept and send a RUM event W onGlobalError() {no message}', async () =
|
|
|
66
65
|
// THEN
|
|
67
66
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
68
67
|
expect(DdRum.addError.mock.calls[0][0]).toBe(String(error));
|
|
69
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
70
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
68
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
69
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
70
|
+
'doSomething() at ./path/to/file.js:67:3'
|
|
71
|
+
);
|
|
71
72
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
72
|
-
expect(attributes[
|
|
73
|
-
expect(attributes[
|
|
73
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
74
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
74
75
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
75
|
-
})
|
|
76
|
+
});
|
|
76
77
|
|
|
77
78
|
it('M intercept and send a RUM event W onGlobalError() {empty stack trace}', async () => {
|
|
78
79
|
// GIVEN
|
|
79
80
|
DdRumErrorTracking.startTracking();
|
|
80
81
|
const is_fatal = Math.random() < 0.5;
|
|
81
82
|
const error = {
|
|
82
|
-
|
|
83
|
+
message: 'Something bad happened'
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
// WHEN
|
|
@@ -88,14 +89,14 @@ it('M intercept and send a RUM event W onGlobalError() {empty stack trace}', asy
|
|
|
88
89
|
|
|
89
90
|
// THEN
|
|
90
91
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
91
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
92
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
93
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
92
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
93
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
94
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe('');
|
|
94
95
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
95
|
-
expect(attributes[
|
|
96
|
-
expect(attributes[
|
|
96
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
97
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
97
98
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
98
|
-
})
|
|
99
|
+
});
|
|
99
100
|
|
|
100
101
|
it('M intercept and send a RUM event W onGlobalError() {Error object}', async () => {
|
|
101
102
|
// GIVEN
|
|
@@ -109,26 +110,29 @@ it('M intercept and send a RUM event W onGlobalError() {Error object}', async ()
|
|
|
109
110
|
|
|
110
111
|
// THEN
|
|
111
112
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
112
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
113
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
114
|
-
expect(DdRum.addError.mock.calls[0][2]).toContain(
|
|
115
|
-
|
|
113
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
114
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
115
|
+
expect(DdRum.addError.mock.calls[0][2]).toContain(
|
|
116
|
+
'Error: Something bad happened'
|
|
117
|
+
);
|
|
118
|
+
expect(DdRum.addError.mock.calls[0][2]).toContain(
|
|
119
|
+
'/packages/core/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx'
|
|
120
|
+
);
|
|
116
121
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
117
|
-
expect(attributes[
|
|
118
|
-
expect(attributes[
|
|
122
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
123
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
119
124
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
120
|
-
})
|
|
121
|
-
|
|
125
|
+
});
|
|
122
126
|
|
|
123
127
|
it('M intercept and send a RUM event W onGlobalError() {with source file info}', async () => {
|
|
124
128
|
// GIVEN
|
|
125
129
|
DdRumErrorTracking.startTracking();
|
|
126
130
|
const is_fatal = Math.random() < 0.5;
|
|
127
131
|
const error = {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
sourceURL: './path/to/file.js',
|
|
133
|
+
line: 1038,
|
|
134
|
+
column: 57,
|
|
135
|
+
message: 'Something bad happened'
|
|
132
136
|
};
|
|
133
137
|
|
|
134
138
|
// WHEN
|
|
@@ -137,23 +141,28 @@ it('M intercept and send a RUM event W onGlobalError() {with source file info}',
|
|
|
137
141
|
|
|
138
142
|
// THEN
|
|
139
143
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
140
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
141
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
142
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
144
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
145
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
146
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
147
|
+
'at ./path/to/file.js:1038:57'
|
|
148
|
+
);
|
|
143
149
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
144
|
-
expect(attributes[
|
|
145
|
-
expect(attributes[
|
|
150
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
151
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
146
152
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
147
|
-
})
|
|
148
|
-
|
|
153
|
+
});
|
|
149
154
|
|
|
150
155
|
it('M intercept and send a RUM event W onGlobalError() {with component stack}', async () => {
|
|
151
156
|
// GIVEN
|
|
152
157
|
DdRumErrorTracking.startTracking();
|
|
153
158
|
const is_fatal = Math.random() < 0.5;
|
|
154
159
|
const error = {
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
componentStack: [
|
|
161
|
+
'doSomething() at ./path/to/file.js:67:3',
|
|
162
|
+
'nestedCall() at ./path/to/file.js:1064:9',
|
|
163
|
+
'root() at ./path/to/index.js:10:1'
|
|
164
|
+
],
|
|
165
|
+
message: 'Something bad happened'
|
|
157
166
|
};
|
|
158
167
|
|
|
159
168
|
// WHEN
|
|
@@ -162,22 +171,28 @@ it('M intercept and send a RUM event W onGlobalError() {with component stack}',
|
|
|
162
171
|
|
|
163
172
|
// THEN
|
|
164
173
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
165
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
166
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
167
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
174
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
175
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
176
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
177
|
+
'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1'
|
|
178
|
+
);
|
|
168
179
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
169
|
-
expect(attributes[
|
|
170
|
-
expect(attributes[
|
|
180
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
181
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
171
182
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
172
|
-
})
|
|
183
|
+
});
|
|
173
184
|
|
|
174
185
|
it('M intercept and send a RUM event W onGlobalError() {with stack}', async () => {
|
|
175
186
|
// GIVEN
|
|
176
187
|
DdRumErrorTracking.startTracking();
|
|
177
188
|
const is_fatal = Math.random() < 0.5;
|
|
178
189
|
const error = {
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
stack: [
|
|
191
|
+
'doSomething() at ./path/to/file.js:67:3',
|
|
192
|
+
'nestedCall() at ./path/to/file.js:1064:9',
|
|
193
|
+
'root() at ./path/to/index.js:10:1'
|
|
194
|
+
],
|
|
195
|
+
message: 'Something bad happened'
|
|
181
196
|
};
|
|
182
197
|
|
|
183
198
|
// WHEN
|
|
@@ -186,22 +201,28 @@ it('M intercept and send a RUM event W onGlobalError() {with stack}', async () =
|
|
|
186
201
|
|
|
187
202
|
// THEN
|
|
188
203
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
189
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
190
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
191
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
204
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
205
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
206
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
207
|
+
'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1'
|
|
208
|
+
);
|
|
192
209
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
193
|
-
expect(attributes[
|
|
194
|
-
expect(attributes[
|
|
210
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
211
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
195
212
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
196
|
-
})
|
|
213
|
+
});
|
|
197
214
|
|
|
198
215
|
it('M intercept and send a RUM event W onGlobalError() {with stacktrace}', async () => {
|
|
199
216
|
// GIVEN
|
|
200
217
|
DdRumErrorTracking.startTracking();
|
|
201
218
|
const is_fatal = Math.random() < 0.5;
|
|
202
219
|
const error = {
|
|
203
|
-
|
|
204
|
-
|
|
220
|
+
stacktrace: [
|
|
221
|
+
'doSomething() at ./path/to/file.js:67:3',
|
|
222
|
+
'nestedCall() at ./path/to/file.js:1064:9',
|
|
223
|
+
'root() at ./path/to/index.js:10:1'
|
|
224
|
+
],
|
|
225
|
+
message: 'Something bad happened'
|
|
205
226
|
};
|
|
206
227
|
|
|
207
228
|
// WHEN
|
|
@@ -210,18 +231,20 @@ it('M intercept and send a RUM event W onGlobalError() {with stacktrace}', async
|
|
|
210
231
|
|
|
211
232
|
// THEN
|
|
212
233
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
213
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
214
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
215
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
234
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
235
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
236
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
237
|
+
'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1'
|
|
238
|
+
);
|
|
216
239
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
217
|
-
expect(attributes[
|
|
218
|
-
expect(attributes[
|
|
240
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
241
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
219
242
|
expect(baseErrorHandlerCalled).toStrictEqual(true);
|
|
220
|
-
})
|
|
243
|
+
});
|
|
221
244
|
|
|
222
245
|
it('M not report error in console handler W onGlobalError() {with console reporting handler}', async () => {
|
|
223
246
|
// GIVEN
|
|
224
|
-
const consoleReportingErrorHandler = jest.fn((error, isFatal)=> {
|
|
247
|
+
const consoleReportingErrorHandler = jest.fn((error, isFatal) => {
|
|
225
248
|
console.error(error.message);
|
|
226
249
|
baseErrorHandler(error, isFatal);
|
|
227
250
|
});
|
|
@@ -229,8 +252,12 @@ it('M not report error in console handler W onGlobalError() {with console report
|
|
|
229
252
|
DdRumErrorTracking.startTracking();
|
|
230
253
|
const is_fatal = Math.random() < 0.5;
|
|
231
254
|
const error = {
|
|
232
|
-
|
|
233
|
-
|
|
255
|
+
componentStack: [
|
|
256
|
+
'doSomething() at ./path/to/file.js:67:3',
|
|
257
|
+
'nestedCall() at ./path/to/file.js:1064:9',
|
|
258
|
+
'root() at ./path/to/index.js:10:1'
|
|
259
|
+
],
|
|
260
|
+
message: 'Something bad happened'
|
|
234
261
|
};
|
|
235
262
|
|
|
236
263
|
// WHEN
|
|
@@ -239,25 +266,27 @@ it('M not report error in console handler W onGlobalError() {with console report
|
|
|
239
266
|
|
|
240
267
|
// THEN
|
|
241
268
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
242
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
243
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
244
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
269
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe('Something bad happened');
|
|
270
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('SOURCE');
|
|
271
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
272
|
+
'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1'
|
|
273
|
+
);
|
|
245
274
|
const attributes = DdRum.addError.mock.calls[0][3];
|
|
246
|
-
expect(attributes[
|
|
247
|
-
expect(attributes[
|
|
275
|
+
expect(attributes['_dd.error.raw']).toStrictEqual(error);
|
|
276
|
+
expect(attributes['_dd.error.is_crash']).toStrictEqual(is_fatal);
|
|
248
277
|
expect(consoleReportingErrorHandler).toBeCalledTimes(1);
|
|
249
278
|
expect(baseConsoleErrorCalled).toStrictEqual(false);
|
|
250
|
-
})
|
|
279
|
+
});
|
|
251
280
|
|
|
252
281
|
it('M intercept and send a RUM event W onConsole() {Error with source file info}', async () => {
|
|
253
282
|
// GIVEN
|
|
254
283
|
DdRumErrorTracking.startTracking();
|
|
255
|
-
const message=
|
|
284
|
+
const message = 'Oops I did it again!';
|
|
256
285
|
const error = {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
286
|
+
sourceURL: './path/to/file.js',
|
|
287
|
+
line: 1038,
|
|
288
|
+
column: 57,
|
|
289
|
+
message: 'Something bad happened'
|
|
261
290
|
};
|
|
262
291
|
|
|
263
292
|
// WHEN
|
|
@@ -266,20 +295,28 @@ it('M intercept and send a RUM event W onConsole() {Error with source file info}
|
|
|
266
295
|
|
|
267
296
|
// THEN
|
|
268
297
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
269
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
expect(DdRum.addError.mock.calls[0][
|
|
298
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
299
|
+
'Oops I did it again! Something bad happened'
|
|
300
|
+
);
|
|
301
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('CONSOLE');
|
|
302
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
303
|
+
'at ./path/to/file.js:1038:57'
|
|
304
|
+
);
|
|
305
|
+
expect(DdRum.addError.mock.calls[0][3]).toBeUndefined();
|
|
273
306
|
expect(baseConsoleErrorCalled).toStrictEqual(true);
|
|
274
|
-
})
|
|
307
|
+
});
|
|
275
308
|
|
|
276
309
|
it('M intercept and send a RUM event W onConsole() {Error with component stack}', async () => {
|
|
277
310
|
// GIVEN
|
|
278
311
|
DdRumErrorTracking.startTracking();
|
|
279
|
-
const message=
|
|
312
|
+
const message = 'Oops I did it again!';
|
|
280
313
|
const error = {
|
|
281
|
-
|
|
282
|
-
|
|
314
|
+
componentStack: [
|
|
315
|
+
'doSomething() at ./path/to/file.js:67:3',
|
|
316
|
+
'nestedCall() at ./path/to/file.js:1064:9',
|
|
317
|
+
'root() at ./path/to/index.js:10:1'
|
|
318
|
+
],
|
|
319
|
+
message: 'Something bad happened'
|
|
283
320
|
};
|
|
284
321
|
|
|
285
322
|
// WHEN
|
|
@@ -288,17 +325,21 @@ it('M intercept and send a RUM event W onConsole() {Error with component stack}'
|
|
|
288
325
|
|
|
289
326
|
// THEN
|
|
290
327
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
291
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
expect(DdRum.addError.mock.calls[0][
|
|
328
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
329
|
+
'Oops I did it again! Something bad happened'
|
|
330
|
+
);
|
|
331
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('CONSOLE');
|
|
332
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
333
|
+
'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1'
|
|
334
|
+
);
|
|
335
|
+
expect(DdRum.addError.mock.calls[0][3]).toBeUndefined();
|
|
295
336
|
expect(baseConsoleErrorCalled).toStrictEqual(true);
|
|
296
|
-
})
|
|
337
|
+
});
|
|
297
338
|
|
|
298
339
|
it('M intercept and send a RUM event W onConsole() {message only}', async () => {
|
|
299
340
|
// GIVEN
|
|
300
341
|
DdRumErrorTracking.startTracking();
|
|
301
|
-
const message=
|
|
342
|
+
const message = 'Something bad happened';
|
|
302
343
|
|
|
303
344
|
// WHEN
|
|
304
345
|
DdRumErrorTracking.onConsoleError(message);
|
|
@@ -307,16 +348,23 @@ it('M intercept and send a RUM event W onConsole() {message only}', async () =>
|
|
|
307
348
|
// THEN
|
|
308
349
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
309
350
|
expect(DdRum.addError.mock.calls[0][0]).toBe(message);
|
|
310
|
-
expect(DdRum.addError.mock.calls[0][1]).toBe(
|
|
311
|
-
expect(DdRum.addError.mock.calls[0][2]).toBe(
|
|
312
|
-
expect(DdRum.addError.mock.calls[0][3]).toBeUndefined()
|
|
351
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('CONSOLE');
|
|
352
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe('');
|
|
353
|
+
expect(DdRum.addError.mock.calls[0][3]).toBeUndefined();
|
|
313
354
|
expect(baseConsoleErrorCalled).toStrictEqual(true);
|
|
314
|
-
})
|
|
355
|
+
});
|
|
315
356
|
|
|
316
|
-
describe.each(
|
|
317
|
-
[
|
|
318
|
-
|
|
319
|
-
|
|
357
|
+
describe.each([
|
|
358
|
+
[undefined],
|
|
359
|
+
[null],
|
|
360
|
+
[true],
|
|
361
|
+
[1],
|
|
362
|
+
['message'],
|
|
363
|
+
[() => {}],
|
|
364
|
+
[{}],
|
|
365
|
+
[['a']]
|
|
366
|
+
])('console calls with different message types', message => {
|
|
367
|
+
it(`M intercept and send a RUM event W onConsole() { message has ${typeof message} type }`, async () => {
|
|
320
368
|
// GIVEN
|
|
321
369
|
DdRumErrorTracking.startTracking();
|
|
322
370
|
|
|
@@ -326,10 +374,14 @@ describe.each(
|
|
|
326
374
|
|
|
327
375
|
// THEN
|
|
328
376
|
expect(DdRum.addError.mock.calls.length).toBe(1);
|
|
329
|
-
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
377
|
+
expect(DdRum.addError.mock.calls[0][0]).toBe(
|
|
378
|
+
message === undefined || message === null
|
|
379
|
+
? 'Unknown Error'
|
|
380
|
+
: String(message)
|
|
381
|
+
);
|
|
382
|
+
expect(DdRum.addError.mock.calls[0][1]).toBe('CONSOLE');
|
|
383
|
+
expect(DdRum.addError.mock.calls[0][2]).toBe('');
|
|
384
|
+
expect(DdRum.addError.mock.calls[0][3]).toBeUndefined();
|
|
333
385
|
expect(baseConsoleErrorCalled).toStrictEqual(true);
|
|
334
|
-
})
|
|
335
|
-
})
|
|
386
|
+
});
|
|
387
|
+
});
|