@datadog/mobile-react-native 3.8.0 → 3.10.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/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +6 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +16 -8
- package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +11 -6
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdFlagsImplementationTest.kt +19 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +131 -0
- package/datadog-configuration.schema.json +11 -0
- package/ios/Sources/DdRumImplementation.swift +2 -2
- package/ios/Sources/DdSdkConfiguration.swift +13 -0
- package/ios/Sources/DdSdkImplementation.swift +4 -3
- package/ios/Sources/DdSdkNativeInitialization.swift +26 -8
- package/ios/Sources/JSRefreshRateListener.swift +6 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +9 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +16 -16
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/config/FileBasedConfiguration.js +3 -1
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +3 -0
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfiguration.js +8 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
- package/lib/commonjs/flags/FlagsClient.js +81 -8
- package/lib/commonjs/flags/FlagsClient.js.map +1 -1
- package/lib/commonjs/flags/configuration/precomputed.js +2 -3
- package/lib/commonjs/flags/configuration/precomputed.js.map +1 -1
- package/lib/commonjs/flags/internal.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +2 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js +3 -3
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/utils.js +8 -0
- package/lib/commonjs/sdk/AttributesEncoding/utils.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/sdk/DdSdkInternal.js +22 -22
- package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
- package/lib/commonjs/sdk/EventMappers/EventMapper.js +2 -2
- package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/commonjs/utils/time-provider/TimeProvider.js +4 -1
- package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +16 -16
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/config/FileBasedConfiguration.js +3 -1
- package/lib/module/config/FileBasedConfiguration.js.map +1 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +3 -0
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfiguration.js +8 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -1
- package/lib/module/flags/FlagsClient.js +81 -8
- package/lib/module/flags/FlagsClient.js.map +1 -1
- package/lib/module/flags/configuration/precomputed.js +2 -3
- package/lib/module/flags/configuration/precomputed.js.map +1 -1
- package/lib/module/flags/internal.js.map +1 -1
- package/lib/module/rum/DdRum.js +2 -2
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +2 -2
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/helpers.js +4 -4
- package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/utils.js +7 -0
- package/lib/module/sdk/AttributesEncoding/utils.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/sdk/DdSdkInternal.js +21 -22
- package/lib/module/sdk/DdSdkInternal.js.map +1 -1
- package/lib/module/sdk/EventMappers/EventMapper.js +2 -2
- package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/module/utils/time-provider/TimeProvider.js +4 -1
- package/lib/module/utils/time-provider/TimeProvider.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +4 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -0
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts +4 -0
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +21 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
- package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
- package/lib/typescript/flags/FlagsClient.d.ts +38 -1
- package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
- package/lib/typescript/flags/internal.d.ts +1 -0
- package/lib/typescript/flags/internal.d.ts.map +1 -1
- package/lib/typescript/flags/types.d.ts +1 -1
- package/lib/typescript/flags/types.d.ts.map +1 -1
- package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts +1 -0
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts.map +1 -1
- package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -8
- package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
- package/lib/typescript/utils/time-provider/TimeProvider.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +16 -16
- package/src/__tests__/DdSdkReactNative.test.tsx +272 -19
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +12 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
- package/src/config/FileBasedConfiguration.ts +6 -1
- package/src/config/FileBasedConfiguration.type.ts +2 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +79 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +2 -0
- package/src/config/async/AutoInstrumentationConfiguration.ts +9 -0
- package/src/config/async/PartialInitializationConfiguration.ts +2 -0
- package/src/config/features/RumConfiguration.ts +10 -0
- package/src/config/features/RumConfiguration.type.ts +23 -0
- package/src/config/features/RumConfigurationNative.ts +2 -0
- package/src/flags/FlagsClient.ts +128 -19
- package/src/flags/__tests__/FlagsClient.test.ts +167 -0
- package/src/flags/configuration/precomputed.ts +2 -3
- package/src/flags/internal.ts +2 -0
- package/src/flags/types.ts +2 -0
- package/src/rum/DdRum.ts +2 -2
- package/src/rum/__tests__/DdRum.test.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -3
- package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +104 -1
- package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +25 -0
- package/src/sdk/AttributesEncoding/defaultEncoders.ts +6 -2
- package/src/sdk/AttributesEncoding/helpers.ts +6 -6
- package/src/sdk/AttributesEncoding/utils.ts +8 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +2 -2
- package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +165 -0
- package/src/sdk/DdSdkInternal.ts +23 -30
- package/src/sdk/EventMappers/EventMapper.ts +2 -2
- package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
- package/src/utils/__tests__/TimeProvider.test.tsx +49 -0
- package/src/utils/time-provider/TimeProvider.tsx +10 -1
- package/src/version.ts +1 -1
package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts
CHANGED
|
@@ -69,7 +69,10 @@ describe('DdBabelInteractionTracking.wrapRumAction', () => {
|
|
|
69
69
|
|
|
70
70
|
it('should forward the first handler argument as actionContext to DdRum.addAction', () => {
|
|
71
71
|
const mockAddAction = jest.fn().mockResolvedValue(undefined);
|
|
72
|
-
DdBabelInteractionTracking.config = {
|
|
72
|
+
DdBabelInteractionTracking.config = {
|
|
73
|
+
trackInteractions: true,
|
|
74
|
+
useAccessibilityLabel: true
|
|
75
|
+
};
|
|
73
76
|
DdBabelInteractionTracking.attachRumInstance({
|
|
74
77
|
addAction: mockAddAction
|
|
75
78
|
} as any);
|
|
@@ -94,4 +97,104 @@ describe('DdBabelInteractionTracking.wrapRumAction', () => {
|
|
|
94
97
|
event
|
|
95
98
|
);
|
|
96
99
|
});
|
|
100
|
+
|
|
101
|
+
describe('action naming precedence', () => {
|
|
102
|
+
const mockAddAction = jest.fn().mockResolvedValue(undefined);
|
|
103
|
+
const originalConfig = DdBabelInteractionTracking.config;
|
|
104
|
+
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
mockAddAction.mockClear();
|
|
107
|
+
DdBabelInteractionTracking.attachRumInstance({
|
|
108
|
+
addAction: mockAddAction
|
|
109
|
+
} as any);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
afterEach(() => {
|
|
113
|
+
DdBabelInteractionTracking.config = originalConfig;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe.each([true, false])(
|
|
117
|
+
'useAccessibilityLabel=%s',
|
|
118
|
+
useAccessibilityLabel => {
|
|
119
|
+
it.each([
|
|
120
|
+
{
|
|
121
|
+
source:
|
|
122
|
+
'dd-action-name over custom attribute, accessibility label and content',
|
|
123
|
+
attributes: {
|
|
124
|
+
'dd-action-name': ['Explicit'],
|
|
125
|
+
customName: ['Custom'],
|
|
126
|
+
accessibilityLabel: ['Accessible']
|
|
127
|
+
},
|
|
128
|
+
content: ['Content'],
|
|
129
|
+
expected: 'Pressable ("Explicit")'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
source:
|
|
133
|
+
'custom attribute over accessibility label and content',
|
|
134
|
+
attributes: {
|
|
135
|
+
customName: ['Custom'],
|
|
136
|
+
accessibilityLabel: ['Accessible']
|
|
137
|
+
},
|
|
138
|
+
content: ['Content'],
|
|
139
|
+
expected: 'Pressable ("Custom")'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
source:
|
|
143
|
+
'accessibility label or content according to configuration',
|
|
144
|
+
attributes: { accessibilityLabel: ['Accessible'] },
|
|
145
|
+
content: ['Content'],
|
|
146
|
+
expected: useAccessibilityLabel
|
|
147
|
+
? 'Pressable ("Accessible")'
|
|
148
|
+
: 'Pressable ("Content")'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
source:
|
|
152
|
+
'accessibility label or component name when there is no content',
|
|
153
|
+
attributes: { accessibilityLabel: ['Edit'] },
|
|
154
|
+
content: [],
|
|
155
|
+
expected: useAccessibilityLabel
|
|
156
|
+
? 'Pressable ("Edit")'
|
|
157
|
+
: 'Pressable'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
source: 'content when there are no naming attributes',
|
|
161
|
+
attributes: {},
|
|
162
|
+
content: ['Content'],
|
|
163
|
+
expected: 'Pressable ("Content")'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
source:
|
|
167
|
+
'component name when there are no naming attributes or content',
|
|
168
|
+
attributes: {},
|
|
169
|
+
content: [],
|
|
170
|
+
expected: 'Pressable'
|
|
171
|
+
}
|
|
172
|
+
])('uses $source', ({ attributes, content, expected }) => {
|
|
173
|
+
DdBabelInteractionTracking.config = {
|
|
174
|
+
trackInteractions: true,
|
|
175
|
+
useAccessibilityLabel
|
|
176
|
+
};
|
|
177
|
+
const wrapped = DdBabelInteractionTracking.wrapRumAction(
|
|
178
|
+
jest.fn(),
|
|
179
|
+
RumActionType.TAP,
|
|
180
|
+
{
|
|
181
|
+
options: {
|
|
182
|
+
useContent: true,
|
|
183
|
+
useNamePrefix: true
|
|
184
|
+
},
|
|
185
|
+
handlerArgs: [],
|
|
186
|
+
componentName: 'Pressable',
|
|
187
|
+
getContent: () => content,
|
|
188
|
+
...attributes
|
|
189
|
+
} as any
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
wrapped();
|
|
193
|
+
|
|
194
|
+
expect(mockAddAction).toHaveBeenCalledTimes(1);
|
|
195
|
+
expect(mockAddAction.mock.calls[0][1]).toBe(expected);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
});
|
|
97
200
|
});
|
|
@@ -41,6 +41,31 @@ describe('encodeAttributes', () => {
|
|
|
41
41
|
expect(warn).toHaveBeenCalled();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
it('drops a null-prototype object without throwing', () => {
|
|
45
|
+
expect(() =>
|
|
46
|
+
encodeAttributes({ bad: Object.create(null) })
|
|
47
|
+
).not.toThrow();
|
|
48
|
+
expect(warn).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('drops a value whose toString throws without throwing', () => {
|
|
52
|
+
const bad = {
|
|
53
|
+
toString() {
|
|
54
|
+
throw new Error('boom');
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
Object.setPrototypeOf(bad, null);
|
|
58
|
+
expect(() => encodeAttributes({ bad })).not.toThrow();
|
|
59
|
+
expect(warn).toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('drops a null-prototype object nested in an array without throwing', () => {
|
|
63
|
+
expect(() =>
|
|
64
|
+
encodeAttributes({ bad: [Object.create(null)] })
|
|
65
|
+
).not.toThrow();
|
|
66
|
+
expect(warn).toHaveBeenCalled();
|
|
67
|
+
});
|
|
68
|
+
|
|
44
69
|
it('drops unsupported root function', () => {
|
|
45
70
|
const result = encodeAttributes(() => {});
|
|
46
71
|
expect(result).toEqual({});
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from './errorUtils';
|
|
17
17
|
import { encodeAttributesInPlace, sanitizeForJson } from './helpers';
|
|
18
18
|
import type { AttributeEncoder, Encodable } from './types';
|
|
19
|
-
import { warn } from './utils';
|
|
19
|
+
import { safeToString, warn } from './utils';
|
|
20
20
|
|
|
21
21
|
/** Primitives: keep them explicit so the full pipeline is used uniformly. */
|
|
22
22
|
export const stringEncoder: AttributeEncoder<string> = {
|
|
@@ -165,7 +165,11 @@ export const mapEncoder: AttributeEncoder<Map<unknown, unknown>> = {
|
|
|
165
165
|
value: sanitizeForJson(v, allEncoders)
|
|
166
166
|
});
|
|
167
167
|
} catch (err) {
|
|
168
|
-
warn(
|
|
168
|
+
warn(
|
|
169
|
+
`Failed to encode Map key: ${safeToString(
|
|
170
|
+
k
|
|
171
|
+
)}. ERROR: ${safeToString(err)}`
|
|
172
|
+
);
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { AttributeEncoder, Encodable } from './types';
|
|
8
|
-
import { formatPathForLog, isPlainObject, warn } from './utils';
|
|
8
|
+
import { formatPathForLog, isPlainObject, safeToString, warn } from './utils';
|
|
9
9
|
|
|
10
10
|
const MAX_ATTRIBUTES = 256;
|
|
11
11
|
|
|
@@ -69,7 +69,7 @@ export function encodeAttributesInPlace(
|
|
|
69
69
|
warn(
|
|
70
70
|
`Dropped unsupported value in array at '${formatPathForLog(
|
|
71
71
|
path
|
|
72
|
-
)}': ${
|
|
72
|
+
)}': ${safeToString(v)}`
|
|
73
73
|
);
|
|
74
74
|
return undefined;
|
|
75
75
|
};
|
|
@@ -94,9 +94,9 @@ export function encodeAttributesInPlace(
|
|
|
94
94
|
|
|
95
95
|
// Unsupported
|
|
96
96
|
warn(
|
|
97
|
-
`Dropped unsupported value at '${formatPathForLog(
|
|
98
|
-
|
|
99
|
-
)}`
|
|
97
|
+
`Dropped unsupported value at '${formatPathForLog(
|
|
98
|
+
path
|
|
99
|
+
)}': ${safeToString(value)}`
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -138,7 +138,7 @@ export function applyEncoders(
|
|
|
138
138
|
return enc.encode(value as never);
|
|
139
139
|
}
|
|
140
140
|
} catch (err) {
|
|
141
|
-
warn(`Encoder error: ${
|
|
141
|
+
warn(`Encoder error: ${safeToString(err)}`);
|
|
142
142
|
return undefined;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -11,6 +11,14 @@ export function warn(text: string) {
|
|
|
11
11
|
InternalLog.log(`[ATTRIBUTES] ${text}`, SdkVerbosity.WARN);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export function safeToString(value: unknown): string {
|
|
15
|
+
try {
|
|
16
|
+
return String(value);
|
|
17
|
+
} catch {
|
|
18
|
+
return Object.prototype.toString.call(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
export function isPlainObject(v: unknown): v is Record<string, unknown> {
|
|
15
23
|
return !!v && typeof v === 'object' && (v as any).constructor === Object;
|
|
16
24
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { InternalLog } from '../../../InternalLog';
|
|
8
8
|
import { SdkVerbosity } from '../../../config/types/SdkVerbosity';
|
|
9
9
|
import { getErrorStackTrace } from '../../AttributesEncoding/errorUtils';
|
|
10
|
-
import {
|
|
10
|
+
import { DdSdk } from '../../DdSdk';
|
|
11
11
|
|
|
12
12
|
import { DatadogBuffer } from './DatadogBuffer';
|
|
13
13
|
|
|
@@ -206,7 +206,7 @@ export class BoundedBuffer extends DatadogBuffer {
|
|
|
206
206
|
private drainTelemetry = () => {
|
|
207
207
|
Object.values(this.telemetryBuffer).forEach(
|
|
208
208
|
({ message, stack, kind, occurrences }) => {
|
|
209
|
-
|
|
209
|
+
DdSdk.telemetryError(
|
|
210
210
|
`${message} happened ${occurrences} times.`,
|
|
211
211
|
stack,
|
|
212
212
|
kind
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { InternalLog } from '../../../../InternalLog';
|
|
8
|
-
import
|
|
8
|
+
import NativeDdSdkSpec from '../../../../specs/NativeDdSdk';
|
|
9
9
|
import { BoundedBuffer } from '../BoundedBuffer';
|
|
10
10
|
|
|
11
11
|
describe('BoundedBuffer', () => {
|
|
@@ -126,7 +126,7 @@ describe('BoundedBuffer', () => {
|
|
|
126
126
|
await buffer.drain();
|
|
127
127
|
expect(callbackWithId).toHaveBeenCalledTimes(1);
|
|
128
128
|
expect(callbackWithId).toHaveBeenNthCalledWith(1, 'callbackId1');
|
|
129
|
-
expect(
|
|
129
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
130
130
|
'Could not generate enough random numbers happened 2 times.',
|
|
131
131
|
'',
|
|
132
132
|
'RandomIdGenerationError'
|
|
@@ -146,7 +146,7 @@ describe('BoundedBuffer', () => {
|
|
|
146
146
|
|
|
147
147
|
await buffer.drain();
|
|
148
148
|
expect(fakeCallback).toHaveBeenCalledTimes(3);
|
|
149
|
-
expect(
|
|
149
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
150
150
|
'Buffer overflow happened 1 times.',
|
|
151
151
|
'',
|
|
152
152
|
'BufferOverflow'
|
|
@@ -171,7 +171,7 @@ describe('BoundedBuffer', () => {
|
|
|
171
171
|
expect(fakeCallback).toHaveBeenCalledTimes(1);
|
|
172
172
|
expect(callbackReturningId).not.toHaveBeenCalled();
|
|
173
173
|
expect(callbackWithId).not.toHaveBeenCalled();
|
|
174
|
-
expect(
|
|
174
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
175
175
|
'Buffer overflow happened 2 times.',
|
|
176
176
|
'',
|
|
177
177
|
'BufferOverflow'
|
|
@@ -196,7 +196,7 @@ describe('BoundedBuffer', () => {
|
|
|
196
196
|
expect(fakeCallback).toHaveBeenCalledTimes(1);
|
|
197
197
|
expect(callbackReturningId).toHaveBeenCalledTimes(1);
|
|
198
198
|
expect(callbackWithId).toHaveBeenCalledTimes(1);
|
|
199
|
-
expect(
|
|
199
|
+
expect(NativeDdSdkSpec.telemetryError).not.toHaveBeenCalled();
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
202
|
});
|
|
@@ -96,6 +96,8 @@ describe('DatadogProvider', () => {
|
|
|
96
96
|
"longTaskThresholdMs": 0,
|
|
97
97
|
"nativeCrashReportEnabled": false,
|
|
98
98
|
"nativeInteractionTracking": false,
|
|
99
|
+
"nativeIosResourceTracking": undefined,
|
|
100
|
+
"nativeIosResourceTrackingDisallowList": undefined,
|
|
99
101
|
"nativeLongTaskThresholdMs": 200,
|
|
100
102
|
"nativeViewTracking": false,
|
|
101
103
|
"resourceEventMapper": null,
|
|
@@ -178,6 +180,169 @@ describe('DatadogProvider', () => {
|
|
|
178
180
|
});
|
|
179
181
|
});
|
|
180
182
|
|
|
183
|
+
describe('nativeIosResourceTracking', () => {
|
|
184
|
+
it('sends nativeIosResourceTracking undefined to native by default', async () => {
|
|
185
|
+
renderWithProvider();
|
|
186
|
+
await flushPromises();
|
|
187
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
188
|
+
const receivedConfiguration =
|
|
189
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
190
|
+
expect(receivedConfiguration.rumConfiguration).toBeDefined();
|
|
191
|
+
expect(
|
|
192
|
+
receivedConfiguration.rumConfiguration.nativeIosResourceTracking
|
|
193
|
+
).toBeUndefined();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it.each([true, false])(
|
|
197
|
+
'sends nativeIosResourceTracking %s to native when set',
|
|
198
|
+
async value => {
|
|
199
|
+
const configuration = getDefaultConfiguration();
|
|
200
|
+
const rumConfiguration = configuration.rumConfiguration;
|
|
201
|
+
if (rumConfiguration) {
|
|
202
|
+
rumConfiguration.nativeIosResourceTracking = value;
|
|
203
|
+
}
|
|
204
|
+
renderWithProvider({ configuration });
|
|
205
|
+
await flushPromises();
|
|
206
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
207
|
+
const receivedConfiguration =
|
|
208
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
209
|
+
expect(
|
|
210
|
+
receivedConfiguration.rumConfiguration
|
|
211
|
+
.nativeIosResourceTracking
|
|
212
|
+
).toBe(value);
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
it.each([
|
|
217
|
+
[undefined, undefined, undefined],
|
|
218
|
+
[true, undefined, true],
|
|
219
|
+
[false, undefined, false],
|
|
220
|
+
[undefined, true, true],
|
|
221
|
+
[undefined, false, false]
|
|
222
|
+
])(
|
|
223
|
+
'partial initialization: features %s, initialize %s => native %s',
|
|
224
|
+
async (featuresValue, initializeValue, expected) => {
|
|
225
|
+
renderWithProvider({
|
|
226
|
+
configuration: {
|
|
227
|
+
rumConfiguration: {
|
|
228
|
+
trackErrors: false,
|
|
229
|
+
trackResources: false,
|
|
230
|
+
trackInteractions: false,
|
|
231
|
+
...(featuresValue !== undefined && {
|
|
232
|
+
nativeIosResourceTracking: featuresValue
|
|
233
|
+
})
|
|
234
|
+
},
|
|
235
|
+
traceConfiguration: {},
|
|
236
|
+
logsConfiguration: {}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
await flushPromises();
|
|
240
|
+
expect(NativeModules.DdSdk.initialize).not.toHaveBeenCalled();
|
|
241
|
+
|
|
242
|
+
await DatadogProvider.initialize({
|
|
243
|
+
clientToken: 'fake-client-token',
|
|
244
|
+
env: 'fake-env',
|
|
245
|
+
rumConfiguration: {
|
|
246
|
+
applicationId: 'fake-application-id',
|
|
247
|
+
...(initializeValue !== undefined && {
|
|
248
|
+
nativeIosResourceTracking: initializeValue
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
await flushPromises();
|
|
253
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
254
|
+
const receivedConfiguration =
|
|
255
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
256
|
+
expect(
|
|
257
|
+
receivedConfiguration.rumConfiguration
|
|
258
|
+
.nativeIosResourceTracking
|
|
259
|
+
).toBe(expected);
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe('nativeIosResourceTrackingDisallowList', () => {
|
|
265
|
+
const disallowList = [
|
|
266
|
+
'https://3p.example.com/*',
|
|
267
|
+
'https://cdn.example.com/a'
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
it('sends nativeIosResourceTrackingDisallowList undefined to native by default', async () => {
|
|
271
|
+
renderWithProvider();
|
|
272
|
+
await flushPromises();
|
|
273
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
274
|
+
const receivedConfiguration =
|
|
275
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
276
|
+
expect(receivedConfiguration.rumConfiguration).toBeDefined();
|
|
277
|
+
expect(
|
|
278
|
+
receivedConfiguration.rumConfiguration
|
|
279
|
+
.nativeIosResourceTrackingDisallowList
|
|
280
|
+
).toBeUndefined();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('sends nativeIosResourceTrackingDisallowList to native when set', async () => {
|
|
284
|
+
const configuration = getDefaultConfiguration();
|
|
285
|
+
const rumConfiguration = configuration.rumConfiguration;
|
|
286
|
+
if (rumConfiguration) {
|
|
287
|
+
rumConfiguration.nativeIosResourceTrackingDisallowList = disallowList;
|
|
288
|
+
}
|
|
289
|
+
renderWithProvider({ configuration });
|
|
290
|
+
await flushPromises();
|
|
291
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
292
|
+
const receivedConfiguration =
|
|
293
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
294
|
+
expect(
|
|
295
|
+
receivedConfiguration.rumConfiguration
|
|
296
|
+
.nativeIosResourceTrackingDisallowList
|
|
297
|
+
).toEqual(disallowList);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it.each([
|
|
301
|
+
['unset', 'unset', undefined],
|
|
302
|
+
['list', 'unset', disallowList],
|
|
303
|
+
['unset', 'list', disallowList]
|
|
304
|
+
])(
|
|
305
|
+
'partial initialization: features %s, initialize %s => native %p',
|
|
306
|
+
async (featuresValue, initializeValue, expected) => {
|
|
307
|
+
renderWithProvider({
|
|
308
|
+
configuration: {
|
|
309
|
+
rumConfiguration: {
|
|
310
|
+
trackErrors: false,
|
|
311
|
+
trackResources: false,
|
|
312
|
+
trackInteractions: false,
|
|
313
|
+
...(featuresValue === 'list' && {
|
|
314
|
+
nativeIosResourceTrackingDisallowList: disallowList
|
|
315
|
+
})
|
|
316
|
+
},
|
|
317
|
+
traceConfiguration: {},
|
|
318
|
+
logsConfiguration: {}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
await flushPromises();
|
|
322
|
+
expect(NativeModules.DdSdk.initialize).not.toHaveBeenCalled();
|
|
323
|
+
|
|
324
|
+
await DatadogProvider.initialize({
|
|
325
|
+
clientToken: 'fake-client-token',
|
|
326
|
+
env: 'fake-env',
|
|
327
|
+
rumConfiguration: {
|
|
328
|
+
applicationId: 'fake-application-id',
|
|
329
|
+
...(initializeValue === 'list' && {
|
|
330
|
+
nativeIosResourceTrackingDisallowList: disallowList
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
await flushPromises();
|
|
335
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
336
|
+
const receivedConfiguration =
|
|
337
|
+
NativeModules.DdSdk.initialize.mock.calls[0][0];
|
|
338
|
+
expect(
|
|
339
|
+
receivedConfiguration.rumConfiguration
|
|
340
|
+
.nativeIosResourceTrackingDisallowList
|
|
341
|
+
).toEqual(expected);
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
});
|
|
345
|
+
|
|
181
346
|
describe('onInitialization callback', () => {
|
|
182
347
|
it('runs after initialization when SYNC initialization', async () => {
|
|
183
348
|
const onInitialization = jest.fn();
|
package/src/sdk/DdSdkInternal.ts
CHANGED
|
@@ -10,16 +10,11 @@ import type { DdNativeSdkType } from '../nativeModulesTypes';
|
|
|
10
10
|
import type { AttributeEncoder } from './AttributesEncoding/types';
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
13
|
-
const
|
|
13
|
+
const NativeDdSdkSpec: DdNativeSdkType = require('../specs/NativeDdSdk')
|
|
14
|
+
.default;
|
|
14
15
|
|
|
15
|
-
export type DdSdkType = {
|
|
16
|
+
export type DdSdkType = DdNativeSdkType & {
|
|
16
17
|
readonly attributeEncoders: AttributeEncoder<any>[];
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Initializes Datadog's features.
|
|
20
|
-
* @param configuration: The configuration to use.
|
|
21
|
-
*/
|
|
22
|
-
initialize(configuration: DdSdkNativeConfiguration): Promise<void>;
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
export class DdSdkWrapper implements DdNativeSdkType {
|
|
@@ -30,49 +25,49 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
30
25
|
|
|
31
26
|
initialize(configuration: DdSdkNativeConfiguration): Promise<void> {
|
|
32
27
|
this._attributeEncoders = [...configuration.attributeEncoders];
|
|
33
|
-
return
|
|
28
|
+
return NativeDdSdkSpec.initialize(configuration);
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
getConstants() {
|
|
37
|
-
return
|
|
32
|
+
return NativeDdSdkSpec.getConstants();
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
setUserInfo(user: object): Promise<object> {
|
|
41
|
-
return
|
|
36
|
+
return NativeDdSdkSpec.setUserInfo(user);
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
clearUserInfo(): Promise<void> {
|
|
45
|
-
return
|
|
40
|
+
return NativeDdSdkSpec.clearUserInfo();
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
addUserExtraInfo(extraInfo: object): Promise<object> {
|
|
49
|
-
return
|
|
44
|
+
return NativeDdSdkSpec.addUserExtraInfo(extraInfo);
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
addAttribute(key: string, value: object): Promise<void> {
|
|
53
|
-
return
|
|
48
|
+
return NativeDdSdkSpec.addAttribute(key, value);
|
|
54
49
|
}
|
|
55
50
|
removeAttribute(key: string): Promise<void> {
|
|
56
|
-
return
|
|
51
|
+
return NativeDdSdkSpec.removeAttribute(key);
|
|
57
52
|
}
|
|
58
53
|
addAttributes(attributes: object): Promise<void> {
|
|
59
|
-
return
|
|
54
|
+
return NativeDdSdkSpec.addAttributes(attributes);
|
|
60
55
|
}
|
|
61
56
|
removeAttributes(keys: string[]): Promise<void> {
|
|
62
|
-
return
|
|
57
|
+
return NativeDdSdkSpec.removeAttributes(keys);
|
|
63
58
|
}
|
|
64
59
|
setAccountInfo(account: object): Promise<object> {
|
|
65
|
-
return
|
|
60
|
+
return NativeDdSdkSpec.setAccountInfo(account);
|
|
66
61
|
}
|
|
67
62
|
clearAccountInfo(): Promise<void> {
|
|
68
|
-
return
|
|
63
|
+
return NativeDdSdkSpec.clearAccountInfo();
|
|
69
64
|
}
|
|
70
65
|
addAccountExtraInfo(extraInfo: object): Promise<object> {
|
|
71
|
-
return
|
|
66
|
+
return NativeDdSdkSpec.addAccountExtraInfo(extraInfo);
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
setTrackingConsent(trackingConsent: string): Promise<void> {
|
|
75
|
-
return
|
|
70
|
+
return NativeDdSdkSpec.setTrackingConsent(trackingConsent);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
sendTelemetryLog(
|
|
@@ -80,11 +75,11 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
80
75
|
attributes: object,
|
|
81
76
|
config: object
|
|
82
77
|
): Promise<void> {
|
|
83
|
-
return
|
|
78
|
+
return NativeDdSdkSpec.sendTelemetryLog(message, attributes, config);
|
|
84
79
|
}
|
|
85
80
|
|
|
86
81
|
telemetryDebug(message: string): Promise<void> {
|
|
87
|
-
return
|
|
82
|
+
return NativeDdSdkSpec.telemetryDebug(message);
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
telemetryError(
|
|
@@ -92,23 +87,23 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
92
87
|
stack: string,
|
|
93
88
|
kind: string
|
|
94
89
|
): Promise<void> {
|
|
95
|
-
return
|
|
90
|
+
return NativeDdSdkSpec.telemetryError(message, stack, kind);
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
consumeWebviewEvent(message: string): Promise<void> {
|
|
99
|
-
return
|
|
94
|
+
return NativeDdSdkSpec.consumeWebviewEvent(message);
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
clearAllData(): Promise<void> {
|
|
103
|
-
return
|
|
98
|
+
return NativeDdSdkSpec.clearAllData();
|
|
104
99
|
}
|
|
105
100
|
|
|
106
101
|
addListener(eventType: string): void {
|
|
107
|
-
return
|
|
102
|
+
return NativeDdSdkSpec.addListener(eventType);
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
removeListeners(count: number): void {
|
|
111
|
-
return
|
|
106
|
+
return NativeDdSdkSpec.removeListeners(count);
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
_setAttributeEncodersForTesting(
|
|
@@ -117,5 +112,3 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
117
112
|
this._attributeEncoders = [...attributeEncoders];
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
|
-
|
|
121
|
-
export { NativeDdSdk };
|
|
@@ -10,7 +10,7 @@ import { AccountInfoSingleton } from '../AccountInfoSingleton/AccountInfoSinglet
|
|
|
10
10
|
import type { AccountInfo } from '../AccountInfoSingleton/types';
|
|
11
11
|
import { AttributesSingleton } from '../AttributesSingleton/AttributesSingleton';
|
|
12
12
|
import type { Attributes } from '../AttributesSingleton/types';
|
|
13
|
-
import {
|
|
13
|
+
import { DdSdk } from '../DdSdk';
|
|
14
14
|
import { UserInfoSingleton } from '../UserInfoSingleton/UserInfoSingleton';
|
|
15
15
|
import type { UserInfo } from '../UserInfoSingleton/types';
|
|
16
16
|
|
|
@@ -92,7 +92,7 @@ export class EventMapper<RawEvent, MapperEvent, NativeEvent> {
|
|
|
92
92
|
)}: ${error}`,
|
|
93
93
|
SdkVerbosity.WARN
|
|
94
94
|
);
|
|
95
|
-
|
|
95
|
+
DdSdk.telemetryDebug('Error while running the event mapper');
|
|
96
96
|
return this.formatMapperEventForNative(backupEvent, backupEvent);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import NativeDdSdkSpec from '../../../specs/NativeDdSdk';
|
|
8
8
|
import { EventMapper } from '../EventMapper';
|
|
9
9
|
|
|
10
10
|
describe('EventMapper', () => {
|
|
@@ -26,7 +26,7 @@ describe('EventMapper', () => {
|
|
|
26
26
|
).toEqual({
|
|
27
27
|
someData: 'some data'
|
|
28
28
|
});
|
|
29
|
-
expect(
|
|
29
|
+
expect(NativeDdSdkSpec.telemetryDebug).toHaveBeenCalledWith(
|
|
30
30
|
'Error while running the event mapper'
|
|
31
31
|
);
|
|
32
32
|
});
|