@datadog/mobile-react-native 1.1.5 → 1.2.0-beta2

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 (160) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/README.md +18 -14
  3. package/android/build.gradle +28 -3
  4. package/android/detekt.yml +572 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +12 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +15 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +143 -8
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +25 -1
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +31 -1
  10. package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +41 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +7 -2
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +429 -27
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +5 -1
  14. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +40 -1
  15. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +21 -1
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +1 -1
  17. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +1 -0
  18. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +22 -2
  19. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +2 -3
  20. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +94 -0
  21. package/datadog-sourcemaps.gradle +85 -28
  22. package/ios/Sources/Attributes.swift +0 -4
  23. package/ios/Sources/DdSdk.m +10 -0
  24. package/ios/Sources/DdSdk.swift +113 -10
  25. package/ios/Sources/DdSdkConfiguration.swift +38 -1
  26. package/ios/Sources/JSRefreshRateListener.swift +86 -0
  27. package/ios/Sources/QueueHolder.swift +7 -0
  28. package/ios/Sources/RNDdSdkConfiguration.swift +25 -1
  29. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
  30. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  31. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
  32. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  33. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
  34. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  35. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
  36. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  37. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
  38. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  39. package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
  40. package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
  41. package/lib/commonjs/DdSdkReactNative.js +140 -59
  42. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  43. package/lib/commonjs/DdSdkReactNativeConfiguration.js +166 -9
  44. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  45. package/lib/commonjs/errorUtils.js +69 -0
  46. package/lib/commonjs/errorUtils.js.map +1 -0
  47. package/lib/commonjs/foundation.js +19 -12
  48. package/lib/commonjs/foundation.js.map +1 -1
  49. package/lib/commonjs/index.js +20 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/longTasksUtils.js +40 -0
  52. package/lib/commonjs/longTasksUtils.js.map +1 -0
  53. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  54. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
  55. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  56. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
  57. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  58. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
  59. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  63. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  64. package/lib/commonjs/types.js +6 -1
  65. package/lib/commonjs/types.js.map +1 -1
  66. package/lib/commonjs/version.js +1 -1
  67. package/lib/commonjs/version.js.map +1 -1
  68. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
  69. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  70. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
  71. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  72. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
  73. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  74. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
  75. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  76. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
  77. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  78. package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
  79. package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
  80. package/lib/module/DdSdkReactNative.js +132 -57
  81. package/lib/module/DdSdkReactNative.js.map +1 -1
  82. package/lib/module/DdSdkReactNativeConfiguration.js +154 -8
  83. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  84. package/lib/module/errorUtils.js +54 -0
  85. package/lib/module/errorUtils.js.map +1 -0
  86. package/lib/module/foundation.js +18 -12
  87. package/lib/module/foundation.js.map +1 -1
  88. package/lib/module/index.js +3 -2
  89. package/lib/module/index.js.map +1 -1
  90. package/lib/module/longTasksUtils.js +31 -0
  91. package/lib/module/longTasksUtils.js.map +1 -0
  92. package/lib/module/nativeModulesTypes.js.map +1 -1
  93. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
  94. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  95. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
  96. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  97. package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
  98. package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
  99. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  100. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  101. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  102. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  103. package/lib/module/types.js +6 -1
  104. package/lib/module/types.js.map +1 -1
  105. package/lib/module/version.js +1 -1
  106. package/lib/module/version.js.map +1 -1
  107. package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  108. package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  109. package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  110. package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  111. package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  112. package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
  113. package/lib/typescript/DdSdkReactNative.d.ts +18 -3
  114. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +114 -0
  115. package/lib/typescript/errorUtils.d.ts +12 -0
  116. package/lib/typescript/index.d.ts +3 -2
  117. package/lib/typescript/longTasksUtils.d.ts +6 -0
  118. package/lib/typescript/nativeModulesTypes.d.ts +12 -0
  119. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
  120. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
  121. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +1 -0
  122. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +1 -1
  123. package/lib/typescript/types.d.ts +16 -1
  124. package/lib/typescript/version.d.ts +1 -1
  125. package/package.json +3 -2
  126. package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
  127. package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
  128. package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
  129. package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
  130. package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
  131. package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
  132. package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
  133. package/src/DatadogProvider/DatadogProvider.tsx +122 -0
  134. package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
  135. package/src/DatadogProvider/__tests__/initialization.test.tsx +182 -0
  136. package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
  137. package/src/DdSdkReactNative.tsx +206 -109
  138. package/src/DdSdkReactNativeConfiguration.tsx +225 -8
  139. package/src/__tests__/DdRumWrapper.test.tsx +3 -27
  140. package/src/__tests__/DdSdkReactNative.test.tsx +57 -13
  141. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +181 -0
  142. package/src/__tests__/foundation.test.ts +11 -2
  143. package/src/__tests__/longTasksUtils.ts +23 -0
  144. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
  145. package/src/errorUtils.ts +58 -0
  146. package/src/foundation.tsx +15 -12
  147. package/src/index.tsx +9 -1
  148. package/src/longTasksUtils.ts +30 -0
  149. package/src/nativeModulesTypes.ts +14 -0
  150. package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
  151. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
  152. package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
  153. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
  154. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +3 -1
  155. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +1 -1
  156. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +2 -1
  157. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
  158. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +12 -47
  159. package/src/types.tsx +11 -1
  160. package/src/version.ts +1 -1
@@ -3,17 +3,46 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DdSdkReactNativeConfiguration = void 0;
6
+ exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.VitalsUpdateFrequency = void 0;
7
7
 
8
8
  var _TrackingConsent = require("./TrackingConsent");
9
9
 
10
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
 
12
+ let VitalsUpdateFrequency;
13
+ exports.VitalsUpdateFrequency = VitalsUpdateFrequency;
14
+
15
+ (function (VitalsUpdateFrequency) {
16
+ VitalsUpdateFrequency["FREQUENT"] = "FREQUENT";
17
+ VitalsUpdateFrequency["AVERAGE"] = "AVERAGE";
18
+ VitalsUpdateFrequency["RARE"] = "RARE";
19
+ VitalsUpdateFrequency["NEVER"] = "NEVER";
20
+ })(VitalsUpdateFrequency || (exports.VitalsUpdateFrequency = VitalsUpdateFrequency = {}));
21
+
22
+ const DEFAULTS = {
23
+ nativeCrashReportEnabled: false,
24
+ sessionSamplingRate: 100.0,
25
+ resourceTracingSamplingRate: 20.0,
26
+ site: 'US1',
27
+ longTaskThresholdMs: 0,
28
+ nativeLongTaskThresholdMs: 200,
29
+ nativeViewTracking: false,
30
+ getFirstPartyHosts: () => [],
31
+ getAdditionalConfig: () => ({}),
32
+ trackingConsent: _TrackingConsent.TrackingConsent.GRANTED,
33
+ telemetrySampleRate: 20.0,
34
+ vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE
35
+ };
12
36
  /**
13
37
  * The SDK configuration class.
14
38
  * It will be used to configure the SDK functionality at initialization.
15
39
  */
40
+
16
41
  class DdSdkReactNativeConfiguration {
42
+ /**
43
+ * Enables crash reporting for native plaforms (iOS, Android). Default `false`.
44
+ */
45
+
17
46
  /**
18
47
  * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
19
48
  */
@@ -26,6 +55,23 @@ class DdSdkReactNativeConfiguration {
26
55
  * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
27
56
  */
28
57
 
58
+ /**
59
+ * Verbosity for internal SDK logging.
60
+ * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.
61
+ */
62
+
63
+ /**
64
+ * Enables native views tracking.
65
+ * Set to `true` if you use a custom navigation system relying on native views.
66
+ */
67
+
68
+ /**
69
+ * List of your backends hosts to enable tracing with.
70
+ * Regular expressions are NOT supported.
71
+ *
72
+ * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
73
+ */
74
+
29
75
  /**
30
76
  * Overrides the reported version of the app.
31
77
  * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
@@ -45,7 +91,41 @@ class DdSdkReactNativeConfiguration {
45
91
  *
46
92
  * A dash (`-`) will be automatically added between the version and the suffix
47
93
  */
48
- constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = _TrackingConsent.TrackingConsent.GRANTED) {
94
+
95
+ /**
96
+ * The sampling rate for Internal Telemetry (info related to the work of the
97
+ * SDK internals).
98
+ *
99
+ * The sampling rate must be a value between 0 and 100. A value of 0 means no
100
+ * telemetry will be sent, 100 means all telemetry will be sent. When
101
+ * `telemetrySampleRate` is not set, the default value from the iOS and
102
+ * Android SDK is used, which is 20.
103
+ */
104
+
105
+ /**
106
+ * The threshold for native long tasks reporting in milliseconds.
107
+ *
108
+ * - Setting it to `0` or `false` disables native long task reporting.
109
+ * - Values below `100` will be raised to `100`.
110
+ * - Values above `5000` will be lowered to `5000`.
111
+ *
112
+ * Default value is `200`.
113
+ */
114
+
115
+ /**
116
+ * The threshold for javascript long tasks reporting in milliseconds.
117
+ *
118
+ * - Setting it to `0` or `false` disables javascript long task reporting.
119
+ * - Values below `100` will be raised to `100`.
120
+ * - Values above `5000` will be lowered to `5000`.
121
+ *
122
+ * Default value is `0`
123
+ */
124
+
125
+ /**
126
+ * Sets the preferred frequency for collecting mobile vitals.
127
+ */
128
+ constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
49
129
  this.clientToken = clientToken;
50
130
  this.env = env;
51
131
  this.applicationId = applicationId;
@@ -54,34 +134,111 @@ class DdSdkReactNativeConfiguration {
54
134
  this.trackErrors = trackErrors;
55
135
  this.trackingConsent = trackingConsent;
56
136
 
57
- _defineProperty(this, "nativeCrashReportEnabled", false);
137
+ _defineProperty(this, "nativeCrashReportEnabled", DEFAULTS.nativeCrashReportEnabled);
58
138
 
59
139
  _defineProperty(this, "sampleRate", void 0);
60
140
 
61
- _defineProperty(this, "sessionSamplingRate", 100.0);
141
+ _defineProperty(this, "sessionSamplingRate", DEFAULTS.sessionSamplingRate);
62
142
 
63
- _defineProperty(this, "resourceTracingSamplingRate", 20.0);
143
+ _defineProperty(this, "resourceTracingSamplingRate", DEFAULTS.resourceTracingSamplingRate);
64
144
 
65
- _defineProperty(this, "site", 'US');
145
+ _defineProperty(this, "site", DEFAULTS.site);
66
146
 
67
147
  _defineProperty(this, "verbosity", undefined);
68
148
 
69
- _defineProperty(this, "nativeViewTracking", false);
149
+ _defineProperty(this, "nativeViewTracking", DEFAULTS.nativeViewTracking);
70
150
 
71
151
  _defineProperty(this, "proxyConfig", undefined);
72
152
 
73
153
  _defineProperty(this, "serviceName", undefined);
74
154
 
75
- _defineProperty(this, "firstPartyHosts", []);
155
+ _defineProperty(this, "firstPartyHosts", DEFAULTS.getFirstPartyHosts());
76
156
 
77
157
  _defineProperty(this, "version", void 0);
78
158
 
79
159
  _defineProperty(this, "versionSuffix", void 0);
80
160
 
81
- _defineProperty(this, "additionalConfig", {});
161
+ _defineProperty(this, "telemetrySampleRate", DEFAULTS.telemetrySampleRate);
162
+
163
+ _defineProperty(this, "nativeLongTaskThresholdMs", DEFAULTS.nativeLongTaskThresholdMs);
164
+
165
+ _defineProperty(this, "longTaskThresholdMs", DEFAULTS.longTaskThresholdMs);
166
+
167
+ _defineProperty(this, "vitalsUpdateFrequency", DEFAULTS.vitalsUpdateFrequency);
168
+
169
+ _defineProperty(this, "additionalConfig", DEFAULTS.getAdditionalConfig());
82
170
  }
83
171
 
84
172
  }
173
+ /**
174
+ * Auto Instrumentation configuration passed to DatadogProvider.
175
+ * Does not include default values.
176
+ */
177
+
85
178
 
86
179
  exports.DdSdkReactNativeConfiguration = DdSdkReactNativeConfiguration;
180
+
181
+ /**
182
+ * We could use `Proxy` instead of this function, but `Proxy` is not available on
183
+ * the older android jsc that can still be used.
184
+ */
185
+ const addDefaultValuesToAutoInstrumentationConfiguration = features => {
186
+ return { ...features,
187
+ firstPartyHosts: features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),
188
+ resourceTracingSamplingRate: features.resourceTracingSamplingRate || DEFAULTS.resourceTracingSamplingRate
189
+ };
190
+ };
191
+
192
+ exports.addDefaultValuesToAutoInstrumentationConfiguration = addDefaultValuesToAutoInstrumentationConfiguration;
193
+
194
+ const setConfigurationAttribute = (attribute, configuration) => {
195
+ if (attribute.value !== undefined) {
196
+ configuration[attribute.name] = attribute.value;
197
+ }
198
+ };
199
+
200
+ const buildConfigurationFromPartialConfiguration = (features, configuration) => {
201
+ const {
202
+ clientToken,
203
+ env,
204
+ applicationId,
205
+ ...remainingConfiguration
206
+ } = configuration;
207
+ const SdkConfiguration = new DdSdkReactNativeConfiguration(clientToken, env, applicationId, features.trackInteractions, features.trackResources, features.trackErrors, configuration.trackingConsent);
208
+ Object.keys(remainingConfiguration).forEach(name => {
209
+ setConfigurationAttribute({
210
+ value: remainingConfiguration[name],
211
+ name
212
+ }, SdkConfiguration);
213
+ });
214
+ setConfigurationAttribute({
215
+ name: 'resourceTracingSamplingRate',
216
+ value: features.resourceTracingSamplingRate
217
+ }, SdkConfiguration);
218
+ setConfigurationAttribute({
219
+ name: 'firstPartyHosts',
220
+ value: features.firstPartyHosts
221
+ }, SdkConfiguration);
222
+ return SdkConfiguration;
223
+ };
224
+
225
+ exports.buildConfigurationFromPartialConfiguration = buildConfigurationFromPartialConfiguration;
226
+
227
+ class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
228
+ constructor(...args) {
229
+ super(...args);
230
+
231
+ _defineProperty(this, "initializationMode", InitializationMode.SYNC);
232
+ }
233
+
234
+ }
235
+
236
+ exports.DatadogProviderConfiguration = DatadogProviderConfiguration;
237
+ let InitializationMode;
238
+ exports.InitializationMode = InitializationMode;
239
+
240
+ (function (InitializationMode) {
241
+ InitializationMode["SYNC"] = "SYNC";
242
+ InitializationMode["ASYNC"] = "ASYNC";
243
+ })(InitializationMode || (exports.InitializationMode = InitializationMode = {}));
87
244
  //# sourceMappingURL=DdSdkReactNativeConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","TrackingConsent","GRANTED","undefined"],"mappings":";;;;;;;AAQA;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAQI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGC,iCAAgBC,OAPrD,EAQT;AAAA,SAPWR,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlDyC,KAkDzC;;AAAA;;AAAA,iDA1CmC,KA0CnC;;AAAA,yDAtC2C,IAsC3C;;AAAA,kCArCoB,IAqCpB;;AAAA,uCApC2CG,SAoC3C;;AAAA,gDAnCmC,KAmCnC;;AAAA,yCAlCwCA,SAkCxC;;AAAA,yCAjC4BA,SAiC5B;;AAAA,6CAhCiC,EAgCjC;;AAAA;;AAAA;;AAAA,8CAV8C,EAU9C;AAAE;;AAnDmC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n public additionalConfig: { [k: string]: any } = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {}\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","firstPartyHosts","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;;;IAEYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAOZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,kBAAkB,EAAE,MAAM,EARb;AASbC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CATR;AAUbC,EAAAA,eAAe,EAAEC,iCAAgBC,OAVpB;AAWbC,EAAAA,mBAAmB,EAAE,IAXR;AAYbC,EAAAA,qBAAqB,EAAEf,qBAAqB,CAACgB;AAZhC,CAAjB;AAeA;AACA;AACA;AACA;;AACO,MAAMC,6BAAN,CAAoC;AACvC;AACJ;AACA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BG,gBAFqB,CAAzB;AAIH,GAPD;AASAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,6BADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACvB;AAFpB,GADqB,EAKrBgC,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEL,QAAQ,CAACC;AAA3C,GADqB,EAErBQ,gBAFqB,CAAzB;AAKA,SAAOA,gBAAP;AACH,CA1CM;;;;AA4CA,MAAMI,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: string[] = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: string[];\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: string[];\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate ||\n DEFAULTS.resourceTracingSamplingRate\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getErrorStackTrace = exports.getErrorMessage = exports.EMPTY_STACK_TRACE = exports.EMPTY_MESSAGE = void 0;
7
+
8
+ /*
9
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
11
+ * Copyright 2016-Present Datadog, Inc.
12
+ */
13
+ const EMPTY_MESSAGE = 'Unknown Error';
14
+ exports.EMPTY_MESSAGE = EMPTY_MESSAGE;
15
+ const EMPTY_STACK_TRACE = '';
16
+ exports.EMPTY_STACK_TRACE = EMPTY_STACK_TRACE;
17
+
18
+ const getErrorMessage = error => {
19
+ let message = EMPTY_MESSAGE;
20
+
21
+ if (error === undefined || error === null) {
22
+ message = EMPTY_MESSAGE;
23
+ } else if (typeof error === 'object' && 'message' in error) {
24
+ message = String(error.message);
25
+ } else {
26
+ message = String(error);
27
+ }
28
+
29
+ return message;
30
+ };
31
+ /**
32
+ * Will extract the stack from the error, taking the first key found among:
33
+ * `stacktrace`, `stack`, `componentStack` (component tree for component errors,
34
+ * which contains only native components names in production).
35
+ *
36
+ * In last resort and if `sourceURL`, `line` and `column` are present, it will
37
+ * generate a stack from this information.
38
+ */
39
+
40
+
41
+ exports.getErrorMessage = getErrorMessage;
42
+
43
+ const getErrorStackTrace = error => {
44
+ let stack = EMPTY_STACK_TRACE;
45
+
46
+ try {
47
+ if (error === undefined || error === null) {
48
+ stack = EMPTY_STACK_TRACE;
49
+ } else if (typeof error === 'string') {
50
+ stack = EMPTY_STACK_TRACE;
51
+ } else if (typeof error === 'object') {
52
+ if ('stacktrace' in error) {
53
+ stack = String(error.stacktrace);
54
+ } else if ('stack' in error) {
55
+ stack = String(error.stack);
56
+ } else if ('componentStack' in error) {
57
+ stack = String(error.componentStack);
58
+ } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
59
+ stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
60
+ }
61
+ }
62
+ } catch (e) {// Do nothing
63
+ }
64
+
65
+ return stack;
66
+ };
67
+
68
+ exports.getErrorStackTrace = getErrorStackTrace;
69
+ //# sourceMappingURL=errorUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","stacktrace","componentStack","sourceURL","line","column","e"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,MAAMA,aAAa,GAAG,eAAtB;;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;;AAEA,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGJ,aAAd;;AACA,MAAIG,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGJ,aAAV;AACH,GAFD,MAEO,IAAI,OAAOG,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXM;AAaP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,kBAAkB,GAAIJ,KAAD,IAAoC;AAClE,MAAIK,KAAK,GAAGP,iBAAZ;;AAEA,MAAI;AACA,QAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACM,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWN,KAAf,EAAsB;AACzBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACK,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBL,KAAxB,EAA+B;AAClCK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACO,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeP,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEK,QAAAA,KAAK,GAAI,MAAKL,KAAK,CAACQ,SAAU,IAAGR,KAAK,CAACS,IAAK,IAAGT,KAAK,CAACU,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOC,CAAP,EAAU,CACR;AACH;;AACD,SAAON,KAAP;AACH,CA3BM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\n/**\n * Will extract the stack from the error, taking the first key found among:\n * `stacktrace`, `stack`, `componentStack` (component tree for component errors,\n * which contains only native components names in production).\n *\n * In last resort and if `sourceURL`, `line` and `column` are present, it will\n * generate a stack from this information.\n */\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
@@ -21,6 +21,8 @@ var _SdkVerbosity = require("./SdkVerbosity");
21
21
 
22
22
  var _TimeProvider = require("./TimeProvider");
23
23
 
24
+ var _bufferNativeCall = require("./DatadogProvider/Buffer/bufferNativeCall");
25
+
24
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
27
 
26
28
  const timeProvider = new _TimeProvider.TimeProvider();
@@ -62,7 +64,7 @@ class DdTraceWrapper {
62
64
  }
63
65
 
64
66
  startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
65
- let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
67
+ let spanId = (0, _bufferNativeCall.bufferNativeCallReturningId)(() => this.nativeTrace.startSpan(operation, context, timestampMs));
66
68
 
67
69
  _InternalLog.InternalLog.log("Starting span “" + operation + "” #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
68
70
 
@@ -72,7 +74,7 @@ class DdTraceWrapper {
72
74
  finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
73
75
  _InternalLog.InternalLog.log("Finishing span #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
74
76
 
75
- return this.nativeTrace.finishSpan(spanId, context, timestampMs);
77
+ return (0, _bufferNativeCall.bufferNativeCallWithId)(id => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);
76
78
  }
77
79
 
78
80
  }
@@ -93,12 +95,17 @@ class DdRumWrapper {
93
95
 
94
96
  _defineProperty(this, "getStopActionNativeCall", args => {
95
97
  if (isNewStopActionAPI(args)) {
96
- return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now());
98
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()));
97
99
  }
98
100
 
99
101
  if (isOldStopActionAPI(args)) {
100
102
  if (this.lastActionData) {
101
- return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
103
+ DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
104
+ const {
105
+ type,
106
+ name
107
+ } = this.lastActionData;
108
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));
102
109
  }
103
110
 
104
111
  _InternalLog.InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", _SdkVerbosity.SdkVerbosity.WARN);
@@ -113,13 +120,13 @@ class DdRumWrapper {
113
120
  startView(key, name, context = {}, timestampMs = timeProvider.now()) {
114
121
  _InternalLog.InternalLog.log("Starting RUM View “" + name + "” #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
115
122
 
116
- return this.nativeRum.startView(key, name, context, timestampMs);
123
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startView(key, name, context, timestampMs));
117
124
  }
118
125
 
119
126
  stopView(key, context = {}, timestampMs = timeProvider.now()) {
120
127
  _InternalLog.InternalLog.log("Stopping RUM View #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
121
128
 
122
- return this.nativeRum.stopView(key, context, timestampMs);
129
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopView(key, context, timestampMs));
123
130
  }
124
131
 
125
132
  startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
@@ -129,7 +136,7 @@ class DdRumWrapper {
129
136
  type,
130
137
  name
131
138
  };
132
- return this.nativeRum.startAction(type, name, context, timestampMs);
139
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startAction(type, name, context, timestampMs));
133
140
  }
134
141
 
135
142
  stopAction(...args) {
@@ -143,19 +150,19 @@ class DdRumWrapper {
143
150
  addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
144
151
  _InternalLog.InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
145
152
 
146
- return this.nativeRum.addAction(type, name, context, timestampMs);
153
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addAction(type, name, context, timestampMs));
147
154
  }
148
155
 
149
156
  startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
150
157
  _InternalLog.InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, _SdkVerbosity.SdkVerbosity.DEBUG);
151
158
 
152
- return this.nativeRum.startResource(key, method, url, context, timestampMs);
159
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
153
160
  }
154
161
 
155
162
  stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
156
163
  _InternalLog.InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, _SdkVerbosity.SdkVerbosity.DEBUG);
157
164
 
158
- return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
165
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));
159
166
  }
160
167
 
161
168
  addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
@@ -163,13 +170,13 @@ class DdRumWrapper {
163
170
 
164
171
  let updatedContext = context;
165
172
  updatedContext["_dd.error.source_type"] = "react-native";
166
- return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
173
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));
167
174
  }
168
175
 
169
176
  addTiming(name) {
170
177
  _InternalLog.InternalLog.log("Adding timing “" + name + "” to RUM View", _SdkVerbosity.SdkVerbosity.DEBUG);
171
178
 
172
- return this.nativeRum.addTiming(name);
179
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addTiming(name));
173
180
  }
174
181
 
175
182
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,2BAAcC,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAA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GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMa,KAAgB,GAAG,IAAID,YAAJ,EAAzB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
1
+ {"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","id","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","DdSdk","telemetryDebug","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AAEA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,2BAAcC,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDC,6BAAYC,GAAZ,CAAgB,yBAA0BH,OAA1B,GAAoC,GAApD,EAAyDI,2BAAaC,KAAtE;;AACA,WAAO,KAAKC,UAAL,CAAgBP,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDM,EAAAA,IAAI,CAACP,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDC,6BAAYC,GAAZ,CAAgB,wBAAyBH,OAAzB,GAAmC,GAAnD,EAAwDI,2BAAaC,KAArE;;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBP,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDO,EAAAA,IAAI,CAACR,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AAJ,EAAzB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\nimport { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = bufferNativeCallReturningId(() =>this.nativeTrace.startSpan(operation, context, timestampMs));\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId((id) => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()))\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature')\n const {type, name} = this.lastActionData;\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
@@ -3,12 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "DatadogProvider", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _DatadogProvider.DatadogProvider;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "DatadogProviderConfiguration", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _DdSdkReactNativeConfiguration.DatadogProviderConfiguration;
16
+ }
17
+ });
6
18
  Object.defineProperty(exports, "DdSdkReactNativeConfiguration", {
7
19
  enumerable: true,
8
20
  get: function () {
9
21
  return _DdSdkReactNativeConfiguration.DdSdkReactNativeConfiguration;
10
22
  }
11
23
  });
24
+ Object.defineProperty(exports, "InitializationMode", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _DdSdkReactNativeConfiguration.InitializationMode;
28
+ }
29
+ });
12
30
  Object.defineProperty(exports, "DdSdkReactNative", {
13
31
  enumerable: true,
14
32
  get: function () {
@@ -76,6 +94,8 @@ Object.defineProperty(exports, "ErrorSource", {
76
94
  }
77
95
  });
78
96
 
97
+ var _DatadogProvider = require("./DatadogProvider/DatadogProvider");
98
+
79
99
  var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
80
100
 
81
101
  var _DdSdkReactNative = require("./DdSdkReactNative");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DatadogProvider } from './DatadogProvider/DatadogProvider';\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.adaptLongTaskThreshold = void 0;
7
+
8
+ /**
9
+ * 100ms is the lower bound for a noticeable long task event.
10
+ */
11
+ const MIN_LONG_TASK_THRESHOLD_MS = 100;
12
+ /**
13
+ * 5000ms is considered an Application Not Responding (ANR) event.
14
+ */
15
+
16
+ const MAX_LONG_TASK_THRESHOLD_MS = 5000;
17
+ /**
18
+ * Makes sure the long task threshold value is above 100 and below 5000.
19
+ * Also makes sure it is a number, passing `0` if it is `false`, as the React Native
20
+ * bridge cannot handle values with dual types.
21
+ */
22
+
23
+ const adaptLongTaskThreshold = longTaskThreshold => {
24
+ if (!longTaskThreshold) {
25
+ return 0;
26
+ }
27
+
28
+ if (longTaskThreshold < MIN_LONG_TASK_THRESHOLD_MS) {
29
+ return MIN_LONG_TASK_THRESHOLD_MS;
30
+ }
31
+
32
+ if (longTaskThreshold > MAX_LONG_TASK_THRESHOLD_MS) {
33
+ return MAX_LONG_TASK_THRESHOLD_MS;
34
+ }
35
+
36
+ return longTaskThreshold;
37
+ };
38
+
39
+ exports.adaptLongTaskThreshold = adaptLongTaskThreshold;
40
+ //# sourceMappingURL=longTasksUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["longTasksUtils.ts"],"names":["MIN_LONG_TASK_THRESHOLD_MS","MAX_LONG_TASK_THRESHOLD_MS","adaptLongTaskThreshold","longTaskThreshold"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA,MAAMA,0BAA0B,GAAG,GAAnC;AAEA;AACA;AACA;;AACA,MAAMC,0BAA0B,GAAG,IAAnC;AAEA;AACA;AACA;AACA;AACA;;AACO,MAAMC,sBAAsB,GAC/BC,iBADkC,IAEzB;AACT,MAAI,CAACA,iBAAL,EAAwB;AACpB,WAAO,CAAP;AACH;;AACD,MAAIA,iBAAiB,GAAGH,0BAAxB,EAAoD;AAChD,WAAOA,0BAAP;AACH;;AACD,MAAIG,iBAAiB,GAAGF,0BAAxB,EAAoD;AAChD,WAAOA,0BAAP;AACH;;AAED,SAAOE,iBAAP;AACH,CAdM","sourcesContent":["/**\n * 100ms is the lower bound for a noticeable long task event.\n */\nconst MIN_LONG_TASK_THRESHOLD_MS = 100;\n\n/**\n * 5000ms is considered an Application Not Responding (ANR) event.\n */\nconst MAX_LONG_TASK_THRESHOLD_MS = 5000;\n\n/**\n * Makes sure the long task threshold value is above 100 and below 5000.\n * Also makes sure it is a number, passing `0` if it is `false`, as the React Native\n * bridge cannot handle values with dual types.\n */\nexport const adaptLongTaskThreshold = (\n longTaskThreshold: number | false\n): number => {\n if (!longTaskThreshold) {\n return 0;\n }\n if (longTaskThreshold < MIN_LONG_TASK_THRESHOLD_MS) {\n return MIN_LONG_TASK_THRESHOLD_MS;\n }\n if (longTaskThreshold > MAX_LONG_TASK_THRESHOLD_MS) {\n return MAX_LONG_TASK_THRESHOLD_MS;\n }\n\n return longTaskThreshold;\n};\n"]}