@datadog/mobile-react-native 1.7.1 → 1.8.0-rc0

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 (131) hide show
  1. package/DatadogSDKReactNative.podspec +14 -1
  2. package/android/build.gradle +20 -7
  3. package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
  4. package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
  5. package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
  7. package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
  9. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
  11. package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
  12. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
  13. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
  14. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
  15. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
  16. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
  20. package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
  21. package/ios/Sources/DdLogs.h +24 -0
  22. package/ios/Sources/DdLogs.mm +149 -0
  23. package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
  24. package/ios/Sources/DdRum.h +24 -0
  25. package/ios/Sources/DdRum.mm +188 -0
  26. package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
  27. package/ios/Sources/DdSdk.h +24 -0
  28. package/ios/Sources/DdSdk.mm +119 -0
  29. package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
  30. package/ios/Sources/DdTrace.h +24 -0
  31. package/ios/Sources/DdTrace.mm +66 -0
  32. package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
  33. package/ios/Sources/QueueHolder.swift +8 -0
  34. package/jest/mock.js +3 -1
  35. package/lib/commonjs/DdSdkReactNative.js +32 -49
  36. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  37. package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
  38. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  39. package/lib/commonjs/logs/DdLogs.js +33 -40
  40. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  41. package/lib/commonjs/nativeModulesTypes.js +13 -0
  42. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  43. package/lib/commonjs/rum/DdRum.js +104 -106
  44. package/lib/commonjs/rum/DdRum.js.map +1 -1
  45. package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
  46. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  47. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  48. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  49. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  50. package/lib/commonjs/sdk/DdSdk.js +3 -3
  51. package/lib/commonjs/sdk/DdSdk.js.map +1 -1
  52. package/lib/commonjs/specs/NativeDdLogs.js +20 -0
  53. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
  54. package/lib/commonjs/specs/NativeDdRum.js +20 -0
  55. package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
  56. package/lib/commonjs/specs/NativeDdSdk.js +20 -0
  57. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
  58. package/lib/commonjs/specs/NativeDdTrace.js +20 -0
  59. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
  60. package/lib/commonjs/trace/DdTrace.js +10 -12
  61. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  62. package/lib/commonjs/version.js +1 -1
  63. package/lib/commonjs/version.js.map +1 -1
  64. package/lib/module/DdSdkReactNative.js +27 -44
  65. package/lib/module/DdSdkReactNative.js.map +1 -1
  66. package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
  67. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  68. package/lib/module/logs/DdLogs.js +33 -39
  69. package/lib/module/logs/DdLogs.js.map +1 -1
  70. package/lib/module/nativeModulesTypes.js +13 -0
  71. package/lib/module/nativeModulesTypes.js.map +1 -1
  72. package/lib/module/rum/DdRum.js +100 -101
  73. package/lib/module/rum/DdRum.js.map +1 -1
  74. package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
  75. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  76. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  77. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  78. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  79. package/lib/module/sdk/DdSdk.js +3 -2
  80. package/lib/module/sdk/DdSdk.js.map +1 -1
  81. package/lib/module/specs/NativeDdLogs.js +14 -0
  82. package/lib/module/specs/NativeDdLogs.js.map +1 -0
  83. package/lib/module/specs/NativeDdRum.js +14 -0
  84. package/lib/module/specs/NativeDdRum.js.map +1 -0
  85. package/lib/module/specs/NativeDdSdk.js +14 -0
  86. package/lib/module/specs/NativeDdSdk.js.map +1 -0
  87. package/lib/module/specs/NativeDdTrace.js +14 -0
  88. package/lib/module/specs/NativeDdTrace.js.map +1 -0
  89. package/lib/module/trace/DdTrace.js +10 -11
  90. package/lib/module/trace/DdTrace.js.map +1 -1
  91. package/lib/module/version.js +1 -1
  92. package/lib/module/version.js.map +1 -1
  93. package/lib/typescript/DdSdkReactNative.d.ts +4 -4
  94. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
  95. package/lib/typescript/logs/DdLogs.d.ts +4 -4
  96. package/lib/typescript/nativeModulesTypes.d.ts +28 -168
  97. package/lib/typescript/rum/DdRum.d.ts +12 -12
  98. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
  99. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
  100. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
  101. package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
  102. package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
  103. package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
  104. package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
  105. package/lib/typescript/version.d.ts +1 -1
  106. package/package.json +10 -2
  107. package/src/DdSdkReactNative.tsx +12 -10
  108. package/src/DdSdkReactNativeConfiguration.tsx +22 -0
  109. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
  110. package/src/__tests__/longTasksUtils.test.ts +5 -0
  111. package/src/__tests__/mock.test.ts +89 -0
  112. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
  113. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
  114. package/src/logs/DdLogs.ts +11 -11
  115. package/src/logs/__tests__/DdLogs.test.ts +1 -1
  116. package/src/nativeModulesTypes.ts +49 -254
  117. package/src/rum/DdRum.ts +36 -32
  118. package/src/rum/eventMappers/errorEventMapper.ts +4 -4
  119. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
  120. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
  121. package/src/sdk/DdSdk.ts +2 -3
  122. package/src/specs/NativeDdLogs.ts +110 -0
  123. package/src/specs/NativeDdRum.ts +151 -0
  124. package/src/specs/NativeDdSdk.ts +62 -0
  125. package/src/specs/NativeDdTrace.ts +42 -0
  126. package/src/trace/DdTrace.ts +9 -9
  127. package/src/version.ts +1 -1
  128. package/ios/Sources/DdLogs.m +0 -62
  129. package/ios/Sources/DdRum.m +0 -82
  130. package/ios/Sources/DdSdk.m +0 -41
  131. package/ios/Sources/DdTrace.m +0 -23
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","ProxyType","SdkVerbosity","DdLogs","adaptLongTaskThreshold","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","UserInfoSingleton","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","log","JSON","stringify","DEBUG","getInstance","setUser","user","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","INFO","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","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","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,sBAAT,QAAuC,kBAAvC;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,wEAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,mBAAT,QAAoC,+CAApC;AAEA,SAASC,eAAT,QAAgC,8CAAhC;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,iBAAT,QAAkC,2CAAlC;AAEA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAO,IAAIC,UAApB,QAAsC,WAAtC;AAEA;AACA;AACA;;AACA,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,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAIjG,aAAa,CAACiG,aAAd,IAA+B,CAACjG,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAAC2D,gBAAd,CACI7D,gBAAgB,CAACoG,iBADrB,IAEK,IAAGlG,aAAa,CAACiG,aAAc,EAFpC;AAGH;;AAEDjG,EAAAA,aAAa,CAAC2D,gBAAd,CACI,uBADJ,IAEI9E,qBAAqB,CAACmB,aAAa,CAAC8B,eAAf,CAFzB;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 { 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 { DdSdk } from './sdk/DdSdk';\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 configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\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"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","ProxyType","SdkVerbosity","DdLogs","adaptLongTaskThreshold","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","UserInfoSingleton","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","initializationMode","SYNC","initializeNativeSDK","initializationModeForTelemetry","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","wasAutoInstrumented","log","WARN","trackInteractions","startTracking","actionNameAttribute","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","initialize","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","INFO","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","getInstance","user","setUser","setUserInfo","consent","setTrackingConsent","DD_SOURCE_KEY","DD_SDK_VERSION","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","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAAS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AACnD,gBAAgB,CAACgG,qBAAlB,CAAhB,GACIb,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIzF,aAAa,CAAC+F,WAAlB,EAA+B;AAC3B/F,IAAAA,aAAa,CAACiD,gBAAd,CAA+BnD,gBAAgB,CAACkG,eAAhD,IACIhG,aAAa,CAAC+F,WADlB;AAEH;;AAED,MAAI/F,aAAa,CAACJ,OAAlB,EAA2B;AACvBI,IAAAA,aAAa,CAACiD,gBAAd,CAA+BnD,gBAAgB,CAACmG,UAAhD,IAA+D,GAC3DjG,aAAa,CAACJ,OACjB,GACGI,aAAa,CAACkG,aAAd,GACO,IAAGlG,aAAa,CAACkG,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAIlG,aAAa,CAACkG,aAAd,IAA+B,CAAClG,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAACiD,gBAAd,CACInD,gBAAgB,CAACqG,iBADrB,IAEK,IAAGnG,aAAa,CAACkG,aAAc,EAFpC;AAGH;;AAEDlG,EAAAA,aAAa,CAACiD,gBAAd,CACI,uBADJ,IAEIpE,qBAAqB,CAACmB,aAAa,CAACmB,eAAf,CAFzB;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 { 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 { DdSdk } from './sdk/DdSdk';\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 initialize = async (\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 configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\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 setAttributes = async (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 setUser = async (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 actionNameAttribute: configuration.actionNameAttribute\n });\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"]}
@@ -193,6 +193,18 @@ export class DdSdkReactNativeConfiguration {
193
193
  * By default, background events are not tracked. Enabling this feature might increase the
194
194
  * number of sessions tracked and impact your billing.
195
195
  */
196
+
197
+ /**
198
+ * Specifies a custom prop to name RUM actions on elements having an `onPress` prop.
199
+ *
200
+ * For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:
201
+ *
202
+ * ```js
203
+ * <TouchableOpacity testID="Dismiss notification" onPress={() => dismiss()}>
204
+ * ```
205
+ *
206
+ * `dd-action-name` is favored when both attributes are present on an element.
207
+ */
196
208
  constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
197
209
  this.clientToken = clientToken;
198
210
  this.env = env;
@@ -244,6 +256,8 @@ export class DdSdkReactNativeConfiguration {
244
256
 
245
257
  _defineProperty(this, "trackBackgroundEvents", DEFAULTS.trackBackgroundEvents);
246
258
 
259
+ _defineProperty(this, "actionNameAttribute", void 0);
260
+
247
261
  _defineProperty(this, "logEventMapper", DEFAULTS.logEventMapper);
248
262
 
249
263
  _defineProperty(this, "errorEventMapper", DEFAULTS.errorEventMapper);
@@ -320,6 +334,10 @@ export const buildConfigurationFromPartialConfiguration = (features, configurati
320
334
  name: 'actionEventMapper',
321
335
  value: features.actionEventMapper
322
336
  }, SdkConfiguration);
337
+ setConfigurationAttribute({
338
+ name: 'actionNameAttribute',
339
+ value: features.actionNameAttribute
340
+ }, SdkConfiguration);
323
341
  return SdkConfiguration;
324
342
  };
325
343
  export class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","PropagatorType","VitalsUpdateFrequency","UploadFrequency","BatchSize","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","uploadFrequency","batchSize","MEDIUM","trackBackgroundEvents","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":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAMA,SAASC,cAAT,QAA+B,aAA/B;AAEA,WAAYC,qBAAZ;;WAAYA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,KAAAA,qB;;AAOZ,WAAYC,eAAZ;;WAAYA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;GAAAA,e,KAAAA,e;;AAeZ,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAsBZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACA,OAAO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACn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2BD,IAAAA,KAAK,EAAEJ,QAAQ,CAACzC;AAA3C,GADqB,EAErBiD,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACnB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAClB;AAFpB,GADqB,EAKrB0B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACjB;AAFpB,GADqB,EAKrByB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAChB;AAFpB,GADqB,EAKrBwB,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;AAwEP,OAAO,MAAMI,4BAAN,SAA2CtB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BuB,kBAAkB,CAACC,IADS;AAAA;;AAAA;AAIhF,WAAYD,kBAAZ;;WAAYA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,KAAAA,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 enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\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 trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false\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 /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\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 readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\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":["TrackingConsent","PropagatorType","VitalsUpdateFrequency","UploadFrequency","BatchSize","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","uploadFrequency","batchSize","MEDIUM","trackBackgroundEvents","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","actionNameAttribute","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAMA,SAASC,cAAT,QAA+B,aAA/B;AAEA,WAAYC,qBAAZ;;WAAYA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,KAAAA,qB;;AAOZ,WAAYC,eAAZ;;WAAYA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;GAAAA,e,KAAAA,e;;AAeZ,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAsBZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACA,OAAO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACnB,SAAOA,eAAe,CAACC,GAAhB,CAAoBC,IAAI,IAAI;AAC/B,QAA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;AAA2BD,IAAAA,KAAK,EAAEJ,QAAQ,CAACzC;AAA3C,GADqB,EAErBiD,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACnB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAClB;AAFpB,GADqB,EAKrB0B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACjB;AAFpB,GADqB,EAKrByB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAChB;AAFpB,GADqB,EAKrBwB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACY;AAFpB,GADqB,EAKrBJ,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CA7EM;AA+EP,OAAO,MAAMK,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;AAIhF,WAAYD,kBAAZ;;WAAYA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,KAAAA,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 enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\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 trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false\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 /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\n\n /**\n * Specifies a custom prop to name RUM actions on elements having an `onPress` prop.\n *\n * For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:\n *\n * ```js\n * <TouchableOpacity testID=\"Dismiss notification\" onPress={() => dismiss()}>\n * ```\n *\n * `dd-action-name` is favored when both attributes are present on an element.\n */\n public actionNameAttribute?: string;\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 readonly actionNameAttribute?: string;\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 readonly actionNameAttribute?: string;\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 readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\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 setConfigurationAttribute(\n {\n name: 'actionNameAttribute',\n value: features.actionNameAttribute\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"]}
@@ -5,7 +5,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
5
5
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
- import { NativeModules } from 'react-native';
9
8
  import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
10
9
  import { SdkVerbosity } from '../SdkVerbosity';
11
10
  import { generateEventMapper } from './eventMapper';
@@ -24,10 +23,42 @@ const isLogWithError = args => {
24
23
 
25
24
  class DdLogsWrapper {
26
25
  constructor() {
27
- _defineProperty(this, "nativeLogs", NativeModules.DdLogs);
26
+ _defineProperty(this, "nativeLogs", require('../specs/NativeDdLogs').default);
28
27
 
29
28
  _defineProperty(this, "logEventMapper", generateEventMapper(undefined));
30
29
 
30
+ _defineProperty(this, "debug", (...args) => {
31
+ if (isLogWithError(args)) {
32
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'debug');
33
+ }
34
+
35
+ return this.log(args[0], args[1] || {}, 'debug');
36
+ });
37
+
38
+ _defineProperty(this, "info", (...args) => {
39
+ if (isLogWithError(args)) {
40
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'info');
41
+ }
42
+
43
+ return this.log(args[0], args[1] || {}, 'info');
44
+ });
45
+
46
+ _defineProperty(this, "warn", (...args) => {
47
+ if (isLogWithError(args)) {
48
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'warn');
49
+ }
50
+
51
+ return this.log(args[0], args[1] || {}, 'warn');
52
+ });
53
+
54
+ _defineProperty(this, "error", (...args) => {
55
+ if (isLogWithError(args)) {
56
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'error');
57
+ }
58
+
59
+ return this.log(args[0], args[1] || {}, 'error');
60
+ });
61
+
31
62
  _defineProperty(this, "printLogDroppedSdkNotInitialized", (message, status) => {
32
63
  if (__DEV__) {
33
64
  console.warn(`${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: "${message}"`);
@@ -104,43 +135,6 @@ class DdLogsWrapper {
104
135
  });
105
136
  }
106
137
 
107
- debug(...args) {
108
- if (isLogWithError(args)) {
109
- return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'debug');
110
- }
111
-
112
- return this.log(args[0], args[1] || {}, 'debug');
113
- }
114
-
115
- info(...args) {
116
- if (isLogWithError(args)) {
117
- return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'info');
118
- }
119
-
120
- return this.log(args[0], args[1] || {}, 'info');
121
- }
122
-
123
- warn(...args) {
124
- if (isLogWithError(args)) {
125
- return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'warn');
126
- }
127
-
128
- return this.log(args[0], args[1] || {}, 'warn');
129
- }
130
-
131
- error(...args) {
132
- if (isLogWithError(args)) {
133
- return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'error');
134
- }
135
-
136
- return this.log(args[0], args[1] || {}, 'error');
137
- }
138
- /**
139
- * Since the InternalLog does not have a verbosity set yet in this case,
140
- * we use console.warn to warn the user in dev mode.
141
- */
142
-
143
-
144
138
  registerLogEventMapper(logEventMapper) {
145
139
  this.logEventMapper = generateEventMapper(logEventMapper);
146
140
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["DdLogs.ts"],"names":["NativeModules","DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","generateEventMapper","SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","DdLogs","undefined","message","status","__DEV__","console","warn","log","DEBUG","context","event","logEventMapper","applyEventMapper","printlogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","debug","logWithError","info","registerLogEventMapper","unregisterLogEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,sBAAT,EAAiCC,WAAjC,QAAoD,gBAApD;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAGA,SAASC,mBAAT,QAAoC,eAApC;AASA,MAAMC,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;AAEA;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAChBC,IADmB,IAEa;AAChC,SACI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IACA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QADnB,IAEA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAFnB,IAGA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAJvB;AAMH,CATD;;AAWA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCACCX,aAAa,CAACY,MADf;;AAAA,4CAEbR,mBAAmB,CAACS,SAAD,CAFN;;AAAA,8DAgEK,CACvCC,OADuC,EAEvCC,MAFuC,KAGtC;AACD,UAAIC,OAAJ,EAAa;AACTC,QAAAA,OAAO,CAACC,IAAR,CACK,GAAEjB,sBAAuB,aAAYc,MAAO,4CAA2CD,OAAQ,GADpG;AAGH;AACJ,KAzEqC;;AAAA,qDA2EJ,CAC9BA,OAD8B,EAE9BC,MAF8B,KAG7B;AACDb,MAAAA,WAAW,CAACiB,GAAZ,CACK,GAAE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B,EAAiC,OAAjC,CAAP;AACH;AAED;AACJ;AACA;AACA;;;AAwGI0B,EAAAA,sBAAsB,CAACb,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsBnB,mBAAmB,CAACmB,cAAD,CAAzC;AACH;;AAEDc,EAAAA,wBAAwB,GAAG;AACvB,SAAKd,cAAL,GAAsBnB,mBAAmB,CAACS,SAAD,CAAzC;AACH;;AA7KqC;;AAgL1C,OAAO,MAAMD,MAAM,GAAG,IAAID,aAAJ,EAAf","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 { NativeModules } from 'react-native';\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n private logEventMapper = generateEventMapper(undefined);\n\n debug(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n }\n\n info(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n }\n\n warn(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n }\n\n error(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n }\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printlogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
1
+ {"version":3,"sources":["DdLogs.ts"],"names":["DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","generateEventMapper","SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","require","default","undefined","logWithError","log","message","status","__DEV__","console","warn","DEBUG","context","event","logEventMapper","applyEventMapper","printlogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","registerLogEventMapper","unregisterLogEventMapper","DdLogs"],"mappings":";;AAAA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,EAAf","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 { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeLogs: DdNativeLogsType = require('../specs/NativeDdLogs')\n .default;\n private logEventMapper = generateEventMapper(undefined);\n\n debug = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n };\n\n info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n };\n\n warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n };\n\n error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n };\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printlogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
@@ -4,6 +4,19 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
+ /**
8
+ * In this file, native modules types extend the specs for TurboModules.
9
+ * As we cannot use enums or classes in the specs, we override methods using them here.
10
+ */
11
+
12
+ /**
13
+ * The entry point to use Datadog's Logs feature.
14
+ */
15
+
16
+ /**
17
+ * The entry point to use Datadog's Trace feature.
18
+ */
19
+
7
20
  /**
8
21
  * A configuration object to initialize Datadog's features.
9
22
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n debugWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n infoWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n warnWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n errorWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: object): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
1
+ {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { Spec as NativeDdLogs } from './specs/NativeDdLogs';\nimport type { Spec as NativeDdRum } from './specs/NativeDdRum';\nimport type { Spec as NativeDdSdk } from './specs/NativeDdSdk';\nimport type { Spec as NativeDdTrace } from './specs/NativeDdTrace';\n\n/**\n * In this file, native modules types extend the specs for TurboModules.\n * As we cannot use enums or classes in the specs, we override methods using them here.\n */\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = NativeDdLogs;\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = NativeDdTrace;\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport interface DdNativeSdkType extends NativeDdSdk {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n}\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport interface DdNativeRumType extends NativeDdRum {\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n}\n"]}