@datadog/mobile-react-native 2.3.5 → 2.4.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 (95) hide show
  1. package/DatadogSDKReactNative.podspec +6 -6
  2. package/android/build.gradle +4 -4
  3. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  4. package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +2 -0
  5. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +15 -0
  6. package/android/src/test/resources/input/complete-configuration.json +5 -1
  7. package/datadog-configuration.schema.json +54 -9
  8. package/datadog-sourcemaps.gradle +64 -1
  9. package/ios/Sources/DatadogSDKWrapper.swift +3 -3
  10. package/ios/Sources/SdkVersion.swift +1 -1
  11. package/lib/commonjs/DdSdkReactNative.js +2 -1
  12. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  13. package/lib/commonjs/DdSdkReactNativeConfiguration.js +7 -4
  14. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  15. package/lib/commonjs/logs/DdLogs.js +10 -8
  16. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  17. package/lib/commonjs/rum/DdRum.js +50 -48
  18. package/lib/commonjs/rum/DdRum.js.map +1 -1
  19. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
  20. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  21. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
  22. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  23. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +182 -0
  24. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
  25. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -57
  26. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  27. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +18 -10
  28. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
  29. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +4 -2
  30. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
  31. package/lib/commonjs/trace/DdTrace.js +4 -2
  32. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  33. package/lib/commonjs/utils/argsUtils.js +43 -0
  34. package/lib/commonjs/utils/argsUtils.js.map +1 -0
  35. package/lib/commonjs/version.js +1 -1
  36. package/lib/commonjs/version.js.map +1 -1
  37. package/lib/module/DdSdkReactNative.js +2 -1
  38. package/lib/module/DdSdkReactNative.js.map +1 -1
  39. package/lib/module/DdSdkReactNativeConfiguration.js +7 -4
  40. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  41. package/lib/module/logs/DdLogs.js +9 -8
  42. package/lib/module/logs/DdLogs.js.map +1 -1
  43. package/lib/module/rum/DdRum.js +48 -47
  44. package/lib/module/rum/DdRum.js.map +1 -1
  45. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
  46. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  47. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
  48. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  49. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +169 -0
  50. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
  51. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +3 -54
  52. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  53. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +13 -8
  54. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
  55. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +3 -2
  56. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
  57. package/lib/module/trace/DdTrace.js +3 -2
  58. package/lib/module/trace/DdTrace.js.map +1 -1
  59. package/lib/module/utils/argsUtils.js +30 -0
  60. package/lib/module/utils/argsUtils.js.map +1 -0
  61. package/lib/module/version.js +1 -1
  62. package/lib/module/version.js.map +1 -1
  63. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -1
  64. package/lib/typescript/rum/DdRum.d.ts +2 -2
  65. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +12 -3
  66. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +2 -3
  67. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +111 -0
  68. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +1 -24
  69. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +2 -0
  70. package/lib/typescript/utils/argsUtils.d.ts +1 -0
  71. package/lib/typescript/version.d.ts +1 -1
  72. package/package.json +2 -2
  73. package/src/DdSdkReactNative.tsx +4 -1
  74. package/src/DdSdkReactNativeConfiguration.tsx +10 -4
  75. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
  76. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +32 -0
  77. package/src/logs/DdLogs.ts +9 -8
  78. package/src/logs/__tests__/DdLogs.test.ts +543 -0
  79. package/src/rum/DdRum.ts +112 -94
  80. package/src/rum/__tests__/DdRum.test.ts +552 -0
  81. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +23 -7
  82. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -4
  83. package/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx +227 -0
  84. package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/__utils__/TracingIdentifierUtils.ts +64 -0
  85. package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +314 -42
  86. package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +4 -59
  87. package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +33 -19
  88. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +7 -2
  89. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +134 -11
  90. package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +3 -0
  91. package/src/trace/DdTrace.ts +12 -2
  92. package/src/trace/__tests__/DdTrace.test.ts +146 -0
  93. package/src/utils/__tests__/argsUtils.test.ts +66 -0
  94. package/src/utils/argsUtils.ts +35 -0
  95. package/src/version.ts +1 -1
@@ -4,6 +4,7 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
  import { PropagatorType } from '../../../types';
7
+ import { TracingIdFormat } from './TracingIdentifier';
7
8
  export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
8
9
  /**
9
10
  * Datadog headers
@@ -13,6 +14,8 @@ export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
13
14
  export const ORIGIN_RUM = 'rum';
14
15
  export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
15
16
  export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
17
+ export const TAGS_HEADER_KEY = 'x-datadog-tags';
18
+ export const DD_TRACE_ID_TAG = '_dd.p.tid';
16
19
  /**
17
20
  * OTel headers
18
21
  */
@@ -42,10 +45,13 @@ export const getTracingHeaders = tracingAttributes => {
42
45
  value: tracingAttributes.samplingPriorityHeader
43
46
  }, {
44
47
  header: TRACE_ID_HEADER_KEY,
45
- value: tracingAttributes.traceId.toString(10)
48
+ value: tracingAttributes.traceId.toString(TracingIdFormat.lowDecimal)
46
49
  }, {
47
50
  header: PARENT_ID_HEADER_KEY,
48
- value: tracingAttributes.spanId.toString(10)
51
+ value: tracingAttributes.spanId.toString(TracingIdFormat.decimal)
52
+ }, {
53
+ header: TAGS_HEADER_KEY,
54
+ value: `${DD_TRACE_ID_TAG}=${tracingAttributes.traceId.toString(TracingIdFormat.paddedHighHex)}`
49
55
  });
50
56
  break;
51
57
  }
@@ -87,10 +93,10 @@ export const getTracingHeaders = tracingAttributes => {
87
93
  {
88
94
  headers.push({
89
95
  header: B3_MULTI_TRACE_ID_HEADER_KEY,
90
- value: tracingAttributes.traceId.toPaddedString(16, 32)
96
+ value: tracingAttributes.traceId.toString(TracingIdFormat.paddedHex)
91
97
  }, {
92
98
  header: B3_MULTI_SPAN_ID_HEADER_KEY,
93
- value: tracingAttributes.spanId.toPaddedString(16, 16)
99
+ value: tracingAttributes.spanId.toString(TracingIdFormat.paddedHex)
94
100
  }, {
95
101
  header: B3_MULTI_SAMPLED_HEADER_KEY,
96
102
  value: tracingAttributes.samplingPriorityHeader
@@ -108,7 +114,7 @@ const generateTraceContextHeader = ({
108
114
  isSampled
109
115
  }) => {
110
116
  const flags = isSampled ? '01' : '00';
111
- return `${version}-${traceId.toPaddedString(16, 32)}-${parentId.toPaddedString(16, 16)}-${flags}`;
117
+ return `${version}-${traceId.toString(TracingIdFormat.paddedHex)}-${parentId.toString(TracingIdFormat.paddedHex)}-${flags}`;
112
118
  };
113
119
 
114
120
  const generateTraceStateHeader = ({
@@ -117,7 +123,7 @@ const generateTraceStateHeader = ({
117
123
  }) => {
118
124
  const sampled = `s:${isSampled ? '1' : '0'}`;
119
125
  const origin = 'o:rum';
120
- const parent = `p:${parentId.toPaddedString(16, 16)}`;
126
+ const parent = `p:${parentId.toString(TracingIdFormat.paddedHex)}`;
121
127
  return `dd=${sampled};${origin};${parent}`;
122
128
  };
123
129
 
@@ -126,7 +132,6 @@ const generateB3Header = ({
126
132
  spanId,
127
133
  isSampled
128
134
  }) => {
129
- const flags = isSampled ? '1' : '0';
130
- return `${traceId.toPaddedString(16, 32)}-${spanId.toPaddedString(16, 16)}-${flags}`;
135
+ return [traceId.toString(TracingIdFormat.paddedHex), spanId.toString(TracingIdFormat.paddedHex), isSampled ? '1' : '0'].join('-');
131
136
  };
132
137
  //# sourceMappingURL=distributedTracingHeaders.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracingHeaders.ts"],"names":["PropagatorType","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TRACECONTEXT_HEADER_KEY","TRACESTATE_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","getTracingHeaders","tracingAttributes","headers","tracingStrategy","propagatorTypes","forEach","propagator","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","spanId","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","toPaddedString","flags","sampled","origin","parent"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,cAAT,QAA+B,gBAA/B;AAQA,OAAO,MAAMC,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAG,kBAA1B;AACP,OAAO,MAAMC,UAAU,GAAG,KAAnB;AACP,OAAO,MAAMC,mBAAmB,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ET,iBAAiB,CAACU;AAF7B,WATJ;AAcH;AAxEL;AA0EH,GA3ED;AA6EA,SAAOT,OAAP;AACH,CArFM;;AAuFP,MAAMc,0BAA0B,GAAG,CAAC;AAChCC,EAAAA,OADgC;AAEhCL,EAAAA,OAFgC;AAGhCM,EAAAA,QAHgC;AAIhCC,EAAAA;AAJgC,CAAD,KAU7B;AACF,QAAMM,KAAK,GAAGN,SAAS,GAAG,IAAH,GAAU,IAAjC;AACA,SAAQ,GAAEF,OAAQ,IAAGL,OAAO,CAACY,cAAR,CACjB,EADiB,EAEjB,EAFiB,CAGnB,IAAGN,QAAQ,CAACM,cAAT,CAAwB,EAAxB,EAA4B,EAA5B,CAAgC,IAAGC,KAAM,EAH9C;AAIH,CAhBD;;AAkBA,MAAML,wBAAwB,GAAG,CAAC;AAC9BF,EAAAA,QAD8B;AAE9BC,EAAAA;AAF8B,CAAD,KAM3B;AACF,QAAMO,OAAO,GAAI,KAAIP,SAAS,GAAG,GAAH,GAAS,GAAI,EAA3C;AACA,QAAMQ,MAAM,GAAG,OAAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACM,cAAT,CAAwB,EAAxB,EAA4B,EAA5B,CAAgC,EAApD;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBV,EAAAA,OADsB;AAEtBE,EAAAA,MAFsB;AAGtBK,EAAAA;AAHsB,CAAD,KAQnB;AACF,QAAMM,KAAK,GAAGN,SAAS,GAAG,GAAH,GAAS,GAAhC;AACA,SAAQ,GAAEP,OAAO,CAACY,cAAR,CAAuB,EAAvB,EAA2B,EAA3B,CAA+B,IAAGV,MAAM,CAACU,cAAP,CACxC,EADwC,EAExC,EAFwC,CAG1C,IAAGC,KAAM,EAHX;AAIH,CAdD","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 { PropagatorType } from '../../../types';\n\nimport type {\n DdRumResourceTracingAttributes,\n SpanId,\n TraceId\n} from './distributedTracing';\n\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\n/**\n * Datadog headers\n */\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const ORIGIN_RUM = 'rum';\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\n/**\n * OTel headers\n */\nexport const TRACECONTEXT_HEADER_KEY = 'traceparent';\nexport const TRACESTATE_HEADER_KEY = 'tracestate';\nexport const B3_HEADER_KEY = 'b3';\nexport const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';\nexport const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';\nexport const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';\n\nexport const getTracingHeaders = (\n tracingAttributes: DdRumResourceTracingAttributes\n): { header: string; value: string }[] => {\n const headers: { header: string; value: string }[] = [];\n if (tracingAttributes.tracingStrategy === 'DISCARD') {\n return headers;\n }\n tracingAttributes.propagatorTypes.forEach(propagator => {\n switch (propagator) {\n case PropagatorType.DATADOG: {\n headers.push(\n {\n header: ORIGIN_HEADER_KEY,\n value: ORIGIN_RUM\n },\n {\n header: SAMPLING_PRIORITY_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n },\n {\n header: TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(10)\n },\n {\n header: PARENT_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(10)\n }\n );\n break;\n }\n case PropagatorType.TRACECONTEXT: {\n headers.push(\n {\n header: TRACECONTEXT_HEADER_KEY,\n value: generateTraceContextHeader({\n version: '00',\n traceId: tracingAttributes.traceId,\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n },\n {\n header: TRACESTATE_HEADER_KEY,\n value: generateTraceStateHeader({\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n }\n );\n break;\n }\n case PropagatorType.B3: {\n headers.push({\n header: B3_HEADER_KEY,\n value: generateB3Header({\n traceId: tracingAttributes.traceId,\n spanId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n });\n break;\n }\n case PropagatorType.B3MULTI: {\n headers.push(\n {\n header: B3_MULTI_TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toPaddedString(16, 32)\n },\n {\n header: B3_MULTI_SPAN_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toPaddedString(16, 16)\n },\n {\n header: B3_MULTI_SAMPLED_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n }\n );\n }\n }\n });\n\n return headers;\n};\n\nconst generateTraceContextHeader = ({\n version,\n traceId,\n parentId,\n isSampled\n}: {\n version: string;\n traceId: TraceId;\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '01' : '00';\n return `${version}-${traceId.toPaddedString(\n 16,\n 32\n )}-${parentId.toPaddedString(16, 16)}-${flags}`;\n};\n\nconst generateTraceStateHeader = ({\n parentId,\n isSampled\n}: {\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const sampled = `s:${isSampled ? '1' : '0'}`;\n const origin = 'o:rum';\n const parent = `p:${parentId.toPaddedString(16, 16)}`;\n\n return `dd=${sampled};${origin};${parent}`;\n};\n\nconst generateB3Header = ({\n traceId,\n spanId,\n isSampled\n}: {\n traceId: TraceId;\n spanId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '1' : '0';\n return `${traceId.toPaddedString(16, 32)}-${spanId.toPaddedString(\n 16,\n 16\n )}-${flags}`;\n};\n"]}
1
+ {"version":3,"sources":["distributedTracingHeaders.ts"],"names":["PropagatorType","TracingIdFormat","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TAGS_HEADER_KEY","DD_TRACE_ID_TAG","TRACECONTEXT_HEADER_KEY","TRACESTATE_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","getTracingHeaders","tracingAttributes","headers","tracingStrategy","propagatorTypes","forEach","propagator","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","lowDecimal","spanId","decimal","paddedHighHex","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","paddedHex","flags","sampled","origin","parent","join"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,cAAT,QAA+B,gBAA/B;AAEA,SAASC,eAAT,QAAgC,qBAAhC;AAIA,OAAO,MAAMC,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAG,kBAA1B;AACP,OAAO,MAAMC,UAAU,GAAG,KAAnB;AACP,OAAO,MAAMC,mBAAmB,GAAG,oBAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,qBAA7B;AACP,OAAO,MAAMC,eAAe,GAAG,gBAAxB;AACP,OAAO,MAAMC,eAAe,GAAG,WAAxB;AAEP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAG,aAAhC;AACP,OAAO,MAAMC,qBAAqB,GAAG,YAA9B;AACP,OAAO,MAAMC,aAAa,GAAG,IAAtB;AACP,OAAO,MAAMC,4BAA4B,GAAG,cAArC;AACP,OAAO,MAAMC,2BAA2B,GAAG,aAApC;AACP,OAAO,MAAMC,2BAA2B,GAAG,cAApC;AAEP,OAAO,MAAMC,iBAAiB,GAC1BC,iBAD6B,IAES;AACtC,QAAMC,OAA4C,GAAG,EAArD;;AACA,MAAID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EAAAA;AAJgC,CAAD,KAU7B;AACF,QAAMM,KAAK,GAAGN,SAAS,GAAG,IAAH,GAAU,IAAjC;AACA,SAAQ,GAAEF,OAAQ,IAAGR,OAAO,CAACC,QAAR,CACjB3B,eAAe,CAACyC,SADC,CAEnB,IAAGN,QAAQ,CAACR,QAAT,CAAkB3B,eAAe,CAACyC,SAAlC,CAA6C,IAAGC,KAAM,EAF3D;AAGH,CAfD;;AAiBA,MAAML,wBAAwB,GAAG,CAAC;AAC9BF,EAAAA,QAD8B;AAE9BC,EAAAA;AAF8B,CAAD,KAM3B;AACF,QAAMO,OAAO,GAAI,KAAIP,SAAS,GAAG,GAAH,GAAS,GAAI,EAA3C;AACA,QAAMQ,MAAM,GAAG,OAAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACR,QAAT,CAAkB3B,eAAe,CAACyC,SAAlC,CAA6C,EAAjE;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBb,EAAAA,OADsB;AAEtBG,EAAAA,MAFsB;AAGtBO,EAAAA;AAHsB,CAAD,KAQnB;AACF,SAAO,CACHV,OAAO,CAACC,QAAR,CAAiB3B,eAAe,CAACyC,SAAjC,CADG,EAEHZ,MAAM,CAACF,QAAP,CAAgB3B,eAAe,CAACyC,SAAhC,CAFG,EAGHL,SAAS,GAAG,GAAH,GAAS,GAHf,EAILU,IAJK,CAIA,GAJA,CAAP;AAKH,CAdD","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 { PropagatorType } from '../../../types';\n\nimport { TracingIdFormat } from './TracingIdentifier';\nimport type { TraceId, SpanId } from './TracingIdentifier';\nimport type { DdRumResourceTracingAttributes } from './distributedTracing';\n\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\n/**\n * Datadog headers\n */\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const ORIGIN_RUM = 'rum';\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\nexport const TAGS_HEADER_KEY = 'x-datadog-tags';\nexport const DD_TRACE_ID_TAG = '_dd.p.tid';\n\n/**\n * OTel headers\n */\nexport const TRACECONTEXT_HEADER_KEY = 'traceparent';\nexport const TRACESTATE_HEADER_KEY = 'tracestate';\nexport const B3_HEADER_KEY = 'b3';\nexport const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';\nexport const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';\nexport const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';\n\nexport const getTracingHeaders = (\n tracingAttributes: DdRumResourceTracingAttributes\n): { header: string; value: string }[] => {\n const headers: { header: string; value: string }[] = [];\n if (tracingAttributes.tracingStrategy === 'DISCARD') {\n return headers;\n }\n tracingAttributes.propagatorTypes.forEach(propagator => {\n switch (propagator) {\n case PropagatorType.DATADOG: {\n headers.push(\n {\n header: ORIGIN_HEADER_KEY,\n value: ORIGIN_RUM\n },\n {\n header: SAMPLING_PRIORITY_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n },\n {\n header: TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(\n TracingIdFormat.lowDecimal\n )\n },\n {\n header: PARENT_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n )\n },\n {\n header: TAGS_HEADER_KEY,\n value: `${DD_TRACE_ID_TAG}=${tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHighHex\n )}`\n }\n );\n break;\n }\n case PropagatorType.TRACECONTEXT: {\n headers.push(\n {\n header: TRACECONTEXT_HEADER_KEY,\n value: generateTraceContextHeader({\n version: '00',\n traceId: tracingAttributes.traceId,\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n },\n {\n header: TRACESTATE_HEADER_KEY,\n value: generateTraceStateHeader({\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n }\n );\n break;\n }\n case PropagatorType.B3: {\n headers.push({\n header: B3_HEADER_KEY,\n value: generateB3Header({\n traceId: tracingAttributes.traceId,\n spanId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n });\n break;\n }\n case PropagatorType.B3MULTI: {\n headers.push(\n {\n header: B3_MULTI_TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHex\n )\n },\n {\n header: B3_MULTI_SPAN_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.paddedHex\n )\n },\n {\n header: B3_MULTI_SAMPLED_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n }\n );\n }\n }\n });\n\n return headers;\n};\n\nconst generateTraceContextHeader = ({\n version,\n traceId,\n parentId,\n isSampled\n}: {\n version: string;\n traceId: TraceId;\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '01' : '00';\n return `${version}-${traceId.toString(\n TracingIdFormat.paddedHex\n )}-${parentId.toString(TracingIdFormat.paddedHex)}-${flags}`;\n};\n\nconst generateTraceStateHeader = ({\n parentId,\n isSampled\n}: {\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const sampled = `s:${isSampled ? '1' : '0'}`;\n const origin = 'o:rum';\n const parent = `p:${parentId.toString(TracingIdFormat.paddedHex)}`;\n\n return `dd=${sampled};${origin};${parent}`;\n};\n\nconst generateB3Header = ({\n traceId,\n spanId,\n isSampled\n}: {\n traceId: TraceId;\n spanId: SpanId;\n isSampled: boolean;\n}) => {\n return [\n traceId.toString(TracingIdFormat.paddedHex),\n spanId.toString(TracingIdFormat.paddedHex),\n isSampled ? '1' : '0'\n ].join('-');\n};\n"]}
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { DdRum } from '../../../../../DdRum';
9
+ import { TracingIdFormat } from '../../../distributedTracing/TracingIdentifier';
9
10
  import { createTimings } from './resourceTiming';
10
11
  export class ResourceReporter {
11
12
  constructor(resourceMappers) {
@@ -34,8 +35,8 @@ const formatResourceStartContext = tracingAttributes => {
34
35
  const attributes = {};
35
36
 
36
37
  if (tracingAttributes.samplingPriorityHeader !== '0') {
37
- attributes['_dd.span_id'] = tracingAttributes.spanId.toString(10);
38
- attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(10);
38
+ attributes['_dd.span_id'] = tracingAttributes.spanId.toString(TracingIdFormat.decimal);
39
+ attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(TracingIdFormat.paddedHex);
39
40
  attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;
40
41
  }
41
42
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","traceId","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,sBAAtB;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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;;AACD,QAAIN,iBAAiB,CAACO,SAAtB,EAAiC;AAC7Bf,MAAAA,UAAU,CAAC,uBAAD,CAAV,GAAsCQ,iBAAiB,CAACO,SAAxD;AACH;AACJ;;AAED,SAAOf,UAAP;AACH,CA3BD;;AA6BA,MAAMH,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAML,KAAK,CAAC4B,aAAN,CACFvB,QAAQ,CAACwB,GADP,EAEFxB,QAAQ,CAACyB,OAAT,CAAiBC,MAFf,EAGF1B,QAAQ,CAACyB,OAAT,CAAiBE,GAHf,EAIFtB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACc,OAAT,CAAiBI,SALf,CAAN;AAQAvB,EAAAA,KAAK,CAACiC,YAAN,CACI5B,QAAQ,CAACwB,GADb,EAEIxB,QAAQ,CAAC6B,QAAT,CAAkBC,UAFtB,EAGI9B,QAAQ,CAACyB,OAAT,CAAiBM,IAHrB,EAII/B,QAAQ,CAAC6B,QAAT,CAAkBG,IAJtB,EAKInB,yBAAyB,CAACb,QAAQ,CAACc,OAAV,EAAmBd,QAAQ,CAACe,iBAA5B,CAL7B,EAMIf,QAAQ,CAACc,OAAT,CAAiBK,QANrB,EAOInB,QAAQ,CAACiC,eAPb;AASH,CAlBD","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 '../../../../../DdRum';\nimport type { RUMResource } from '../../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, string | number> => {\n const attributes: Record<string, string | number> = {};\n if (tracingAttributes.samplingPriorityHeader !== '0') {\n attributes['_dd.span_id'] = tracingAttributes.spanId.toString(10);\n attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(10);\n attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;\n }\n\n return attributes;\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings'],\n graphqlAttributes: RUMResource['graphqlAttributes']\n): Record<string, unknown> => {\n const attributes: Record<string, unknown> = {};\n\n if (timings.responseStartTime !== undefined) {\n attributes['_dd.resource_timings'] = createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n );\n }\n\n if (graphqlAttributes?.operationType) {\n attributes['_dd.graphql.operation_type'] =\n graphqlAttributes.operationType;\n if (graphqlAttributes.operationName) {\n attributes['_dd.graphql.operation_name'] =\n graphqlAttributes.operationName;\n }\n if (graphqlAttributes.variables) {\n attributes['_dd.graphql.variables'] = graphqlAttributes.variables;\n }\n }\n\n return attributes;\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, resource.graphqlAttributes),\n resource.timings.stopTime,\n resource.resourceContext\n );\n};\n"]}
1
+ {"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","TracingIdFormat","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","decimal","traceId","paddedHex","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,sBAAtB;AACA,SAASC,eAAT,QAAgC,+CAAhC;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,IAEG;AAClC,QAAMC,UAA2C,GAAG,EAApD;;AACA,MAAID,iBAAiB,CAACE,sBAAlB,KAA6C,GAAjD,EAAsD;AAClDD,IAAAA,UAAU,CAAC,aAAD,CAAV,GAA4BD,iBAAiB,CAACG,MAAlB,CAAyBC,QAAzB,CACxBf,eAAe,CAACgB,OADQ,CAA5B;AAGAJ,IAAAA,UAAU,CAAC,cAAD,CAAV,GAA6BD,iBAAiB,CAACM,OAAlB,CAA0BF,QAA1B,CACzBf,eAAe,CAACkB,SADS,CAA7B;AAGAN,IAAAA,UAAU,CAAC,cAAD,CAAV,GAA6BD,iBAAiB,CAACQ,OAA/C;AACH;;AAED,SAAOP,UAAP;AACH,CAfD;;AAiBA,MAAMQ,yBAAyB,GAAG,CAC9BC,OAD8B,EAE9BC,iBAF8B,KAGJ;AAC1B,QAAMV,UAAmC,GAAG,EAA5C;;AAEA,MAAIS,OAAO,CAACE,iBAAR,KAA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,eAPb;AASH,CAlBD","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 '../../../../../DdRum';\nimport { TracingIdFormat } from '../../../distributedTracing/TracingIdentifier';\nimport type { RUMResource } from '../../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, string | number> => {\n const attributes: Record<string, string | number> = {};\n if (tracingAttributes.samplingPriorityHeader !== '0') {\n attributes['_dd.span_id'] = tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n );\n attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHex\n );\n attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;\n }\n\n return attributes;\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings'],\n graphqlAttributes: RUMResource['graphqlAttributes']\n): Record<string, unknown> => {\n const attributes: Record<string, unknown> = {};\n\n if (timings.responseStartTime !== undefined) {\n attributes['_dd.resource_timings'] = createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n );\n }\n\n if (graphqlAttributes?.operationType) {\n attributes['_dd.graphql.operation_type'] =\n graphqlAttributes.operationType;\n if (graphqlAttributes.operationName) {\n attributes['_dd.graphql.operation_name'] =\n graphqlAttributes.operationName;\n }\n if (graphqlAttributes.variables) {\n attributes['_dd.graphql.variables'] = graphqlAttributes.variables;\n }\n }\n\n return attributes;\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, resource.graphqlAttributes),\n resource.timings.stopTime,\n resource.resourceContext\n );\n};\n"]}
@@ -8,6 +8,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import { InternalLog } from '../InternalLog';
9
9
  import { SdkVerbosity } from '../SdkVerbosity';
10
10
  import { bufferNativeCallReturningId, bufferNativeCallWithId } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';
11
+ import { validateContext } from '../utils/argsUtils';
11
12
  import { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';
12
13
  const timeProvider = new DefaultTimeProvider();
13
14
 
@@ -16,14 +17,14 @@ class DdTraceWrapper {
16
17
  _defineProperty(this, "nativeTrace", require('../specs/NativeDdTrace').default);
17
18
 
18
19
  _defineProperty(this, "startSpan", (operation, context = {}, timestampMs = timeProvider.now()) => {
19
- const spanId = bufferNativeCallReturningId(() => this.nativeTrace.startSpan(operation, context, timestampMs));
20
+ const spanId = bufferNativeCallReturningId(() => this.nativeTrace.startSpan(operation, validateContext(context), timestampMs));
20
21
  InternalLog.log(`Starting span “${operation}” #${spanId}`, SdkVerbosity.DEBUG);
21
22
  return spanId;
22
23
  });
23
24
 
24
25
  _defineProperty(this, "finishSpan", (spanId, context = {}, timestampMs = timeProvider.now()) => {
25
26
  InternalLog.log(`Finishing span #${spanId}`, SdkVerbosity.DEBUG);
26
- return bufferNativeCallWithId(id => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);
27
+ return bufferNativeCallWithId(id => this.nativeTrace.finishSpan(id, validateContext(context), timestampMs), spanId);
27
28
  });
28
29
  }
29
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdTrace.ts"],"names":["InternalLog","SdkVerbosity","bufferNativeCallReturningId","bufferNativeCallWithId","DefaultTimeProvider","timeProvider","DdTraceWrapper","require","default","operation","context","timestampMs","now","spanId","nativeTrace","startSpan","log","DEBUG","id","finishSpan","DdTrace"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SACIC,2BADJ,EAEIC,sBAFJ,QAGO,gDAHP;AAKA,SAASC,mBAAT,QAAoC,4CAApC;AAEA,MAAMC,YAAY,GAAG,IAAID,mBAAJ,EAArB;;AAEA,MAAME,cAAN,CAA4C;AAAA;AAAA,yCAECC,OAAO,CAAC,wBAAD,CAAP,CACpCC,OAHmC;;AAAA,uCAK5B,CACRC,SADQ,EAERC,OAAe,GAAG,EAFV,EAGRC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHd,KAIU;AAClB,YAAMC,MAAM,GAAGX,2BAA2B,CAAC,MACvC,KAAKY,WAAL,CAAiBC,SAAjB,CAA2BN,SAA3B,EAAsCC,OAAtC,EAA+CC,WAA/C,CADsC,CAA1C;AAGAX,MAAAA,WAAW,CAACgB,GAAZ,CACK,kBAAiBP,SAAU,MAAKI,MAAO,EAD5C,EAEIZ,YAAY,CAACgB,KAFjB;AAIA,aAAOJ,MAAP;AACH,KAlBuC;;AAAA,wCAoB3B,CACTA,MADS,EAETH,OAAe,GAAG,EAFT,EAGTC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHb,KAIO;AAChBZ,MAAAA,WAAW,CAACgB,GAAZ,CAAiB,mBAAkBH,MAAO,EAA1C,EAA6CZ,YAAY,CAACgB,KAA1D;AACA,aAAOd,sBAAsB,CACzBe,EAAE,IAAI,KAAKJ,WAAL,CAAiBK,UAAjB,CAA4BD,EAA5B,EAAgCR,OAAhC,EAAyCC,WAAzC,CADmB,EAEzBE,MAFyB,CAA7B;AAIH,KA9BuC;AAAA;;AAAA;;AAiC5C,MAAMO,OAAoB,GAAG,IAAId,cAAJ,EAA7B;AAEA,SAASc,OAAT","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 { DdNativeTraceType } from '../nativeModulesTypes';\nimport {\n bufferNativeCallReturningId,\n bufferNativeCallWithId\n} from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport type { DdTraceType } from '../types';\nimport { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';\n\nconst timeProvider = new DefaultTimeProvider();\n\nclass DdTraceWrapper implements DdTraceType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeTrace: DdNativeTraceType = require('../specs/NativeDdTrace')\n .default;\n\n startSpan = (\n operation: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<string> => {\n const spanId = bufferNativeCallReturningId(() =>\n this.nativeTrace.startSpan(operation, context, timestampMs)\n );\n InternalLog.log(\n `Starting span “${operation}” #${spanId}`,\n SdkVerbosity.DEBUG\n );\n return spanId;\n };\n\n finishSpan = (\n spanId: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(`Finishing span #${spanId}`, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId(\n id => this.nativeTrace.finishSpan(id, context, timestampMs),\n spanId\n );\n };\n}\n\nconst DdTrace: DdTraceType = new DdTraceWrapper();\n\nexport { DdTrace };\n"]}
1
+ {"version":3,"sources":["DdTrace.ts"],"names":["InternalLog","SdkVerbosity","bufferNativeCallReturningId","bufferNativeCallWithId","validateContext","DefaultTimeProvider","timeProvider","DdTraceWrapper","require","default","operation","context","timestampMs","now","spanId","nativeTrace","startSpan","log","DEBUG","id","finishSpan","DdTrace"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SACIC,2BADJ,EAEIC,sBAFJ,QAGO,gDAHP;AAKA,SAASC,eAAT,QAAgC,oBAAhC;AACA,SAASC,mBAAT,QAAoC,4CAApC;AAEA,MAAMC,YAAY,GAAG,IAAID,mBAAJ,EAArB;;AAEA,MAAME,cAAN,CAA4C;AAAA;AAAA,yCAECC,OAAO,CAAC,wBAAD,CAAP,CACpCC,OAHmC;;AAAA,uCAK5B,CACRC,SADQ,EAERC,OAAe,GAAG,EAFV,EAGRC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHd,KAIU;AAClB,YAAMC,MAAM,GAAGZ,2BAA2B,CAAC,MACvC,KAAKa,WAAL,CAAiBC,SAAjB,CACIN,SADJ,EAEIN,eAAe,CAACO,OAAD,CAFnB,EAGIC,WAHJ,CADsC,CAA1C;AAOAZ,MAAAA,WAAW,CAACiB,GAAZ,CACK,kBAAiBP,SAAU,MAAKI,MAAO,EAD5C,EAEIb,YAAY,CAACiB,KAFjB;AAIA,aAAOJ,MAAP;AACH,KAtBuC;;AAAA,wCAwB3B,CACTA,MADS,EAETH,OAAe,GAAG,EAFT,EAGTC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHb,KAIO;AAChBb,MAAAA,WAAW,CAACiB,GAAZ,CAAiB,mBAAkBH,MAAO,EAA1C,EAA6Cb,YAAY,CAACiB,KAA1D;AACA,aAAOf,sBAAsB,CACzBgB,EAAE,IACE,KAAKJ,WAAL,CAAiBK,UAAjB,CACID,EADJ,EAEIf,eAAe,CAACO,OAAD,CAFnB,EAGIC,WAHJ,CAFqB,EAOzBE,MAPyB,CAA7B;AASH,KAvCuC;AAAA;;AAAA;;AA0C5C,MAAMO,OAAoB,GAAG,IAAId,cAAJ,EAA7B;AAEA,SAASc,OAAT","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 { DdNativeTraceType } from '../nativeModulesTypes';\nimport {\n bufferNativeCallReturningId,\n bufferNativeCallWithId\n} from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport type { DdTraceType } from '../types';\nimport { validateContext } from '../utils/argsUtils';\nimport { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';\n\nconst timeProvider = new DefaultTimeProvider();\n\nclass DdTraceWrapper implements DdTraceType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeTrace: DdNativeTraceType = require('../specs/NativeDdTrace')\n .default;\n\n startSpan = (\n operation: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<string> => {\n const spanId = bufferNativeCallReturningId(() =>\n this.nativeTrace.startSpan(\n operation,\n validateContext(context),\n timestampMs\n )\n );\n InternalLog.log(\n `Starting span “${operation}” #${spanId}`,\n SdkVerbosity.DEBUG\n );\n return spanId;\n };\n\n finishSpan = (\n spanId: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(`Finishing span #${spanId}`, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId(\n id =>\n this.nativeTrace.finishSpan(\n id,\n validateContext(context),\n timestampMs\n ),\n spanId\n );\n };\n}\n\nconst DdTrace: DdTraceType = new DdTraceWrapper();\n\nexport { DdTrace };\n"]}
@@ -0,0 +1,30 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
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 { InternalLog } from '../InternalLog';
9
+ import { SdkVerbosity } from '../SdkVerbosity';
10
+ export const validateContext = context => {
11
+ if (!context) {
12
+ return {};
13
+ } // eslint-disable-next-line eqeqeq
14
+
15
+
16
+ if (context.constructor == Object) {
17
+ return context;
18
+ }
19
+
20
+ if (Array.isArray(context)) {
21
+ InternalLog.log("The given context is an array, it will be nested in 'context' property inside a new object.", SdkVerbosity.WARN);
22
+ return {
23
+ context
24
+ };
25
+ }
26
+
27
+ InternalLog.log(`The given context (${context}) is invalid - it must be an object. Context will be empty.`, SdkVerbosity.ERROR);
28
+ return {};
29
+ };
30
+ //# sourceMappingURL=argsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["argsUtils.ts"],"names":["InternalLog","SdkVerbosity","validateContext","context","constructor","Object","Array","isArray","log","WARN","ERROR"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,OAAO,MAAMC,eAAe,GAAIC,OAAD,IAAkB;AAC7C,MAAI,CAACA,OAAL,EAAc;AACV,WAAO,EAAP;AACH,GAH4C,CAK7C;;;AACA,MAAIA,OAAO,CAACC,WAAR,IAAuBC,MAA3B,EAAmC;AAC/B,WAAOF,OAAP;AACH;;AAED,MAAIG,KAAK,CAACC,OAAN,CAAcJ,OAAd,CAAJ,EAA4B;AACxBH,IAAAA,WAAW,CAACQ,GAAZ,CACI,6FADJ,EAEIP,YAAY,CAACQ,IAFjB;AAIA,WAAO;AAAEN,MAAAA;AAAF,KAAP;AACH;;AAEDH,EAAAA,WAAW,CAACQ,GAAZ,CACK,sBAAqBL,OAAQ,6DADlC,EAEIF,YAAY,CAACS,KAFjB;AAKA,SAAO,EAAP;AACH,CAxBM","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/*\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\nexport const validateContext = (context: any) => {\n if (!context) {\n return {};\n }\n\n // eslint-disable-next-line eqeqeq\n if (context.constructor == Object) {\n return context;\n }\n\n if (Array.isArray(context)) {\n InternalLog.log(\n \"The given context is an array, it will be nested in 'context' property inside a new object.\",\n SdkVerbosity.WARN\n );\n return { context };\n }\n\n InternalLog.log(\n `The given context (${context}) is invalid - it must be an object. Context will be empty.`,\n SdkVerbosity.ERROR\n );\n\n return {};\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '2.3.5';
2
+ export const version = '2.4.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.5';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.4.0';\n"]}
@@ -77,6 +77,7 @@ export declare const DEFAULTS: {
77
77
  getCustomEndpoints: () => {};
78
78
  bundleLogsWithRum: boolean;
79
79
  bundleLogsWithTraces: boolean;
80
+ useAccessibilityLabel: boolean;
80
81
  };
81
82
  /**
82
83
  * The SDK configuration class.
@@ -90,6 +91,7 @@ export declare class DdSdkReactNativeConfiguration {
90
91
  readonly trackResources: boolean;
91
92
  readonly trackErrors: boolean;
92
93
  readonly trackingConsent: TrackingConsent;
94
+ readonly useAccessibilityLabel: boolean;
93
95
  /**
94
96
  * Enables crash reporting for native platforms (iOS, Android). Default `false`.
95
97
  */
@@ -237,7 +239,7 @@ export declare class DdSdkReactNativeConfiguration {
237
239
  [k: string]: any;
238
240
  };
239
241
  customEndpoints: CustomEndpoints;
240
- constructor(clientToken: string, env: string, applicationId: string, trackInteractions?: boolean, trackResources?: boolean, trackErrors?: boolean, trackingConsent?: TrackingConsent);
242
+ constructor(clientToken: string, env: string, applicationId: string, trackInteractions?: boolean, trackResources?: boolean, trackErrors?: boolean, trackingConsent?: TrackingConsent, useAccessibilityLabel?: boolean);
241
243
  }
242
244
  /**
243
245
  * Auto Instrumentation configuration passed to DatadogProvider.
@@ -253,6 +255,7 @@ export type AutoInstrumentationConfiguration = {
253
255
  readonly errorEventMapper?: ErrorEventMapper | null;
254
256
  readonly resourceEventMapper?: ResourceEventMapper | null;
255
257
  readonly actionEventMapper?: ActionEventMapper | null;
258
+ readonly useAccessibilityLabel?: boolean;
256
259
  readonly actionNameAttribute?: string;
257
260
  };
258
261
  /**
@@ -268,6 +271,7 @@ export type AutoInstrumentationParameters = {
268
271
  readonly errorEventMapper: ErrorEventMapper | null;
269
272
  readonly resourceEventMapper: ResourceEventMapper | null;
270
273
  readonly actionEventMapper: ActionEventMapper | null;
274
+ readonly useAccessibilityLabel: boolean;
271
275
  readonly actionNameAttribute?: string;
272
276
  };
273
277
  /**
@@ -21,8 +21,6 @@ declare class DdRumWrapper implements DdRumType {
21
21
  timestampMs?: number
22
22
  ] | [context?: object, timestampMs?: number]) => Promise<void>;
23
23
  setTimeProvider: (timeProvider: TimeProvider) => void;
24
- private callNativeStopAction;
25
- private getStopActionNativeCallArgs;
26
24
  addAction: (type: RumActionType, name: string, context?: object, timestampMs?: number, actionContext?: GestureResponderEvent) => Promise<void>;
27
25
  startResource: (key: string, method: string, url: string, context?: object, timestampMs?: number) => Promise<void>;
28
26
  stopResource: (key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number, resourceContext?: XMLHttpRequest) => Promise<void>;
@@ -37,6 +35,8 @@ declare class DdRumWrapper implements DdRumType {
37
35
  unregisterResourceEventMapper(): void;
38
36
  registerActionEventMapper(actionEventMapper: ActionEventMapper): void;
39
37
  unregisterActionEventMapper(): void;
38
+ private callNativeStopAction;
39
+ private getStopActionNativeCallArgs;
40
40
  }
41
41
  export declare const DdRum: DdRumWrapper;
42
42
  export {};
@@ -1,12 +1,21 @@
1
1
  import type EventsInterceptor from './EventsInterceptor';
2
2
  export declare const UNKNOWN_TARGET_NAME = "unknown_target";
3
+ export type DdEventsInterceptorOptions = {
4
+ /**
5
+ * Specifies a custom prop to name RUM actions on elements having an `onPress` prop
6
+ * */
7
+ actionNameAttribute?: string;
8
+ /**
9
+ * Determines whether the accessibility label can be used to resolve the action name.
10
+ * */
11
+ useAccessibilityLabel?: boolean;
12
+ };
3
13
  export declare class DdEventsInterceptor implements EventsInterceptor {
4
14
  static ACTION_EVENT_DROPPED_DEBUG_MESSAGE: string;
5
15
  private debouncingStartedTimestamp;
6
16
  private actionNameAttribute?;
7
- constructor({ actionNameAttribute }?: {
8
- actionNameAttribute?: string;
9
- });
17
+ private useAccessibilityLabel;
18
+ constructor(options?: DdEventsInterceptorOptions);
10
19
  interceptOnPress(...args: any[]): void;
11
20
  private handleTargetEvent;
12
21
  private resolveTargetName;
@@ -1,3 +1,4 @@
1
+ import type { DdEventsInterceptorOptions } from './DdEventsInterceptor';
1
2
  /**
2
3
  * Provides RUM auto-instrumentation feature to track user interaction as RUM events.
3
4
  * For now we are only covering the "onPress" events.
@@ -14,8 +15,6 @@ export declare class DdRumUserInteractionTracking {
14
15
  * Please note that we are only considering as valid - for - tracking only the user interactions that have
15
16
  * a visible output (either an UI state change or a Resource request)
16
17
  */
17
- static startTracking({ actionNameAttribute }?: {
18
- actionNameAttribute?: string;
19
- }): void;
18
+ static startTracking(options: DdEventsInterceptorOptions): void;
20
19
  static stopTracking(): void;
21
20
  }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Available formats for representing the {@link TracingIdentifier} as a string.
3
+ */
4
+ export declare enum TracingIdFormat {
5
+ /**
6
+ * Decimal string representation of the full tracing id.
7
+ */
8
+ decimal = 0,
9
+ /**
10
+ * The low bits of the tracing id as a decimal.
11
+ */
12
+ lowDecimal = 1,
13
+ /**
14
+ * The high bits of the tracing id as a decimal.
15
+ */
16
+ highDecimal = 2,
17
+ /**
18
+ * Hexadecimal string representation of the full tracing id.
19
+ */
20
+ hex = 3,
21
+ /**
22
+ * Hexadecimal string representation of the low bits of the tracing id.
23
+ */
24
+ lowHex = 4,
25
+ /**
26
+ * Hexadecimal string representation of the high bits of the tracing id.
27
+ */
28
+ highHex = 5,
29
+ /**
30
+ * Padded hexadecimal string representation of the full tracing id.
31
+ */
32
+ paddedHex = 6,
33
+ /**
34
+ * Padded hexadecimal string representation of the low bits of the tracing id.
35
+ */
36
+ paddedLowHex = 7,
37
+ /**
38
+ * Padded hexadecimal string representation of the high bits of the tracing id.
39
+ */
40
+ paddedHighHex = 8
41
+ }
42
+ /**
43
+ * A {@link TracingIdentifier} used for Traces (128 bit).
44
+ */
45
+ export type TraceId = TracingIdentifier & {
46
+ _brand: 'traceId';
47
+ };
48
+ /**
49
+ * A {@link TracingIdentifier} used for Spans (64 bit).
50
+ */
51
+ export type SpanId = TracingIdentifier & {
52
+ _brand: 'spanId';
53
+ };
54
+ /**
55
+ * The tracing identifier type.
56
+ */
57
+ export declare enum TracingIdType {
58
+ /**
59
+ * 128-bit UUID.
60
+ */
61
+ trace = 0,
62
+ /**
63
+ * 64-bit UUID.
64
+ */
65
+ span = 1
66
+ }
67
+ /**
68
+ * A {@link TracingIdentifier} is a unique UUID that can be 64bit or 128bit, and provides
69
+ * convenient methods to represent it as a HEX or DECIMAL string, and it allows the masking
70
+ * of its low or high bits.
71
+ *
72
+ * Create a new identifier by calling {@link TracingIdentifier.createTraceId()} or
73
+ * {@link TracingIdentifier.createSpanId()}.
74
+ */
75
+ export declare class TracingIdentifier {
76
+ /**
77
+ * Read-only generated ID as a {@link bigint}.
78
+ */
79
+ readonly id: bigint;
80
+ /**
81
+ * Read-only type to determine whether the identifier is a {@link TraceId} or a {@link SpanId}.
82
+ */
83
+ readonly type: TracingIdType;
84
+ /**
85
+ * Creates a new unique Trace ID.
86
+ * @returns the generated {@link TraceId}.
87
+ */
88
+ static createTraceId(): TraceId;
89
+ /**
90
+ * Creates a new unique Span ID.
91
+ * @returns the generated {@link SpanId}.
92
+ */
93
+ static createSpanId(): SpanId;
94
+ /**
95
+ * Private constructor to initialize the {@link TracingIdentifier} based on the given
96
+ * {@link TracingIdType}.
97
+ */
98
+ private constructor();
99
+ /**
100
+ * Generates a unique ID with the given format.
101
+ * @param format - the desired format (64bit or 128bit).
102
+ * @returns the generated UUID as a {@link bigint}.
103
+ */
104
+ private generateUUID;
105
+ /**
106
+ * Returns a string representation of the Tracing ID.
107
+ * @param format - The type of representation to use.
108
+ * @returns The ID as a string in the specified representation type.
109
+ */
110
+ toString(format: TracingIdFormat): string;
111
+ }
@@ -1,5 +1,6 @@
1
1
  import type { PropagatorType } from '../../../types';
2
2
  import type { RegexMap } from '../requestProxy/interfaces/RequestProxy';
3
+ import type { SpanId, TraceId } from './TracingIdentifier';
3
4
  import type { Hostname } from './firstPartyHosts';
4
5
  export type DdRumResourceTracingAttributes = {
5
6
  tracingStrategy: 'KEEP';
@@ -19,27 +20,3 @@ export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap,
19
20
  firstPartyHostsRegexMap: RegexMap;
20
21
  tracingSamplingRate: number;
21
22
  }) => DdRumResourceTracingAttributes;
22
- /**
23
- * Using branded types will ensure we don't accidentally use
24
- * traceId for spanId when generating headers.
25
- */
26
- export type TraceId = TraceIdentifier & {
27
- _brand: 'traceId';
28
- };
29
- export type SpanId = TraceIdentifier & {
30
- _brand: 'spanId';
31
- };
32
- export declare class TraceIdentifier {
33
- private low;
34
- private high;
35
- constructor();
36
- toString: (radix: number) => string;
37
- /**
38
- * This function pads the trace with `0`.
39
- * It should not be used with a `length` lower than the trace, as we return the full trace in this case.
40
- * @param radix radix for the trace
41
- * @param length minimum length
42
- * @returns padded string
43
- */
44
- toPaddedString: (radix: number, length: number) => string;
45
- }
@@ -7,6 +7,8 @@ export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
7
7
  export declare const ORIGIN_RUM = "rum";
8
8
  export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
9
9
  export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
10
+ export declare const TAGS_HEADER_KEY = "x-datadog-tags";
11
+ export declare const DD_TRACE_ID_TAG = "_dd.p.tid";
10
12
  /**
11
13
  * OTel headers
12
14
  */
@@ -0,0 +1 @@
1
+ export declare const validateContext: (context: any) => any;
@@ -1 +1 @@
1
- export declare const version = "2.3.5";
1
+ export declare const version = "2.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "2.3.5",
3
+ "version": "2.4.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -97,5 +97,5 @@
97
97
  "javaPackageName": "com.datadog.reactnative"
98
98
  }
99
99
  },
100
- "gitHead": "d80e122e5f06e6d126f9e271f641b3cec9e21832"
100
+ "gitHead": "3717f76f94bb68f6d871f84e38db5ba606eb7b06"
101
101
  }
@@ -47,6 +47,7 @@ export class DdSdkReactNative {
47
47
  private static readonly DD_SDK_VERSION = '_dd.sdk_version';
48
48
  private static readonly DD_VERSION = '_dd.version';
49
49
  private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';
50
+
50
51
  private static wasAutoInstrumented = false;
51
52
  private static features?: AutoInstrumentationConfiguration;
52
53
  private static _isInitialized = false;
@@ -299,9 +300,11 @@ export class DdSdkReactNative {
299
300
  );
300
301
  return;
301
302
  }
303
+
302
304
  if (configuration.trackInteractions) {
303
305
  DdRumUserInteractionTracking.startTracking({
304
- actionNameAttribute: configuration.actionNameAttribute
306
+ actionNameAttribute: configuration.actionNameAttribute,
307
+ useAccessibilityLabel: configuration.useAccessibilityLabel
305
308
  });
306
309
  }
307
310
 
@@ -115,7 +115,8 @@ export const DEFAULTS = {
115
115
  trackBackgroundEvents: false,
116
116
  getCustomEndpoints: () => ({}),
117
117
  bundleLogsWithRum: true,
118
- bundleLogsWithTraces: true
118
+ bundleLogsWithTraces: true,
119
+ useAccessibilityLabel: true
119
120
  };
120
121
 
121
122
  /**
@@ -303,7 +304,8 @@ export class DdSdkReactNativeConfiguration {
303
304
  readonly trackInteractions: boolean = false,
304
305
  readonly trackResources: boolean = false,
305
306
  readonly trackErrors: boolean = false,
306
- readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent
307
+ readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent,
308
+ readonly useAccessibilityLabel: boolean = DEFAULTS.useAccessibilityLabel
307
309
  ) {}
308
310
  }
309
311
 
@@ -321,6 +323,7 @@ export type AutoInstrumentationConfiguration = {
321
323
  readonly errorEventMapper?: ErrorEventMapper | null;
322
324
  readonly resourceEventMapper?: ResourceEventMapper | null;
323
325
  readonly actionEventMapper?: ActionEventMapper | null;
326
+ readonly useAccessibilityLabel?: boolean;
324
327
  readonly actionNameAttribute?: string;
325
328
  };
326
329
 
@@ -337,6 +340,7 @@ export type AutoInstrumentationParameters = {
337
340
  readonly errorEventMapper: ErrorEventMapper | null;
338
341
  readonly resourceEventMapper: ResourceEventMapper | null;
339
342
  readonly actionEventMapper: ActionEventMapper | null;
343
+ readonly useAccessibilityLabel: boolean;
340
344
  readonly actionNameAttribute?: string;
341
345
  };
342
346
 
@@ -370,7 +374,8 @@ export const addDefaultValuesToAutoInstrumentationConfiguration = (
370
374
  actionEventMapper:
371
375
  features.actionEventMapper === undefined
372
376
  ? DEFAULTS.actionEventMapper
373
- : features.actionEventMapper
377
+ : features.actionEventMapper,
378
+ useAccessibilityLabel: DEFAULTS.useAccessibilityLabel
374
379
  };
375
380
  };
376
381
 
@@ -434,7 +439,8 @@ export const buildConfigurationFromPartialConfiguration = (
434
439
  features.trackInteractions,
435
440
  features.trackResources,
436
441
  features.trackErrors,
437
- configuration.trackingConsent
442
+ configuration.trackingConsent,
443
+ features.useAccessibilityLabel
438
444
  );
439
445
 
440
446
  (Object.keys(