@datadog/mobile-react-native 1.0.0-rc8 → 1.1.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 (192) hide show
  1. package/DatadogSDKReactNative.podspec +2 -1
  2. package/android/build.gradle +73 -3
  3. package/android/gradle.properties +1 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
  6. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
  9. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
  10. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
  11. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
  12. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
  14. package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
  15. package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
  16. package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
  20. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
  21. package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
  22. package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
  23. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
  24. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
  25. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
  26. package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
  27. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
  28. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
  29. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
  30. package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
  31. package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
  32. package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
  33. package/datadog-sourcemaps.gradle +137 -0
  34. package/ios/Sources/AnyEncodable.swift +138 -0
  35. package/ios/Sources/Attributes.swift +101 -0
  36. package/ios/Sources/DdLogs.swift +35 -11
  37. package/ios/Sources/DdRum.m +3 -1
  38. package/ios/Sources/DdRum.swift +184 -22
  39. package/ios/Sources/DdSdk.swift +190 -10
  40. package/ios/Sources/DdSdkConfiguration.swift +51 -0
  41. package/ios/Sources/DdTrace.swift +41 -6
  42. package/ios/Sources/GlobalState.swift +28 -0
  43. package/ios/Sources/QueueHolder.swift +10 -0
  44. package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
  45. package/lib/commonjs/DdSdkReactNative.js +16 -2
  46. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  47. package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
  48. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  49. package/lib/commonjs/foundation.js +36 -2
  50. package/lib/commonjs/foundation.js.map +1 -1
  51. package/lib/commonjs/nativeModulesTypes.js +36 -0
  52. package/lib/commonjs/nativeModulesTypes.js.map +1 -0
  53. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
  54. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  55. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
  56. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  57. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +73 -0
  58. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
  59. package/lib/commonjs/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +40 -1
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +51 -0
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
  63. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +25 -0
  64. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
  65. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
  66. package/lib/commonjs/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
  67. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +57 -0
  68. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
  69. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +49 -0
  70. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  71. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +45 -0
  72. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
  73. package/lib/commonjs/rum/instrumentation/{URLHostParser.js → resourceTracking/implementation/URLHostParser.js} +16 -7
  74. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
  75. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +167 -0
  76. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
  77. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js +97 -0
  78. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
  79. package/lib/commonjs/types.js +26 -1
  80. package/lib/commonjs/types.js.map +1 -1
  81. package/lib/commonjs/version.js +1 -1
  82. package/lib/commonjs/version.js.map +1 -1
  83. package/lib/module/DdSdkReactNative.js +15 -1
  84. package/lib/module/DdSdkReactNative.js.map +1 -1
  85. package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
  86. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  87. package/lib/module/foundation.js +36 -2
  88. package/lib/module/foundation.js.map +1 -1
  89. package/lib/module/nativeModulesTypes.js +26 -0
  90. package/lib/module/nativeModulesTypes.js.map +1 -0
  91. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
  92. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  93. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
  94. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  95. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +61 -0
  96. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
  97. package/lib/module/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +35 -1
  98. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
  99. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +34 -0
  100. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
  101. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +16 -0
  102. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
  103. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
  104. package/lib/module/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
  105. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +50 -0
  106. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
  107. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +40 -0
  108. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  109. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +36 -0
  110. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
  111. package/{src/rum/instrumentation/URLHostParser.ts → lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js} +15 -8
  112. package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
  113. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +151 -0
  114. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
  115. package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js +86 -0
  116. package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
  117. package/lib/module/types.js +23 -0
  118. package/lib/module/types.js.map +1 -1
  119. package/lib/module/version.js +1 -1
  120. package/lib/module/version.js.map +1 -1
  121. package/lib/typescript/DdSdkReactNative.d.ts +2 -0
  122. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
  123. package/lib/typescript/foundation.d.ts +3 -2
  124. package/lib/typescript/nativeModulesTypes.d.ts +168 -0
  125. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
  126. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +15 -0
  127. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +18 -0
  128. package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +6 -0
  129. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +8 -0
  130. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +20 -0
  131. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.d.ts +8 -0
  132. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
  133. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.d.ts +17 -0
  134. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/URLHostParser.d.ts +6 -0
  135. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +25 -0
  136. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +3 -0
  137. package/lib/typescript/types.d.ts +42 -7
  138. package/lib/typescript/version.d.ts +1 -1
  139. package/package.json +7 -5
  140. package/src/DdSdkReactNative.tsx +21 -1
  141. package/src/DdSdkReactNativeConfiguration.tsx +20 -0
  142. package/src/__tests__/DdSdkReactNative.test.tsx +87 -8
  143. package/src/__tests__/foundation.test.ts +79 -0
  144. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +9 -9
  145. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +1 -1
  146. package/src/foundation.tsx +40 -11
  147. package/src/nativeModulesTypes.ts +258 -0
  148. package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
  149. package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
  150. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +67 -0
  151. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +79 -0
  152. package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/__tests__}/__utils__/XMLHttpRequestMock.ts +0 -0
  153. package/src/{__tests__/rum/instrumentation/TraceIdentifier.test.tsx → rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts} +1 -1
  154. package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +22 -0
  155. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +87 -0
  156. package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +52 -0
  157. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +15 -0
  158. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +27 -0
  159. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +78 -0
  160. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +83 -0
  161. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +45 -0
  162. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +69 -0
  163. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.ts +50 -0
  164. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.ts +70 -0
  165. package/src/rum/instrumentation/resourceTracking/implementation/URLHostParser.ts +30 -0
  166. package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +197 -0
  167. package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/implementation/__tests__}/URLHostParser.test.ts +3 -3
  168. package/src/{__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx → rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts} +83 -49
  169. package/src/rum/instrumentation/resourceTracking/implementation/responseSize.ts +83 -0
  170. package/src/types.tsx +62 -7
  171. package/src/version.ts +1 -1
  172. package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
  173. package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
  174. package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
  175. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +0 -356
  176. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
  177. package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -2
  178. package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +0 -1
  179. package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +0 -1
  180. package/lib/module/rum/instrumentation/DdRumResourceTracking.js +0 -331
  181. package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
  182. package/lib/module/rum/instrumentation/DdRumXhr.js +0 -2
  183. package/lib/module/rum/instrumentation/TraceIdentifier.js.map +0 -1
  184. package/lib/module/rum/instrumentation/URLHostParser.js +0 -24
  185. package/lib/module/rum/instrumentation/URLHostParser.js.map +0 -1
  186. package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +0 -40
  187. package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +0 -23
  188. package/lib/typescript/rum/instrumentation/TraceIdentifier.d.ts +0 -1
  189. package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +0 -6
  190. package/src/rum/instrumentation/DdRumResourceTracking.tsx +0 -426
  191. package/src/rum/instrumentation/DdRumXhr.tsx +0 -33
  192. package/src/rum/instrumentation/TraceIdentifier.tsx +0 -34
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterDevResource = 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
+
14
+ /**
15
+ * Expo sends all console.* calls to the packager. As we log all API calls
16
+ * when the SDKVerbosity is DEBUG, this would result in an infinite loop of
17
+ * `console.log` and API calls, creating 250 RUM resources per second.
18
+ *
19
+ * The hostname is always going to be localhost or a local IP.
20
+ *
21
+ * An example URL is http://192.168.1.20:8081/logs or http://10.46.29.155:19000/logs
22
+ */
23
+ const EXPO_DEV_LOGS_REGEX = new RegExp('^http://((10|172|192).[0-9]+.[0-9]+.[0-9]+|localhost):[0-9]+/logs$');
24
+ /**
25
+ * This call is made every time the RN packager reloads the js in dev mode.
26
+ */
27
+
28
+ const RN_PACKAGER_SYMBOLICATE_REGEX = new RegExp('^http://localhost:[0-9]+/symbolicate$');
29
+ const internalResourceBlocklist = [EXPO_DEV_LOGS_REGEX, RN_PACKAGER_SYMBOLICATE_REGEX];
30
+ /**
31
+ * Filters RN symbolicate calls and Expo logs calls that happen only in dev.
32
+ * @param resource RUMResource
33
+ */
34
+
35
+ const filterDevResource = resource => {
36
+ // TODO: if we get the confirmation by Expo that the
37
+ // logs call is only made when __DEV__ is true, add an
38
+ // early return for when it is false.
39
+ for (const resourceRegex of internalResourceBlocklist) {
40
+ if (resourceRegex.test(resource.request.url)) {
41
+ return null;
42
+ }
43
+ }
44
+
45
+ return resource;
46
+ };
47
+
48
+ exports.filterDevResource = filterDevResource;
49
+ //# sourceMappingURL=internalDevResourceBlocklist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["internalDevResourceBlocklist.ts"],"names":["EXPO_DEV_LOGS_REGEX","RegExp","RN_PACKAGER_SYMBOLICATE_REGEX","internalResourceBlocklist","filterDevResource","resource","resourceRegex","test","request","url"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,IAAIC,MAAJ,CACxB,oEADwB,CAA5B;AAIA;AACA;AACA;;AACA,MAAMC,6BAA6B,GAAG,IAAID,MAAJ,CAClC,uCADkC,CAAtC;AAIA,MAAME,yBAAmC,GAAG,CACxCH,mBADwC,EAExCE,6BAFwC,CAA5C;AAKA;AACA;AACA;AACA;;AACO,MAAME,iBAAiB,GAC1BC,QAD6B,IAER;AACrB;AACA;AACA;AACA,OAAK,MAAMC,aAAX,IAA4BH,yBAA5B,EAAuD;AACnD,QAAIG,aAAa,CAACC,IAAd,CAAmBF,QAAQ,CAACG,OAAT,CAAiBC,GAApC,CAAJ,EAA8C;AAC1C,aAAO,IAAP;AACH;AACJ;;AACD,SAAOJ,QAAP;AACH,CAZM","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 { RUMResource } from '../../domain/interfaces/RumResource';\n\n/**\n * Expo sends all console.* calls to the packager. As we log all API calls\n * when the SDKVerbosity is DEBUG, this would result in an infinite loop of\n * `console.log` and API calls, creating 250 RUM resources per second.\n *\n * The hostname is always going to be localhost or a local IP.\n *\n * An example URL is http://192.168.1.20:8081/logs or http://10.46.29.155:19000/logs\n */\nconst EXPO_DEV_LOGS_REGEX = new RegExp(\n '^http://((10|172|192).[0-9]+.[0-9]+.[0-9]+|localhost):[0-9]+/logs$'\n);\n\n/**\n * This call is made every time the RN packager reloads the js in dev mode.\n */\nconst RN_PACKAGER_SYMBOLICATE_REGEX = new RegExp(\n '^http://localhost:[0-9]+/symbolicate$'\n);\n\nconst internalResourceBlocklist: RegExp[] = [\n EXPO_DEV_LOGS_REGEX,\n RN_PACKAGER_SYMBOLICATE_REGEX\n];\n\n/**\n * Filters RN symbolicate calls and Expo logs calls that happen only in dev.\n * @param resource RUMResource\n */\nexport const filterDevResource = (\n resource: RUMResource\n): RUMResource | null => {\n // TODO: if we get the confirmation by Expo that the\n // logs call is only made when __DEV__ is true, add an\n // early return for when it is false.\n for (const resourceRegex of internalResourceBlocklist) {\n if (resourceRegex.test(resource.request.url)) {\n return null;\n }\n }\n return resource;\n};\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createTimings = createTimings;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ /*
11
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
12
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
13
+ * Copyright 2016-Present Datadog, Inc.
14
+ */
15
+ function createTimings(startTime, responseStartTime, responseEndTime) {
16
+ const firstByte = formatTiming(startTime, startTime, responseStartTime);
17
+ const download = formatTiming(startTime, responseStartTime, responseEndTime); // needed for iOS, simply total duration from start to end
18
+
19
+ const fetch = formatTiming(startTime, startTime, responseEndTime);
20
+ return {
21
+ firstByte,
22
+ download,
23
+ fetch
24
+ };
25
+ }
26
+ /**
27
+ * @param origin Start time (absolute) of the request
28
+ * @param start Start time (absolute) of the timing
29
+ * @param end End time (absolute) of the timing
30
+ */
31
+
32
+
33
+ function formatTiming(origin, start, end) {
34
+ return {
35
+ duration: timeToNanos(end - start),
36
+ // if it is Android, startTime should be relative to the origin,
37
+ // if it is iOS - absolute (unix timestamp)
38
+ startTime: _reactNative.Platform.OS === 'ios' ? timeToNanos(start) : timeToNanos(start - origin)
39
+ };
40
+ }
41
+
42
+ function timeToNanos(durationMs) {
43
+ return +(durationMs * 1e6).toFixed(0);
44
+ }
45
+ //# sourceMappingURL=resourceTiming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["resourceTiming.ts"],"names":["createTimings","startTime","responseStartTime","responseEndTime","firstByte","formatTiming","download","fetch","origin","start","end","duration","timeToNanos","Platform","OS","durationMs","toFixed"],"mappings":";;;;;;;AAMA;;AANA;AACA;AACA;AACA;AACA;AAyBO,SAASA,aAAT,CACHC,SADG,EAEHC,iBAFG,EAGHC,eAHG,EAIY;AACf,QAAMC,SAAS,GAAGC,YAAY,CAACJ,SAAD,EAAYA,SAAZ,EAAuBC,iBAAvB,CAA9B;AACA,QAAMI,QAAQ,GAAGD,YAAY,CACzBJ,SADyB,EAEzBC,iBAFyB,EAGzBC,eAHyB,CAA7B,CAFe,CAOf;;AACA,QAAMI,KAAK,GAAGF,YAAY,CAACJ,SAAD,EAAYA,SAAZ,EAAuBE,eAAvB,CAA1B;AAEA,SAAO;AACHC,IAAAA,SADG;AAEHE,IAAAA,QAFG;AAGHC,IAAAA;AAHG,GAAP;AAKH;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASF,YAAT,CAAsBG,MAAtB,EAAsCC,KAAtC,EAAqDC,GAArD,EAA0E;AACtE,SAAO;AACHC,IAAAA,QAAQ,EAAEC,WAAW,CAACF,GAAG,GAAGD,KAAP,CADlB;AAEH;AACA;AACAR,IAAAA,SAAS,EACLY,sBAASC,EAAT,KAAgB,KAAhB,GACMF,WAAW,CAACH,KAAD,CADjB,GAEMG,WAAW,CAACH,KAAK,GAAGD,MAAT;AAPlB,GAAP;AASH;;AAED,SAASI,WAAT,CAAqBG,UAArB,EAAiD;AAC7C,SAAO,CAAC,CAACA,UAAU,GAAG,GAAd,EAAmBC,OAAnB,CAA2B,CAA3B,CAAR;AACH","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 { Platform } from 'react-native';\n\ninterface Timing {\n /**\n * Time relative (absolute in case of iOS) to some point, in ns.\n */\n startTime: number;\n /**\n * Duration in ns.\n */\n duration: number;\n}\n\ninterface ResourceTimings {\n // unlike in Performance API it is not the time until request\n // starts (requestStart, before it can be connect, SSL, DNS),\n // but the time until the response is first seen\n firstByte: Timing;\n download: Timing;\n // required by iOS, total timing from the beginning to the end\n fetch: Timing;\n}\n\nexport function createTimings(\n startTime: number,\n responseStartTime: number,\n responseEndTime: number\n): ResourceTimings {\n const firstByte = formatTiming(startTime, startTime, responseStartTime);\n const download = formatTiming(\n startTime,\n responseStartTime,\n responseEndTime\n );\n // needed for iOS, simply total duration from start to end\n const fetch = formatTiming(startTime, startTime, responseEndTime);\n\n return {\n firstByte,\n download,\n fetch\n };\n}\n\n/**\n * @param origin Start time (absolute) of the request\n * @param start Start time (absolute) of the timing\n * @param end End time (absolute) of the timing\n */\nfunction formatTiming(origin: number, start: number, end: number): Timing {\n return {\n duration: timeToNanos(end - start),\n // if it is Android, startTime should be relative to the origin,\n // if it is iOS - absolute (unix timestamp)\n startTime:\n Platform.OS === 'ios'\n ? timeToNanos(start)\n : timeToNanos(start - origin)\n };\n}\n\nfunction timeToNanos(durationMs: number): number {\n return +(durationMs * 1e6).toFixed(0);\n}\n"]}
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.URLHostParser = void 0;
7
7
 
8
+ var _InternalLog = require("../../../../InternalLog");
9
+
10
+ var _SdkVerbosity = require("../../../../SdkVerbosity");
11
+
8
12
  /*
9
13
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
14
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
@@ -14,19 +18,24 @@ exports.URLHostParser = void 0;
14
18
  const hostRegex = '^.+://([^:/\\s]+)';
15
19
  /**
16
20
  * Returns the host from an URL.
17
- * @returns the host (without the port)
18
- * @throws if URL is not well formatted
21
+ * @returns the host (without the port) or null if could not cast the URL as host
19
22
  */
20
23
 
21
24
  const URLHostParser = url => {
22
- const matchedHost = url.match(hostRegex);
25
+ try {
26
+ const matchedHost = url.match(hostRegex);
27
+
28
+ if (matchedHost === null) {
29
+ return null;
30
+ } // [0] is the input, [1] is the captured group
23
31
 
24
- if (matchedHost === null) {
25
- throw new Error(`${url} is not a correctly formatted URL`);
26
- } // [0] is the input, [1] is the captured group
27
32
 
33
+ return matchedHost[1];
34
+ } catch (e) {
35
+ _InternalLog.InternalLog.log(`Impossible to cast ${url} as URL`, _SdkVerbosity.SdkVerbosity.WARN);
28
36
 
29
- return matchedHost[1];
37
+ return null;
38
+ }
30
39
  };
31
40
 
32
41
  exports.URLHostParser = URLHostParser;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["URLHostParser.ts"],"names":["hostRegex","URLHostParser","url","matchedHost","match","e","InternalLog","log","SdkVerbosity","WARN"],"mappings":";;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AAMA;AACA,MAAMA,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;;AACO,MAAMC,aAAa,GAAIC,GAAD,IAAkC;AAC3D,MAAI;AACA,UAAMC,WAAW,GAAGD,GAAG,CAACE,KAAJ,CAAUJ,SAAV,CAApB;;AACA,QAAIG,WAAW,KAAK,IAApB,EAA0B;AACtB,aAAO,IAAP;AACH,KAJD,CAKA;;;AACA,WAAOA,WAAW,CAAC,CAAD,CAAlB;AACH,GAPD,CAOE,OAAOE,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CAAiB,sBAAqBL,GAAI,SAA1C,EAAoDM,2BAAaC,IAAjE;;AACA,WAAO,IAAP;AACH;AACJ,CAZM","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 { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\nimport type { Hostname } from '../domain/firstPartyHosts';\n\n// matches what is between the first \"://\" and the next \"/\", \":\" or whitespace\nconst hostRegex = '^.+://([^:/\\\\s]+)';\n\n/**\n * Returns the host from an URL.\n * @returns the host (without the port) or null if could not cast the URL as host\n */\nexport const URLHostParser = (url: string): Hostname | null => {\n try {\n const matchedHost = url.match(hostRegex);\n if (matchedHost === null) {\n return null;\n }\n // [0] is the input, [1] is the captured group\n return matchedHost[1] as Hostname;\n } catch (e) {\n InternalLog.log(`Impossible to cast ${url} as URL`, SdkVerbosity.WARN);\n return null;\n }\n};\n"]}
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.XHRProxy = exports.ORIGIN_RUM = exports.SAMPLING_PRIORITY_HEADER_KEY = exports.ORIGIN_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = exports.TRACE_ID_HEADER_KEY = void 0;
7
+
8
+ var _Timer = _interopRequireDefault(require("../../../../Timer"));
9
+
10
+ var _distributedTracing = require("../domain/distributedTracing");
11
+
12
+ var _RequestProxy = require("../domain/interfaces/RequestProxy");
13
+
14
+ var _URLHostParser = require("./URLHostParser");
15
+
16
+ var _responseSize = require("./responseSize");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ 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; }
21
+
22
+ const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
23
+ exports.TRACE_ID_HEADER_KEY = TRACE_ID_HEADER_KEY;
24
+ const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
25
+ exports.PARENT_ID_HEADER_KEY = PARENT_ID_HEADER_KEY;
26
+ const ORIGIN_HEADER_KEY = 'x-datadog-origin';
27
+ exports.ORIGIN_HEADER_KEY = ORIGIN_HEADER_KEY;
28
+ const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
29
+ exports.SAMPLING_PRIORITY_HEADER_KEY = SAMPLING_PRIORITY_HEADER_KEY;
30
+ const ORIGIN_RUM = 'rum';
31
+ exports.ORIGIN_RUM = ORIGIN_RUM;
32
+ const RESPONSE_START_LABEL = 'response_start';
33
+
34
+ /**
35
+ * Proxies XMLHTTPRequest to track resources.
36
+ */
37
+ class XHRProxy extends _RequestProxy.RequestProxy {
38
+ constructor(providers) {
39
+ super();
40
+
41
+ _defineProperty(this, "providers", void 0);
42
+
43
+ _defineProperty(this, "onTrackingStart", context => {
44
+ XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;
45
+ XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;
46
+ proxyRequests(this.providers, context);
47
+ });
48
+
49
+ _defineProperty(this, "onTrackingStop", () => {
50
+ this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;
51
+ this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;
52
+ });
53
+
54
+ this.providers = providers;
55
+ }
56
+
57
+ }
58
+
59
+ exports.XHRProxy = XHRProxy;
60
+
61
+ _defineProperty(XHRProxy, "originalXhrOpen", void 0);
62
+
63
+ _defineProperty(XHRProxy, "originalXhrSend", void 0);
64
+
65
+ const proxyRequests = (providers, context) => {
66
+ proxyOpen(providers, context);
67
+ proxySend(providers);
68
+ };
69
+
70
+ const proxyOpen = ({
71
+ xhrType
72
+ }, context) => {
73
+ const originalXhrOpen = xhrType.prototype.open;
74
+ const firstPartyHostsRegex = context.firstPartyHostsRegex;
75
+ const tracingSamplingRate = context.tracingSamplingRate;
76
+
77
+ xhrType.prototype.open = function (method, url) {
78
+ const hostname = (0, _URLHostParser.URLHostParser)(url); // Keep track of the method and url
79
+ // start time is tracked by the `send` method
80
+
81
+ this._datadog_xhr = {
82
+ method,
83
+ url,
84
+ reported: false,
85
+ timer: new _Timer.default(),
86
+ tracingAttributes: (0, _distributedTracing.getTracingAttributes)({
87
+ hostname,
88
+ firstPartyHostsRegex,
89
+ tracingSamplingRate
90
+ })
91
+ }; // eslint-disable-next-line prefer-rest-params
92
+
93
+ return originalXhrOpen.apply(this, arguments);
94
+ };
95
+ };
96
+
97
+ const proxySend = providers => {
98
+ const xhrType = providers.xhrType;
99
+ const originalXhrSend = xhrType.prototype.send;
100
+
101
+ xhrType.prototype.send = function () {
102
+ if (this._datadog_xhr) {
103
+ // keep track of start time
104
+ this._datadog_xhr.timer.start();
105
+
106
+ this.setRequestHeader(ORIGIN_HEADER_KEY, ORIGIN_RUM);
107
+ const tracingAttributes = this._datadog_xhr.tracingAttributes;
108
+ this.setRequestHeader(SAMPLING_PRIORITY_HEADER_KEY, tracingAttributes.samplingPriorityHeader);
109
+
110
+ if (tracingAttributes.tracingStrategy !== 'DISCARD') {
111
+ this.setRequestHeader(TRACE_ID_HEADER_KEY, tracingAttributes.traceId);
112
+ this.setRequestHeader(PARENT_ID_HEADER_KEY, tracingAttributes.spanId);
113
+ }
114
+ }
115
+
116
+ proxyOnReadyStateChange(this, providers); // eslint-disable-next-line prefer-rest-params
117
+
118
+ return originalXhrSend.apply(this, arguments);
119
+ };
120
+ };
121
+
122
+ const proxyOnReadyStateChange = (xhrProxy, providers) => {
123
+ const xhrType = providers.xhrType;
124
+ const originalOnreadystatechange = xhrProxy.onreadystatechange;
125
+
126
+ xhrProxy.onreadystatechange = function () {
127
+ if (xhrProxy.readyState === xhrType.DONE) {
128
+ if (!xhrProxy._datadog_xhr.reported) {
129
+ reportXhr(xhrProxy, providers.resourceReporter);
130
+ xhrProxy._datadog_xhr.reported = true;
131
+ }
132
+ } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {
133
+ xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);
134
+ }
135
+
136
+ if (originalOnreadystatechange) {
137
+ // eslint-disable-next-line prefer-rest-params
138
+ originalOnreadystatechange.apply(xhrProxy, arguments);
139
+ }
140
+ };
141
+ };
142
+
143
+ const reportXhr = async (xhrProxy, resourceReporter) => {
144
+ const responseSize = (0, _responseSize.calculateResponseSize)(xhrProxy);
145
+ const context = xhrProxy._datadog_xhr;
146
+ const key = `${context.timer.startTime}/${context.method}`;
147
+ context.timer.stop();
148
+ resourceReporter.reportResource({
149
+ key,
150
+ request: {
151
+ method: context.method,
152
+ url: context.url,
153
+ kind: 'xhr'
154
+ },
155
+ tracingAttributes: context.tracingAttributes,
156
+ response: {
157
+ statusCode: xhrProxy.status,
158
+ size: responseSize
159
+ },
160
+ timings: {
161
+ startTime: context.timer.startTime,
162
+ stopTime: context.timer.stopTime,
163
+ responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL) ? context.timer.timeAt(RESPONSE_START_LABEL) : undefined
164
+ }
165
+ });
166
+ };
167
+ //# sourceMappingURL=XHRProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["XHRProxy.ts"],"names":["TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","ORIGIN_HEADER_KEY","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_RUM","RESPONSE_START_LABEL","XHRProxy","RequestProxy","constructor","providers","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","proxyRequests","proxyOpen","proxySend","firstPartyHostsRegex","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","timer","Timer","tracingAttributes","apply","arguments","start","setRequestHeader","samplingPriorityHeader","tracingStrategy","traceId","spanId","proxyOnReadyStateChange","xhrProxy","originalOnreadystatechange","onreadystatechange","readyState","DONE","reportXhr","resourceReporter","HEADERS_RECEIVED","recordTick","responseSize","key","startTime","stop","reportResource","request","kind","response","statusCode","status","size","timings","stopTime","responseStartTime","hasTickFor","timeAt","undefined"],"mappings":";;;;;;;AAMA;;AAEA;;AAEA;;AAGA;;AACA;;;;;;AAEO,MAAMA,mBAAmB,GAAG,oBAA5B;;AACA,MAAMC,oBAAoB,GAAG,qBAA7B;;AACA,MAAMC,iBAAiB,GAAG,kBAA1B;;AACA,MAAMC,4BAA4B,GAAG,6BAArC;;AACA,MAAMC,UAAU,GAAG,KAAnB;;AAEP,MAAMC,oBAAoB,GAAG,gBAA7B;;AAmBA;AACA;AACA;AACO,MAAMC,QAAN,SAAuBC,0BAAvB,CAAoC;AAKvCC,EAAAA,WAAW,CAACC,SAAD,EAA+B;AACtC;;AADsC;;AAAA,6CAKvBC,OAAD,IAAkC;AAChDJ,MAAAA,QAAQ,CAACK,eAAT,GAA2B,KAAKF,SAAL,CAAeG,OAAf,CAAuBC,SAAvB,CAAiCC,IAA5D;AACAR,MAAAA,QAAQ,CAACS,eAAT,GAA2B,KAAKN,SAAL,CAAeG,OAAf,CAAuBC,SAAvB,CAAiCG,IAA5D;AACAC,MAAAA,aAAa,CAAC,KAAKR,SAAN,EAAiBC,OAAjB,CAAb;AACH,KATyC;;AAAA,4CAWzB,MAAM;AACnB,WAAKD,SAAL,CAAeG,OAAf,CAAuBC,SAAvB,CAAiCC,IAAjC,GAAwCR,QAAQ,CAACK,eAAjD;AACA,WAAKF,SAAL,CAAeG,OAAf,CAAuBC,SAAvB,CAAiCG,IAAjC,GAAwCV,QAAQ,CAACS,eAAjD;AACH,KAdyC;;AAEtC,SAAKN,SAAL,GAAiBA,SAAjB;AACH;;AARsC;;;;gBAA9BH,Q;;gBAAAA,Q;;AAsBb,MAAMW,aAAa,GAAG,CAClBR,SADkB,EAElBC,OAFkB,KAGX;AACPQ,EAAAA,SAAS,CAACT,SAAD,EAAYC,OAAZ,CAAT;AACAS,EAAAA,SAAS,CAACV,SAAD,CAAT;AACH,CAND;;AAQA,MAAMS,SAAS,GAAG,CACd;AAAEN,EAAAA;AAAF,CADc,EAEdF,OAFc,KAGP;AACP,QAAMC,eAAe,GAAGC,OAAO,CAACC,SAAR,CAAkBC,IAA1C;AACA,QAAMM,oBAAoB,GAAGV,OAAO,CAACU,oBAArC;AACA,QAAMC,mBAAmB,GAAGX,OAAO,CAACW,mBAApC;;AAEAT,EAAAA,OAAO,CAACC,SAAR,CAAkBC,IAAlB,GAAyB,UAErBQ,MAFqB,EAGrBC,GAHqB,EAIvB;AACE,UAAMC,QAAQ,GAAG,kCAAcD,GAAd,CAAjB,CADF,CAEE;AACA;;AACA,SAAKE,YAAL,GAAoB;AAChBH,MAAAA,MADgB;AAEhBC,MAAAA,GAFgB;AAGhBG,MAAAA,QAAQ,EAAE,KAHM;AAIhBC,MAAAA,KAAK,EAAE,IAAIC,cAAJ,EAJS;AAKhBC,MAAAA,iBAAiB,EAAE,8CAAqB;AACpCL,QAAAA,QADoC;AAEpCJ,QAAAA,oBAFoC;AAGpCC,QAAAA;AAHoC,OAArB;AALH,KAApB,CAJF,CAeE;;AACA,WAAOV,eAAe,CAACmB,KAAhB,CAAsB,IAAtB,EAA4BC,SAA5B,CAAP;AACH,GArBD;AAsBH,CA9BD;;AAgCA,MAAMZ,SAAS,GAAIV,SAAD,IAAwC;AACtD,QAAMG,OAAO,GAAGH,SAAS,CAACG,OAA1B;AACA,QAAMG,eAAe,GAAGH,OAAO,CAACC,SAAR,CAAkBG,IAA1C;;AAEAJ,EAAAA,OAAO,CAACC,SAAR,CAAkBG,IAAlB,GAAyB,YAA0B;AAC/C,QAAI,KAAKS,YAAT,EAAuB;AACnB;AACA,WAAKA,YAAL,CAAkBE,KAAlB,CAAwBK,KAAxB;;AACA,WAAKC,gBAAL,CAAsB/B,iBAAtB,EAAyCE,UAAzC;AAEA,YAAMyB,iBAAiB,GAAG,KAAKJ,YAAL,CAAkBI,iBAA5C;AACA,WAAKI,gBAAL,CACI9B,4BADJ,EAEI0B,iBAAiB,CAACK,sBAFtB;;AAIA,UAAIL,iBAAiB,CAACM,eAAlB,KAAsC,SAA1C,EAAqD;AACjD,aAAKF,gBAAL,CACIjC,mBADJ,EAEI6B,iBAAiB,CAACO,OAFtB;AAIA,aAAKH,gBAAL,CACIhC,oBADJ,EAEI4B,iBAAiB,CAACQ,MAFtB;AAIH;AACJ;;AAEDC,IAAAA,uBAAuB,CAAC,IAAD,EAAO7B,SAAP,CAAvB,CAvB+C,CAyB/C;;AACA,WAAOM,eAAe,CAACe,KAAhB,CAAsB,IAAtB,EAA4BC,SAA5B,CAAP;AACH,GA3BD;AA4BH,CAhCD;;AAkCA,MAAMO,uBAAuB,GAAG,CAC5BC,QAD4B,EAE5B9B,SAF4B,KAGrB;AACP,QAAMG,OAAO,GAAGH,SAAS,CAACG,OAA1B;AACA,QAAM4B,0BAA0B,GAAGD,QAAQ,CAACE,kBAA5C;;AAEAF,EAAAA,QAAQ,CAACE,kBAAT,GAA8B,YAAY;AACtC,QAAIF,QAAQ,CAACG,UAAT,KAAwB9B,OAAO,CAAC+B,IAApC,EAA0C;AACtC,UAAI,CAACJ,QAAQ,CAACd,YAAT,CAAsBC,QAA3B,EAAqC;AACjCkB,QAAAA,SAAS,CAACL,QAAD,EAAW9B,SAAS,CAACoC,gBAArB,CAAT;AACAN,QAAAA,QAAQ,CAACd,YAAT,CAAsBC,QAAtB,GAAiC,IAAjC;AACH;AACJ,KALD,MAKO,IAAIa,QAAQ,CAACG,UAAT,KAAwB9B,OAAO,CAACkC,gBAApC,EAAsD;AACzDP,MAAAA,QAAQ,CAACd,YAAT,CAAsBE,KAAtB,CAA4BoB,UAA5B,CAAuC1C,oBAAvC;AACH;;AAED,QAAImC,0BAAJ,EAAgC;AAC5B;AACAA,MAAAA,0BAA0B,CAACV,KAA3B,CAAiCS,QAAjC,EAA2CR,SAA3C;AACH;AACJ,GAdD;AAeH,CAtBD;;AAwBA,MAAMa,SAAS,GAAG,OACdL,QADc,EAEdM,gBAFc,KAGE;AAChB,QAAMG,YAAY,GAAG,yCAAsBT,QAAtB,CAArB;AAEA,QAAM7B,OAAO,GAAG6B,QAAQ,CAACd,YAAzB;AAEA,QAAMwB,GAAG,GAAI,GAAEvC,OAAO,CAACiB,KAAR,CAAcuB,SAAU,IAAGxC,OAAO,CAACY,MAAO,EAAzD;AAEAZ,EAAAA,OAAO,CAACiB,KAAR,CAAcwB,IAAd;AAEAN,EAAAA,gBAAgB,CAACO,cAAjB,CAAgC;AAC5BH,IAAAA,GAD4B;AAE5BI,IAAAA,OAAO,EAAE;AACL/B,MAAAA,MAAM,EAAEZ,OAAO,CAACY,MADX;AAELC,MAAAA,GAAG,EAAEb,OAAO,CAACa,GAFR;AAGL+B,MAAAA,IAAI,EAAE;AAHD,KAFmB;AAO5BzB,IAAAA,iBAAiB,EAAEnB,OAAO,CAACmB,iBAPC;AAQ5B0B,IAAAA,QAAQ,EAAE;AACNC,MAAAA,UAAU,EAAEjB,QAAQ,CAACkB,MADf;AAENC,MAAAA,IAAI,EAAEV;AAFA,KARkB;AAY5BW,IAAAA,OAAO,EAAE;AACLT,MAAAA,SAAS,EAAExC,OAAO,CAACiB,KAAR,CAAcuB,SADpB;AAELU,MAAAA,QAAQ,EAAElD,OAAO,CAACiB,KAAR,CAAciC,QAFnB;AAGLC,MAAAA,iBAAiB,EAAEnD,OAAO,CAACiB,KAAR,CAAcmC,UAAd,CAAyBzD,oBAAzB,IACbK,OAAO,CAACiB,KAAR,CAAcoC,MAAd,CAAqB1D,oBAArB,CADa,GAEb2D;AALD;AAZmB,GAAhC;AAoBH,CAhCD","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 Timer from '../../../../Timer';\nimport type { DdRumResourceTracingAttributes } from '../domain/distributedTracing';\nimport { getTracingAttributes } from '../domain/distributedTracing';\nimport type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';\nimport { RequestProxy } from '../domain/interfaces/RequestProxy';\n\nimport type { ResourceReporter } from './DatadogRumResource/ResourceReporter';\nimport { URLHostParser } from './URLHostParser';\nimport { calculateResponseSize } from './responseSize';\n\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\nexport const ORIGIN_RUM = 'rum';\n\nconst RESPONSE_START_LABEL = 'response_start';\n\ninterface DdRumXhr extends XMLHttpRequest {\n _datadog_xhr: DdRumXhrContext;\n}\n\ninterface DdRumXhrContext {\n method: string;\n url: string;\n reported: boolean;\n timer: Timer;\n tracingAttributes: DdRumResourceTracingAttributes;\n}\n\ninterface XHRProxyProviders {\n xhrType: typeof XMLHttpRequest;\n resourceReporter: ResourceReporter;\n}\n\n/**\n * Proxies XMLHTTPRequest to track resources.\n */\nexport class XHRProxy extends RequestProxy {\n private providers: XHRProxyProviders;\n private static originalXhrOpen: typeof XMLHttpRequest.prototype.open;\n private static originalXhrSend: typeof XMLHttpRequest.prototype.send;\n\n constructor(providers: XHRProxyProviders) {\n super();\n this.providers = providers;\n }\n\n onTrackingStart = (context: RequestProxyOptions) => {\n XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;\n XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;\n proxyRequests(this.providers, context);\n };\n\n onTrackingStop = () => {\n this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;\n this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;\n };\n}\n\nconst proxyRequests = (\n providers: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n proxyOpen(providers, context);\n proxySend(providers);\n};\n\nconst proxyOpen = (\n { xhrType }: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n const originalXhrOpen = xhrType.prototype.open;\n const firstPartyHostsRegex = context.firstPartyHostsRegex;\n const tracingSamplingRate = context.tracingSamplingRate;\n\n xhrType.prototype.open = function (\n this: DdRumXhr,\n method: string,\n url: string\n ) {\n const hostname = URLHostParser(url);\n // Keep track of the method and url\n // start time is tracked by the `send` method\n this._datadog_xhr = {\n method,\n url,\n reported: false,\n timer: new Timer(),\n tracingAttributes: getTracingAttributes({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n })\n };\n // eslint-disable-next-line prefer-rest-params\n return originalXhrOpen.apply(this, arguments as any);\n };\n};\n\nconst proxySend = (providers: XHRProxyProviders): void => {\n const xhrType = providers.xhrType;\n const originalXhrSend = xhrType.prototype.send;\n\n xhrType.prototype.send = function (this: DdRumXhr) {\n if (this._datadog_xhr) {\n // keep track of start time\n this._datadog_xhr.timer.start();\n this.setRequestHeader(ORIGIN_HEADER_KEY, ORIGIN_RUM);\n\n const tracingAttributes = this._datadog_xhr.tracingAttributes;\n this.setRequestHeader(\n SAMPLING_PRIORITY_HEADER_KEY,\n tracingAttributes.samplingPriorityHeader\n );\n if (tracingAttributes.tracingStrategy !== 'DISCARD') {\n this.setRequestHeader(\n TRACE_ID_HEADER_KEY,\n tracingAttributes.traceId\n );\n this.setRequestHeader(\n PARENT_ID_HEADER_KEY,\n tracingAttributes.spanId\n );\n }\n }\n\n proxyOnReadyStateChange(this, providers);\n\n // eslint-disable-next-line prefer-rest-params\n return originalXhrSend.apply(this, arguments as any);\n };\n};\n\nconst proxyOnReadyStateChange = (\n xhrProxy: DdRumXhr,\n providers: XHRProxyProviders\n): void => {\n const xhrType = providers.xhrType;\n const originalOnreadystatechange = xhrProxy.onreadystatechange;\n\n xhrProxy.onreadystatechange = function () {\n if (xhrProxy.readyState === xhrType.DONE) {\n if (!xhrProxy._datadog_xhr.reported) {\n reportXhr(xhrProxy, providers.resourceReporter);\n xhrProxy._datadog_xhr.reported = true;\n }\n } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {\n xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);\n }\n\n if (originalOnreadystatechange) {\n // eslint-disable-next-line prefer-rest-params\n originalOnreadystatechange.apply(xhrProxy, arguments as any);\n }\n };\n};\n\nconst reportXhr = async (\n xhrProxy: DdRumXhr,\n resourceReporter: ResourceReporter\n): Promise<void> => {\n const responseSize = calculateResponseSize(xhrProxy);\n\n const context = xhrProxy._datadog_xhr;\n\n const key = `${context.timer.startTime}/${context.method}`;\n\n context.timer.stop();\n\n resourceReporter.reportResource({\n key,\n request: {\n method: context.method,\n url: context.url,\n kind: 'xhr'\n },\n tracingAttributes: context.tracingAttributes,\n response: {\n statusCode: xhrProxy.status,\n size: responseSize\n },\n timings: {\n startTime: context.timer.startTime,\n stopTime: context.timer.stopTime,\n responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL)\n ? context.timer.timeAt(RESPONSE_START_LABEL)\n : undefined\n }\n });\n};\n"]}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.calculateResponseSize = calculateResponseSize;
7
+ exports.RESOURCE_SIZE_ERROR_MESSAGE = void 0;
8
+
9
+ var _InternalLog = require("../../../../InternalLog");
10
+
11
+ var _SdkVerbosity = require("../../../../SdkVerbosity");
12
+
13
+ /*
14
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
15
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
16
+ * Copyright 2016-Present Datadog, Inc.
17
+ */
18
+ const MISSING_RESOURCE_SIZE = -1;
19
+ const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
20
+ exports.RESOURCE_SIZE_ERROR_MESSAGE = RESOURCE_SIZE_ERROR_MESSAGE;
21
+
22
+ function byteLength(str) {
23
+ // This is a weird trick, but it works.
24
+ // Output is the same as TextEncoder.encode(...).length
25
+ return unescape(encodeURI(str)).length;
26
+ }
27
+
28
+ function getResponseContentLengthFromHeader(xhr) {
29
+ var _xhr$getResponseHeade;
30
+
31
+ const contentLengthHeader = parseInt((_xhr$getResponseHeade = xhr.getResponseHeader('Content-Length')) !== null && _xhr$getResponseHeade !== void 0 ? _xhr$getResponseHeade : '', 10);
32
+
33
+ if (!isNaN(contentLengthHeader)) {
34
+ return contentLengthHeader;
35
+ }
36
+
37
+ return null;
38
+ }
39
+
40
+ function calculateResponseSize(xhr) {
41
+ const contentLengthHeader = getResponseContentLengthFromHeader(xhr);
42
+
43
+ if (contentLengthHeader != null) {
44
+ return contentLengthHeader;
45
+ }
46
+
47
+ const response = xhr.response;
48
+
49
+ if (!response) {
50
+ return MISSING_RESOURCE_SIZE;
51
+ }
52
+
53
+ let size;
54
+
55
+ try {
56
+ switch (xhr.responseType) {
57
+ case '':
58
+ case 'text':
59
+ // String
60
+ size = byteLength(response);
61
+ break;
62
+
63
+ case 'blob':
64
+ size = response.size;
65
+ break;
66
+
67
+ case 'arraybuffer':
68
+ size = response.byteLength;
69
+ break;
70
+
71
+ case 'document':
72
+ // currently not supported by RN as of 0.66
73
+ // HTML Document or XML Document
74
+ break;
75
+
76
+ case 'json':
77
+ // plain JS object
78
+ // original size was lost, because this is the object which was parsed.
79
+ // We can only convert back to the string and calculate the size,
80
+ // which will roughly match original.
81
+ size = byteLength(JSON.stringify(response));
82
+ break;
83
+
84
+ default:
85
+ break;
86
+ }
87
+ } catch (e) {
88
+ _InternalLog.InternalLog.log(`${RESOURCE_SIZE_ERROR_MESSAGE}${e}`, _SdkVerbosity.SdkVerbosity.ERROR);
89
+ }
90
+
91
+ if (typeof size !== 'number') {
92
+ return MISSING_RESOURCE_SIZE;
93
+ }
94
+
95
+ return size;
96
+ }
97
+ //# sourceMappingURL=responseSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["responseSize.ts"],"names":["MISSING_RESOURCE_SIZE","RESOURCE_SIZE_ERROR_MESSAGE","byteLength","str","unescape","encodeURI","length","getResponseContentLengthFromHeader","xhr","contentLengthHeader","parseInt","getResponseHeader","isNaN","calculateResponseSize","response","size","responseType","JSON","stringify","e","InternalLog","log","SdkVerbosity","ERROR"],"mappings":";;;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AAKA,MAAMA,qBAAqB,GAAG,CAAC,CAA/B;AACO,MAAMC,2BAA2B,GACpC,wDADG;;;AAGP,SAASC,UAAT,CAAoBC,GAApB,EAAyC;AACrC;AACA;AACA,SAAOC,QAAQ,CAACC,SAAS,CAACF,GAAD,CAAV,CAAR,CAAyBG,MAAhC;AACH;;AAED,SAASC,kCAAT,CACIC,GADJ,EAEiB;AAAA;;AACb,QAAMC,mBAAmB,GAAGC,QAAQ,0BAChCF,GAAG,CAACG,iBAAJ,CAAsB,gBAAtB,CADgC,yEACW,EADX,EAEhC,EAFgC,CAApC;;AAIA,MAAI,CAACC,KAAK,CAACH,mBAAD,CAAV,EAAiC;AAC7B,WAAOA,mBAAP;AACH;;AACD,SAAO,IAAP;AACH;;AAEM,SAASI,qBAAT,CAA+BL,GAA/B,EAA4D;AAC/D,QAAMC,mBAAmB,GAAGF,kCAAkC,CAACC,GAAD,CAA9D;;AACA,MAAIC,mBAAmB,IAAI,IAA3B,EAAiC;AAC7B,WAAOA,mBAAP;AACH;;AAED,QAAMK,QAAQ,GAAGN,GAAG,CAACM,QAArB;;AACA,MAAI,CAACA,QAAL,EAAe;AACX,WAAOd,qBAAP;AACH;;AAED,MAAIe,IAAJ;;AACA,MAAI;AACA,YAAQP,GAAG,CAACQ,YAAZ;AACI,WAAK,EAAL;AACA,WAAK,MAAL;AACI;AACAD,QAAAA,IAAI,GAAGb,UAAU,CAACY,QAAD,CAAjB;AACA;;AACJ,WAAK,MAAL;AACIC,QAAAA,IAAI,GAAGD,QAAQ,CAACC,IAAhB;AACA;;AACJ,WAAK,aAAL;AACIA,QAAAA,IAAI,GAAGD,QAAQ,CAACZ,UAAhB;AACA;;AACJ,WAAK,UAAL;AACI;AACA;AACA;;AACJ,WAAK,MAAL;AACI;AACA;AACA;AACA;AACAa,QAAAA,IAAI,GAAGb,UAAU,CAACe,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAAD,CAAjB;AACA;;AACJ;AACI;AAxBR;AA0BH,GA3BD,CA2BE,OAAOK,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CACK,GAAEpB,2BAA4B,GAAEkB,CAAE,EADvC,EAEIG,2BAAaC,KAFjB;AAIH;;AAED,MAAI,OAAOR,IAAP,KAAgB,QAApB,EAA8B;AAC1B,WAAOf,qBAAP;AACH;;AACD,SAAOe,IAAP;AACH","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 { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nconst MISSING_RESOURCE_SIZE = -1;\nexport const RESOURCE_SIZE_ERROR_MESSAGE =\n \"Couldn't get resource size, because an error occured: \";\n\nfunction byteLength(str: string): number {\n // This is a weird trick, but it works.\n // Output is the same as TextEncoder.encode(...).length\n return unescape(encodeURI(str)).length;\n}\n\nfunction getResponseContentLengthFromHeader(\n xhr: XMLHttpRequest\n): number | null {\n const contentLengthHeader = parseInt(\n xhr.getResponseHeader('Content-Length') ?? '',\n 10\n );\n if (!isNaN(contentLengthHeader)) {\n return contentLengthHeader;\n }\n return null;\n}\n\nexport function calculateResponseSize(xhr: XMLHttpRequest): number {\n const contentLengthHeader = getResponseContentLengthFromHeader(xhr);\n if (contentLengthHeader != null) {\n return contentLengthHeader as number;\n }\n\n const response = xhr.response;\n if (!response) {\n return MISSING_RESOURCE_SIZE;\n }\n\n let size;\n try {\n switch (xhr.responseType) {\n case '':\n case 'text':\n // String\n size = byteLength(response);\n break;\n case 'blob':\n size = response.size;\n break;\n case 'arraybuffer':\n size = response.byteLength;\n break;\n case 'document':\n // currently not supported by RN as of 0.66\n // HTML Document or XML Document\n break;\n case 'json':\n // plain JS object\n // original size was lost, because this is the object which was parsed.\n // We can only convert back to the string and calculate the size,\n // which will roughly match original.\n size = byteLength(JSON.stringify(response));\n break;\n default:\n break;\n }\n } catch (e) {\n InternalLog.log(\n `${RESOURCE_SIZE_ERROR_MESSAGE}${e}`,\n SdkVerbosity.ERROR\n );\n }\n\n if (typeof size !== 'number') {\n return MISSING_RESOURCE_SIZE;\n }\n return size;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DdSdkConfiguration = void 0;
6
+ exports.ErrorSource = exports.RumActionType = exports.DdSdkConfiguration = void 0;
7
7
 
8
8
  /*
9
9
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
@@ -33,4 +33,29 @@ class DdSdkConfiguration {
33
33
 
34
34
 
35
35
  exports.DdSdkConfiguration = DdSdkConfiguration;
36
+
37
+ /**
38
+ * Describe the type of a RUM Action.
39
+ */
40
+ let RumActionType;
41
+ exports.RumActionType = RumActionType;
42
+
43
+ (function (RumActionType) {
44
+ RumActionType["TAP"] = "TAP";
45
+ RumActionType["SCROLL"] = "SCROLL";
46
+ RumActionType["SWIPE"] = "SWIPE";
47
+ RumActionType["BACK"] = "BACK";
48
+ RumActionType["CUSTOM"] = "CUSTOM";
49
+ })(RumActionType || (exports.RumActionType = RumActionType = {}));
50
+
51
+ let ErrorSource;
52
+ exports.ErrorSource = ErrorSource;
53
+
54
+ (function (ErrorSource) {
55
+ ErrorSource["NETWORK"] = "NETWORK";
56
+ ErrorSource["SOURCE"] = "SOURCE";
57
+ ErrorSource["CONSOLE"] = "CONSOLE";
58
+ ErrorSource["WEBVIEW"] = "WEBVIEW";
59
+ ErrorSource["CUSTOM"] = "CUSTOM";
60
+ })(ErrorSource || (exports.ErrorSource = ErrorSource = {}));
36
61
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;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\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: string,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, logger, …).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: string,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig","RumActionType","ErrorSource"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA;;;;;AAqOA;AACA;AACA;IACYC,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","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\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '1.0.0-rc8';
8
+ const version = '1.1.0';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc8';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.1.0';\n"]}
@@ -10,8 +10,8 @@ import { ProxyType } from './ProxyConfiguration';
10
10
  import { SdkVerbosity } from './SdkVerbosity';
11
11
  import { DdSdk } from './foundation';
12
12
  import { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';
13
- import { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking';
14
13
  import { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';
14
+ import { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';
15
15
  import { DdSdkConfiguration } from './types';
16
16
  import { version as sdkVersion } from './version';
17
17
  /**
@@ -64,6 +64,16 @@ export class DdSdkReactNative {
64
64
  configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
65
65
  }
66
66
 
67
+ if (configuration.version) {
68
+ configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${configuration.version}${configuration.versionSuffix ? `-${configuration.versionSuffix}` : ''}`;
69
+ } // If both version and version suffix are provided, we merge them into the version field.
70
+ // To avoid adding it in again the native part, we only set it if the version isn't set.
71
+
72
+
73
+ if (configuration.versionSuffix && !configuration.version) {
74
+ configuration.additionalConfig[DdSdkReactNative.DD_VERSION_SUFFIX] = `-${configuration.versionSuffix}`;
75
+ }
76
+
67
77
  configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
68
78
  configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
69
79
  DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
@@ -141,6 +151,10 @@ _defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", '_dd.sdk_verbosity');
141
151
 
142
152
  _defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", '_dd.native_view_tracking');
143
153
 
154
+ _defineProperty(DdSdkReactNative, "DD_VERSION", '_dd.version');
155
+
156
+ _defineProperty(DdSdkReactNative, "DD_VERSION_SUFFIX", '_dd.version_suffix');
157
+
144
158
  _defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", '_dd.proxy.type');
145
159
 
146
160
  _defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", '_dd.proxy.address');