@datadog/mobile-react-native 3.12.0 → 3.13.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 (81) hide show
  1. package/DatadogSDKReactNative.podspec +357 -14
  2. package/README.md +3 -2
  3. package/android/build.gradle +9 -9
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +27 -2
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +27 -2
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +25 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -0
  9. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +104 -0
  10. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +8 -0
  11. package/android/src/test/resources/input/complete-configuration.json +5 -0
  12. package/datadog-configuration.schema.json +21 -0
  13. package/ios/Sources/DdFlagsImplementation.swift +3 -0
  14. package/ios/Sources/DdSdkConfiguration.swift +11 -1
  15. package/ios/Sources/DdSdkNativeInitialization.swift +24 -2
  16. package/ios/Sources/RNDdSdkConfiguration.swift +14 -2
  17. package/ios/Sources/SdkVersion.swift +1 -1
  18. package/lib/commonjs/config/FileBasedConfiguration.js +2 -1
  19. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  20. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +1 -0
  21. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  22. package/lib/commonjs/config/features/RumConfiguration.js +4 -0
  23. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  24. package/lib/commonjs/config/features/RumConfigurationNative.js +4 -0
  25. package/lib/commonjs/config/types/TimeseriesConfiguration.js +25 -0
  26. package/lib/commonjs/config/types/TimeseriesConfiguration.js.map +1 -0
  27. package/lib/commonjs/config/types/index.js +7 -0
  28. package/lib/commonjs/config/types/index.js.map +1 -1
  29. package/lib/commonjs/index.js +7 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/version.js +1 -1
  32. package/lib/module/config/FileBasedConfiguration.js +2 -1
  33. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  34. package/lib/module/config/async/AutoInstrumentationConfiguration.js +1 -0
  35. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  36. package/lib/module/config/features/RumConfiguration.js +4 -0
  37. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  38. package/lib/module/config/features/RumConfigurationNative.js +1 -1
  39. package/lib/module/config/types/TimeseriesConfiguration.js +19 -0
  40. package/lib/module/config/types/TimeseriesConfiguration.js.map +1 -0
  41. package/lib/module/config/types/index.js +1 -0
  42. package/lib/module/config/types/index.js.map +1 -1
  43. package/lib/module/index.js +2 -1
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/version.js +1 -1
  46. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  47. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -1
  48. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  49. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +3 -0
  50. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  51. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -1
  52. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  53. package/lib/typescript/config/features/RumConfiguration.d.ts +3 -0
  54. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  55. package/lib/typescript/config/features/RumConfiguration.type.d.ts +9 -1
  56. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  57. package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
  58. package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
  59. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts +19 -0
  60. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts.map +1 -0
  61. package/lib/typescript/config/types/index.d.ts +2 -0
  62. package/lib/typescript/config/types/index.d.ts.map +1 -1
  63. package/lib/typescript/index.d.ts +4 -2
  64. package/lib/typescript/index.d.ts.map +1 -1
  65. package/lib/typescript/version.d.ts +1 -1
  66. package/package.json +3 -3
  67. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
  68. package/src/config/FileBasedConfiguration.ts +3 -1
  69. package/src/config/FileBasedConfiguration.type.ts +2 -0
  70. package/src/config/__tests__/FileBasedConfiguration.test.ts +7 -0
  71. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +6 -1
  72. package/src/config/async/AutoInstrumentationConfiguration.ts +4 -0
  73. package/src/config/async/PartialInitializationConfiguration.ts +2 -0
  74. package/src/config/features/RumConfiguration.ts +6 -0
  75. package/src/config/features/RumConfiguration.type.ts +11 -1
  76. package/src/config/features/RumConfigurationNative.ts +3 -0
  77. package/src/config/types/TimeseriesConfiguration.ts +26 -0
  78. package/src/config/types/index.ts +5 -0
  79. package/src/index.tsx +8 -0
  80. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +52 -0
  81. package/src/version.ts +1 -1
@@ -92,6 +92,11 @@ describe('FileBasedConfiguration', () => {
92
92
  "trackNonFatalAnrs": true,
93
93
  "trackResources": true,
94
94
  "trackWatchdogTerminations": true,
95
+ "unstable_timeseries": {
96
+ "collectTypes": [
97
+ "cpu",
98
+ ],
99
+ },
95
100
  "useAccessibilityLabel": false,
96
101
  "vitalsUpdateFrequency": "NEVER",
97
102
  },
@@ -208,6 +213,7 @@ describe('FileBasedConfiguration', () => {
208
213
  "trackNonFatalAnrs": undefined,
209
214
  "trackResources": true,
210
215
  "trackWatchdogTerminations": false,
216
+ "unstable_timeseries": undefined,
211
217
  "useAccessibilityLabel": false,
212
218
  "vitalsUpdateFrequency": "AVERAGE",
213
219
  },
@@ -276,6 +282,7 @@ describe('FileBasedConfiguration', () => {
276
282
  "trackNonFatalAnrs": undefined,
277
283
  "trackResources": false,
278
284
  "trackWatchdogTerminations": false,
285
+ "unstable_timeseries": undefined,
279
286
  "useAccessibilityLabel": true,
280
287
  "vitalsUpdateFrequency": "AVERAGE",
281
288
  },
@@ -43,7 +43,12 @@
43
43
  "trackBackgroundEvents": true,
44
44
  "trackMemoryWarnings": false,
45
45
  "trackWatchdogTerminations": true,
46
- "vitalsUpdateFrequency": "NEVER"
46
+ "vitalsUpdateFrequency": "NEVER",
47
+ "unstable_timeseries": {
48
+ "collectTypes": [
49
+ "cpu"
50
+ ]
51
+ }
47
52
  },
48
53
  "traceConfiguration": {
49
54
  "customEndpoint": "https://example.com/trace"
@@ -12,6 +12,7 @@ import { LOGS_DEFAULTS } from '../features/LogsConfiguration';
12
12
  import type { HeaderCaptureRule } from '../features/RumConfiguration.type';
13
13
  import { RUM_DEFAULTS } from '../features/RumConfiguration';
14
14
  import type { TraceConfiguration } from '../features/TraceConfiguration';
15
+ import type { TimeseriesConfiguration } from '../types';
15
16
 
16
17
  /**
17
18
  * Auto Instrumentation configuration passed to DatadogProvider.
@@ -32,6 +33,7 @@ export type AutoInstrumentationConfiguration = {
32
33
  readonly nativeViewTracking?: boolean;
33
34
  readonly nativeIosResourceTracking?: boolean;
34
35
  readonly nativeIosResourceTrackingDisallowList?: string[];
36
+ readonly unstable_timeseries?: TimeseriesConfiguration;
35
37
  readonly actionEventMapper?: ActionEventMapper | null;
36
38
  readonly errorEventMapper?: ErrorEventMapper | null;
37
39
  readonly resourceEventMapper?: ResourceEventMapper | null;
@@ -59,6 +61,7 @@ export type AutoInstrumentationParameters = {
59
61
  readonly nativeViewTracking?: boolean;
60
62
  readonly nativeIosResourceTracking?: boolean;
61
63
  readonly nativeIosResourceTrackingDisallowList?: string[];
64
+ readonly unstable_timeseries?: TimeseriesConfiguration;
62
65
  readonly actionEventMapper: ActionEventMapper | null;
63
66
  readonly errorEventMapper: ErrorEventMapper | null;
64
67
  readonly resourceEventMapper: ResourceEventMapper | null;
@@ -129,6 +132,7 @@ export const addDefaultValuesToAutoInstrumentationConfiguration = (
129
132
  features.rumConfiguration.nativeIosResourceTracking,
130
133
  nativeIosResourceTrackingDisallowList:
131
134
  features.rumConfiguration.nativeIosResourceTrackingDisallowList,
135
+ unstable_timeseries: features.rumConfiguration.unstable_timeseries,
132
136
  firstPartyHosts:
133
137
  features.rumConfiguration.firstPartyHosts ||
134
138
  RUM_DEFAULTS.getFirstPartyHosts(),
@@ -9,6 +9,7 @@ import type {
9
9
  BatchSize,
10
10
  ProxyConfiguration,
11
11
  SdkVerbosity,
12
+ TimeseriesConfiguration,
12
13
  TrackingConsent,
13
14
  UploadFrequency,
14
15
  VitalsUpdateFrequency
@@ -49,6 +50,7 @@ export type PartialInitializationConfiguration = {
49
50
  readonly trackNonFatalAnrs?: boolean;
50
51
  readonly appHangThreshold?: number;
51
52
  readonly resourceTraceSampleRate?: number;
53
+ readonly unstable_timeseries?: TimeseriesConfiguration;
52
54
  };
53
55
  readonly logsConfiguration?: {
54
56
  readonly bundleLogsWithRum?: boolean;
@@ -7,6 +7,7 @@ import type { ActionEventMapper } from '../../rum/eventMappers/actionEventMapper
7
7
  import type { ErrorEventMapper } from '../../rum/eventMappers/errorEventMapper';
8
8
  import type { ResourceEventMapper } from '../../rum/eventMappers/resourceEventMapper';
9
9
  import type { FirstPartyHost } from '../../rum/types';
10
+ import type { TimeseriesConfiguration } from '../types';
10
11
  import { VitalsUpdateFrequency } from '../types';
11
12
 
12
13
  import type {
@@ -47,6 +48,7 @@ const DEFAULTS = {
47
48
  | undefined,
48
49
  trackResources: false,
49
50
  trackWatchdogTerminations: false,
51
+ unstable_timeseries: undefined,
50
52
  useAccessibilityLabel: true,
51
53
  vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE
52
54
  };
@@ -139,6 +141,10 @@ export class RumConfiguration implements RumConfigurationType {
139
141
  public trackWatchdogTerminations: boolean =
140
142
  DEFAULTS.trackWatchdogTerminations;
141
143
 
144
+ // Experimental Timeseries Configuration
145
+ public unstable_timeseries?: TimeseriesConfiguration =
146
+ DEFAULTS.unstable_timeseries;
147
+
142
148
  // Use Accessibility Label enabled for interaction tracking
143
149
  public useAccessibilityLabel: boolean = DEFAULTS.useAccessibilityLabel;
144
150
 
@@ -7,7 +7,7 @@ import type { ActionEventMapper } from '../../rum/eventMappers/actionEventMapper
7
7
  import type { ErrorEventMapper } from '../../rum/eventMappers/errorEventMapper';
8
8
  import type { ResourceEventMapper } from '../../rum/eventMappers/resourceEventMapper';
9
9
  import type { FirstPartyHost } from '../../rum/types';
10
- import type { VitalsUpdateFrequency } from '../types';
10
+ import type { TimeseriesConfiguration, VitalsUpdateFrequency } from '../types';
11
11
 
12
12
  /**
13
13
  * Required RUM configuration values.
@@ -303,6 +303,16 @@ export interface RumConfigurationOptions {
303
303
  * Preferred frequency for collecting mobile vitals.
304
304
  */
305
305
  vitalsUpdateFrequency?: VitalsUpdateFrequency;
306
+
307
+ // TODO: RUM-18601 remove the Android limitation note once the Android SDK supports late initialization
308
+ /**
309
+ * Experimental: configuration for memory and CPU timeseries collection.
310
+ *
311
+ * On Android, timeseries are only collected when the SDK is initialized natively
312
+ * from `MainApplication.onCreate` (`DdSdkNativeInitialization.initFromNative`),
313
+ * because the Android SDK must be initialized before the first Activity starts.
314
+ */
315
+ unstable_timeseries?: TimeseriesConfiguration;
306
316
  }
307
317
 
308
318
  /**
@@ -3,6 +3,8 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
+ import type { TimeseriesConfiguration } from '../types';
7
+
6
8
  export type RumNativeConfiguration = {
7
9
  readonly applicationId: string;
8
10
  readonly trackFrustrations: boolean;
@@ -25,4 +27,5 @@ export type RumNativeConfiguration = {
25
27
  readonly telemetrySampleRate: number;
26
28
  readonly customEndpoint: string;
27
29
  readonly firstPartyHosts: { match: string; propagatorTypes: string[] }[];
30
+ readonly unstable_timeseries: TimeseriesConfiguration | undefined;
28
31
  };
@@ -0,0 +1,26 @@
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
+ * Experimental: the type of timeseries data to collect.
9
+ */
10
+ export type TimeseriesType = 'cpu' | 'memory';
11
+
12
+ /**
13
+ * Experimental: configuration for memory and CPU timeseries collection.
14
+ */
15
+ export interface TimeseriesConfiguration {
16
+ /**
17
+ * The types of timeseries data to collect. Required.
18
+ * Use `defaultTimeseriesTypes` to collect the default set (cpu and memory).
19
+ */
20
+ collectTypes: TimeseriesType[];
21
+ }
22
+
23
+ /**
24
+ * Experimental: the default set of timeseries types to collect (cpu and memory).
25
+ */
26
+ export const defaultTimeseriesTypes: TimeseriesType[] = ['cpu', 'memory'];
@@ -8,6 +8,11 @@ export { BatchProcessingLevel } from './BatchProcessingLevel';
8
8
  export { BatchSize } from './BatchSize';
9
9
  export { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
10
10
  export { SdkVerbosity } from './SdkVerbosity';
11
+ export type {
12
+ TimeseriesConfiguration,
13
+ TimeseriesType
14
+ } from './TimeseriesConfiguration';
15
+ export { defaultTimeseriesTypes } from './TimeseriesConfiguration';
11
16
  export { TrackingConsent } from './TrackingConsent';
12
17
  export { UploadFrequency } from './UploadFrequency';
13
18
  export { VitalsUpdateFrequency } from './VitalsUpdateFrequency';
package/src/index.tsx CHANGED
@@ -22,6 +22,11 @@ import {
22
22
  ProxyType
23
23
  } from './config/types/ProxyConfiguration';
24
24
  import { SdkVerbosity } from './config/types/SdkVerbosity';
25
+ import { defaultTimeseriesTypes } from './config/types/TimeseriesConfiguration';
26
+ import type {
27
+ TimeseriesConfiguration,
28
+ TimeseriesType
29
+ } from './config/types/TimeseriesConfiguration';
25
30
  import { TrackingConsent } from './config/types/TrackingConsent';
26
31
  import {
27
32
  BatchProcessingLevel,
@@ -97,6 +102,7 @@ export {
97
102
  TrackingConsent,
98
103
  SdkVerbosity,
99
104
  VitalsUpdateFrequency,
105
+ defaultTimeseriesTypes,
100
106
  PropagatorType,
101
107
  UploadFrequency,
102
108
  BatchSize,
@@ -130,6 +136,8 @@ export type {
130
136
  PartialInitializationConfiguration,
131
137
  CoreConfigurationOptions,
132
138
  RumConfigurationOptions,
139
+ TimeseriesConfiguration,
140
+ TimeseriesType,
133
141
  LogsConfigurationOptions,
134
142
  TraceConfigurationOptions,
135
143
  FlagsConfiguration,
@@ -8,6 +8,7 @@ import { version as reactNativeVersion } from 'react-native/package.json';
8
8
  import { NativeModules } from 'react-native';
9
9
 
10
10
  import { InitializationMode } from '../../../config/types';
11
+ import type { TimeseriesConfiguration } from '../../../config/types';
11
12
  import { DdLogs } from '../../../logs/DdLogs';
12
13
  import { DdRum } from '../../../rum/DdRum';
13
14
  import { PropagatorType, RumActionType } from '../../../rum/types';
@@ -114,6 +115,7 @@ describe('DatadogProvider', () => {
114
115
  "trackNonFatalAnrs": undefined,
115
116
  "trackResources": false,
116
117
  "trackWatchdogTerminations": false,
118
+ "unstable_timeseries": undefined,
117
119
  "useAccessibilityLabel": true,
118
120
  "vitalsUpdateFrequency": "AVERAGE",
119
121
  },
@@ -344,6 +346,56 @@ describe('DatadogProvider', () => {
344
346
  );
345
347
  });
346
348
 
349
+ describe('unstable_timeseries', () => {
350
+ const timeseries: TimeseriesConfiguration = {
351
+ collectTypes: ['memory']
352
+ };
353
+
354
+ it.each([
355
+ ['unset', 'unset', undefined],
356
+ ['set', 'unset', timeseries],
357
+ ['unset', 'set', timeseries]
358
+ ])(
359
+ 'partial initialization: features %s, initialize %s => native %p',
360
+ async (featuresValue, initializeValue, expected) => {
361
+ renderWithProvider({
362
+ configuration: {
363
+ rumConfiguration: {
364
+ trackErrors: false,
365
+ trackResources: false,
366
+ trackInteractions: false,
367
+ ...(featuresValue === 'set' && {
368
+ unstable_timeseries: timeseries
369
+ })
370
+ },
371
+ traceConfiguration: {},
372
+ logsConfiguration: {}
373
+ }
374
+ });
375
+ await flushPromises();
376
+ expect(NativeModules.DdSdk.initialize).not.toHaveBeenCalled();
377
+
378
+ await DatadogProvider.initialize({
379
+ clientToken: 'fake-client-token',
380
+ env: 'fake-env',
381
+ rumConfiguration: {
382
+ applicationId: 'fake-application-id',
383
+ ...(initializeValue === 'set' && {
384
+ unstable_timeseries: timeseries
385
+ })
386
+ }
387
+ });
388
+ await flushPromises();
389
+ expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
390
+ const receivedConfiguration =
391
+ NativeModules.DdSdk.initialize.mock.calls[0][0];
392
+ expect(
393
+ receivedConfiguration.rumConfiguration.unstable_timeseries
394
+ ).toEqual(expected);
395
+ }
396
+ );
397
+ });
398
+
347
399
  describe('onInitialization callback', () => {
348
400
  it('runs after initialization when SYNC initialization', async () => {
349
401
  const onInitialization = jest.fn();
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '3.12.0';
2
+ export const version = '3.13.0';