@datadog/mobile-react-native 2.2.0 → 2.3.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.
Files changed (102) hide show
  1. package/DatadogSDKReactNative.podspec +2 -1
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +2 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +11 -1
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +5 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +64 -1
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +164 -4
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +6 -354
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +351 -0
  10. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +5 -3
  11. package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -0
  12. package/android/src/main/kotlin/com/datadog/reactnative/JSONFileReader.kt +20 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +4 -1
  14. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +10 -0
  15. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +3 -2
  16. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -2
  17. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +3 -2
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkConfigurationTest.kt +196 -0
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +181 -0
  20. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +12 -271
  21. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +10 -0
  22. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +28 -1
  23. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +24 -0
  24. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +9 -1
  25. package/android/src/test/resources/input/complete-configuration.json +48 -0
  26. package/android/src/test/resources/input/malformed-configuration.json +5 -0
  27. package/android/src/test/resources/input/minimal-configuration.json +8 -0
  28. package/datadog-configuration.gradle +57 -0
  29. package/datadog-configuration.schema.json +200 -0
  30. package/ios/Sources/DatadogSDKWrapper.swift +16 -13
  31. package/ios/Sources/DdLogsImplementation.swift +14 -0
  32. package/ios/Sources/DdSdk.h +2 -0
  33. package/ios/Sources/DdSdk.mm +6 -1
  34. package/ios/Sources/DdSdkConfiguration.swift +47 -56
  35. package/ios/Sources/DdSdkImplementation.swift +10 -279
  36. package/ios/Sources/DdSdkNativeInitialization.swift +218 -0
  37. package/ios/Sources/DdTraceImplementation.swift +3 -1
  38. package/ios/Sources/GlobalState.swift +1 -1
  39. package/ios/Sources/JSONFileReader.swift +28 -0
  40. package/ios/Sources/RNDdSdkConfiguration.swift +227 -9
  41. package/ios/Sources/SdkVersion.swift +10 -0
  42. package/lib/commonjs/DdSdkReactNative.js +24 -66
  43. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  44. package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -4
  45. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  46. package/lib/commonjs/ProxyConfiguration.js +15 -2
  47. package/lib/commonjs/ProxyConfiguration.js.map +1 -1
  48. package/lib/commonjs/index.js +8 -0
  49. package/lib/commonjs/index.js.map +1 -1
  50. package/lib/commonjs/nativeModulesTypes.js +2 -2
  51. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  52. package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
  53. package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js +214 -0
  54. package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
  55. package/lib/commonjs/types.js +10 -2
  56. package/lib/commonjs/types.js.map +1 -1
  57. package/lib/commonjs/version.js +1 -1
  58. package/lib/commonjs/version.js.map +1 -1
  59. package/lib/module/DdSdkReactNative.js +23 -65
  60. package/lib/module/DdSdkReactNative.js.map +1 -1
  61. package/lib/module/DdSdkReactNativeConfiguration.js +22 -4
  62. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  63. package/lib/module/ProxyConfiguration.js +15 -2
  64. package/lib/module/ProxyConfiguration.js.map +1 -1
  65. package/lib/module/index.js +2 -1
  66. package/lib/module/index.js.map +1 -1
  67. package/lib/module/nativeModulesTypes.js +2 -2
  68. package/lib/module/nativeModulesTypes.js.map +1 -1
  69. package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
  70. package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js +197 -0
  71. package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
  72. package/lib/module/types.js +10 -2
  73. package/lib/module/types.js.map +1 -1
  74. package/lib/module/version.js +1 -1
  75. package/lib/module/version.js.map +1 -1
  76. package/lib/typescript/DdSdkReactNative.d.ts +0 -9
  77. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +43 -3
  78. package/lib/typescript/ProxyConfiguration.d.ts +4 -12
  79. package/lib/typescript/index.d.ts +2 -1
  80. package/lib/typescript/nativeModulesTypes.d.ts +2 -2
  81. package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +2 -1
  82. package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +31 -0
  83. package/lib/typescript/types.d.ts +29 -3
  84. package/lib/typescript/version.d.ts +1 -1
  85. package/package.json +7 -4
  86. package/src/DdSdkReactNative.tsx +58 -101
  87. package/src/DdSdkReactNativeConfiguration.tsx +26 -7
  88. package/src/ProxyConfiguration.tsx +17 -3
  89. package/src/__tests__/DdSdkReactNative.test.tsx +134 -112
  90. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +19 -10
  91. package/src/__tests__/mock.test.ts +0 -9
  92. package/src/index.tsx +2 -0
  93. package/src/nativeModulesTypes.ts +1 -1
  94. package/src/sdk/DatadogProvider/DatadogProvider.tsx +3 -1
  95. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +12 -5
  96. package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +1 -2
  97. package/src/sdk/FileBasedConfiguration/FileBasedConfiguration.ts +235 -0
  98. package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +245 -0
  99. package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/configuration-all-fields.json +22 -0
  100. package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/malformed-configuration.json +5 -0
  101. package/src/types.tsx +21 -2
  102. package/src/version.ts +1 -1
@@ -0,0 +1,235 @@
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 type { FirstPartyHostsConfiguration } from '../../DdSdkReactNativeConfiguration';
8
+ import {
9
+ DatadogProviderConfiguration,
10
+ DEFAULTS
11
+ } from '../../DdSdkReactNativeConfiguration';
12
+ import { SdkVerbosity } from '../../SdkVerbosity';
13
+ import { TrackingConsent } from '../../TrackingConsent';
14
+ import type { ActionEventMapper } from '../../rum/eventMappers/actionEventMapper';
15
+ import type { ErrorEventMapper } from '../../rum/eventMappers/errorEventMapper';
16
+ import type { ResourceEventMapper } from '../../rum/eventMappers/resourceEventMapper';
17
+ import { PropagatorType } from '../../rum/types';
18
+
19
+ export class FileBasedConfiguration extends DatadogProviderConfiguration {
20
+ constructor(params?: {
21
+ configuration?: unknown;
22
+ errorEventMapper?: ErrorEventMapper;
23
+ resourceEventMapper?: ResourceEventMapper;
24
+ actionEventMapper?: ActionEventMapper;
25
+ }) {
26
+ const configuration = getJSONConfiguration(params?.configuration);
27
+ super(
28
+ configuration.clientToken,
29
+ configuration.env,
30
+ configuration.applicationId,
31
+ configuration.trackInteractions,
32
+ configuration.trackResources,
33
+ configuration.trackErrors,
34
+ configuration.trackingConsent
35
+ );
36
+ this.longTaskThresholdMs =
37
+ configuration.longTaskThresholdMs || DEFAULTS.longTaskThresholdMs;
38
+ this.verbosity = configuration.verbosity;
39
+ this.actionNameAttribute = configuration.actionNameAttribute;
40
+ this.resourceTracingSamplingRate =
41
+ configuration.resourceTracingSamplingRate ||
42
+ DEFAULTS.resourceTracingSamplingRate;
43
+ this.firstPartyHosts =
44
+ configuration.firstPartyHosts || DEFAULTS.getFirstPartyHosts();
45
+ this.errorEventMapper =
46
+ params?.errorEventMapper || DEFAULTS.errorEventMapper;
47
+ this.resourceEventMapper =
48
+ params?.resourceEventMapper || DEFAULTS.resourceEventMapper;
49
+ this.actionEventMapper =
50
+ params?.actionEventMapper || DEFAULTS.actionEventMapper;
51
+ }
52
+ }
53
+
54
+ const resolveJSONConfiguration = (
55
+ userSpecifiedConfiguration: unknown
56
+ ): Record<string, any> => {
57
+ if (
58
+ userSpecifiedConfiguration === undefined ||
59
+ userSpecifiedConfiguration === null
60
+ ) {
61
+ try {
62
+ // This corresponds to a file located at the root of a RN project.
63
+ // /!\ We have to write the require this way as dynamic requires are not supported by Hermes.
64
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
65
+ const jsonContent = require('../../../../../../datadog-configuration.json');
66
+
67
+ if (
68
+ typeof jsonContent !== 'object' ||
69
+ !jsonContent['configuration']
70
+ ) {
71
+ console.error(`Failed to parse the Datadog configuration file located at the root of the project.
72
+ Your configuration must validate the node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json JSON schema.
73
+ You can use VSCode to check your configuration by adding the following line to your JSON file:
74
+ {
75
+ "$schema": "./node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json",
76
+ }`);
77
+
78
+ return {};
79
+ }
80
+
81
+ return jsonContent.configuration as Record<string, any>;
82
+ } catch (error) {
83
+ console.error(`Failed to read Datadog configuration file at the root of the project.
84
+ If you don't have a datadog-configuration.json file at the same level as your node_modules directory,\
85
+ please use the following syntax:\n
86
+ new FileBasedConfiguration({configuration: require('./file/to/configuration-file.json')})
87
+ `);
88
+ return {};
89
+ }
90
+ }
91
+ if (
92
+ typeof userSpecifiedConfiguration !== 'object' ||
93
+ !(userSpecifiedConfiguration as any)['configuration']
94
+ ) {
95
+ console.error(`Failed to parse the Datadog configuration file you provided.
96
+ Your configuration must validate the node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json JSON schema.
97
+ You can use VSCode to check your configuration by adding the following line to your JSON file:
98
+ {
99
+ "$schema": "./node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json",
100
+ }`);
101
+
102
+ return {};
103
+ }
104
+
105
+ return (userSpecifiedConfiguration as any)['configuration'] as Record<
106
+ string,
107
+ any
108
+ >;
109
+ };
110
+
111
+ export const getJSONConfiguration = (
112
+ userSpecifiedConfiguration: unknown
113
+ ): {
114
+ clientToken: string;
115
+ env: string;
116
+ applicationId: string;
117
+ trackInteractions: boolean | undefined;
118
+ trackResources: boolean | undefined;
119
+ trackErrors: boolean | undefined;
120
+ trackingConsent: TrackingConsent | undefined;
121
+ longTaskThresholdMs: number | undefined;
122
+ verbosity: SdkVerbosity | undefined;
123
+ actionNameAttribute: string | undefined;
124
+ resourceTracingSamplingRate: number | undefined;
125
+ firstPartyHosts: FirstPartyHostsConfiguration | undefined;
126
+ } => {
127
+ const configuration = resolveJSONConfiguration(userSpecifiedConfiguration);
128
+
129
+ return {
130
+ clientToken: configuration.clientToken,
131
+ env: configuration.env,
132
+ applicationId: configuration.applicationId,
133
+ trackInteractions: configuration.trackInteractions,
134
+ trackResources: configuration.trackResources,
135
+ trackErrors: configuration.trackErrors,
136
+ trackingConsent: buildTrackingConsent(configuration.trackingConsent),
137
+ longTaskThresholdMs: configuration.longTaskThresholdMs,
138
+ verbosity: buildSdkVerbosity(configuration.verbosity),
139
+ actionNameAttribute: configuration.actionNameAttribute,
140
+ resourceTracingSamplingRate: configuration.resourceTracingSamplingRate,
141
+ firstPartyHosts: buildFirstPartyHosts(configuration.firstPartyHosts)
142
+ };
143
+ };
144
+
145
+ const buildFirstPartyHosts = (
146
+ firstPartyHosts: { match: string; propagatorTypes: string[] }[] | undefined
147
+ ): FirstPartyHostsConfiguration | undefined => {
148
+ if (!firstPartyHosts) {
149
+ return undefined;
150
+ }
151
+
152
+ try {
153
+ return firstPartyHosts.map(({ match, propagatorTypes }) => ({
154
+ match,
155
+ propagatorTypes: propagatorTypes.map(formatPropagatorType)
156
+ }));
157
+ } catch (error) {
158
+ console.error(`Failed to parse the first party hosts from the Datadog configuration file you provided:
159
+ ${(error as any).message}
160
+ The first party hosts will not be set for this session.
161
+ `);
162
+ return undefined;
163
+ }
164
+ };
165
+
166
+ export const formatPropagatorType = (
167
+ propagatorType: string
168
+ ): PropagatorType => {
169
+ switch (propagatorType.toLowerCase()) {
170
+ case 'b3': {
171
+ return PropagatorType.B3;
172
+ }
173
+ case 'b3multi': {
174
+ return PropagatorType.B3MULTI;
175
+ }
176
+ case 'datadog': {
177
+ return PropagatorType.DATADOG;
178
+ }
179
+ case 'tracecontext': {
180
+ return PropagatorType.TRACECONTEXT;
181
+ }
182
+ default: {
183
+ throw new Error(
184
+ `Failed to parse propagator type ${propagatorType}.`
185
+ );
186
+ }
187
+ }
188
+ };
189
+
190
+ const buildTrackingConsent = (
191
+ trackingConsent: string | undefined
192
+ ): TrackingConsent | undefined => {
193
+ if (trackingConsent === undefined) {
194
+ return undefined;
195
+ }
196
+ switch (trackingConsent.toLowerCase()) {
197
+ case 'granted': {
198
+ return TrackingConsent.GRANTED;
199
+ }
200
+ case 'pending': {
201
+ return TrackingConsent.PENDING;
202
+ }
203
+ case 'not_granted': {
204
+ return TrackingConsent.NOT_GRANTED;
205
+ }
206
+ default: {
207
+ return DEFAULTS.trackingConsent;
208
+ }
209
+ }
210
+ };
211
+
212
+ const buildSdkVerbosity = (
213
+ verbosity: string | undefined
214
+ ): SdkVerbosity | undefined => {
215
+ if (verbosity === undefined) {
216
+ return undefined;
217
+ }
218
+ switch (verbosity.toLowerCase()) {
219
+ case 'debug': {
220
+ return SdkVerbosity.DEBUG;
221
+ }
222
+ case 'info': {
223
+ return SdkVerbosity.INFO;
224
+ }
225
+ case 'warn': {
226
+ return SdkVerbosity.WARN;
227
+ }
228
+ case 'error': {
229
+ return SdkVerbosity.ERROR;
230
+ }
231
+ default: {
232
+ return undefined;
233
+ }
234
+ }
235
+ };
@@ -0,0 +1,245 @@
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 { PropagatorType } from '../../../rum/types';
8
+ import {
9
+ FileBasedConfiguration,
10
+ formatPropagatorType,
11
+ getJSONConfiguration
12
+ } from '../FileBasedConfiguration';
13
+
14
+ import configurationAllFields from './__fixtures__/configuration-all-fields.json';
15
+ import malformedConfiguration from './__fixtures__/malformed-configuration.json';
16
+
17
+ describe('FileBasedConfiguration', () => {
18
+ describe('with user-specified configuration', () => {
19
+ it('resolves all properties from a given file path', () => {
20
+ const config = new FileBasedConfiguration({
21
+ configuration: {
22
+ configuration: {
23
+ applicationId: 'fake-app-id',
24
+ env: 'fake-env',
25
+ clientToken: 'fake-client-token',
26
+ trackInteractions: true,
27
+ trackResources: true,
28
+ trackErrors: true,
29
+ trackingConsent: 'NOT_GRANTED',
30
+ longTaskThresholdMs: 44,
31
+ verbosity: 'WARN',
32
+ actionNameAttribute: 'action-name-attr',
33
+ resourceTracingSamplingRate: 33,
34
+ firstPartyHosts: [
35
+ {
36
+ match: 'example.com',
37
+ propagatorTypes: [
38
+ 'B3MULTI',
39
+ 'TRACECONTEXT',
40
+ 'B3',
41
+ 'DATADOG'
42
+ ]
43
+ }
44
+ ]
45
+ }
46
+ }
47
+ });
48
+ expect(config).toMatchInlineSnapshot(`
49
+ FileBasedConfiguration {
50
+ "actionEventMapper": null,
51
+ "actionNameAttribute": "action-name-attr",
52
+ "additionalConfiguration": {},
53
+ "applicationId": "fake-app-id",
54
+ "batchSize": "MEDIUM",
55
+ "bundleLogsWithRum": true,
56
+ "bundleLogsWithTraces": true,
57
+ "clientToken": "fake-client-token",
58
+ "customEndpoints": {},
59
+ "env": "fake-env",
60
+ "errorEventMapper": null,
61
+ "firstPartyHosts": [
62
+ {
63
+ "match": "example.com",
64
+ "propagatorTypes": [
65
+ "b3multi",
66
+ "tracecontext",
67
+ "b3",
68
+ "datadog",
69
+ ],
70
+ },
71
+ ],
72
+ "initializationMode": "SYNC",
73
+ "logEventMapper": null,
74
+ "longTaskThresholdMs": 44,
75
+ "nativeCrashReportEnabled": false,
76
+ "nativeInteractionTracking": false,
77
+ "nativeLongTaskThresholdMs": 200,
78
+ "nativeViewTracking": false,
79
+ "proxyConfig": undefined,
80
+ "resourceEventMapper": null,
81
+ "resourceTracingSamplingRate": 33,
82
+ "serviceName": undefined,
83
+ "sessionSamplingRate": 100,
84
+ "site": "US1",
85
+ "telemetrySampleRate": 20,
86
+ "trackBackgroundEvents": false,
87
+ "trackErrors": true,
88
+ "trackFrustrations": true,
89
+ "trackInteractions": true,
90
+ "trackResources": true,
91
+ "trackingConsent": "not_granted",
92
+ "uploadFrequency": "AVERAGE",
93
+ "verbosity": "warn",
94
+ "vitalsUpdateFrequency": "AVERAGE",
95
+ }
96
+ `);
97
+ });
98
+ it('applies default values to configuration from a given file path', () => {
99
+ const config = new FileBasedConfiguration({
100
+ configuration: {
101
+ configuration: {
102
+ applicationId: 'fake-app-id',
103
+ env: 'fake-env',
104
+ clientToken: 'fake-client-token'
105
+ }
106
+ }
107
+ });
108
+ expect(config).toMatchInlineSnapshot(`
109
+ FileBasedConfiguration {
110
+ "actionEventMapper": null,
111
+ "actionNameAttribute": undefined,
112
+ "additionalConfiguration": {},
113
+ "applicationId": "fake-app-id",
114
+ "batchSize": "MEDIUM",
115
+ "bundleLogsWithRum": true,
116
+ "bundleLogsWithTraces": true,
117
+ "clientToken": "fake-client-token",
118
+ "customEndpoints": {},
119
+ "env": "fake-env",
120
+ "errorEventMapper": null,
121
+ "firstPartyHosts": [],
122
+ "initializationMode": "SYNC",
123
+ "logEventMapper": null,
124
+ "longTaskThresholdMs": 0,
125
+ "nativeCrashReportEnabled": false,
126
+ "nativeInteractionTracking": false,
127
+ "nativeLongTaskThresholdMs": 200,
128
+ "nativeViewTracking": false,
129
+ "proxyConfig": undefined,
130
+ "resourceEventMapper": null,
131
+ "resourceTracingSamplingRate": 20,
132
+ "serviceName": undefined,
133
+ "sessionSamplingRate": 100,
134
+ "site": "US1",
135
+ "telemetrySampleRate": 20,
136
+ "trackBackgroundEvents": false,
137
+ "trackErrors": false,
138
+ "trackFrustrations": true,
139
+ "trackInteractions": false,
140
+ "trackResources": false,
141
+ "trackingConsent": "granted",
142
+ "uploadFrequency": "AVERAGE",
143
+ "verbosity": undefined,
144
+ "vitalsUpdateFrequency": "AVERAGE",
145
+ }
146
+ `);
147
+ });
148
+ it('applies event mappers to configuration when provided', () => {
149
+ const actionEventMapper = () => null;
150
+ const errorEventMapper = () => null;
151
+ const resourceEventMapper = () => null;
152
+ const config = new FileBasedConfiguration({
153
+ configuration: {
154
+ configuration: {
155
+ applicationId: 'fake-app-id',
156
+ env: 'fake-env',
157
+ clientToken: 'fake-client-token'
158
+ }
159
+ },
160
+ actionEventMapper,
161
+ errorEventMapper,
162
+ resourceEventMapper
163
+ });
164
+ expect(config.actionEventMapper).toBe(actionEventMapper);
165
+ expect(config.errorEventMapper).toBe(errorEventMapper);
166
+ expect(config.resourceEventMapper).toBe(resourceEventMapper);
167
+ });
168
+ it('prints a warning message when the configuration file cannot be parsed correctly', () => {
169
+ expect(
170
+ () =>
171
+ new FileBasedConfiguration({
172
+ configuration: {
173
+ applicationId: 'fake-app-id',
174
+ env: 'fake-env',
175
+ clientToken: 'fake-client-token'
176
+ }
177
+ })
178
+ ).not.toThrow();
179
+ });
180
+ it('prints a warning message when the first party hosts contain unknown propagator types', () => {
181
+ const config = new FileBasedConfiguration({
182
+ configuration: {
183
+ configuration: {
184
+ applicationId: 'fake-app-id',
185
+ env: 'fake-env',
186
+ clientToken: 'fake-client-token',
187
+ firstPartyHosts: [
188
+ {
189
+ match: 'example.com',
190
+ propagatorTypes: ['UNKNOWN']
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ });
196
+ expect(config.firstPartyHosts).toHaveLength(0);
197
+ });
198
+ });
199
+ describe('with resolved file configuration', () => {
200
+ it('resolves configuration fields', () => {
201
+ const configuration = getJSONConfiguration(configurationAllFields);
202
+
203
+ expect(configuration).toMatchInlineSnapshot(`
204
+ {
205
+ "actionNameAttribute": "action-name-attr",
206
+ "applicationId": "fake-app-id",
207
+ "clientToken": "fake-client-token",
208
+ "env": "fake-env",
209
+ "firstPartyHosts": [
210
+ {
211
+ "match": "example.com",
212
+ "propagatorTypes": [
213
+ "b3multi",
214
+ "tracecontext",
215
+ ],
216
+ },
217
+ ],
218
+ "longTaskThresholdMs": 44,
219
+ "resourceTracingSamplingRate": 33,
220
+ "trackErrors": true,
221
+ "trackInteractions": true,
222
+ "trackResources": true,
223
+ "trackingConsent": "not_granted",
224
+ "verbosity": "warn",
225
+ }
226
+ `);
227
+ });
228
+ it('prints a warning message when the configuration file is not found', () => {
229
+ expect(() => getJSONConfiguration(undefined)).not.toThrow();
230
+ });
231
+ it('prints a warning message when the configuration file cannot be parsed correctly', () => {
232
+ expect(() =>
233
+ getJSONConfiguration(malformedConfiguration)
234
+ ).not.toThrow();
235
+ });
236
+ });
237
+
238
+ describe('formatPropagatorType', () => {
239
+ it('formats all propagatorTypes correctly', () => {
240
+ Object.values(PropagatorType).forEach(propagator => {
241
+ expect(formatPropagatorType(propagator)).not.toBeNull();
242
+ });
243
+ });
244
+ });
245
+ });
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "../../../../../datadog-configuration.schema.json",
3
+ "configuration": {
4
+ "applicationId": "fake-app-id",
5
+ "env": "fake-env",
6
+ "clientToken": "fake-client-token",
7
+ "trackInteractions": true,
8
+ "trackResources": true,
9
+ "trackErrors": true,
10
+ "trackingConsent": "NOT_GRANTED",
11
+ "longTaskThresholdMs": 44,
12
+ "verbosity": "WARN",
13
+ "actionNameAttribute": "action-name-attr",
14
+ "resourceTracingSamplingRate": 33,
15
+ "firstPartyHosts": [
16
+ {
17
+ "match": "example.com",
18
+ "propagatorTypes": ["B3MULTI", "TRACECONTEXT"]
19
+ }
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "clientToken": "clientToken",
3
+ "env": "env",
4
+ "applicationId": "applicationId"
5
+ }
package/src/types.tsx CHANGED
@@ -18,7 +18,7 @@ export class DdSdkConfiguration {
18
18
  readonly sampleRate: number,
19
19
  readonly site: string,
20
20
  readonly trackingConsent: string,
21
- readonly additionalConfig: object,
21
+ readonly additionalConfiguration: object,
22
22
  readonly telemetrySampleRate: number,
23
23
  readonly vitalsUpdateFrequency: string,
24
24
  readonly uploadFrequency: string,
@@ -37,7 +37,26 @@ export class DdSdkConfiguration {
37
37
  trackNetworkRequests: boolean;
38
38
  reactVersion: string;
39
39
  reactNativeVersion: string;
40
- }
40
+ },
41
+ readonly nativeViewTracking: boolean,
42
+ readonly nativeInteractionTracking: boolean,
43
+ readonly verbosity: string | undefined,
44
+ readonly proxyConfig:
45
+ | {
46
+ type: string;
47
+ address: string;
48
+ port: number;
49
+ username?: string;
50
+ password?: string;
51
+ }
52
+ | undefined,
53
+ readonly serviceName: string | undefined,
54
+ readonly firstPartyHosts: {
55
+ match: string;
56
+ propagatorTypes: string[];
57
+ }[],
58
+ readonly bundleLogsWithRum: boolean,
59
+ readonly bundleLogsWithTraces: boolean
41
60
  ) {}
42
61
  }
43
62
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '2.2.0';
2
+ export const version = '2.3.0';