@datadog/mobile-react-native 1.5.2 → 1.7.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 (119) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/android/build.gradle +2 -1
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -1
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdLogs.kt +162 -6
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +25 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +32 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +11 -1
  10. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +10 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +242 -2
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +27 -0
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +126 -30
  14. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +19 -1
  15. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +2 -2
  16. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +18 -1
  17. package/ios/Sources/Attributes.swift +7 -0
  18. package/ios/Sources/DdLogs.m +31 -0
  19. package/ios/Sources/DdLogs.swift +84 -4
  20. package/ios/Sources/DdRum.m +8 -0
  21. package/ios/Sources/DdRum.swift +17 -0
  22. package/ios/Sources/DdSdk.swift +40 -0
  23. package/ios/Sources/DdSdkConfiguration.swift +19 -1
  24. package/ios/Sources/RNDdSdkConfiguration.swift +11 -1
  25. package/lib/commonjs/DdSdkReactNative.js +6 -2
  26. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  27. package/lib/commonjs/DdSdkReactNativeConfiguration.js +45 -2
  28. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  29. package/lib/commonjs/InternalLog.js +6 -2
  30. package/lib/commonjs/InternalLog.js.map +1 -1
  31. package/lib/commonjs/errorUtils.js +20 -1
  32. package/lib/commonjs/errorUtils.js.map +1 -1
  33. package/lib/commonjs/index.js +12 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/logs/DdLogs.js +102 -11
  36. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  37. package/lib/commonjs/logs/eventMapper.js.map +1 -1
  38. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  39. package/lib/commonjs/rum/DdRum.js +14 -0
  40. package/lib/commonjs/rum/DdRum.js.map +1 -1
  41. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +62 -46
  42. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  43. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
  44. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  45. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
  46. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  47. package/lib/commonjs/rum/types.js.map +1 -1
  48. package/lib/commonjs/types.js +4 -1
  49. package/lib/commonjs/types.js.map +1 -1
  50. package/lib/commonjs/version.js +1 -1
  51. package/lib/commonjs/version.js.map +1 -1
  52. package/lib/module/DdSdkReactNative.js +6 -2
  53. package/lib/module/DdSdkReactNative.js.map +1 -1
  54. package/lib/module/DdSdkReactNativeConfiguration.js +42 -1
  55. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  56. package/lib/module/InternalLog.js +2 -1
  57. package/lib/module/InternalLog.js.map +1 -1
  58. package/lib/module/errorUtils.js +15 -0
  59. package/lib/module/errorUtils.js.map +1 -1
  60. package/lib/module/index.js +2 -2
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/logs/DdLogs.js +103 -12
  63. package/lib/module/logs/DdLogs.js.map +1 -1
  64. package/lib/module/logs/eventMapper.js.map +1 -1
  65. package/lib/module/nativeModulesTypes.js.map +1 -1
  66. package/lib/module/rum/DdRum.js +12 -0
  67. package/lib/module/rum/DdRum.js.map +1 -1
  68. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +63 -46
  69. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  70. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
  71. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  72. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
  73. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  74. package/lib/module/rum/types.js.map +1 -1
  75. package/lib/module/types.js +4 -1
  76. package/lib/module/types.js.map +1 -1
  77. package/lib/module/version.js +1 -1
  78. package/lib/module/version.js.map +1 -1
  79. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +47 -0
  80. package/lib/typescript/InternalLog.d.ts +1 -0
  81. package/lib/typescript/errorUtils.d.ts +2 -0
  82. package/lib/typescript/index.d.ts +2 -2
  83. package/lib/typescript/logs/DdLogs.d.ts +13 -5
  84. package/lib/typescript/logs/eventMapper.d.ts +5 -5
  85. package/lib/typescript/logs/types.d.ts +34 -8
  86. package/lib/typescript/nativeModulesTypes.d.ts +51 -4
  87. package/lib/typescript/rum/DdRum.d.ts +2 -0
  88. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
  89. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
  90. package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +5 -2
  91. package/lib/typescript/rum/types.d.ts +4 -0
  92. package/lib/typescript/types.d.ts +8 -1
  93. package/lib/typescript/version.d.ts +1 -1
  94. package/package.json +2 -2
  95. package/src/DdSdkReactNative.tsx +9 -1
  96. package/src/DdSdkReactNativeConfiguration.tsx +56 -1
  97. package/src/InternalLog.tsx +3 -1
  98. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +20 -3
  99. package/src/__tests__/errorUtils.test.ts +49 -0
  100. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +14 -14
  101. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +474 -109
  102. package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +18 -0
  103. package/src/errorUtils.ts +15 -0
  104. package/src/index.tsx +6 -2
  105. package/src/logs/DdLogs.ts +166 -16
  106. package/src/logs/__tests__/DdLogs.test.ts +169 -0
  107. package/src/logs/__tests__/eventMapper.test.ts +34 -0
  108. package/src/logs/eventMapper.ts +15 -4
  109. package/src/logs/types.ts +36 -8
  110. package/src/nativeModulesTypes.ts +81 -4
  111. package/src/rum/DdRum.ts +17 -0
  112. package/src/rum/__tests__/DdRum.test.ts +12 -27
  113. package/src/rum/instrumentation/DdRumErrorTracking.tsx +44 -10
  114. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +7 -4
  115. package/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.ts +11 -3
  116. package/src/rum/types.ts +5 -0
  117. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -0
  118. package/src/types.tsx +5 -0
  119. package/src/version.ts +1 -1
@@ -12,6 +12,34 @@ export declare enum VitalsUpdateFrequency {
12
12
  RARE = "RARE",
13
13
  NEVER = "NEVER"
14
14
  }
15
+ export declare enum UploadFrequency {
16
+ /**
17
+ * Upload data every 1000ms.
18
+ */
19
+ FREQUENT = "FREQUENT",
20
+ /**
21
+ * Upload data every 5000ms.
22
+ */
23
+ AVERAGE = "AVERAGE",
24
+ /**
25
+ * Upload data every 10000ms.
26
+ */
27
+ RARE = "RARE"
28
+ }
29
+ export declare enum BatchSize {
30
+ /**
31
+ * Upload less frequent, larger batches of data
32
+ */
33
+ LARGE = "LARGE",
34
+ /**
35
+ * Use default size for batches of data
36
+ */
37
+ MEDIUM = "MEDIUM",
38
+ /**
39
+ * Upload more frequent, smaller batches of data
40
+ */
41
+ SMALL = "SMALL"
42
+ }
15
43
  export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
16
44
  export declare type LegacyFirstPartyHost = string;
17
45
  /**
@@ -130,6 +158,22 @@ export declare class DdSdkReactNativeConfiguration {
130
158
  * Enables tracking of frustration signals (error taps). Defaults to `true`.
131
159
  */
132
160
  trackFrustrations: boolean;
161
+ /**
162
+ * Sets the preferred frequency for uploading batches of data.
163
+ */
164
+ uploadFrequency: UploadFrequency;
165
+ /**
166
+ * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.
167
+ * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.
168
+ */
169
+ batchSize: BatchSize;
170
+ /**
171
+ * Enables tracking of RUM event when no RUM View is active.
172
+ *
173
+ * By default, background events are not tracked. Enabling this feature might increase the
174
+ * number of sessions tracked and impact your billing.
175
+ */
176
+ trackBackgroundEvents: boolean;
133
177
  logEventMapper: LogEventMapper | null;
134
178
  errorEventMapper: ErrorEventMapper | null;
135
179
  resourceEventMapper: ResourceEventMapper | null;
@@ -196,6 +240,9 @@ export declare type PartialInitializationConfiguration = {
196
240
  readonly telemetrySampleRate?: number;
197
241
  readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
198
242
  readonly trackFrustrations?: boolean;
243
+ readonly uploadFrequency?: UploadFrequency;
244
+ readonly batchSize?: BatchSize;
245
+ readonly trackBackgroundEvents?: boolean;
199
246
  };
200
247
  export declare const buildConfigurationFromPartialConfiguration: (features: AutoInstrumentationConfiguration, configuration: PartialInitializationConfiguration) => DdSdkReactNativeConfiguration;
201
248
  export declare class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
@@ -1,4 +1,5 @@
1
1
  import { SdkVerbosity } from './SdkVerbosity';
2
+ export declare const DATADOG_MESSAGE_PREFIX = "DATADOG:";
2
3
  /**
3
4
  * /!\ DO NOT USE THIS IN YOUR APP /!\\
4
5
  *
@@ -1,5 +1,6 @@
1
1
  export declare const EMPTY_MESSAGE = "Unknown Error";
2
2
  export declare const EMPTY_STACK_TRACE = "";
3
+ export declare const DEFAULT_ERROR_NAME = "Error";
3
4
  export declare const getErrorMessage: (error: any | undefined) => string;
4
5
  /**
5
6
  * Will extract the stack from the error, taking the first key found among:
@@ -10,3 +11,4 @@ export declare const getErrorMessage: (error: any | undefined) => string;
10
11
  * generate a stack from this information.
11
12
  */
12
13
  export declare const getErrorStackTrace: (error: any | undefined) => string;
14
+ export declare const getErrorName: (error: unknown) => string;
@@ -1,4 +1,4 @@
1
- import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency } from './DdSdkReactNativeConfiguration';
1
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency, UploadFrequency, BatchSize } from './DdSdkReactNativeConfiguration';
2
2
  import { DdSdkReactNative } from './DdSdkReactNative';
3
3
  import { InternalLog } from './InternalLog';
4
4
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -9,4 +9,4 @@ import { DdRum } from './rum/DdRum';
9
9
  import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
10
10
  import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
11
11
  import { DdTrace } from './trace/DdTrace';
12
- export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType };
12
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize };
@@ -1,12 +1,20 @@
1
- import type { DdLogsType, LogEventMapper } from './types';
1
+ import type { DdLogsType, LogArguments, LogEventMapper, LogWithErrorArguments } from './types';
2
2
  declare class DdLogsWrapper implements DdLogsType {
3
3
  private nativeLogs;
4
4
  private logEventMapper;
5
- debug(message: string, context?: object): Promise<void>;
6
- info(message: string, context?: object): Promise<void>;
7
- warn(message: string, context?: object): Promise<void>;
8
- error(message: string, context?: object): Promise<void>;
5
+ debug(...args: LogArguments | LogWithErrorArguments): Promise<void>;
6
+ info(...args: LogArguments | LogWithErrorArguments): Promise<void>;
7
+ warn(...args: LogArguments | LogWithErrorArguments): Promise<void>;
8
+ error(...args: LogArguments | LogWithErrorArguments): Promise<void>;
9
+ /**
10
+ * Since the InternalLog does not have a verbosity set yet in this case,
11
+ * we use console.warn to warn the user in dev mode.
12
+ */
13
+ private printLogDroppedSdkNotInitialized;
14
+ private printlogDroppedByMapper;
15
+ private printLogTracked;
9
16
  private log;
17
+ private logWithError;
10
18
  registerLogEventMapper(logEventMapper: LogEventMapper): void;
11
19
  unregisterLogEventMapper(): void;
12
20
  }
@@ -1,11 +1,11 @@
1
1
  import type { Attributes } from '../sdk/AttributesSingleton/types';
2
2
  import { EventMapper } from '../sdk/EventMappers/EventMapper';
3
3
  import type { UserInfo } from '../sdk/UserInfoSingleton/types';
4
- import type { LogEvent, LogEventMapper, NativeLog, RawLog } from './types';
5
- export declare const formatLogEventToNativeLog: (logEvent: LogEvent) => NativeLog;
6
- export declare const formatRawLogToNativeEvent: (rawLog: RawLog) => NativeLog;
7
- export declare const formatRawLogToLogEvent: (rawLog: RawLog, additionalInformation: {
4
+ import type { LogEvent, LogEventMapper, NativeLog, NativeLogWithError, RawLog, RawLogWithError } from './types';
5
+ export declare const formatLogEventToNativeLog: (logEvent: LogEvent) => NativeLog | NativeLogWithError;
6
+ export declare const formatRawLogToNativeEvent: (rawLog: RawLog | RawLogWithError) => NativeLog | NativeLogWithError;
7
+ export declare const formatRawLogToLogEvent: (rawLog: RawLog | RawLogWithError, additionalInformation: {
8
8
  userInfo: UserInfo;
9
9
  attributes: Attributes;
10
10
  }) => LogEvent;
11
- export declare const generateEventMapper: (logEventMapper: LogEventMapper | undefined) => EventMapper<RawLog, LogEvent, NativeLog>;
11
+ export declare const generateEventMapper: (logEventMapper: LogEventMapper | undefined) => EventMapper<RawLog | RawLogWithError, LogEvent, NativeLog | NativeLogWithError>;
@@ -4,29 +4,29 @@ import type { UserInfo } from '../sdk/UserInfoSingleton/types';
4
4
  */
5
5
  export declare type DdLogsType = {
6
6
  /**
7
- * Send a log with level debug.
7
+ * Send a log with debug level.
8
8
  * @param message: The message to send.
9
9
  * @param context: The additional context to send.
10
10
  */
11
- debug(message: string, context?: object): Promise<void>;
11
+ debug(...args: LogArguments | LogWithErrorArguments): Promise<void>;
12
12
  /**
13
- * Send a log with level info.
13
+ * Send a log with info level.
14
14
  * @param message: The message to send.
15
15
  * @param context: The additional context to send.
16
16
  */
17
- info(message: string, context?: object): Promise<void>;
17
+ info(...args: LogArguments | LogWithErrorArguments): Promise<void>;
18
18
  /**
19
- * Send a log with level warn.
19
+ * Send a log with warn level.
20
20
  * @param message: The message to send.
21
21
  * @param context: The additional context to send.
22
22
  */
23
- warn(message: string, context?: object): Promise<void>;
23
+ warn(...args: LogArguments | LogWithErrorArguments): Promise<void>;
24
24
  /**
25
- * Send a log with level error.
25
+ * Send a log with error level.
26
26
  * @param message: The message to send.
27
27
  * @param context: The additional context to send.
28
28
  */
29
- error(message: string, context?: object): Promise<void>;
29
+ error(...args: LogArguments | LogWithErrorArguments): Promise<void>;
30
30
  };
31
31
  /**
32
32
  * Log input from developers
@@ -36,6 +36,14 @@ export declare type RawLog = {
36
36
  context: object;
37
37
  status: LogStatus;
38
38
  };
39
+ export declare type RawLogWithError = {
40
+ message: string;
41
+ errorKind: string;
42
+ errorMessage: string;
43
+ stacktrace: string;
44
+ context: object;
45
+ status: LogStatus;
46
+ };
39
47
  /**
40
48
  * Log input for native SDKs
41
49
  */
@@ -43,12 +51,30 @@ export declare type NativeLog = {
43
51
  message: string;
44
52
  context: object;
45
53
  };
54
+ export declare type NativeLogWithError = {
55
+ message: string;
56
+ errorKind: string;
57
+ errorMessage: string;
58
+ stacktrace: string;
59
+ context: object;
60
+ };
46
61
  export declare type LogStatus = 'debug' | 'info' | 'warn' | 'error';
47
62
  export declare type LogEvent = {
48
63
  message: string;
49
64
  context: object;
65
+ errorKind?: string;
66
+ errorMessage?: string;
67
+ stacktrace?: string;
50
68
  readonly status: LogStatus;
51
69
  readonly userInfo: UserInfo;
52
70
  readonly attributes?: object;
53
71
  };
54
72
  export declare type LogEventMapper = (logEvent: LogEvent) => LogEvent | null;
73
+ export declare type LogArguments = [message: string, context?: object];
74
+ export declare type LogWithErrorArguments = [
75
+ message: string,
76
+ errorKind?: string,
77
+ errorMessage?: string,
78
+ stacktrace?: string,
79
+ context?: object
80
+ ];
@@ -59,29 +59,65 @@ export declare type DdNativeSdkType = {
59
59
  */
60
60
  export declare type DdNativeLogsType = {
61
61
  /**
62
- * Send a log with level debug.
62
+ * Send a log with DEBUG level.
63
63
  * @param message: The message to send.
64
64
  * @param context: The additional context to send.
65
65
  */
66
66
  debug(message: string, context?: object): Promise<void>;
67
67
  /**
68
- * Send a log with level info.
68
+ * Send a log with INFO level.
69
69
  * @param message: The message to send.
70
70
  * @param context: The additional context to send.
71
71
  */
72
72
  info(message: string, context?: object): Promise<void>;
73
73
  /**
74
- * Send a log with level warn.
74
+ * Send a log with WARN level.
75
75
  * @param message: The message to send.
76
76
  * @param context: The additional context to send.
77
77
  */
78
78
  warn(message: string, context?: object): Promise<void>;
79
79
  /**
80
- * Send a log with level error.
80
+ * Send a log with ERROR level.
81
81
  * @param message: The message to send.
82
82
  * @param context: The additional context to send.
83
83
  */
84
84
  error(message: string, context?: object): Promise<void>;
85
+ /**
86
+ * Send a log containing an error with DEBUG level.
87
+ * @param message: The message to send.
88
+ * @param errorKind: The error kind to send.
89
+ * @param errorMessage: The error message to send.
90
+ * @param stacktrace: The stack trace to send.
91
+ * @param context: The additional context to send.
92
+ */
93
+ debugWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
94
+ /**
95
+ * Send a log containing an error with INDO level.
96
+ * @param message: The message to send.
97
+ * @param errorKind: The error kind to send.
98
+ * @param errorMessage: The error message to send.
99
+ * @param stacktrace: The stack trace to send.
100
+ * @param context: The additional context to send.
101
+ */
102
+ infoWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
103
+ /**
104
+ * Send a log containing an error with WARN level.
105
+ * @param message: The message to send.
106
+ * @param errorKind: The error kind to send.
107
+ * @param errorMessage: The error message to send.
108
+ * @param stacktrace: The stack trace to send.
109
+ * @param context: The additional context to send.
110
+ */
111
+ warnWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
112
+ /**
113
+ * Send a log containing an error with ERROR level.
114
+ * @param message: The message to send.
115
+ * @param errorKind: The error kind to send.
116
+ * @param errorMessage: The error message to send.
117
+ * @param stacktrace: The stack trace to send.
118
+ * @param context: The additional context to send.
119
+ */
120
+ errorWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
85
121
  };
86
122
  /**
87
123
  * The entry point to use Datadog's Trace feature.
@@ -178,6 +214,17 @@ export declare type DdNativeRumType = {
178
214
  * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
179
215
  */
180
216
  addTiming(name: string): Promise<void>;
217
+ /**
218
+ * Stops the current RUM Session.
219
+ */
220
+ stopSession(): Promise<void>;
221
+ /**
222
+ * Adds the result of evaluating a feature flag with a given name and value to the view.
223
+ * Feature flag evaluations are local to the active view and are cleared when the view is stopped.
224
+ * @param name: The name of the feature flag
225
+ * @param value: The value of the feature flag, encapsulated in an object to accept all types
226
+ */
227
+ addFeatureFlagEvaluation(name: string, value: object): Promise<void>;
181
228
  };
182
229
  declare type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
183
230
  declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
@@ -25,6 +25,8 @@ declare class DdRumWrapper implements DdRumType {
25
25
  stopResource(key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number, resourceContext?: XMLHttpRequest): Promise<void>;
26
26
  addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
27
27
  addTiming(name: string): Promise<void>;
28
+ stopSession(): Promise<void>;
29
+ addFeatureFlagEvaluation(name: string, value: unknown): Promise<void>;
28
30
  registerErrorEventMapper(errorEventMapper: ErrorEventMapper): void;
29
31
  unregisterErrorEventMapper(): void;
30
32
  registerResourceEventMapper(resourceEventMapper: ResourceEventMapper): void;
@@ -10,6 +10,7 @@ export declare class DdRumErrorTracking {
10
10
  * Starts tracking errors and sends a RUM Error event every time an error is detected.
11
11
  */
12
12
  static startTracking(): void;
13
- static onGlobalError(error: any, isFatal?: boolean): void;
14
- static onConsoleError(...params: unknown[]): void;
13
+ static onGlobalError: (error: any, isFatal?: boolean) => void;
14
+ static onConsoleError: (...params: unknown[]) => void;
15
+ private static reportError;
15
16
  }
@@ -1,7 +1,7 @@
1
1
  import type EventsInterceptor from './EventsInterceptor';
2
2
  export declare const UNKNOWN_TARGET_NAME = "unknown_target";
3
3
  export declare class DdEventsInterceptor implements EventsInterceptor {
4
- static ACTION_EVENT_DROPPED_WARN_MESSAGE: string;
4
+ static ACTION_EVENT_DROPPED_DEBUG_MESSAGE: string;
5
5
  private debouncingStartedTimestamp;
6
6
  interceptOnPress(...args: any[]): void;
7
7
  private handleTargetEvent;
@@ -1,4 +1,7 @@
1
1
  /**
2
- * Does a shallow comparison between 2 objects
2
+ * Does a shallow comparison between 2 objects.
3
+ *
4
+ * In some rare cases, one of the objects can be `undefined` or `null`.
5
+ * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
3
6
  */
4
- export declare const areObjectShallowEqual: (objectA: Record<string, unknown>, objectB: Record<string, unknown>) => boolean;
7
+ export declare const areObjectShallowEqual: (objectA: Record<string, unknown> | undefined | null, objectB: Record<string, unknown> | undefined | null) => boolean;
@@ -84,6 +84,10 @@ export declare type DdRumType = {
84
84
  * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
85
85
  */
86
86
  addTiming(name: string): Promise<void>;
87
+ /**
88
+ * Stops the current RUM Session.
89
+ */
90
+ stopSession(): Promise<void>;
87
91
  };
88
92
  /**
89
93
  * Describe the type of a RUM Action.
@@ -14,18 +14,25 @@ export declare class DdSdkConfiguration {
14
14
  readonly additionalConfig: object;
15
15
  readonly telemetrySampleRate: number;
16
16
  readonly vitalsUpdateFrequency: string;
17
+ readonly uploadFrequency: string;
18
+ readonly batchSize: string;
17
19
  readonly trackFrustrations: boolean;
20
+ readonly trackBackgroundEvents: boolean;
18
21
  readonly configurationForTelemetry: {
19
22
  initializationType: string;
20
23
  trackErrors: boolean;
21
24
  trackInteractions: boolean;
22
25
  trackNetworkRequests: boolean;
26
+ reactVersion: string;
27
+ reactNativeVersion: string;
23
28
  };
24
- constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, trackFrustrations: boolean, configurationForTelemetry: {
29
+ constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, uploadFrequency: string, batchSize: string, trackFrustrations: boolean, trackBackgroundEvents: boolean, configurationForTelemetry: {
25
30
  initializationType: string;
26
31
  trackErrors: boolean;
27
32
  trackInteractions: boolean;
28
33
  trackNetworkRequests: boolean;
34
+ reactVersion: string;
35
+ reactNativeVersion: string;
29
36
  });
30
37
  }
31
38
  /**
@@ -1 +1 @@
1
- export declare const version = "1.5.2";
1
+ export declare const version = "1.7.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "1.5.2",
3
+ "version": "1.7.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  ]
79
79
  },
80
- "gitHead": "2987dffcc3f438771e7a33fab8d4609a17070a78"
80
+ "gitHead": "e7eb5ba2ac1eefbacf5c60695c7d761560c4f2cb"
81
81
  }
@@ -118,12 +118,20 @@ export class DdSdkReactNative {
118
118
  configuration.additionalConfig,
119
119
  configuration.telemetrySampleRate,
120
120
  configuration.vitalsUpdateFrequency,
121
+ configuration.uploadFrequency,
122
+ configuration.batchSize,
121
123
  configuration.trackFrustrations,
124
+ configuration.trackBackgroundEvents,
122
125
  {
123
126
  initializationType: params.initializationModeForTelemetry,
124
127
  trackErrors: configuration.trackErrors,
125
128
  trackInteractions: configuration.trackInteractions,
126
- trackNetworkRequests: configuration.trackResources
129
+ trackNetworkRequests: configuration.trackResources,
130
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
131
+ reactNativeVersion: require('react-native/package.json')
132
+ .version,
133
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
134
+ reactVersion: require('react/package.json').version
127
135
  }
128
136
  )
129
137
  );
@@ -21,6 +21,36 @@ export enum VitalsUpdateFrequency {
21
21
  NEVER = 'NEVER'
22
22
  }
23
23
 
24
+ export enum UploadFrequency {
25
+ /**
26
+ * Upload data every 1000ms.
27
+ */
28
+ FREQUENT = 'FREQUENT',
29
+ /**
30
+ * Upload data every 5000ms.
31
+ */
32
+ AVERAGE = 'AVERAGE',
33
+ /**
34
+ * Upload data every 10000ms.
35
+ */
36
+ RARE = 'RARE'
37
+ }
38
+
39
+ export enum BatchSize {
40
+ /**
41
+ * Upload less frequent, larger batches of data
42
+ */
43
+ LARGE = 'LARGE',
44
+ /**
45
+ * Use default size for batches of data
46
+ */
47
+ MEDIUM = 'MEDIUM',
48
+ /**
49
+ * Upload more frequent, smaller batches of data
50
+ */
51
+ SMALL = 'SMALL'
52
+ }
53
+
24
54
  export type FirstPartyHostsConfiguration = (
25
55
  | FirstPartyHost
26
56
  | LegacyFirstPartyHost
@@ -70,7 +100,10 @@ const DEFAULTS = {
70
100
  errorEventMapper: null,
71
101
  resourceEventMapper: null,
72
102
  actionEventMapper: null,
73
- trackFrustrations: true
103
+ trackFrustrations: true,
104
+ uploadFrequency: UploadFrequency.AVERAGE,
105
+ batchSize: BatchSize.MEDIUM,
106
+ trackBackgroundEvents: false
74
107
  };
75
108
 
76
109
  /**
@@ -188,6 +221,25 @@ export class DdSdkReactNativeConfiguration {
188
221
  */
189
222
  public trackFrustrations: boolean = DEFAULTS.trackFrustrations;
190
223
 
224
+ /**
225
+ * Sets the preferred frequency for uploading batches of data.
226
+ */
227
+ public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;
228
+
229
+ /**
230
+ * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.
231
+ * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.
232
+ */
233
+ public batchSize: BatchSize = DEFAULTS.batchSize;
234
+
235
+ /**
236
+ * Enables tracking of RUM event when no RUM View is active.
237
+ *
238
+ * By default, background events are not tracked. Enabling this feature might increase the
239
+ * number of sessions tracked and impact your billing.
240
+ */
241
+ public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;
242
+
191
243
  public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;
192
244
 
193
245
  public errorEventMapper: ErrorEventMapper | null =
@@ -300,6 +352,9 @@ export type PartialInitializationConfiguration = {
300
352
  readonly telemetrySampleRate?: number;
301
353
  readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
302
354
  readonly trackFrustrations?: boolean;
355
+ readonly uploadFrequency?: UploadFrequency;
356
+ readonly batchSize?: BatchSize;
357
+ readonly trackBackgroundEvents?: boolean;
303
358
  };
304
359
 
305
360
  const setConfigurationAttribute = <
@@ -6,6 +6,8 @@
6
6
 
7
7
  import { SdkVerbosity } from './SdkVerbosity';
8
8
 
9
+ export const DATADOG_MESSAGE_PREFIX = 'DATADOG:';
10
+
9
11
  /**
10
12
  * /!\ DO NOT USE THIS IN YOUR APP /!\\
11
13
  *
@@ -30,7 +32,7 @@ export class InternalLog {
30
32
  if (allowedLevel === undefined || requiredLevel === undefined) {
31
33
  return;
32
34
  }
33
- const prefixedMessage = `DATADOG: ${message}`;
35
+ const prefixedMessage = `${DATADOG_MESSAGE_PREFIX} ${message}`;
34
36
  if (verbosity === SdkVerbosity.ERROR && requiredLevel >= allowedLevel) {
35
37
  console.error(prefixedMessage);
36
38
  }
@@ -4,7 +4,11 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import { buildConfigurationFromPartialConfiguration } from '../DdSdkReactNativeConfiguration';
7
+ import {
8
+ BatchSize,
9
+ UploadFrequency,
10
+ buildConfigurationFromPartialConfiguration
11
+ } from '../DdSdkReactNativeConfiguration';
8
12
  import { ProxyConfiguration, ProxyType } from '../ProxyConfiguration';
9
13
  import { SdkVerbosity } from '../SdkVerbosity';
10
14
  import { TrackingConsent } from '../TrackingConsent';
@@ -30,6 +34,7 @@ describe('DdSdkReactNativeConfiguration', () => {
30
34
  "actionEventMapper": null,
31
35
  "additionalConfig": {},
32
36
  "applicationId": "fake-app-id",
37
+ "batchSize": "MEDIUM",
33
38
  "clientToken": "fake-client-token",
34
39
  "env": "fake-env",
35
40
  "errorEventMapper": null,
@@ -47,11 +52,13 @@ describe('DdSdkReactNativeConfiguration', () => {
47
52
  "sessionSamplingRate": 100,
48
53
  "site": "US1",
49
54
  "telemetrySampleRate": 20,
55
+ "trackBackgroundEvents": false,
50
56
  "trackErrors": false,
51
57
  "trackFrustrations": true,
52
58
  "trackInteractions": false,
53
59
  "trackResources": false,
54
60
  "trackingConsent": "granted",
61
+ "uploadFrequency": "AVERAGE",
55
62
  "verbosity": undefined,
56
63
  "vitalsUpdateFrequency": "AVERAGE",
57
64
  }
@@ -95,7 +102,10 @@ describe('DdSdkReactNativeConfiguration', () => {
95
102
  nativeCrashReportEnabled: true,
96
103
  nativeLongTaskThresholdMs: 345,
97
104
  longTaskThresholdMs: 567,
98
- trackFrustrations: true
105
+ trackFrustrations: true,
106
+ uploadFrequency: UploadFrequency.FREQUENT,
107
+ batchSize: BatchSize.LARGE,
108
+ trackBackgroundEvents: true
99
109
  }
100
110
  )
101
111
  ).toMatchInlineSnapshot(`
@@ -105,6 +115,7 @@ describe('DdSdkReactNativeConfiguration', () => {
105
115
  "additionalField": "fake-value",
106
116
  },
107
117
  "applicationId": "fake-app-id",
118
+ "batchSize": "LARGE",
108
119
  "clientToken": "fake-client-token",
109
120
  "env": "fake-env",
110
121
  "errorEventMapper": [Function],
@@ -130,11 +141,13 @@ describe('DdSdkReactNativeConfiguration', () => {
130
141
  "sessionSamplingRate": 80,
131
142
  "site": "EU",
132
143
  "telemetrySampleRate": 20,
144
+ "trackBackgroundEvents": true,
133
145
  "trackErrors": true,
134
146
  "trackFrustrations": true,
135
147
  "trackInteractions": true,
136
148
  "trackResources": true,
137
149
  "trackingConsent": "pending",
150
+ "uploadFrequency": "FREQUENT",
138
151
  "verbosity": "debug",
139
152
  "version": "1.4.5",
140
153
  "versionSuffix": "codepush-3",
@@ -167,7 +180,8 @@ describe('DdSdkReactNativeConfiguration', () => {
167
180
  nativeCrashReportEnabled: false,
168
181
  nativeLongTaskThresholdMs: false,
169
182
  longTaskThresholdMs: false,
170
- trackFrustrations: false
183
+ trackFrustrations: false,
184
+ trackBackgroundEvents: false
171
185
  }
172
186
  )
173
187
  ).toMatchInlineSnapshot(`
@@ -175,6 +189,7 @@ describe('DdSdkReactNativeConfiguration', () => {
175
189
  "actionEventMapper": null,
176
190
  "additionalConfig": {},
177
191
  "applicationId": "",
192
+ "batchSize": "MEDIUM",
178
193
  "clientToken": "",
179
194
  "env": "",
180
195
  "errorEventMapper": null,
@@ -192,11 +207,13 @@ describe('DdSdkReactNativeConfiguration', () => {
192
207
  "sessionSamplingRate": 0,
193
208
  "site": "",
194
209
  "telemetrySampleRate": 20,
210
+ "trackBackgroundEvents": false,
195
211
  "trackErrors": false,
196
212
  "trackFrustrations": false,
197
213
  "trackInteractions": false,
198
214
  "trackResources": false,
199
215
  "trackingConsent": "granted",
216
+ "uploadFrequency": "AVERAGE",
200
217
  "verbosity": undefined,
201
218
  "version": "",
202
219
  "versionSuffix": "",