@datadog/mobile-react-native 1.0.0-rc8 → 1.0.0-rc9

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 (108) hide show
  1. package/DatadogSDKReactNative.podspec +1 -1
  2. package/lib/commonjs/DdSdkReactNative.js +2 -2
  3. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  4. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +73 -0
  5. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
  6. package/lib/commonjs/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +40 -1
  7. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
  8. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +46 -0
  9. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
  10. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +25 -0
  11. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
  12. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
  13. package/lib/commonjs/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
  14. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +57 -0
  15. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
  16. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +49 -0
  17. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  18. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +45 -0
  19. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
  20. package/lib/commonjs/rum/instrumentation/{URLHostParser.js → resourceTracking/implementation/URLHostParser.js} +16 -7
  21. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
  22. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +167 -0
  23. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
  24. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js +97 -0
  25. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
  26. package/lib/commonjs/version.js +1 -1
  27. package/lib/commonjs/version.js.map +1 -1
  28. package/lib/module/DdSdkReactNative.js +1 -1
  29. package/lib/module/DdSdkReactNative.js.map +1 -1
  30. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +61 -0
  31. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
  32. package/lib/module/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +35 -1
  33. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
  34. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +29 -0
  35. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
  36. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +16 -0
  37. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
  38. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
  39. package/lib/module/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
  40. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +50 -0
  41. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
  42. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +40 -0
  43. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  44. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +36 -0
  45. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
  46. package/{src/rum/instrumentation/URLHostParser.ts → lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js} +15 -8
  47. package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
  48. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +151 -0
  49. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
  50. package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js +86 -0
  51. package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
  52. package/lib/module/version.js +1 -1
  53. package/lib/module/version.js.map +1 -1
  54. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +15 -0
  55. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +18 -0
  56. package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +6 -0
  57. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +8 -0
  58. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +19 -0
  59. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.d.ts +8 -0
  60. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
  61. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.d.ts +17 -0
  62. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/URLHostParser.d.ts +6 -0
  63. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +25 -0
  64. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +3 -0
  65. package/lib/typescript/version.d.ts +1 -1
  66. package/package.json +4 -3
  67. package/src/DdSdkReactNative.tsx +1 -1
  68. package/src/__tests__/DdSdkReactNative.test.tsx +11 -8
  69. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +1 -1
  70. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +1 -1
  71. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +67 -0
  72. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +79 -0
  73. package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/__tests__}/__utils__/XMLHttpRequestMock.ts +0 -0
  74. package/src/{__tests__/rum/instrumentation/TraceIdentifier.test.tsx → rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts} +1 -1
  75. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +87 -0
  76. package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +45 -0
  77. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +15 -0
  78. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +26 -0
  79. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +78 -0
  80. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +83 -0
  81. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +45 -0
  82. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +69 -0
  83. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.ts +50 -0
  84. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.ts +70 -0
  85. package/src/rum/instrumentation/resourceTracking/implementation/URLHostParser.ts +30 -0
  86. package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +197 -0
  87. package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/implementation/__tests__}/URLHostParser.test.ts +3 -3
  88. package/src/{__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx → rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts} +83 -49
  89. package/src/rum/instrumentation/resourceTracking/implementation/responseSize.ts +83 -0
  90. package/src/version.ts +1 -1
  91. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +0 -356
  92. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
  93. package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -2
  94. package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +0 -1
  95. package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +0 -1
  96. package/lib/module/rum/instrumentation/DdRumResourceTracking.js +0 -331
  97. package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
  98. package/lib/module/rum/instrumentation/DdRumXhr.js +0 -2
  99. package/lib/module/rum/instrumentation/TraceIdentifier.js.map +0 -1
  100. package/lib/module/rum/instrumentation/URLHostParser.js +0 -24
  101. package/lib/module/rum/instrumentation/URLHostParser.js.map +0 -1
  102. package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +0 -40
  103. package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +0 -23
  104. package/lib/typescript/rum/instrumentation/TraceIdentifier.d.ts +0 -1
  105. package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +0 -6
  106. package/src/rum/instrumentation/DdRumResourceTracking.tsx +0 -426
  107. package/src/rum/instrumentation/DdRumXhr.tsx +0 -33
  108. package/src/rum/instrumentation/TraceIdentifier.tsx +0 -34
@@ -0,0 +1,50 @@
1
+ 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; }
2
+
3
+ /*
4
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
5
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
+ * Copyright 2016-Present Datadog, Inc.
7
+ */
8
+ import { DdRum } from '../../../../../foundation';
9
+ import { createTimings } from './resourceTiming';
10
+ export class ResourceReporter {
11
+ constructor(resourceMappers) {
12
+ _defineProperty(this, "mappers", void 0);
13
+
14
+ _defineProperty(this, "reportResource", resource => {
15
+ let modifiedResource = resource;
16
+
17
+ for (const mapper of this.mappers) {
18
+ modifiedResource = mapper(resource);
19
+
20
+ if (modifiedResource === null) {
21
+ return;
22
+ }
23
+ }
24
+
25
+ reportResource(modifiedResource);
26
+ });
27
+
28
+ this.mappers = resourceMappers;
29
+ }
30
+
31
+ }
32
+
33
+ const formatResourceStartContext = tracingAttributes => {
34
+ return tracingAttributes.tracingStrategy === 'DISCARD' ? undefined : {
35
+ '_dd.span_id': tracingAttributes.spanId,
36
+ '_dd.trace_id': tracingAttributes.traceId
37
+ };
38
+ };
39
+
40
+ const formatResourceStopContext = timings => {
41
+ return {
42
+ '_dd.resource_timings': timings.responseStartTime !== undefined ? createTimings(timings.startTime, timings.responseStartTime, timings.stopTime) : null
43
+ };
44
+ };
45
+
46
+ const reportResource = async resource => {
47
+ await DdRum.startResource(resource.key, resource.request.method, resource.request.url, formatResourceStartContext(resource.tracingAttributes), resource.timings.startTime);
48
+ DdRum.stopResource(resource.key, resource.response.statusCode, resource.request.kind, resource.response.size, formatResourceStopContext(resource.timings), resource.timings.stopTime);
49
+ };
50
+ //# sourceMappingURL=ResourceReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,2BAAtB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAIA,OAAO,MAAMC,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEO;AACtC,SAAOA,iBAAiB,CAACC,eAAlB,KAAsC,SAAtC,GACDC,SADC,GAED;AACI,mBAAeF,iBAAiB,CAACG,MADrC;AAEI,oBAAgBH,iBAAiB,CAACI;AAFtC,GAFN;AAMH,CATD;;AAWA,MAAMC,yBAAyB,GAC3BC,OAD8B,IAEJ;AAC1B,SAAO;AACH,4BACIA,OAAO,CAACC,iBAAR,KAA8BL,SAA9B,GACMZ,aAAa,CACTgB,OAAO,CAACE,SADC,EAETF,OAAO,CAACC,iBAFC,EAGTD,OAAO,CAACG,QAHC,CADnB,GAMM;AARP,GAAP;AAUH,CAbD;;AAeA,MAAMX,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAML,KAAK,CAACqB,aAAN,CACFhB,QAAQ,CAACiB,GADP,EAEFjB,QAAQ,CAACkB,OAAT,CAAiBC,MAFf,EAGFnB,QAAQ,CAACkB,OAAT,CAAiBE,GAHf,EAIFf,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACY,OAAT,CAAiBE,SALf,CAAN;AAQAnB,EAAAA,KAAK,CAAC0B,YAAN,CACIrB,QAAQ,CAACiB,GADb,EAEIjB,QAAQ,CAACsB,QAAT,CAAkBC,UAFtB,EAGIvB,QAAQ,CAACkB,OAAT,CAAiBM,IAHrB,EAIIxB,QAAQ,CAACsB,QAAT,CAAkBG,IAJtB,EAKId,yBAAyB,CAACX,QAAQ,CAACY,OAAV,CAL7B,EAMIZ,QAAQ,CAACY,OAAT,CAAiBG,QANrB;AAQH,CAjBD","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 { DdRum } from '../../../../../foundation';\nimport type { RUMResource } from '../../domain/interfaces/RumResource';\n\nimport { createTimings } from './resourceTiming';\n\ntype ResourceMapper = (resource: RUMResource) => RUMResource | null;\n\nexport class ResourceReporter {\n private mappers: ResourceMapper[];\n\n constructor(resourceMappers: ResourceMapper[]) {\n this.mappers = resourceMappers;\n }\n\n reportResource = (resource: RUMResource) => {\n let modifiedResource: RUMResource | null = resource;\n\n for (const mapper of this.mappers) {\n modifiedResource = mapper(resource);\n if (modifiedResource === null) {\n return;\n }\n }\n\n reportResource(modifiedResource);\n };\n}\n\nconst formatResourceStartContext = (\n tracingAttributes: RUMResource['tracingAttributes']\n): Record<string, unknown> | undefined => {\n return tracingAttributes.tracingStrategy === 'DISCARD'\n ? undefined\n : {\n '_dd.span_id': tracingAttributes.spanId,\n '_dd.trace_id': tracingAttributes.traceId\n };\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings']\n): Record<string, unknown> => {\n return {\n '_dd.resource_timings':\n timings.responseStartTime !== undefined\n ? createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n )\n : null\n };\n};\n\nconst reportResource = async (resource: RUMResource) => {\n await DdRum.startResource(\n resource.key,\n resource.request.method,\n resource.request.url,\n formatResourceStartContext(resource.tracingAttributes),\n resource.timings.startTime\n );\n\n DdRum.stopResource(\n resource.key,\n resource.response.statusCode,\n resource.request.kind,\n resource.response.size,\n formatResourceStopContext(resource.timings),\n resource.timings.stopTime\n );\n};\n"]}
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * Expo sends all console.* calls to the packager. As we log all API calls
9
+ * when the SDKVerbosity is DEBUG, this would result in an infinite loop of
10
+ * `console.log` and API calls, creating 250 RUM resources per second.
11
+ *
12
+ * The hostname is always going to be localhost or a local IP.
13
+ *
14
+ * An example URL is http://192.168.1.20:8081/logs or http://10.46.29.155:19000/logs
15
+ */
16
+ const EXPO_DEV_LOGS_REGEX = new RegExp('^http://((10|172|192).[0-9]+.[0-9]+.[0-9]+|localhost):[0-9]+/logs$');
17
+ /**
18
+ * This call is made every time the RN packager reloads the js in dev mode.
19
+ */
20
+
21
+ const RN_PACKAGER_SYMBOLICATE_REGEX = new RegExp('^http://localhost:[0-9]+/symbolicate$');
22
+ const internalResourceBlocklist = [EXPO_DEV_LOGS_REGEX, RN_PACKAGER_SYMBOLICATE_REGEX];
23
+ /**
24
+ * Filters RN symbolicate calls and Expo logs calls that happen only in dev.
25
+ * @param resource RUMResource
26
+ */
27
+
28
+ export const filterDevResource = resource => {
29
+ // TODO: if we get the confirmation by Expo that the
30
+ // logs call is only made when __DEV__ is true, add an
31
+ // early return for when it is false.
32
+ for (const resourceRegex of internalResourceBlocklist) {
33
+ if (resourceRegex.test(resource.request.url)) {
34
+ return null;
35
+ }
36
+ }
37
+
38
+ return resource;
39
+ };
40
+ //# 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;;AACA,OAAO,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,36 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ import { Platform } from 'react-native';
7
+ export function createTimings(startTime, responseStartTime, responseEndTime) {
8
+ const firstByte = formatTiming(startTime, startTime, responseStartTime);
9
+ const download = formatTiming(startTime, responseStartTime, responseEndTime); // needed for iOS, simply total duration from start to end
10
+
11
+ const fetch = formatTiming(startTime, startTime, responseEndTime);
12
+ return {
13
+ firstByte,
14
+ download,
15
+ fetch
16
+ };
17
+ }
18
+ /**
19
+ * @param origin Start time (absolute) of the request
20
+ * @param start Start time (absolute) of the timing
21
+ * @param end End time (absolute) of the timing
22
+ */
23
+
24
+ function formatTiming(origin, start, end) {
25
+ return {
26
+ duration: timeToNanos(end - start),
27
+ // if it is Android, startTime should be relative to the origin,
28
+ // if it is iOS - absolute (unix timestamp)
29
+ startTime: Platform.OS === 'ios' ? timeToNanos(start) : timeToNanos(start - origin)
30
+ };
31
+ }
32
+
33
+ function timeToNanos(durationMs) {
34
+ return +(durationMs * 1e6).toFixed(0);
35
+ }
36
+ //# sourceMappingURL=resourceTiming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["resourceTiming.ts"],"names":["Platform","createTimings","startTime","responseStartTime","responseEndTime","firstByte","formatTiming","download","fetch","origin","start","end","duration","timeToNanos","OS","durationMs","toFixed"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,cAAzB;AAuBA,OAAO,SAASC,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,EACLF,QAAQ,CAACc,EAAT,KAAgB,KAAhB,GACMD,WAAW,CAACH,KAAD,CADjB,GAEMG,WAAW,CAACH,KAAK,GAAGD,MAAT;AAPlB,GAAP;AASH;;AAED,SAASI,WAAT,CAAqBE,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"]}
@@ -3,21 +3,28 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
-
6
+ import { InternalLog } from '../../../../InternalLog';
7
+ import { SdkVerbosity } from '../../../../SdkVerbosity';
7
8
  // matches what is between the first "://" and the next "/", ":" or whitespace
8
9
  const hostRegex = '^.+://([^:/\\s]+)';
9
-
10
10
  /**
11
11
  * Returns the host from an URL.
12
- * @returns the host (without the port)
13
- * @throws if URL is not well formatted
12
+ * @returns the host (without the port) or null if could not cast the URL as host
14
13
  */
15
- export const URLHostParser = (url: string): string => {
14
+
15
+ export const URLHostParser = url => {
16
+ try {
16
17
  const matchedHost = url.match(hostRegex);
18
+
17
19
  if (matchedHost === null) {
18
- throw new Error(`${url} is not a correctly formatted URL`);
19
- }
20
+ return null;
21
+ } // [0] is the input, [1] is the captured group
22
+
20
23
 
21
- // [0] is the input, [1] is the captured group
22
24
  return matchedHost[1];
25
+ } catch (e) {
26
+ InternalLog.log(`Impossible to cast ${url} as URL`, SdkVerbosity.WARN);
27
+ return null;
28
+ }
23
29
  };
30
+ //# sourceMappingURL=URLHostParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["URLHostParser.ts"],"names":["InternalLog","SdkVerbosity","hostRegex","URLHostParser","url","matchedHost","match","e","log","WARN"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAGA;AACA,MAAMC,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;;AACA,OAAO,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;AACRP,IAAAA,WAAW,CAACQ,GAAZ,CAAiB,sBAAqBJ,GAAI,SAA1C,EAAoDH,YAAY,CAACQ,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,151 @@
1
+ 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; }
2
+
3
+ /*
4
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
5
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
+ * Copyright 2016-Present Datadog, Inc.
7
+ */
8
+ import Timer from '../../../../Timer';
9
+ import { getTracingAttributes } from '../domain/distributedTracing';
10
+ import { RequestProxy } from '../domain/interfaces/RequestProxy';
11
+ import { URLHostParser } from './URLHostParser';
12
+ import { calculateResponseSize } from './responseSize';
13
+ export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
14
+ export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
15
+ export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
16
+ export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
17
+ export const ORIGIN_RUM = 'rum';
18
+ const RESPONSE_START_LABEL = 'response_start';
19
+
20
+ /**
21
+ * Proxies XMLHTTPRequest to track resources.
22
+ */
23
+ export class XHRProxy extends RequestProxy {
24
+ constructor(providers) {
25
+ super();
26
+
27
+ _defineProperty(this, "providers", void 0);
28
+
29
+ _defineProperty(this, "onTrackingStart", context => {
30
+ XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;
31
+ XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;
32
+ proxyRequests(this.providers, context);
33
+ });
34
+
35
+ _defineProperty(this, "onTrackingStop", () => {
36
+ this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;
37
+ this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;
38
+ });
39
+
40
+ this.providers = providers;
41
+ }
42
+
43
+ }
44
+
45
+ _defineProperty(XHRProxy, "originalXhrOpen", void 0);
46
+
47
+ _defineProperty(XHRProxy, "originalXhrSend", void 0);
48
+
49
+ const proxyRequests = (providers, context) => {
50
+ proxyOpen(providers, context);
51
+ proxySend(providers);
52
+ };
53
+
54
+ const proxyOpen = ({
55
+ xhrType
56
+ }, context) => {
57
+ const originalXhrOpen = xhrType.prototype.open;
58
+ const firstPartyHostsRegex = context.firstPartyHostsRegex;
59
+ const tracingSamplingRate = context.tracingSamplingRate;
60
+
61
+ xhrType.prototype.open = function (method, url) {
62
+ const hostname = URLHostParser(url); // Keep track of the method and url
63
+ // start time is tracked by the `send` method
64
+
65
+ this._datadog_xhr = {
66
+ method,
67
+ url,
68
+ reported: false,
69
+ timer: new Timer(),
70
+ tracingAttributes: getTracingAttributes({
71
+ hostname,
72
+ firstPartyHostsRegex,
73
+ tracingSamplingRate
74
+ })
75
+ }; // eslint-disable-next-line prefer-rest-params
76
+
77
+ return originalXhrOpen.apply(this, arguments);
78
+ };
79
+ };
80
+
81
+ const proxySend = providers => {
82
+ const xhrType = providers.xhrType;
83
+ const originalXhrSend = xhrType.prototype.send;
84
+
85
+ xhrType.prototype.send = function () {
86
+ if (this._datadog_xhr) {
87
+ // keep track of start time
88
+ this._datadog_xhr.timer.start();
89
+
90
+ this.setRequestHeader(ORIGIN_HEADER_KEY, ORIGIN_RUM);
91
+ const tracingAttributes = this._datadog_xhr.tracingAttributes;
92
+ this.setRequestHeader(SAMPLING_PRIORITY_HEADER_KEY, tracingAttributes.samplingPriorityHeader);
93
+
94
+ if (tracingAttributes.tracingStrategy !== 'DISCARD') {
95
+ this.setRequestHeader(TRACE_ID_HEADER_KEY, tracingAttributes.traceId);
96
+ this.setRequestHeader(PARENT_ID_HEADER_KEY, tracingAttributes.spanId);
97
+ }
98
+ }
99
+
100
+ proxyOnReadyStateChange(this, providers); // eslint-disable-next-line prefer-rest-params
101
+
102
+ return originalXhrSend.apply(this, arguments);
103
+ };
104
+ };
105
+
106
+ const proxyOnReadyStateChange = (xhrProxy, providers) => {
107
+ const xhrType = providers.xhrType;
108
+ const originalOnreadystatechange = xhrProxy.onreadystatechange;
109
+
110
+ xhrProxy.onreadystatechange = function () {
111
+ if (xhrProxy.readyState === xhrType.DONE) {
112
+ if (!xhrProxy._datadog_xhr.reported) {
113
+ reportXhr(xhrProxy, providers.resourceReporter);
114
+ xhrProxy._datadog_xhr.reported = true;
115
+ }
116
+ } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {
117
+ xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);
118
+ }
119
+
120
+ if (originalOnreadystatechange) {
121
+ // eslint-disable-next-line prefer-rest-params
122
+ originalOnreadystatechange.apply(xhrProxy, arguments);
123
+ }
124
+ };
125
+ };
126
+
127
+ const reportXhr = async (xhrProxy, resourceReporter) => {
128
+ const responseSize = calculateResponseSize(xhrProxy);
129
+ const context = xhrProxy._datadog_xhr;
130
+ const key = `${context.timer.startTime}/${context.method}`;
131
+ context.timer.stop();
132
+ resourceReporter.reportResource({
133
+ key,
134
+ request: {
135
+ method: context.method,
136
+ url: context.url,
137
+ kind: 'xhr'
138
+ },
139
+ tracingAttributes: context.tracingAttributes,
140
+ response: {
141
+ statusCode: xhrProxy.status,
142
+ size: responseSize
143
+ },
144
+ timings: {
145
+ startTime: context.timer.startTime,
146
+ stopTime: context.timer.stopTime,
147
+ responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL) ? context.timer.timeAt(RESPONSE_START_LABEL) : undefined
148
+ }
149
+ });
150
+ };
151
+ //# sourceMappingURL=XHRProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["XHRProxy.ts"],"names":["Timer","getTracingAttributes","RequestProxy","URLHostParser","calculateResponseSize","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","ORIGIN_HEADER_KEY","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_RUM","RESPONSE_START_LABEL","XHRProxy","constructor","providers","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","proxyRequests","proxyOpen","proxySend","firstPartyHostsRegex","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","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":"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","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,86 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ import { InternalLog } from '../../../../InternalLog';
7
+ import { SdkVerbosity } from '../../../../SdkVerbosity';
8
+ const MISSING_RESOURCE_SIZE = -1;
9
+ export const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
10
+
11
+ function byteLength(str) {
12
+ // This is a weird trick, but it works.
13
+ // Output is the same as TextEncoder.encode(...).length
14
+ return unescape(encodeURI(str)).length;
15
+ }
16
+
17
+ function getResponseContentLengthFromHeader(xhr) {
18
+ var _xhr$getResponseHeade;
19
+
20
+ const contentLengthHeader = parseInt((_xhr$getResponseHeade = xhr.getResponseHeader('Content-Length')) !== null && _xhr$getResponseHeade !== void 0 ? _xhr$getResponseHeade : '', 10);
21
+
22
+ if (!isNaN(contentLengthHeader)) {
23
+ return contentLengthHeader;
24
+ }
25
+
26
+ return null;
27
+ }
28
+
29
+ export function calculateResponseSize(xhr) {
30
+ const contentLengthHeader = getResponseContentLengthFromHeader(xhr);
31
+
32
+ if (contentLengthHeader != null) {
33
+ return contentLengthHeader;
34
+ }
35
+
36
+ const response = xhr.response;
37
+
38
+ if (!response) {
39
+ return MISSING_RESOURCE_SIZE;
40
+ }
41
+
42
+ let size;
43
+
44
+ try {
45
+ switch (xhr.responseType) {
46
+ case '':
47
+ case 'text':
48
+ // String
49
+ size = byteLength(response);
50
+ break;
51
+
52
+ case 'blob':
53
+ size = response.size;
54
+ break;
55
+
56
+ case 'arraybuffer':
57
+ size = response.byteLength;
58
+ break;
59
+
60
+ case 'document':
61
+ // currently not supported by RN as of 0.66
62
+ // HTML Document or XML Document
63
+ break;
64
+
65
+ case 'json':
66
+ // plain JS object
67
+ // original size was lost, because this is the object which was parsed.
68
+ // We can only convert back to the string and calculate the size,
69
+ // which will roughly match original.
70
+ size = byteLength(JSON.stringify(response));
71
+ break;
72
+
73
+ default:
74
+ break;
75
+ }
76
+ } catch (e) {
77
+ InternalLog.log(`${RESOURCE_SIZE_ERROR_MESSAGE}${e}`, SdkVerbosity.ERROR);
78
+ }
79
+
80
+ if (typeof size !== 'number') {
81
+ return MISSING_RESOURCE_SIZE;
82
+ }
83
+
84
+ return size;
85
+ }
86
+ //# sourceMappingURL=responseSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["responseSize.ts"],"names":["InternalLog","SdkVerbosity","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","log","ERROR"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAEA,MAAMC,qBAAqB,GAAG,CAAC,CAA/B;AACA,OAAO,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;;AAED,OAAO,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;AACRrB,IAAAA,WAAW,CAACsB,GAAZ,CACK,GAAEnB,2BAA4B,GAAEkB,CAAE,EADvC,EAEIpB,YAAY,CAACsB,KAFjB;AAIH;;AAED,MAAI,OAAON,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"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '1.0.0-rc8';
2
+ export const version = '1.0.0-rc9';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,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;AACA,OAAO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc9';\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
3
+ */
4
+ export declare class DdRumResourceTracking {
5
+ private static isTracking;
6
+ private static requestProxy;
7
+ /**
8
+ * Starts tracking resources and sends a RUM Resource event every time a network request is detected.
9
+ */
10
+ static startTracking({ tracingSamplingRate, firstPartyHosts }: {
11
+ tracingSamplingRate: number;
12
+ firstPartyHosts: string[];
13
+ }): void;
14
+ static stopTracking(): void;
15
+ }
@@ -0,0 +1,18 @@
1
+ import type { Hostname } from './firstPartyHosts';
2
+ export declare type DdRumResourceTracingAttributes = {
3
+ tracingStrategy: 'KEEP';
4
+ traceId: string;
5
+ spanId: string;
6
+ samplingPriorityHeader: '1';
7
+ } | {
8
+ tracingStrategy: 'DISCARD';
9
+ traceId?: void;
10
+ spanId?: void;
11
+ samplingPriorityHeader: '0';
12
+ };
13
+ export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegex, tracingSamplingRate }: {
14
+ hostname: Hostname | null;
15
+ firstPartyHostsRegex: RegExp;
16
+ tracingSamplingRate: number;
17
+ }) => DdRumResourceTracingAttributes;
18
+ export declare function generateTraceId(): string;
@@ -0,0 +1,6 @@
1
+ export declare type Hostname = {
2
+ _type: 'Hostname';
3
+ } & string;
4
+ export declare const NO_MATCH_REGEX: RegExp;
5
+ export declare const firstPartyHostsRegexBuilder: (firstPartyHosts: string[]) => RegExp;
6
+ export declare const isHostFirstParty: (hostname: Hostname, firstPartyHostsRegex: RegExp) => boolean;
@@ -0,0 +1,8 @@
1
+ export interface RequestProxyOptions {
2
+ tracingSamplingRate: number;
3
+ firstPartyHostsRegex: RegExp;
4
+ }
5
+ export declare abstract class RequestProxy {
6
+ abstract onTrackingStart: (context: RequestProxyOptions) => void;
7
+ abstract onTrackingStop: () => void;
8
+ }
@@ -0,0 +1,19 @@
1
+ import type { DdRumResourceTracingAttributes } from '../distributedTracing';
2
+ export interface RUMResource {
3
+ key: string;
4
+ request: {
5
+ method: string;
6
+ url: string;
7
+ kind: string;
8
+ };
9
+ tracingAttributes: DdRumResourceTracingAttributes;
10
+ response: {
11
+ statusCode: number;
12
+ size: number;
13
+ };
14
+ timings: {
15
+ startTime: number;
16
+ stopTime: number;
17
+ responseStartTime?: number;
18
+ };
19
+ }
@@ -0,0 +1,8 @@
1
+ import type { RUMResource } from '../../domain/interfaces/RumResource';
2
+ declare type ResourceMapper = (resource: RUMResource) => RUMResource | null;
3
+ export declare class ResourceReporter {
4
+ private mappers;
5
+ constructor(resourceMappers: ResourceMapper[]);
6
+ reportResource: (resource: RUMResource) => void;
7
+ }
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { RUMResource } from '../../domain/interfaces/RumResource';
2
+ /**
3
+ * Filters RN symbolicate calls and Expo logs calls that happen only in dev.
4
+ * @param resource RUMResource
5
+ */
6
+ export declare const filterDevResource: (resource: RUMResource) => RUMResource | null;
@@ -0,0 +1,17 @@
1
+ interface Timing {
2
+ /**
3
+ * Time relative (absolute in case of iOS) to some point, in ns.
4
+ */
5
+ startTime: number;
6
+ /**
7
+ * Duration in ns.
8
+ */
9
+ duration: number;
10
+ }
11
+ interface ResourceTimings {
12
+ firstByte: Timing;
13
+ download: Timing;
14
+ fetch: Timing;
15
+ }
16
+ export declare function createTimings(startTime: number, responseStartTime: number, responseEndTime: number): ResourceTimings;
17
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { Hostname } from '../domain/firstPartyHosts';
2
+ /**
3
+ * Returns the host from an URL.
4
+ * @returns the host (without the port) or null if could not cast the URL as host
5
+ */
6
+ export declare const URLHostParser: (url: string) => Hostname | null;
@@ -0,0 +1,25 @@
1
+ /// <reference types="react-native" />
2
+ import type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';
3
+ import { RequestProxy } from '../domain/interfaces/RequestProxy';
4
+ import type { ResourceReporter } from './DatadogRumResource/ResourceReporter';
5
+ export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
6
+ export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
7
+ export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
8
+ export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
9
+ export declare const ORIGIN_RUM = "rum";
10
+ interface XHRProxyProviders {
11
+ xhrType: typeof XMLHttpRequest;
12
+ resourceReporter: ResourceReporter;
13
+ }
14
+ /**
15
+ * Proxies XMLHTTPRequest to track resources.
16
+ */
17
+ export declare class XHRProxy extends RequestProxy {
18
+ private providers;
19
+ private static originalXhrOpen;
20
+ private static originalXhrSend;
21
+ constructor(providers: XHRProxyProviders);
22
+ onTrackingStart: (context: RequestProxyOptions) => void;
23
+ onTrackingStop: () => void;
24
+ }
25
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react-native" />
2
+ export declare const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
3
+ export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
@@ -1 +1 @@
1
- export declare const version = "1.0.0-rc8";
1
+ export declare const version = "1.0.0-rc9";