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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/README.md +18 -14
  3. package/android/build.gradle +28 -3
  4. package/android/detekt.yml +572 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +12 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +15 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +143 -8
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +25 -1
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +31 -1
  10. package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +41 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +7 -2
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +429 -27
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +5 -1
  14. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +40 -1
  15. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +21 -1
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +1 -1
  17. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +1 -0
  18. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +22 -2
  19. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +2 -3
  20. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +94 -0
  21. package/datadog-sourcemaps.gradle +85 -28
  22. package/ios/Sources/Attributes.swift +0 -4
  23. package/ios/Sources/DdSdk.m +10 -0
  24. package/ios/Sources/DdSdk.swift +113 -10
  25. package/ios/Sources/DdSdkConfiguration.swift +38 -1
  26. package/ios/Sources/JSRefreshRateListener.swift +86 -0
  27. package/ios/Sources/QueueHolder.swift +7 -0
  28. package/ios/Sources/RNDdSdkConfiguration.swift +25 -1
  29. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
  30. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  31. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
  32. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  33. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
  34. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  35. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
  36. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  37. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
  38. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  39. package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
  40. package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
  41. package/lib/commonjs/DdSdkReactNative.js +140 -59
  42. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  43. package/lib/commonjs/DdSdkReactNativeConfiguration.js +166 -9
  44. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  45. package/lib/commonjs/errorUtils.js +69 -0
  46. package/lib/commonjs/errorUtils.js.map +1 -0
  47. package/lib/commonjs/foundation.js +19 -12
  48. package/lib/commonjs/foundation.js.map +1 -1
  49. package/lib/commonjs/index.js +20 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/longTasksUtils.js +40 -0
  52. package/lib/commonjs/longTasksUtils.js.map +1 -0
  53. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  54. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
  55. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  56. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
  57. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  58. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
  59. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  63. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  64. package/lib/commonjs/types.js +6 -1
  65. package/lib/commonjs/types.js.map +1 -1
  66. package/lib/commonjs/version.js +1 -1
  67. package/lib/commonjs/version.js.map +1 -1
  68. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
  69. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  70. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
  71. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  72. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
  73. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  74. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
  75. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  76. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
  77. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  78. package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
  79. package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
  80. package/lib/module/DdSdkReactNative.js +132 -57
  81. package/lib/module/DdSdkReactNative.js.map +1 -1
  82. package/lib/module/DdSdkReactNativeConfiguration.js +154 -8
  83. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  84. package/lib/module/errorUtils.js +54 -0
  85. package/lib/module/errorUtils.js.map +1 -0
  86. package/lib/module/foundation.js +18 -12
  87. package/lib/module/foundation.js.map +1 -1
  88. package/lib/module/index.js +3 -2
  89. package/lib/module/index.js.map +1 -1
  90. package/lib/module/longTasksUtils.js +31 -0
  91. package/lib/module/longTasksUtils.js.map +1 -0
  92. package/lib/module/nativeModulesTypes.js.map +1 -1
  93. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
  94. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  95. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
  96. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  97. package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
  98. package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
  99. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  100. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  101. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  102. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  103. package/lib/module/types.js +6 -1
  104. package/lib/module/types.js.map +1 -1
  105. package/lib/module/version.js +1 -1
  106. package/lib/module/version.js.map +1 -1
  107. package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  108. package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  109. package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  110. package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  111. package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  112. package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
  113. package/lib/typescript/DdSdkReactNative.d.ts +18 -3
  114. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +114 -0
  115. package/lib/typescript/errorUtils.d.ts +12 -0
  116. package/lib/typescript/index.d.ts +3 -2
  117. package/lib/typescript/longTasksUtils.d.ts +6 -0
  118. package/lib/typescript/nativeModulesTypes.d.ts +12 -0
  119. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
  120. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
  121. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +1 -0
  122. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +1 -1
  123. package/lib/typescript/types.d.ts +16 -1
  124. package/lib/typescript/version.d.ts +1 -1
  125. package/package.json +3 -2
  126. package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
  127. package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
  128. package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
  129. package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
  130. package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
  131. package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
  132. package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
  133. package/src/DatadogProvider/DatadogProvider.tsx +122 -0
  134. package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
  135. package/src/DatadogProvider/__tests__/initialization.test.tsx +182 -0
  136. package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
  137. package/src/DdSdkReactNative.tsx +206 -109
  138. package/src/DdSdkReactNativeConfiguration.tsx +225 -8
  139. package/src/__tests__/DdRumWrapper.test.tsx +3 -27
  140. package/src/__tests__/DdSdkReactNative.test.tsx +57 -13
  141. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +181 -0
  142. package/src/__tests__/foundation.test.ts +11 -2
  143. package/src/__tests__/longTasksUtils.ts +23 -0
  144. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
  145. package/src/errorUtils.ts +58 -0
  146. package/src/foundation.tsx +15 -12
  147. package/src/index.tsx +9 -1
  148. package/src/longTasksUtils.ts +30 -0
  149. package/src/nativeModulesTypes.ts +14 -0
  150. package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
  151. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
  152. package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
  153. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
  154. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +3 -1
  155. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +1 -1
  156. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +2 -1
  157. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
  158. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +12 -47
  159. package/src/types.tsx +11 -1
  160. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
1
+ {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
@@ -9,18 +9,17 @@ var _InternalLog = require("../../InternalLog");
9
9
 
10
10
  var _SdkVerbosity = require("../../SdkVerbosity");
11
11
 
12
+ var _errorUtils = require("../../errorUtils");
13
+
12
14
  var _foundation = require("../../foundation");
13
15
 
14
16
  var _types = require("../../types");
15
17
 
16
18
  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; }
17
19
 
18
- const EMPTY_MESSAGE = 'Unknown Error';
19
- const EMPTY_STACK_TRACE = '';
20
20
  /**
21
21
  * Provides RUM auto-instrumentation feature to track errors as RUM events.
22
22
  */
23
-
24
23
  class DdRumErrorTracking {
25
24
  // eslint-disable-next-line
26
25
  // eslint-disable-next-line
@@ -51,8 +50,8 @@ class DdRumErrorTracking {
51
50
 
52
51
 
53
52
  static onGlobalError(error, isFatal) {
54
- const message = DdRumErrorTracking.getErrorMessage(error);
55
- const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
53
+ const message = (0, _errorUtils.getErrorMessage)(error);
54
+ const stacktrace = (0, _errorUtils.getErrorStackTrace)(error);
56
55
 
57
56
  _foundation.DdRum.addError(message, _types.ErrorSource.SOURCE, stacktrace, {
58
57
  '_dd.error.is_crash': isFatal,
@@ -73,13 +72,13 @@ class DdRumErrorTracking {
73
72
  return;
74
73
  }
75
74
 
76
- let stack = EMPTY_STACK_TRACE;
75
+ let stack = _errorUtils.EMPTY_STACK_TRACE;
77
76
 
78
77
  for (let i = 0; i < params.length; i += 1) {
79
78
  const param = params[i];
80
- const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
79
+ const paramStack = (0, _errorUtils.getErrorStackTrace)(param);
81
80
 
82
- if (paramStack !== EMPTY_STACK_TRACE) {
81
+ if (paramStack !== _errorUtils.EMPTY_STACK_TRACE) {
83
82
  stack = paramStack;
84
83
  break;
85
84
  }
@@ -89,7 +88,7 @@ class DdRumErrorTracking {
89
88
  if (typeof param === 'string') {
90
89
  return param;
91
90
  } else {
92
- return DdRumErrorTracking.getErrorMessage(param);
91
+ return (0, _errorUtils.getErrorMessage)(param);
93
92
  }
94
93
  }).join(' ');
95
94
 
@@ -98,42 +97,6 @@ class DdRumErrorTracking {
98
97
  });
99
98
  }
100
99
 
101
- static getErrorMessage(error) {
102
- let message = EMPTY_MESSAGE;
103
-
104
- if (error === undefined || error === null) {
105
- message = EMPTY_MESSAGE;
106
- } else if (typeof error === 'object' && 'message' in error) {
107
- message = String(error.message);
108
- } else {
109
- message = String(error);
110
- }
111
-
112
- return message;
113
- }
114
-
115
- static getErrorStackTrace(error) {
116
- let stack = EMPTY_STACK_TRACE;
117
-
118
- if (error === undefined || error === null) {
119
- stack = EMPTY_STACK_TRACE;
120
- } else if (typeof error === 'string') {
121
- stack = EMPTY_STACK_TRACE;
122
- } else if (typeof error === 'object') {
123
- if ('componentStack' in error) {
124
- stack = String(error.componentStack);
125
- } else if ('stacktrace' in error) {
126
- stack = String(error.stacktrace);
127
- } else if ('stack' in error) {
128
- stack = String(error.stack);
129
- } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
130
- stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
131
- }
132
- }
133
-
134
- return stack;
135
- }
136
-
137
100
  }
138
101
 
139
102
  exports.DdRumErrorTracking = DdRumErrorTracking;
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AAEA;AACA;AACA;;AACO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAA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ensed 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 { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","stacktrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","EMPTY_STACK_TRACE","i","length","param","paramStack","map","join","CONSOLE","apply","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AAKA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAT,MAAAA,kBAAkB,CAACU,mBAAnB,GAAyCC,OAAO,CAACC,KAAjD;AAEAL,MAAAA,UAAU,CAACM,gBAAX,CAA4Bb,kBAAkB,CAACc,aAA/C;AACAH,MAAAA,OAAO,CAACC,KAAR,GAAgBZ,kBAAkB,CAACe,cAAnC;AAEAf,MAAAA,kBAAkB,CAACE,UAAnB,GAAgC,IAAhC;;AACAC,+BAAYC,GAAZ,CACI,gCADJ,EAEIC,2BAAaW,IAFjB;AAIH,KAZD,MAYO;AACHb,+BAAYC,GAAZ,CACI,4DADJ,EAEIC,2BAAaY,KAFjB;AAIH;AACJ,GA1C2B,CA4C5B;;;AACoB,SAAbH,aAAa,CAACF,KAAD,EAAaM,OAAb,EAAsC;AACtD,UAAMC,OAAO,GAAG,iCAAgBP,KAAhB,CAAhB;AACA,UAAMQ,UAAU,GAAG,oCAAmBR,KAAnB,CAAnB;;AACAS,sBAAMC,QAAN,CAAeH,OAAf,EAAwBI,mBAAYC,MAApC,EAA4CJ,UAA5C,EAAwD;AACpD,4BAAsBF,OAD8B;AAEpD,uBAAiBN;AAFmC,KAAxD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AAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1FvC,kB,yBAS4B,CAAC,GAAGwC,OAAJ,KAA2B,CAAG,C","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 { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport {\n getErrorMessage,\n getErrorStackTrace,\n EMPTY_STACK_TRACE\n} from '../../errorUtils';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n}\n"]}
@@ -11,6 +11,10 @@ var _InternalLog = require("../../InternalLog");
11
11
 
12
12
  var _SdkVerbosity = require("../../SdkVerbosity");
13
13
 
14
+ var _errorUtils = require("../../errorUtils");
15
+
16
+ var _foundation = require("../../foundation");
17
+
14
18
  var _DdEventsInterceptor = require("./DdEventsInterceptor");
15
19
 
16
20
  var _NoOpEventsInterceptor = _interopRequireDefault(require("./NoOpEventsInterceptor"));
@@ -55,7 +59,8 @@ class DdRumUserInteractionTracking {
55
59
  jsxRuntime.jsx = (...args) => {
56
60
  return this.patchCreateElementFunction(originaljsx, args);
57
61
  };
58
- } catch (e) {// TODO: Add telemetry
62
+ } catch (e) {
63
+ _foundation.DdSdk.telemetryDebug((0, _errorUtils.getErrorMessage)(e));
59
64
  }
60
65
 
61
66
  const originalMemo = _react.default.memo;
@@ -91,6 +96,12 @@ class DdRumUserInteractionTracking {
91
96
  _InternalLog.InternalLog.log('Datadog SDK is tracking interactions', _SdkVerbosity.SdkVerbosity.INFO);
92
97
  }
93
98
 
99
+ static stopTracking() {
100
+ _react.default.createElement = this.originalCreateElement;
101
+ _react.default.memo = this.originalMemo;
102
+ DdRumUserInteractionTracking.isTracking = false;
103
+ }
104
+
94
105
  }
95
106
 
96
107
  exports.DdRumUserInteractionTracking = DdRumUserInteractionTracking;
@@ -99,6 +110,10 @@ _defineProperty(DdRumUserInteractionTracking, "isTracking", false);
99
110
 
100
111
  _defineProperty(DdRumUserInteractionTracking, "eventsInterceptor", new _NoOpEventsInterceptor.default());
101
112
 
113
+ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", _react.default.createElement);
114
+
115
+ _defineProperty(DdRumUserInteractionTracking, "originalMemo", _react.default.memo);
116
+
102
117
  _defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
103
118
  if (props && typeof props.onPress === 'function') {
104
119
  const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["DdRumUserInteractionTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","eventsInterceptor","DdEventsInterceptor","original","React","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","NoOpEventsInterceptor","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAmC;AA6BtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,4BAA4B,CAACE,UAAjC,EAA6C;AACzCC,+BAAYC,GAAZ,CACI,8CADJ,EAEI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AA,OAAO,EAAED,IAAI,CAACK;AAFA,SAAlB,CAd2C,CAmB3C;;AACA,eAAOP,aAAa,GACdA,aAAa,CAACM,SAAD,EAAYI,SAAZ,CADC,GAEd,yDAAsBA,SAAtB,EAAiCJ,SAAjC,CAFN;AAGH,OAvBkB,CAAnB;AAwBH,KA5BD;;AA8BA3B,IAAAA,4BAA4B,CAACE,UAA7B,GAA0C,IAA1C;;AACAC,6BAAYC,GAAZ,CACI,sCADJ,EAEIC,2BAAa2B,IAFjB;AAIH;;AApGqC;;;;gBAA7BhC,4B,gBACmB,K;;gBADnBA,4B,uBAE6C,IAAIiC,8BAAJ,E;;gBAF7CjC,4B,gCAImC,CACxCkC,gBADwC,EAExC,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAFwC,KAGC;AACzC,MACID,KAAK,IACL,OAAQA,KAAD,CAAmCZ,OAA1C,KAAsD,UAF1D,EAGE;AACE,UAAMc,eAAe,GAAIF,KAAD,EAAmC;AACtDZ,IAAAA,OADL;;AAECY,IAAAA,KAAD,CAAmCZ,OAAnC,GAA6C,CAAC,GAAGZ,IAAJ,KAAoB;AAC7DZ,MAAAA,4BAA4B,CAACO,iBAA7B,CAA+CgC,gBAA/C,CACI,GAAG3B,IADP;AAGA,aAAO0B,eAAe,CAAC,GAAG1B,IAAJ,CAAtB;AACH,KALD,CAHF,CASE;;;AACCwB,IAAAA,KAAD,CAGGR,sCAHH,GAG4CU,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,C","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 React from 'react';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n // TODO: Add telemetry\n }\n\n const originalMemo = React.memo;\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["DdRumUserInteractionTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","eventsInterceptor","DdEventsInterceptor","original","React","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","DdSdk","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","NoOpEventsInterceptor","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAmC;AA+BtC;AACJ;AACA;AACA;AAC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KALD,CAHF,CASE;;;AACC4B,IAAAA,KAAD,CAGGV,sCAHH,GAG4CY,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,C","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 React from 'react';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { getErrorMessage } from '../../errorUtils';\nimport { DdSdk } from '../../foundation';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n }\n}\n"]}
@@ -32,7 +32,7 @@ const getJsxRuntime = () => {
32
32
  const jsxRuntime = require('react/jsx-runtime');
33
33
 
34
34
  if (!jsxRuntime.jsx) {
35
- throw new Error('React version does not support new jsx transform');
35
+ throw new Error('React jsx runtime does not export new jsx transform');
36
36
  }
37
37
 
38
38
  return jsxRuntime;
@@ -1 +1 @@
1
- {"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntime","jsx","Number"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAMC,UAAU,GAAGL,OAAO,CAAC,mBAAD,CAA1B;;AACA,MAAI,CAACK,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIF,KAAJ,CAAU,kDAAV,CAAN;AACH;;AACD,SAAOC,UAAP;AACH,CAvBM;AAyBP;AACA;AACA;;;;;AACA,MAAMF,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIQ,MAAM,CAACT,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIS,MAAM,CAACT,KAAD,CAAN,KAAkB,EAAlB,IAAwBS,MAAM,CAACR,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before requiring 'react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // /!\\/!\\/!\\/!\\/!\\/!\\\n // We have to use inline require here because older React versions (below 16.14) don't have jsx-runtime.\n // metro does not support dynamic require, so 'react/jsx-runtime' is replaced by 'react' on postinstall\n // when react is equal or above 16.14 to avoid this require call to fail during the import phase and then\n // disable all further imports.\n // /!\\/!\\/!\\/!\\/!\\/!\\\n //\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsxRuntime = require('react/jsx-runtime');\n if (!jsxRuntime.jsx) {\n throw new Error('React version does not support new jsx transform');\n }\n return jsxRuntime;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
1
+ {"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntime","jsx","Number"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAMC,UAAU,GAAGL,OAAO,CAAC,mBAAD,CAA1B;;AACA,MAAI,CAACK,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIF,KAAJ,CAAU,qDAAV,CAAN;AACH;;AACD,SAAOC,UAAP;AACH,CAvBM;AAyBP;AACA;AACA;;;;;AACA,MAAMF,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIQ,MAAM,CAACT,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIS,MAAM,CAACT,KAAD,CAAN,KAAkB,EAAlB,IAAwBS,MAAM,CAACR,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before requiring 'react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // /!\\/!\\/!\\/!\\/!\\/!\\\n // We have to use inline require here because older React versions (below 16.14) don't have jsx-runtime.\n // metro does not support dynamic require, so 'react/jsx-runtime' is replaced by 'react' on postinstall\n // when react is equal or above 16.14 to avoid this require call to fail during the import phase and then\n // disable all further imports.\n // /!\\/!\\/!\\/!\\/!\\/!\\\n //\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsxRuntime = require('react/jsx-runtime');\n if (!jsxRuntime.jsx) {\n throw new Error('React jsx runtime does not export new jsx transform');\n }\n return jsxRuntime;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
@@ -42,7 +42,8 @@ const generateTracingAttributesWithSampling = tracingSamplingRate => {
42
42
  traceId: generateTraceId(),
43
43
  spanId: generateTraceId(),
44
44
  samplingPriorityHeader: '1',
45
- tracingStrategy: 'KEEP'
45
+ tracingStrategy: 'KEEP',
46
+ rulePsr: tracingSamplingRate / 100
46
47
  };
47
48
  }
48
49
 
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegex","tracingSamplingRate","generateTracingAttributesWithSampling","Math","random","traceId","generateTraceId","spanId","radix","MAX_32_BITS_NUMBER","low","floor","high","str","modH","temp","digit","toString"],"mappings":";;;;;;;;AAOA;;AAPA;AACA;AACA;AACA;AACA;AAmBA,MAAMA,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;;AAKO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,oBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,MAAI,uCAAiBI,QAAjB,EAA2BC,oBAA3B,CAAJ,EAAsD;AAClD,WAAOE,qCAAqC,CAACD,mBAAD,CAA5C;AACH;;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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 { Hostname } from './firstPartyHosts';\nimport { isHostFirstParty } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: string;\n spanId: string;\n samplingPriorityHeader: '1';\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegex: RegExp;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n if (isHostFirstParty(hostname, firstPartyHostsRegex)) {\n return generateTracingAttributesWithSampling(tracingSamplingRate);\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number\n): DdRumResourceTracingAttributes => {\n if (Math.random() * 100 <= tracingSamplingRate) {\n return {\n traceId: generateTraceId(),\n spanId: generateTraceId(),\n samplingPriorityHeader: '1',\n tracingStrategy: 'KEEP'\n };\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\nexport function generateTraceId(): string {\n const radix = 10;\n const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let str = '';\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix;\n const temp = (modH << 32) + low;\n const digit = temp % radix;\n\n // update the high value\n high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str;\n }\n return str;\n}\n"]}
1
+ {"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegex","tracingSamplingRate","generateTracingAttributesWithSampling","Math","random","traceId","generateTraceId","spanId","rulePsr","radix","MAX_32_BITS_NUMBER","low","floor","high","str","modH","temp","digit","toString"],"mappings":";;;;;;;;AAOA;;AAPA;AACA;AACA;AACA;AACA;AAoBA,MAAMA,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;;AAKO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,oBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,MAAI,uCAAiBI,QAAjB,EAA2BC,oBAA3B,CAAJ,EAAsD;AAClD,WAAOE,qCAAqC,CAACD,mBAAD,CAA5C;AACH;;AACD,SAAON,0BAAP;AACH,CAhBM;;;;AAkBP,MAAMO,qCAAqC,GACvCD,mBAD0C,IAET;AACjC,MAAIE,IAAI,CAACC,MAAL,KAAgB,GAAhB,IAAuBH,mBAA3B,EAAgD;AAC5C,WAAO;AACHI,MAAAA,OAAO,EAAEC,eAAe,EADrB;AAEHC,MAAAA,MAAM,EAAED,eAAe,EAFpB;AAGHV,MAAAA,sBAAsB,EAAE,GAHrB;AAIHC,MAAAA,eAAe,EAAE,MAJd;AAKHW,MAAAA,OAAO,EAAEP,mBAAmB,GAAG;AAL5B,KAAP;AAOH;;AACD,SAAON,0BAAP;AACH,CAbD;AAeA;AACA;AACA;;;AACO,SAASW,eAAT,GAAmC;AACtC,QAAMG,KAAK,GAAG,EAAd;AACA,QAAMC,kBAAkB,GAAG,UAA3B,CAFsC,CAEC;;AACvC,MAAIC,GAAW,GAAGR,IAAI,CAACS,KAAL,CAAWT,IAAI,CAACC,MAAL,KAAgBM,kBAA3B,CAAlB;AACA,MAAIG,IAAY,GAAGV,IAAI,CAACS,KAAL,CAAWT,IAAI,CAACC,MAAL,KAAgBM,kBAA3B,CAAnB;AACA,MAAII,GAAG,GAAG,EAAV;;AAEA,SAAOD,IAAI,GAAG,CAAP,IAAYF,GAAG,GAAG,CAAzB,EAA4B;AACxB;AACA;AACA,UAAMI,IAAI,GAAGF,IAAI,GAAGJ,KAApB;AACA,UAAMO,IAAI,GAAG,CAACD,IAAI,IAAI,EAAT,IAAeJ,GAA5B;AACA,UAAMM,KAAK,GAAGD,IAAI,GAAGP,KAArB,CALwB,CAOxB;;AACAI,IAAAA,IAAI,GAAG,CAACA,IAAI,GAAGE,IAAR,IAAgBN,KAAvB,CARwB,CAQM;AAC9B;;AACAE,IAAAA,GAAG,GAAG,CAACK,IAAI,GAAGC,KAAR,IAAiBR,KAAvB,CAVwB,CAUM;AAE9B;;AACAK,IAAAA,GAAG,GAAGG,KAAK,CAACC,QAAN,KAAmBJ,GAAzB;AACH;;AACD,SAAOA,GAAP;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 type { Hostname } from './firstPartyHosts';\nimport { isHostFirstParty } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: string;\n spanId: string;\n samplingPriorityHeader: '1';\n rulePsr: number;\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegex: RegExp;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n if (isHostFirstParty(hostname, firstPartyHostsRegex)) {\n return generateTracingAttributesWithSampling(tracingSamplingRate);\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number\n): DdRumResourceTracingAttributes => {\n if (Math.random() * 100 <= tracingSamplingRate) {\n return {\n traceId: generateTraceId(),\n spanId: generateTraceId(),\n samplingPriorityHeader: '1',\n tracingStrategy: 'KEEP',\n rulePsr: tracingSamplingRate / 100\n };\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\nexport function generateTraceId(): string {\n const radix = 10;\n const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let str = '';\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix;\n const temp = (modH << 32) + low;\n const digit = temp % radix;\n\n // update the high value\n high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str;\n }\n return str;\n}\n"]}
@@ -39,7 +39,8 @@ exports.ResourceReporter = ResourceReporter;
39
39
  const formatResourceStartContext = tracingAttributes => {
40
40
  return tracingAttributes.tracingStrategy === 'DISCARD' ? undefined : {
41
41
  '_dd.span_id': tracingAttributes.spanId,
42
- '_dd.trace_id': tracingAttributes.traceId
42
+ '_dd.trace_id': tracingAttributes.traceId,
43
+ '_dd.rule_psr': tracingAttributes.rulePsr
43
44
  };
44
45
  };
45
46
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ResourceReporter.ts"],"names":["ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","DdRum","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;;;;;;AAMA;;AAGA;;;;AAIO,MAAMA,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,GACM,mCACII,OAAO,CAACE,SADZ,EAEIF,OAAO,CAACC,iBAFZ,EAGID,OAAO,CAACG,QAHZ,CADN,GAMM;AARP,GAAP;AAUH,CAbD;;AAeA,MAAMX,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAMgB,kBAAMC,aAAN,CACFjB,QAAQ,CAACkB,GADP,EAEFlB,QAAQ,CAACmB,OAAT,CAAiBC,MAFf,EAGFpB,QAAQ,CAACmB,OAAT,CAAiBE,GAHf,EAIFhB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACY,OAAT,CAAiBE,SALf,CAAN;;AAQAE,oBAAMM,YAAN,CACItB,QAAQ,CAACkB,GADb,EAEIlB,QAAQ,CAACuB,QAAT,CAAkBC,UAFtB,EAGIxB,QAAQ,CAACmB,OAAT,CAAiBM,IAHrB,EAIIzB,QAAQ,CAACuB,QAAT,CAAkBG,IAJtB,EAKIf,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"]}
1
+ {"version":3,"sources":["ResourceReporter.ts"],"names":["ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","rulePsr","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","DdRum","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;;;;;;AAMA;;AAGA;;;;AAIO,MAAMA,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,OAFtC;AAGI,oBAAgBJ,iBAAiB,CAACK;AAHtC,GAFN;AAOH,CAVD;;AAYA,MAAMC,yBAAyB,GAC3BC,OAD8B,IAEJ;AAC1B,SAAO;AACH,4BACIA,OAAO,CAACC,iBAAR,KAA8BN,SAA9B,GACM,mCACIK,OAAO,CAACE,SADZ,EAEIF,OAAO,CAACC,iBAFZ,EAGID,OAAO,CAACG,QAHZ,CADN,GAMM;AARP,GAAP;AAUH,CAbD;;AAeA,MAAMZ,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAMiB,kBAAMC,aAAN,CACFlB,QAAQ,CAACmB,GADP,EAEFnB,QAAQ,CAACoB,OAAT,CAAiBC,MAFf,EAGFrB,QAAQ,CAACoB,OAAT,CAAiBE,GAHf,EAIFjB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACa,OAAT,CAAiBE,SALf,CAAN;;AAQAE,oBAAMM,YAAN,CACIvB,QAAQ,CAACmB,GADb,EAEInB,QAAQ,CAACwB,QAAT,CAAkBC,UAFtB,EAGIzB,QAAQ,CAACoB,OAAT,CAAiBM,IAHrB,EAII1B,QAAQ,CAACwB,QAAT,CAAkBG,IAJtB,EAKIf,yBAAyB,CAACZ,QAAQ,CAACa,OAAV,CAL7B,EAMIb,QAAQ,CAACa,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 '_dd.rule_psr': tracingAttributes.rulePsr\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"]}
@@ -15,15 +15,20 @@ exports.ErrorSource = exports.RumActionType = exports.DdSdkConfiguration = void
15
15
  * A configuration object to initialize Datadog's features.
16
16
  */
17
17
  class DdSdkConfiguration {
18
- constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig) {
18
+ constructor(clientToken, env, applicationId, nativeCrashReportEnabled, nativeLongTaskThresholdMs, longTaskThresholdMs, sampleRate, site, trackingConsent, additionalConfig, telemetrySampleRate, vitalsUpdateFrequency, configurationForTelemetry) {
19
19
  this.clientToken = clientToken;
20
20
  this.env = env;
21
21
  this.applicationId = applicationId;
22
22
  this.nativeCrashReportEnabled = nativeCrashReportEnabled;
23
+ this.nativeLongTaskThresholdMs = nativeLongTaskThresholdMs;
24
+ this.longTaskThresholdMs = longTaskThresholdMs;
23
25
  this.sampleRate = sampleRate;
24
26
  this.site = site;
25
27
  this.trackingConsent = trackingConsent;
26
28
  this.additionalConfig = additionalConfig;
29
+ this.telemetrySampleRate = telemetrySampleRate;
30
+ this.vitalsUpdateFrequency = vitalsUpdateFrequency;
31
+ this.configurationForTelemetry = configurationForTelemetry;
27
32
  }
28
33
 
29
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig","RumActionType","ErrorSource"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA;;;;;AAqOA;AACA;AACA;IACYC,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","configurationForTelemetry","RumActionType","ErrorSource"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,yBAbF,EAmBT;AAAA,SAlBWZ,WAkBX,GAlBWA,WAkBX;AAAA,SAjBWC,GAiBX,GAjBWA,GAiBX;AAAA,SAhBWC,aAgBX,GAhBWA,aAgBX;AAAA,SAfWC,wBAeX,GAfWA,wBAeX;AAAA,SAdWC,yBAcX,GAdWA,yBAcX;AAAA,SAbWC,mBAaX,GAbWA,mBAaX;AAAA,SAZWC,UAYX,GAZWA,UAYX;AAAA,SAXWC,IAWX,GAXWA,IAWX;AAAA,SAVWC,eAUX,GAVWA,eAUX;AAAA,SATWC,gBASX,GATWA,gBASX;AAAA,SARWC,mBAQX,GARWA,mBAQX;AAAA,SAPWC,qBAOX,GAPWA,qBAOX;AAAA,SANWC,yBAMX,GANWA,yBAMX;AAAE;;AApBwB;AAuBhC;AACA;AACA;;;;;AAqOA;AACA;AACA;IACYC,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '1.1.5';
8
+ const version = '1.2.0-beta2';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.1.5';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,aAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.2.0-beta2';\n"]}