@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
@@ -0,0 +1,49 @@
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 { getErrorName } from '../errorUtils';
8
+
9
+ describe('errorUtils', () => {
10
+ describe('getErrorName', () => {
11
+ it('returns the error.name if defined', () => {
12
+ let error;
13
+ try {
14
+ // eslint-disable-next-line no-unused-expressions
15
+ error.bad.property;
16
+ } catch (e) {
17
+ // error will be a TypeError
18
+ error = e;
19
+ }
20
+
21
+ expect(getErrorName(error)).toBe('TypeError');
22
+ });
23
+
24
+ it('returns the error.name if defined by an extension', () => {
25
+ class CustomError extends Error {
26
+ name = 'CustomError';
27
+ }
28
+
29
+ const error = new CustomError('some custom error');
30
+ expect(getErrorName(error)).toBe('CustomError');
31
+ });
32
+
33
+ it('returns "Error" for an Error object', () => {
34
+ const error = new Error('some error');
35
+ expect(getErrorName(error)).toBe('Error');
36
+ });
37
+
38
+ it('returns "Error" for an object without a name property', () => {
39
+ const error = { message: 'some error' };
40
+ expect(getErrorName(error)).toBe('Error');
41
+ });
42
+
43
+ it('returns "Error" for an non object types', () => {
44
+ expect(getErrorName(undefined)).toBe('Error');
45
+ expect(getErrorName(null)).toBe('Error');
46
+ expect(getErrorName('some error')).toBe('Error');
47
+ });
48
+ });
49
+ });
@@ -186,9 +186,9 @@ it('M do nothing W interceptOnPress { invalid arguments - empty object } ', asyn
186
186
  expect(DdRum.addAction.mock.calls.length).toBe(0);
187
187
  expect(InternalLog.log.mock.calls.length).toBe(1);
188
188
  expect(InternalLog.log.mock.calls[0][0]).toBe(
189
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
189
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
190
190
  );
191
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
191
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
192
192
  });
193
193
 
194
194
  it('M do nothing W interceptOnPress { invalid arguments - array } ', async () => {
@@ -202,9 +202,9 @@ it('M do nothing W interceptOnPress { invalid arguments - array } ', async () =>
202
202
  expect(DdRum.addAction.mock.calls.length).toBe(0);
203
203
  expect(InternalLog.log.mock.calls.length).toBe(1);
204
204
  expect(InternalLog.log.mock.calls[0][0]).toBe(
205
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
205
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
206
206
  );
207
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
207
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
208
208
  });
209
209
 
210
210
  it('M do nothing W interceptOnPress { invalid arguments - nested array } ', async () => {
@@ -218,9 +218,9 @@ it('M do nothing W interceptOnPress { invalid arguments - nested array } ', asyn
218
218
  expect(DdRum.addAction.mock.calls.length).toBe(0);
219
219
  expect(InternalLog.log.mock.calls.length).toBe(1);
220
220
  expect(InternalLog.log.mock.calls[0][0]).toBe(
221
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
221
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
222
222
  );
223
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
223
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
224
224
  });
225
225
 
226
226
  it('M do nothing W interceptOnPress { invalid arguments - undefined } ', async () => {
@@ -234,9 +234,9 @@ it('M do nothing W interceptOnPress { invalid arguments - undefined } ', async (
234
234
  expect(DdRum.addAction.mock.calls.length).toBe(0);
235
235
  expect(InternalLog.log.mock.calls.length).toBe(1);
236
236
  expect(InternalLog.log.mock.calls[0][0]).toBe(
237
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
237
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
238
238
  );
239
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
239
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
240
240
  });
241
241
 
242
242
  it('M do nothing W interceptOnPress { invalid arguments - null } ', async () => {
@@ -250,9 +250,9 @@ it('M do nothing W interceptOnPress { invalid arguments - null } ', async () =>
250
250
  expect(DdRum.addAction.mock.calls.length).toBe(0);
251
251
  expect(InternalLog.log.mock.calls.length).toBe(1);
252
252
  expect(InternalLog.log.mock.calls[0][0]).toBe(
253
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
253
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
254
254
  );
255
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
255
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
256
256
  });
257
257
 
258
258
  it('M do nothing W interceptOnPress { invalid arguments - wrong object } ', async () => {
@@ -263,9 +263,9 @@ it('M do nothing W interceptOnPress { invalid arguments - wrong object } ', asyn
263
263
  expect(DdRum.addAction.mock.calls.length).toBe(0);
264
264
  expect(InternalLog.log.mock.calls.length).toBe(1);
265
265
  expect(InternalLog.log.mock.calls[0][0]).toBe(
266
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
266
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
267
267
  );
268
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
268
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
269
269
  });
270
270
 
271
271
  it('M do nothing W interceptOnPress { no arguments call } ', async () => {
@@ -276,7 +276,7 @@ it('M do nothing W interceptOnPress { no arguments call } ', async () => {
276
276
  expect(DdRum.addAction.mock.calls.length).toBe(0);
277
277
  expect(InternalLog.log.mock.calls.length).toBe(1);
278
278
  expect(InternalLog.log.mock.calls[0][0]).toBe(
279
- DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
279
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE
280
280
  );
281
- expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
281
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.DEBUG);
282
282
  });