@datadog/mobile-react-native 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/android/build.gradle +58 -64
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +36 -2
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +14 -0
  5. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +162 -16
  6. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +7 -0
  7. package/ios/Sources/DdSdk.swift +2 -2
  8. package/ios/Sources/RNDdSdkConfiguration.swift +42 -0
  9. package/lib/commonjs/DdSdkReactNative.js +2 -2
  10. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  11. package/lib/commonjs/DdSdkReactNativeConfiguration.js +26 -1
  12. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  13. package/lib/commonjs/index.js +12 -0
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
  16. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  17. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +1 -1
  18. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  19. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +59 -41
  20. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  21. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js +136 -0
  22. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js.map +1 -0
  23. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +39 -6
  24. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
  25. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -1
  26. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +3 -3
  27. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  28. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +12 -21
  29. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
  30. package/lib/commonjs/rum/types.js +19 -1
  31. package/lib/commonjs/rum/types.js.map +1 -1
  32. package/lib/commonjs/version.js +1 -1
  33. package/lib/commonjs/version.js.map +1 -1
  34. package/lib/module/DdSdkReactNative.js +3 -3
  35. package/lib/module/DdSdkReactNative.js.map +1 -1
  36. package/lib/module/DdSdkReactNativeConfiguration.js +22 -0
  37. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  38. package/lib/module/index.js +3 -3
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
  41. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  42. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +2 -2
  43. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  44. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +57 -35
  45. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  46. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js +115 -0
  47. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js.map +1 -0
  48. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +37 -3
  49. package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
  50. package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -1
  51. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +3 -3
  52. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  53. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +10 -15
  54. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
  55. package/lib/module/rum/types.js +16 -0
  56. package/lib/module/rum/types.js.map +1 -1
  57. package/lib/module/version.js +1 -1
  58. package/lib/module/version.js.map +1 -1
  59. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +11 -3
  60. package/lib/typescript/index.d.ts +3 -3
  61. package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +0 -1
  62. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +1 -0
  63. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +2 -1
  64. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +32 -6
  65. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.d.ts +21 -0
  66. package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +4 -2
  67. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +6 -1
  68. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +0 -1
  69. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +0 -6
  70. package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +0 -1
  71. package/lib/typescript/rum/types.d.ts +17 -0
  72. package/lib/typescript/version.d.ts +1 -1
  73. package/package.json +2 -2
  74. package/src/DdSdkReactNative.tsx +8 -4
  75. package/src/DdSdkReactNativeConfiguration.tsx +36 -3
  76. package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
  77. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -6
  78. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -1
  79. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +130 -114
  80. package/src/index.tsx +6 -3
  81. package/src/rum/__tests__/DdRum.test.ts +17 -1
  82. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +8 -0
  83. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +6 -3
  84. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +15 -3
  85. package/src/rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts +64 -24
  86. package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +19 -7
  87. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +82 -40
  88. package/src/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.ts +141 -0
  89. package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +43 -7
  90. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +8 -1
  91. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +4 -4
  92. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -1
  93. package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +8 -23
  94. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +257 -74
  95. package/src/rum/types.ts +19 -0
  96. package/src/sdk/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +2 -1
  97. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -4
  98. package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +6 -2
  99. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","initializationType","trackNetworkRequests","INFO","BufferSingleton","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;;;;;;AAMA;;AAEA;;AAaA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;AAEA;AACA;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AAA,gBAAgB,CAAC3E,gBAAgB,CAACwG,qBAAlB,CAAhB,GACIb,WAAW,CAACO,QADhB;AAEAvB,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACyG,qBAAlB,CAAhB,GACId,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIjG,aAAa,CAACwG,WAAlB,EAA+B;AAC3BxG,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC2G,eAAhD,IACIzG,aAAa,CAACwG,WADlB;AAEH;;AAED,MAAIxG,aAAa,CAAC0G,OAAlB,EAA2B;AACvB1G,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC6G,UAAhD,IAA+D,GAC3D3G,aAAa,CAAC0G,OACjB,GACG1G,aAAa,CAAC4G,aAAd,GACO,IAAG5G,aAAa,CAAC4G,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI5G,aAAa,CAAC4G,aAAd,IAA+B,CAAC5G,aAAa,CAAC0G,OAAlD,EAA2D;AACvD1G,IAAAA,aAAa,CAACyE,gBAAd,CACI3E,gBAAgB,CAAC+G,iBADrB,IAEK,IAAG7G,aAAa,CAAC4G,aAAc,EAFpC;AAGH;;AAED5G,EAAAA,aAAa,CAACyE,gBAAd,CAA+B,uBAA/B,IACIzE,aAAa,CAACwC,eADlB;AAEH,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 { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\n ) => {\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","initializationType","trackNetworkRequests","INFO","BufferSingleton","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;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QAAAA,OAAO,CAACC,IAAR,CACI,iEADJ;AAGH,OAJD,MAIO;AACH5B,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACwG,qBAAlB,CAAhB,GACIb,WAAW,CAACO,QADhB;AAEAvB,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACyG,qBAAlB,CAAhB,GACId,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIjG,aAAa,CAACwG,WAAlB,EAA+B;AAC3BxG,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC2G,eAAhD,IACIzG,aAAa,CAACwG,WADlB;AAEH;;AAED,MAAIxG,aAAa,CAAC0G,OAAlB,EAA2B;AACvB1G,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC6G,UAAhD,IAA+D,GAC3D3G,aAAa,CAAC0G,OACjB,GACG1G,aAAa,CAAC4G,aAAd,GACO,IAAG5G,aAAa,CAAC4G,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI5G,aAAa,CAAC4G,aAAd,IAA+B,CAAC5G,aAAa,CAAC0G,OAAlD,EAA2D;AACvD1G,IAAAA,aAAa,CAACyE,gBAAd,CACI3E,gBAAgB,CAAC+G,iBADrB,IAEK,IAAG7G,aAAa,CAAC4G,aAAc,EAFpC;AAGH;;AAED5G,EAAAA,aAAa,CAACyE,gBAAd,CACI,uBADJ,IAEI,0DAAsBzE,aAAa,CAACwC,eAApC,CAFJ;AAGH,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 { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\n ) => {\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(configuration.firstPartyHosts);\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.VitalsUpdateFrequency = void 0;
6
+ exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.formatFirstPartyHosts = exports.VitalsUpdateFrequency = void 0;
7
7
 
8
8
  var _TrackingConsent = require("./TrackingConsent");
9
9
 
10
+ var _types = require("./rum/types");
11
+
10
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
13
 
12
14
  let VitalsUpdateFrequency;
@@ -19,6 +21,29 @@ exports.VitalsUpdateFrequency = VitalsUpdateFrequency;
19
21
  VitalsUpdateFrequency["NEVER"] = "NEVER";
20
22
  })(VitalsUpdateFrequency || (exports.VitalsUpdateFrequency = VitalsUpdateFrequency = {}));
21
23
 
24
+ const isLegacyFirstPartyHost = firstPartyHost => {
25
+ return typeof firstPartyHost === 'string';
26
+ };
27
+ /**
28
+ * Defaults legacy first party hosts format to Datadog first party hosts to keep
29
+ * retro-compatibility before OTel support was introduced.
30
+ */
31
+
32
+
33
+ const formatFirstPartyHosts = firstPartyHosts => {
34
+ return firstPartyHosts.map(host => {
35
+ if (isLegacyFirstPartyHost(host)) {
36
+ return {
37
+ match: host,
38
+ propagatorTypes: [_types.PropagatorType.DATADOG]
39
+ };
40
+ }
41
+
42
+ return host;
43
+ });
44
+ };
45
+
46
+ exports.formatFirstPartyHosts = formatFirstPartyHosts;
22
47
  const DEFAULTS = {
23
48
  nativeCrashReportEnabled: false,
24
49
  sessionSamplingRate: 100.0,
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","firstPartyHosts","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;;;IAMYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAOZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,yBAAyB,EAAE,KARd;AASbC,EAAAA,kBAAkB,EAAE,MAAM,EATb;AAUbC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CAVR;AAWbC,EAAAA,eAAe,EAAEC,iCAAgBC,OAXpB;AAYbC,EAAAA,mBAAm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yB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEL,QAAQ,CAACC;AAA3C,GADqB,EAErBQ,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACd;AAFpB,GADqB,EAKrBuB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACb;AAFpB,GADqB,EAKrBsB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACZ;AAFpB,GADqB,EAKrBqB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACX;AAFpB,GADqB,EAKrBoB,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;;;;AAwEA,MAAMI,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: string[] = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: string[];\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: string[];\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","PropagatorType","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;AAMA;;;;IAEYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAcZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACnB,SAAOA,eAAe,CAACC,GAAhB,CAAoBC,IAAI,IAAI;AAC/B,QAAIL,sBAAsB,CAACK,IAAD,CAA1B,EAAkC;AAC9B,aAAO;AACHC,QAAAA,KAAK,EAAED,IADJ;AAEHE,QAAAA,eAAe,EAAE,CAACC,sBAAeC,OAAhB;AAFd,OAAP;AAIH;;AACD,WAAOJ,IAAP;AACH,GARM,CAAP;AASH,CAZM;;;AAcP,MAAMK,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,yBAAyB,EAAE,KARd;AASbC,EAAAA,kBAAkB,EAAE,MAAM,EATb;AAUbC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CAVR;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AQ,CAAC5B;AAFpB,GADqB,EAKrBoC,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEJ,QAAQ,CAACtC;AAA3C,GADqB,EAErB8C,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACd;AAFpB,GADqB,EAKrBsB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACb;AAFpB,GADqB,EAKrBqB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACZ;AAFpB,GADqB,EAKrBoB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACX;AAFpB,GADqB,EAKrBmB,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;;;;AAwEA,MAAMI,4BAAN,SAA2CtB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BuB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [PropagatorType.DATADOG]\n };\n }\n return host;\n });\n};\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "InitializationMode", {
21
21
  return _DdSdkReactNativeConfiguration.InitializationMode;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "VitalsUpdateFrequency", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _DdSdkReactNativeConfiguration.VitalsUpdateFrequency;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "DdSdkReactNative", {
25
31
  enumerable: true,
26
32
  get: function () {
@@ -87,6 +93,12 @@ Object.defineProperty(exports, "ErrorSource", {
87
93
  return _types.ErrorSource;
88
94
  }
89
95
  });
96
+ Object.defineProperty(exports, "PropagatorType", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _types.PropagatorType;
100
+ }
101
+ });
90
102
  Object.defineProperty(exports, "DatadogProvider", {
91
103
  enumerable: true,
92
104
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdTrace } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { RumActionType, ErrorSource } from './rum/types';\nimport { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode,\n VitalsUpdateFrequency\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdTrace } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { RumActionType, ErrorSource, PropagatorType } from './rum/types';\nimport { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity,\n VitalsUpdateFrequency,\n PropagatorType\n};\n"]}
@@ -55,6 +55,7 @@ class DdRumUserInteractionTracking {
55
55
  try {
56
56
  const jsxRuntime = (0, _getJsxRuntime.getJsxRuntime)();
57
57
  const originaljsx = jsxRuntime.jsx;
58
+ this.originalJsx = originaljsx;
58
59
 
59
60
  jsxRuntime.jsx = (...args) => {
60
61
  return this.patchCreateElementFunction(originaljsx, args);
@@ -100,6 +101,12 @@ class DdRumUserInteractionTracking {
100
101
  _react.default.createElement = this.originalCreateElement;
101
102
  _react.default.memo = this.originalMemo;
102
103
  DdRumUserInteractionTracking.isTracking = false;
104
+
105
+ if (this.originalJsx) {
106
+ const jsxRuntime = (0, _getJsxRuntime.getJsxRuntime)();
107
+ jsxRuntime.jsx = this.originalJsx;
108
+ this.originalJsx = null;
109
+ }
103
110
  }
104
111
 
105
112
  }
@@ -114,6 +121,8 @@ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", _react.de
114
121
 
115
122
  _defineProperty(DdRumUserInteractionTracking, "originalMemo", _react.default.memo);
116
123
 
124
+ _defineProperty(DdRumUserInteractionTracking, "originalJsx", null);
125
+
117
126
  _defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
118
127
  if (props && typeof props.onPress === 'function') {
119
128
  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","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;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,4BAA4B,CAACE,UAAjC,EAA6C;AACzCC,+BAAYC,GAAZ,CACI,8CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AACDN,IAAAA,4BAA4B,CAACO,iBAA7B,GAAiD,IAAIC,wCAAJ,EAAjD;AAEA,UAAMC,QAAQ,GAAGC,eAAMC,aAAvB;;AACAD,mBAAMC,aAAN,GAAsB,CAClB,GAAGC,IADe,KAEZ;AACN,aAAO,KAAKC,0BAAL,CAAgCJ,QAAhC,EAA0CG,IAA1C,CAAP;AACH,KAJD;;AAMA,QAAI;AACA,YAAME,UAAU,GAAG,mCAAnB;AACA,YAAMC,WAAW,GAAGD,UAAU,CAACE,GAA/B;;AACAF,MAAAA,UAAU,CAACE,GAAX,GAAiB,CACb,GAAGJ,IADU,KAE4B;AACzC,eAAO,KAAKC,0BAAL,CAAgCE,WAAhC,EAA6CH,IAA7C,CAAP;AACH,OAJD;AAKH,KARD,CAQE,OAAOK,CAAP,EAAU;AACRC,wBAAMC,cAAN,CAAqB,iCAAgBF,CAAhB,CAArB;AACH;;AAED,UAAMG,YAAY,GAAGV,eAAMW,IAA3B;;AACAX,mBAAMW,IAAN,GAAa,CACTC,SADS,EAETC,aAFS,KAGR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BAJ3BrB,4B,gCAMmC,CACxCsC,gBADwC,EAExC,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAFwC,KAGC;AACzC,MACID,KAAK,IACL,OAAQA,KAAD,CAAmCd,OAA1C,KAAsD,UAF1D,EAGE;AACE,UAAMgB,eAAe,GAAIF,KAAD,EAAmC;AACtDd,IAAAA,OADL;;AAECc,IAAAA,KAAD,CAAmCd,OAAnC,GAA6C,CAAC,GAAGd,IAAJ,KAAoB;AAC7DZ,MAAAA,4BAA4B,CAACO,iBAA7B,CAA+CoC,gBAA/C,CACI,GAAG/B,IADP;AAGA,aAAO8B,eAAe,CAAC,GAAG9B,IAAJ,CAAtB;AACH,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"]}
1
+ {"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["DdRumUserInteractionTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","eventsInterceptor","DdEventsInterceptor","original","React","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","originalJsx","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;AAgCtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,4BAA4B,CAACE,UAAjC,EAA6C;AACzCC,+BAAYC,GAAZ,CACI,8CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AACDN,IAAAA,4BAA4B,CAACO,iBAA7B,GAAiD,IAAIC,wC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IAAJ,CAAtB;AACH,KALD,CAHF,CASE;;;AACC6B,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 private static originalJsx = null;\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 this.originalJsx = originaljsx;\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\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 if (this.originalJsx) {\n const jsxRuntime = getJsxRuntime();\n jsxRuntime.jsx = this.originalJsx;\n this.originalJsx = null;\n }\n }\n}\n"]}
@@ -43,7 +43,7 @@ class DdRumResourceTracking {
43
43
  });
44
44
  this.requestProxy.onTrackingStart({
45
45
  tracingSamplingRate,
46
- firstPartyHostsRegex: (0, _firstPartyHosts.firstPartyHostsRegexBuilder)(firstPartyHosts)
46
+ firstPartyHostsRegexMap: (0, _firstPartyHosts.firstPartyHostsRegexMapBuilder)(firstPartyHosts)
47
47
  });
48
48
 
49
49
  _InternalLog.InternalLog.log('Datadog SDK is tracking XHR resources', _SdkVerbosity.SdkVerbosity.INFO);
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","InternalLog","log","SdkVerbosity","WARN","requestProxy","XHRProxy","xhrType","XMLHttpRequest","resourceReporter","ResourceReporter","filterDevResource","onTrackingStart","firstPartyHostsRegex","INFO","stopTracking","onTrackingStop"],"mappings":";;;;;;;AAMA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,qBAAN,CAA4B;AAI/B;AACJ;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA,mBADiB;AAEjBC,IAAAA;AAFiB,GAAD,EAMX;AACL;AACA,QAAIH,qBAAqB,CAACI,UAA1B,EAAsC;AAClCC,+BAAYC,GAAZ,CACI,+CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,SAAKC,YAAL,GAAoB,IAAIC,kBAAJ,CAAa;AAC7BC,MAAAA,OAAO,EAAEC,cADoB;AAE7BC,MAAAA,gBAAgB,EAAE,IAAIC,kCAAJ,CAAqB,CAACC,+CAAD,CAArB;AAFW,KAAb,CAApB;AAIA,SAAKN,YAAL,CAAkBO,eAAlB,CAAkC;AAC9Bd,MAAAA,mBAD8B;AAE9Be,MAAAA,oBAAoB,EAAE,kDAA4Bd,eAA5B;AAFQ,KAAlC;;AAKAE,6BAAYC,GAAZ,CACI,uCADJ,EAEIC,2BAAaW,IAFjB;;AAIAlB,IAAAA,qBAAqB,CAACI,UAAtB,GAAmC,IAAnC;AACH;;AAEkB,SAAZe,YAAY,GAAS;AACxB,QAAInB,qBAAqB,CAACI,UAA1B,EAAsC;AAClCJ,MAAAA,qBAAqB,CAACI,UAAtB,GAAmC,KAAnC;;AACA,UAAI,KAAKK,YAAT,EAAuB;AACnB,aAAKA,YAAL,CAAkBW,cAAlB;AACH;;AACD,WAAKX,YAAL,GAAoB,IAApB;AACH;AACJ;;AA/C8B;;;;gBAAtBT,qB,gBACmB,K;;gBADnBA,qB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\n\nimport { firstPartyHostsRegexBuilder } from './domain/firstPartyHosts';\nimport type { RequestProxy } from './domain/interfaces/RequestProxy';\nimport { ResourceReporter } from './implementation/DatadogRumResource/ResourceReporter';\nimport { filterDevResource } from './implementation/DatadogRumResource/internalDevResourceBlocklist';\nimport { XHRProxy } from './implementation/XHRProxy';\n\n/**\n * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.\n */\nexport class DdRumResourceTracking {\n private static isTracking = false;\n private static requestProxy: RequestProxy | null;\n\n /**\n * Starts tracking resources and sends a RUM Resource event every time a network request is detected.\n */\n static startTracking({\n tracingSamplingRate,\n firstPartyHosts\n }: {\n tracingSamplingRate: number;\n firstPartyHosts: string[];\n }): void {\n // extra safety to avoid proxying the XHR class twice\n if (DdRumResourceTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking XHR resources',\n SdkVerbosity.WARN\n );\n return;\n }\n\n this.requestProxy = new XHRProxy({\n xhrType: XMLHttpRequest,\n resourceReporter: new ResourceReporter([filterDevResource])\n });\n this.requestProxy.onTrackingStart({\n tracingSamplingRate,\n firstPartyHostsRegex: firstPartyHostsRegexBuilder(firstPartyHosts)\n });\n\n InternalLog.log(\n 'Datadog SDK is tracking XHR resources',\n SdkVerbosity.INFO\n );\n DdRumResourceTracking.isTracking = true;\n }\n\n static stopTracking(): void {\n if (DdRumResourceTracking.isTracking) {\n DdRumResourceTracking.isTracking = false;\n if (this.requestProxy) {\n this.requestProxy.onTrackingStop();\n }\n this.requestProxy = null;\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","InternalLog","log","SdkVerbosity","WARN","requestProxy","XHRProxy","xhrType","XMLHttpRequest","resourceReporter","ResourceReporter","filterDevResource","onTrackingStart","firstPartyHostsRegexMap","INFO","stopTracking","onTrackingStop"],"mappings":";;;;;;;AAMA;;AACA;;AAGA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,qBAAN,CAA4B;AAI/B;AACJ;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA,mBADiB;AAEjBC,IAAAA;AAFiB,GAAD,EAMX;AACL;AACA,QAAIH,qBAAqB,CAACI,UAA1B,EAAsC;AAClCC,+BAAYC,GAAZ,CACI,+CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,SAAKC,YAAL,GAAoB,IAAIC,kBAAJ,CAAa;AAC7BC,MAAAA,OAAO,EAAEC,cADoB;AAE7BC,MAAAA,gBAAgB,EAAE,IAAIC,kCAAJ,CAAqB,CAACC,+CAAD,CAArB;AAFW,KAAb,CAApB;AAIA,SAAKN,YAAL,CAAkBO,eAAlB,CAAkC;AAC9Bd,MAAAA,mBAD8B;AAE9Be,MAAAA,uBAAuB,EAAE,qDACrBd,eADqB;AAFK,KAAlC;;AAOAE,6BAAYC,GAAZ,CACI,uCADJ,EAEIC,2BAAaW,IAFjB;;AAIAlB,IAAAA,qBAAqB,CAACI,UAAtB,GAAmC,IAAnC;AACH;;AAEkB,SAAZe,YAAY,GAAS;AACxB,QAAInB,qBAAqB,CAACI,UAA1B,EAAsC;AAClCJ,MAAAA,qBAAqB,CAACI,UAAtB,GAAmC,KAAnC;;AACA,UAAI,KAAKK,YAAT,EAAuB;AACnB,aAAKA,YAAL,CAAkBW,cAAlB;AACH;;AACD,WAAKX,YAAL,GAAoB,IAApB;AACH;AACJ;;AAjD8B;;;;gBAAtBT,qB,gBACmB,K;;gBADnBA,qB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport type { FirstPartyHost } from '../../types';\n\nimport { firstPartyHostsRegexMapBuilder } from './domain/firstPartyHosts';\nimport type { RequestProxy } from './domain/interfaces/RequestProxy';\nimport { ResourceReporter } from './implementation/DatadogRumResource/ResourceReporter';\nimport { filterDevResource } from './implementation/DatadogRumResource/internalDevResourceBlocklist';\nimport { XHRProxy } from './implementation/XHRProxy';\n\n/**\n * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.\n */\nexport class DdRumResourceTracking {\n private static isTracking = false;\n private static requestProxy: RequestProxy | null;\n\n /**\n * Starts tracking resources and sends a RUM Resource event every time a network request is detected.\n */\n static startTracking({\n tracingSamplingRate,\n firstPartyHosts\n }: {\n tracingSamplingRate: number;\n firstPartyHosts: FirstPartyHost[];\n }): void {\n // extra safety to avoid proxying the XHR class twice\n if (DdRumResourceTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking XHR resources',\n SdkVerbosity.WARN\n );\n return;\n }\n\n this.requestProxy = new XHRProxy({\n xhrType: XMLHttpRequest,\n resourceReporter: new ResourceReporter([filterDevResource])\n });\n this.requestProxy.onTrackingStart({\n tracingSamplingRate,\n firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder(\n firstPartyHosts\n )\n });\n\n InternalLog.log(\n 'Datadog SDK is tracking XHR resources',\n SdkVerbosity.INFO\n );\n DdRumResourceTracking.isTracking = true;\n }\n\n static stopTracking(): void {\n if (DdRumResourceTracking.isTracking) {\n DdRumResourceTracking.isTracking = false;\n if (this.requestProxy) {\n this.requestProxy.onTrackingStop();\n }\n this.requestProxy = null;\n }\n }\n}\n"]}
@@ -3,16 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.generateTraceId = generateTraceId;
7
- exports.getTracingAttributes = void 0;
6
+ exports.TraceIdentifier = exports.getTracingAttributes = void 0;
8
7
 
9
8
  var _firstPartyHosts = require("./firstPartyHosts");
10
9
 
11
- /*
12
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
13
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
14
- * Copyright 2016-Present Datadog, Inc.
15
- */
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
16
12
  const DISCARDED_TRACE_ATTRIBUTES = {
17
13
  samplingPriorityHeader: '0',
18
14
  tracingStrategy: 'DISCARD'
@@ -20,15 +16,17 @@ const DISCARDED_TRACE_ATTRIBUTES = {
20
16
 
21
17
  const getTracingAttributes = ({
22
18
  hostname,
23
- firstPartyHostsRegex,
19
+ firstPartyHostsRegexMap,
24
20
  tracingSamplingRate
25
21
  }) => {
26
22
  if (hostname === null) {
27
23
  return DISCARDED_TRACE_ATTRIBUTES;
28
24
  }
29
25
 
30
- if ((0, _firstPartyHosts.isHostFirstParty)(hostname, firstPartyHostsRegex)) {
31
- return generateTracingAttributesWithSampling(tracingSamplingRate);
26
+ const propagatorsForHost = (0, _firstPartyHosts.getPropagatorsForHost)(hostname, firstPartyHostsRegexMap);
27
+
28
+ if (propagatorsForHost) {
29
+ return generateTracingAttributesWithSampling(tracingSamplingRate, propagatorsForHost);
32
30
  }
33
31
 
34
32
  return DISCARDED_TRACE_ATTRIBUTES;
@@ -36,48 +34,68 @@ const getTracingAttributes = ({
36
34
 
37
35
  exports.getTracingAttributes = getTracingAttributes;
38
36
 
39
- const generateTracingAttributesWithSampling = tracingSamplingRate => {
40
- if (Math.random() * 100 <= tracingSamplingRate) {
41
- return {
42
- traceId: generateTraceId(),
43
- spanId: generateTraceId(),
44
- samplingPriorityHeader: '1',
45
- tracingStrategy: 'KEEP',
46
- rulePsr: tracingSamplingRate / 100
47
- };
48
- }
49
-
50
- return DISCARDED_TRACE_ATTRIBUTES;
37
+ const generateTracingAttributesWithSampling = (tracingSamplingRate, propagatorTypes) => {
38
+ const isSampled = Math.random() * 100 <= tracingSamplingRate;
39
+ const tracingAttributes = {
40
+ traceId: new TraceIdentifier(),
41
+ spanId: new TraceIdentifier(),
42
+ samplingPriorityHeader: isSampled ? '1' : '0',
43
+ tracingStrategy: 'KEEP',
44
+ rulePsr: tracingSamplingRate / 100,
45
+ propagatorTypes
46
+ };
47
+ return tracingAttributes;
51
48
  };
49
+ /**
50
+ * Using branded types will ensure we don't accidentally use
51
+ * traceId for spanId when generating headers.
52
+ */
53
+
54
+
52
55
  /*
53
- * 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)
56
+ * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/0e9722d5b06f6d49264bc82cd254a207d647d66c/packages/rum-core/src/domain/tracing/tracer.ts#L190)
54
57
  */
58
+ const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1
59
+
60
+ const MAX_31_BITS_NUMBER = 2147483647; // 2^31-1
55
61
 
62
+ class TraceIdentifier {
63
+ constructor() {
64
+ _defineProperty(this, "low", void 0);
56
65
 
57
- function generateTraceId() {
58
- const radix = 10;
59
- const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1
66
+ _defineProperty(this, "high", void 0);
60
67
 
61
- let low = Math.floor(Math.random() * MAX_32_BITS_NUMBER);
62
- let high = Math.floor(Math.random() * MAX_32_BITS_NUMBER);
63
- let str = '';
68
+ _defineProperty(this, "toString", radix => {
69
+ let low = this.low;
70
+ let high = this.high;
71
+ let str = '';
64
72
 
65
- while (high > 0 && low > 0) {
66
- // Create an intermediate value with the same modulo as the combined high and low value
67
- // but requiring 36 bits max (32 for the low value + 4 for the high part)
68
- const modH = high % radix;
69
- const temp = (modH << 32) + low;
70
- const digit = temp % radix; // update the high value
73
+ while (high > 0 || low > 0) {
74
+ const mod = high % radix * (MAX_32_BITS_NUMBER + 1) + low;
75
+ high = Math.floor(high / radix);
76
+ low = Math.floor(mod / radix);
77
+ str = (mod % radix).toString(radix) + str;
78
+ }
71
79
 
72
- high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op
73
- // the low value reuses the previous temp value to account for the "missing mod" in the high update
80
+ return str;
81
+ });
74
82
 
75
- low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op
76
- // update the string from right to left
83
+ _defineProperty(this, "toPaddedString", (radix, length) => {
84
+ const traceId = this.toString(radix);
77
85
 
78
- str = digit.toString() + str;
86
+ if (traceId.length > length) {
87
+ return traceId;
88
+ }
89
+
90
+ return Array(length - traceId.length + 1).join('0') + traceId;
91
+ });
92
+
93
+ // We need to have a 63 bits number max
94
+ this.high = Math.floor(Math.random() * MAX_31_BITS_NUMBER);
95
+ this.low = Math.floor(Math.random() * MAX_32_BITS_NUMBER);
79
96
  }
80
97
 
81
- return str;
82
98
  }
99
+
100
+ exports.TraceIdentifier = TraceIdentifier;
83
101
  //# sourceMappingURL=distributedTracing.js.map
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","TraceIdentifier","spanId","rulePsr","MAX_32_BITS_NUMBER","MAX_31_BITS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FC,KAAD,IAAmB;AAC1B,UAAIC,GAAG,GAAG,KAAKA,GAAf;AACA,UAAIC,IAAI,GAAG,KAAKA,IAAhB;AACA,UAAIC,GAAG,GAAG,EAAV;;AAEA,aAAOD,IAAI,GAAG,CAAP,IAAYD,GAAG,GAAG,CAAzB,EAA4B;AACxB,cAAMG,GAAG,GAAIF,IAAI,GAAGF,KAAR,IAAkBH,kBAAkB,GAAG,CAAvC,IAA4CI,GAAxD;AACAC,QAAAA,IAAI,GAAGZ,IAAI,CAACe,KAAL,CAAWH,IAAI,GAAGF,KAAlB,CAAP;AACAC,QAAAA,GAAG,GAAGX,IAAI,CAACe,KAAL,CAAWD,GAAG,GAAGJ,KAAjB,CAAN;AACAG,QAAAA,GAAG,GAAG,CAACC,GAAG,GAAGJ,KAAP,EAAcM,QAAd,CAAuBN,KAAvB,IAAgCG,GAAtC;AACH;;AACD,aAAOA,GAAP;AACH,KAlBa;;AAAA,4CA2BG,CAACH,KAAD,EAAgBO,MAAhB,KAAmC;AAChD,YAAMd,OAAO,GAAG,KAAKa,QAAL,CAAcN,KAAd,CAAhB;;AACA,UAAIP,OAAO,CAACc,MAAR,GAAiBA,MAArB,EAA6B;AACzB,eAAOd,OAAP;AACH;;AACD,aAAOe,KAAK,CAACD,MAAM,GAAGd,OAAO,CAACc,MAAjB,GAA0B,CAA3B,CAAL,CAAmCE,IAAnC,CAAwC,GAAxC,IAA+ChB,OAAtD;AACH,KAjCa;;AACV;AACA,SAAKS,IAAL,GAAYZ,IAAI,CAACe,KAAL,CAAWf,IAAI,CAACC,MAAL,KAAgBO,kBAA3B,CAAZ;AACA,SAAKG,GAAL,GAAWX,IAAI,CAACe,KAAL,CAAWf,IAAI,CAACC,MAAL,KAAgBM,kBAA3B,CAAX;AACH;;AARwB","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 { PropagatorType } from '../../../types';\n\nimport type { Hostname } from './firstPartyHosts';\nimport { getPropagatorsForHost } from './firstPartyHosts';\nimport type { RegexMap } from './interfaces/RequestProxy';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: TraceId;\n spanId: SpanId;\n samplingPriorityHeader: '1' | '0';\n rulePsr: number;\n propagatorTypes: PropagatorType[];\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 firstPartyHostsRegexMap,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegexMap: RegexMap;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n const propagatorsForHost = getPropagatorsForHost(\n hostname,\n firstPartyHostsRegexMap\n );\n if (propagatorsForHost) {\n return generateTracingAttributesWithSampling(\n tracingSamplingRate,\n propagatorsForHost\n );\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number,\n propagatorTypes: PropagatorType[]\n): DdRumResourceTracingAttributes => {\n const isSampled = Math.random() * 100 <= tracingSamplingRate;\n const tracingAttributes: DdRumResourceTracingAttributes = {\n traceId: new TraceIdentifier() as TraceId,\n spanId: new TraceIdentifier() as SpanId,\n samplingPriorityHeader: isSampled ? '1' : '0',\n tracingStrategy: 'KEEP',\n rulePsr: tracingSamplingRate / 100,\n propagatorTypes\n };\n\n return tracingAttributes;\n};\n\n/**\n * Using branded types will ensure we don't accidentally use\n * traceId for spanId when generating headers.\n */\nexport type TraceId = TraceIdentifier & {\n _brand: 'traceId';\n};\n\nexport type SpanId = TraceIdentifier & {\n _brand: 'spanId';\n};\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/0e9722d5b06f6d49264bc82cd254a207d647d66c/packages/rum-core/src/domain/tracing/tracer.ts#L190)\n */\nconst MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\nconst MAX_31_BITS_NUMBER = 2147483647; // 2^31-1\nexport class TraceIdentifier {\n private low: number;\n private high: number;\n\n constructor() {\n // We need to have a 63 bits number max\n this.high = Math.floor(Math.random() * MAX_31_BITS_NUMBER);\n this.low = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n }\n\n toString = (radix: number) => {\n let low = this.low;\n let high = this.high;\n let str = '';\n\n while (high > 0 || low > 0) {\n const mod = (high % radix) * (MAX_32_BITS_NUMBER + 1) + low;\n high = Math.floor(high / radix);\n low = Math.floor(mod / radix);\n str = (mod % radix).toString(radix) + str;\n }\n return str;\n };\n\n /**\n * This function pads the trace with `0`.\n * It should not be used with a `length` lower than the trace, as we return the full trace in this case.\n * @param radix radix for the trace\n * @param length minimum length\n * @returns padded string\n */\n toPaddedString = (radix: number, length: number) => {\n const traceId = this.toString(radix);\n if (traceId.length > length) {\n return traceId;\n }\n return Array(length - traceId.length + 1).join('0') + traceId;\n };\n}\n"]}