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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/README.md +18 -14
  3. package/android/build.gradle +28 -3
  4. package/android/detekt.yml +572 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +12 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +15 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +143 -8
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +25 -1
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +31 -1
  10. package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +41 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +7 -2
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +429 -27
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +5 -1
  14. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +40 -1
  15. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +21 -1
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +1 -1
  17. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +1 -0
  18. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +22 -2
  19. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +2 -3
  20. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +94 -0
  21. package/datadog-sourcemaps.gradle +85 -28
  22. package/ios/Sources/Attributes.swift +0 -4
  23. package/ios/Sources/DdSdk.m +10 -0
  24. package/ios/Sources/DdSdk.swift +113 -10
  25. package/ios/Sources/DdSdkConfiguration.swift +38 -1
  26. package/ios/Sources/JSRefreshRateListener.swift +86 -0
  27. package/ios/Sources/QueueHolder.swift +7 -0
  28. package/ios/Sources/RNDdSdkConfiguration.swift +25 -1
  29. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
  30. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  31. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
  32. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  33. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
  34. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  35. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
  36. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  37. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
  38. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  39. package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
  40. package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
  41. package/lib/commonjs/DdSdkReactNative.js +140 -59
  42. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  43. package/lib/commonjs/DdSdkReactNativeConfiguration.js +166 -9
  44. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  45. package/lib/commonjs/errorUtils.js +69 -0
  46. package/lib/commonjs/errorUtils.js.map +1 -0
  47. package/lib/commonjs/foundation.js +19 -12
  48. package/lib/commonjs/foundation.js.map +1 -1
  49. package/lib/commonjs/index.js +20 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/longTasksUtils.js +40 -0
  52. package/lib/commonjs/longTasksUtils.js.map +1 -0
  53. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  54. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
  55. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  56. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
  57. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  58. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
  59. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  63. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  64. package/lib/commonjs/types.js +6 -1
  65. package/lib/commonjs/types.js.map +1 -1
  66. package/lib/commonjs/version.js +1 -1
  67. package/lib/commonjs/version.js.map +1 -1
  68. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
  69. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  70. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
  71. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  72. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
  73. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  74. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
  75. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  76. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
  77. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  78. package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
  79. package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
  80. package/lib/module/DdSdkReactNative.js +132 -57
  81. package/lib/module/DdSdkReactNative.js.map +1 -1
  82. package/lib/module/DdSdkReactNativeConfiguration.js +154 -8
  83. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  84. package/lib/module/errorUtils.js +54 -0
  85. package/lib/module/errorUtils.js.map +1 -0
  86. package/lib/module/foundation.js +18 -12
  87. package/lib/module/foundation.js.map +1 -1
  88. package/lib/module/index.js +3 -2
  89. package/lib/module/index.js.map +1 -1
  90. package/lib/module/longTasksUtils.js +31 -0
  91. package/lib/module/longTasksUtils.js.map +1 -0
  92. package/lib/module/nativeModulesTypes.js.map +1 -1
  93. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
  94. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  95. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
  96. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  97. package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
  98. package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
  99. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
  100. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
  101. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
  102. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
  103. package/lib/module/types.js +6 -1
  104. package/lib/module/types.js.map +1 -1
  105. package/lib/module/version.js +1 -1
  106. package/lib/module/version.js.map +1 -1
  107. package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  108. package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  109. package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  110. package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  111. package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  112. package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
  113. package/lib/typescript/DdSdkReactNative.d.ts +18 -3
  114. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +114 -0
  115. package/lib/typescript/errorUtils.d.ts +12 -0
  116. package/lib/typescript/index.d.ts +3 -2
  117. package/lib/typescript/longTasksUtils.d.ts +6 -0
  118. package/lib/typescript/nativeModulesTypes.d.ts +12 -0
  119. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
  120. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
  121. package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +1 -0
  122. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +1 -1
  123. package/lib/typescript/types.d.ts +16 -1
  124. package/lib/typescript/version.d.ts +1 -1
  125. package/package.json +3 -2
  126. package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
  127. package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
  128. package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
  129. package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
  130. package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
  131. package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
  132. package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
  133. package/src/DatadogProvider/DatadogProvider.tsx +122 -0
  134. package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
  135. package/src/DatadogProvider/__tests__/initialization.test.tsx +182 -0
  136. package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
  137. package/src/DdSdkReactNative.tsx +206 -109
  138. package/src/DdSdkReactNativeConfiguration.tsx +225 -8
  139. package/src/__tests__/DdRumWrapper.test.tsx +3 -27
  140. package/src/__tests__/DdSdkReactNative.test.tsx +57 -13
  141. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +181 -0
  142. package/src/__tests__/foundation.test.ts +11 -2
  143. package/src/__tests__/longTasksUtils.ts +23 -0
  144. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
  145. package/src/errorUtils.ts +58 -0
  146. package/src/foundation.tsx +15 -12
  147. package/src/index.tsx +9 -1
  148. package/src/longTasksUtils.ts +30 -0
  149. package/src/nativeModulesTypes.ts +14 -0
  150. package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
  151. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
  152. package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
  153. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
  154. package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +3 -1
  155. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +1 -1
  156. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +2 -1
  157. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
  158. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +12 -47
  159. package/src/types.tsx +11 -1
  160. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","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","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","firstPartyHosts","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","trackErrors"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,oDAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAO,IAAIC,UAApB,QAAsC,WAAtC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAN,CAAuB;AAU1B;;AAaA;AACJ;AACA;AACA;AACA;AACqB,SAAVC,UAAU,CACbC,aADa,EAEA;AACb,WAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC1C,UAAIL,gBAAgB,CAACM,cAArB,EAAqC;AACjChB,QAAAA,WAAW,CAACiB,GAAZ,CACI,uDADJ,EAEIf,YAAY,CAACgB,IAFjB;AAIAJ,QAAAA,OAAO;AACP;AACH;;AAEDd,MAAAA,WAAW,CAACmB,SAAZ,GAAwBP,aAAa,CAACO,SAAtC;AAEAP,MAAAA,aAAa,CAACQ,gBAAd,CAA+BV,gBAAgB,CAACW,aAAhD,IACI,cADJ;AAEAT,MAAAA,aAAa,CAACQ,gBAA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AAjB7D,gB,mBAC+B,Y;;gBAD/BA,gB,oBAEgC,iB;;gBAFhCA,gB,qBAGiC,kB;;gBAHjCA,gB,0BAIsC,mB;;gBAJtCA,gB,iCAML,0B;;gBANKA,gB,gBAO4B,a;;gBAP5BA,gB,uBAQmC,oB;;gBARnCA,gB,uBAWmC,gB;;gBAXnCA,gB,0BAYsC,mB;;gBAZtCA,gB,uBAamC,gB;;gBAbnCA,gB,2BAcuC,oB;;gBAdvCA,gB,2BAeuC,oB;;gBAfvCA,gB,uCAkBL,yB;;gBAlBKA,gB,mCAmB+C,G;;gBAnB/CA,gB,oBAqBuB,K","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 { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\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_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 readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n resolve();\n return;\n }\n\n InternalLog.verbosity = configuration.verbosity;\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 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[\n DdSdkReactNative.DD_PROXY_USERNAME_KEY\n ] = proxyConfig.username;\n additionalConfig[\n DdSdkReactNative.DD_PROXY_PASSWORD_KEY\n ] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SERVICE_NAME\n ] = configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\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 DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(\n () => {\n InternalLog.log(\n 'Datadog SDK was initialized',\n SdkVerbosity.INFO\n );\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.wasInitialized = true;\n resolve();\n },\n rejection => {\n reject(rejection);\n }\n );\n });\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.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(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(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 enableFeatures(\n configuration: DdSdkReactNativeConfiguration\n ) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","BufferSingleton","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","InternalLog","ProxyType","SdkVerbosity","DdSdk","adaptLongTaskThreshold","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","log","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","initializationType","trackNetworkRequests","INFO","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","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,SAASC,eAAT,QAAgC,0CAAhC;AACA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,QAKO,iCALP;AAaA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,sBAAT,QAAuC,kBAAvC;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,oDAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAO,IAAIC,UAApB,QAAsC,WAAtC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAN,CAAuB;AAU1B;;AAWA;AACJ;AACA;AACA;AACA;AAC2B,eAAVC,UAAU,CACnBC,aADmB,EAEN;AACb,UAAMF,gBAAgB,CAACG,mBAAjB,CAAqCD,aAArC,EAAoD;AACtDE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AAC8E,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GApDA,CAsDD;AACA;;;AACA,MAAI9E,aAAa,CAAC8E,aAAd,IAA+B,CAAC9E,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAACiD,gBAAd,CACInD,gBAAgB,CAACiF,iBADrB,IAEK,IAAG/E,aAAa,CAAC8E,aAAc,EAFpC;AAGH;;AAED9E,EAAAA,aAAa,CAACiD,gBAAd,CAA+B,uBAA/B,IACIjD,aAAa,CAAC4B,eADlB;AAEH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport { BufferSingleton } from './DatadogProvider/Buffer/BufferSingleton';\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\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_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.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(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(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 if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
@@ -6,12 +6,39 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { TrackingConsent } from './TrackingConsent';
9
+ export let VitalsUpdateFrequency;
10
+
11
+ (function (VitalsUpdateFrequency) {
12
+ VitalsUpdateFrequency["FREQUENT"] = "FREQUENT";
13
+ VitalsUpdateFrequency["AVERAGE"] = "AVERAGE";
14
+ VitalsUpdateFrequency["RARE"] = "RARE";
15
+ VitalsUpdateFrequency["NEVER"] = "NEVER";
16
+ })(VitalsUpdateFrequency || (VitalsUpdateFrequency = {}));
17
+
18
+ const DEFAULTS = {
19
+ nativeCrashReportEnabled: false,
20
+ sessionSamplingRate: 100.0,
21
+ resourceTracingSamplingRate: 20.0,
22
+ site: 'US1',
23
+ longTaskThresholdMs: 0,
24
+ nativeLongTaskThresholdMs: 200,
25
+ nativeViewTracking: false,
26
+ getFirstPartyHosts: () => [],
27
+ getAdditionalConfig: () => ({}),
28
+ trackingConsent: TrackingConsent.GRANTED,
29
+ telemetrySampleRate: 20.0,
30
+ vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE
31
+ };
9
32
  /**
10
33
  * The SDK configuration class.
11
34
  * It will be used to configure the SDK functionality at initialization.
12
35
  */
13
36
 
14
37
  export class DdSdkReactNativeConfiguration {
38
+ /**
39
+ * Enables crash reporting for native plaforms (iOS, Android). Default `false`.
40
+ */
41
+
15
42
  /**
16
43
  * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
17
44
  */
@@ -24,6 +51,23 @@ export class DdSdkReactNativeConfiguration {
24
51
  * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
25
52
  */
26
53
 
54
+ /**
55
+ * Verbosity for internal SDK logging.
56
+ * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.
57
+ */
58
+
59
+ /**
60
+ * Enables native views tracking.
61
+ * Set to `true` if you use a custom navigation system relying on native views.
62
+ */
63
+
64
+ /**
65
+ * List of your backends hosts to enable tracing with.
66
+ * Regular expressions are NOT supported.
67
+ *
68
+ * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
69
+ */
70
+
27
71
  /**
28
72
  * Overrides the reported version of the app.
29
73
  * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
@@ -43,7 +87,41 @@ export class DdSdkReactNativeConfiguration {
43
87
  *
44
88
  * A dash (`-`) will be automatically added between the version and the suffix
45
89
  */
46
- constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = TrackingConsent.GRANTED) {
90
+
91
+ /**
92
+ * The sampling rate for Internal Telemetry (info related to the work of the
93
+ * SDK internals).
94
+ *
95
+ * The sampling rate must be a value between 0 and 100. A value of 0 means no
96
+ * telemetry will be sent, 100 means all telemetry will be sent. When
97
+ * `telemetrySampleRate` is not set, the default value from the iOS and
98
+ * Android SDK is used, which is 20.
99
+ */
100
+
101
+ /**
102
+ * The threshold for native long tasks reporting in milliseconds.
103
+ *
104
+ * - Setting it to `0` or `false` disables native long task reporting.
105
+ * - Values below `100` will be raised to `100`.
106
+ * - Values above `5000` will be lowered to `5000`.
107
+ *
108
+ * Default value is `200`.
109
+ */
110
+
111
+ /**
112
+ * The threshold for javascript long tasks reporting in milliseconds.
113
+ *
114
+ * - Setting it to `0` or `false` disables javascript long task reporting.
115
+ * - Values below `100` will be raised to `100`.
116
+ * - Values above `5000` will be lowered to `5000`.
117
+ *
118
+ * Default value is `0`
119
+ */
120
+
121
+ /**
122
+ * Sets the preferred frequency for collecting mobile vitals.
123
+ */
124
+ constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
47
125
  this.clientToken = clientToken;
48
126
  this.env = env;
49
127
  this.applicationId = applicationId;
@@ -52,32 +130,100 @@ export class DdSdkReactNativeConfiguration {
52
130
  this.trackErrors = trackErrors;
53
131
  this.trackingConsent = trackingConsent;
54
132
 
55
- _defineProperty(this, "nativeCrashReportEnabled", false);
133
+ _defineProperty(this, "nativeCrashReportEnabled", DEFAULTS.nativeCrashReportEnabled);
56
134
 
57
135
  _defineProperty(this, "sampleRate", void 0);
58
136
 
59
- _defineProperty(this, "sessionSamplingRate", 100.0);
137
+ _defineProperty(this, "sessionSamplingRate", DEFAULTS.sessionSamplingRate);
60
138
 
61
- _defineProperty(this, "resourceTracingSamplingRate", 20.0);
139
+ _defineProperty(this, "resourceTracingSamplingRate", DEFAULTS.resourceTracingSamplingRate);
62
140
 
63
- _defineProperty(this, "site", 'US');
141
+ _defineProperty(this, "site", DEFAULTS.site);
64
142
 
65
143
  _defineProperty(this, "verbosity", undefined);
66
144
 
67
- _defineProperty(this, "nativeViewTracking", false);
145
+ _defineProperty(this, "nativeViewTracking", DEFAULTS.nativeViewTracking);
68
146
 
69
147
  _defineProperty(this, "proxyConfig", undefined);
70
148
 
71
149
  _defineProperty(this, "serviceName", undefined);
72
150
 
73
- _defineProperty(this, "firstPartyHosts", []);
151
+ _defineProperty(this, "firstPartyHosts", DEFAULTS.getFirstPartyHosts());
74
152
 
75
153
  _defineProperty(this, "version", void 0);
76
154
 
77
155
  _defineProperty(this, "versionSuffix", void 0);
78
156
 
79
- _defineProperty(this, "additionalConfig", {});
157
+ _defineProperty(this, "telemetrySampleRate", DEFAULTS.telemetrySampleRate);
158
+
159
+ _defineProperty(this, "nativeLongTaskThresholdMs", DEFAULTS.nativeLongTaskThresholdMs);
160
+
161
+ _defineProperty(this, "longTaskThresholdMs", DEFAULTS.longTaskThresholdMs);
162
+
163
+ _defineProperty(this, "vitalsUpdateFrequency", DEFAULTS.vitalsUpdateFrequency);
164
+
165
+ _defineProperty(this, "additionalConfig", DEFAULTS.getAdditionalConfig());
80
166
  }
81
167
 
82
168
  }
169
+ /**
170
+ * Auto Instrumentation configuration passed to DatadogProvider.
171
+ * Does not include default values.
172
+ */
173
+
174
+ /**
175
+ * We could use `Proxy` instead of this function, but `Proxy` is not available on
176
+ * the older android jsc that can still be used.
177
+ */
178
+ export const addDefaultValuesToAutoInstrumentationConfiguration = features => {
179
+ return { ...features,
180
+ firstPartyHosts: features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),
181
+ resourceTracingSamplingRate: features.resourceTracingSamplingRate || DEFAULTS.resourceTracingSamplingRate
182
+ };
183
+ };
184
+
185
+ const setConfigurationAttribute = (attribute, configuration) => {
186
+ if (attribute.value !== undefined) {
187
+ configuration[attribute.name] = attribute.value;
188
+ }
189
+ };
190
+
191
+ export const buildConfigurationFromPartialConfiguration = (features, configuration) => {
192
+ const {
193
+ clientToken,
194
+ env,
195
+ applicationId,
196
+ ...remainingConfiguration
197
+ } = configuration;
198
+ const SdkConfiguration = new DdSdkReactNativeConfiguration(clientToken, env, applicationId, features.trackInteractions, features.trackResources, features.trackErrors, configuration.trackingConsent);
199
+ Object.keys(remainingConfiguration).forEach(name => {
200
+ setConfigurationAttribute({
201
+ value: remainingConfiguration[name],
202
+ name
203
+ }, SdkConfiguration);
204
+ });
205
+ setConfigurationAttribute({
206
+ name: 'resourceTracingSamplingRate',
207
+ value: features.resourceTracingSamplingRate
208
+ }, SdkConfiguration);
209
+ setConfigurationAttribute({
210
+ name: 'firstPartyHosts',
211
+ value: features.firstPartyHosts
212
+ }, SdkConfiguration);
213
+ return SdkConfiguration;
214
+ };
215
+ export class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
216
+ constructor(...args) {
217
+ super(...args);
218
+
219
+ _defineProperty(this, "initializationMode", InitializationMode.SYNC);
220
+ }
221
+
222
+ }
223
+ export let InitializationMode;
224
+
225
+ (function (InitializationMode) {
226
+ InitializationMode["SYNC"] = "SYNC";
227
+ InitializationMode["ASYNC"] = "ASYNC";
228
+ })(InitializationMode || (InitializationMode = {}));
83
229
  //# sourceMappingURL=DdSdkReactNativeConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAQI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGT,eAAe,CAACU,OAPrD,EAQT;AAAA,SAPWP,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlDyC,KAkDzC;;AAAA;;AAAA,iDA1CmC,KA0CnC;;AAAA,yDAtC2C,IAsC3C;;AAAA,kCArCoB,IAqCpB;;AAAA,uCApC2CE,SAoC3C;;AAAA,gDAnCmC,KAmCnC;;AAAA,yCAlCwCA,SAkCxC;;AAAA,yCAjC4BA,SAiC5B;;AAAA,6CAhCiC,EAgCjC;;AAAA;;AAAA;;AAAA,8CAV8C,EAU9C;AAAE;;AAnDmC","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';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\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 = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\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 public additionalConfig: { [k: string]: any } = {};\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 = TrackingConsent.GRANTED\n ) {}\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","VitalsUpdateFrequency","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","firstPartyHosts","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA,WAAYC,qBAAZ;;WAAYA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,KAAAA,qB;;AAOZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,kBAAkB,EAAE,MAAM,EARb;AASbC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CATR;AAUbC,EAAAA,eAAe,EAAEZ,eAAe,CAACa,OAVpB;AAWbC,EAAAA,mBAAmB,EAAE,IAXR;AAYbC,EAAAA,qBAAqB,EAAEd,qBAAqB,CAACe;AAZhC,CAAjB;AAeA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AACvC;AACJ;AACA;;AAGI;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAII;AACJ;AACA;AACA;;AAEI;AACJ;AACA;AACA;;AAII;AACJ;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA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KrB+B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEL,QAAQ,CAACC;AAA3C,GADqB,EAErBQ,gBAFqB,CAAzB;AAKA,SAAOA,gBAAP;AACH,CA1CM;AA4CP,OAAO,MAAMI,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';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE\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 public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: string[] = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: string[];\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: string[];\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n};\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 ||\n DEFAULTS.resourceTracingSamplingRate\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 proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n\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"]}
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ export const EMPTY_MESSAGE = 'Unknown Error';
7
+ export const EMPTY_STACK_TRACE = '';
8
+ export const getErrorMessage = error => {
9
+ let message = EMPTY_MESSAGE;
10
+
11
+ if (error === undefined || error === null) {
12
+ message = EMPTY_MESSAGE;
13
+ } else if (typeof error === 'object' && 'message' in error) {
14
+ message = String(error.message);
15
+ } else {
16
+ message = String(error);
17
+ }
18
+
19
+ return message;
20
+ };
21
+ /**
22
+ * Will extract the stack from the error, taking the first key found among:
23
+ * `stacktrace`, `stack`, `componentStack` (component tree for component errors,
24
+ * which contains only native components names in production).
25
+ *
26
+ * In last resort and if `sourceURL`, `line` and `column` are present, it will
27
+ * generate a stack from this information.
28
+ */
29
+
30
+ export const getErrorStackTrace = error => {
31
+ let stack = EMPTY_STACK_TRACE;
32
+
33
+ try {
34
+ if (error === undefined || error === null) {
35
+ stack = EMPTY_STACK_TRACE;
36
+ } else if (typeof error === 'string') {
37
+ stack = EMPTY_STACK_TRACE;
38
+ } else if (typeof error === 'object') {
39
+ if ('stacktrace' in error) {
40
+ stack = String(error.stacktrace);
41
+ } else if ('stack' in error) {
42
+ stack = String(error.stack);
43
+ } else if ('componentStack' in error) {
44
+ stack = String(error.componentStack);
45
+ } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
46
+ stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
47
+ }
48
+ }
49
+ } catch (e) {// Do nothing
50
+ }
51
+
52
+ return stack;
53
+ };
54
+ //# sourceMappingURL=errorUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","stacktrace","componentStack","sourceURL","line","column","e"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,eAAtB;AACP,OAAO,MAAMC,iBAAiB,GAAG,EAA1B;AAEP,OAAO,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGJ,aAAd;;AACA,MAAIG,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGJ,aAAV;AACH,GAFD,MAEO,IAAI,OAAOG,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXM;AAaP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAIJ,KAAD,IAAoC;AAClE,MAAIK,KAAK,GAAGP,iBAAZ;;AAEA,MAAI;AACA,QAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACM,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWN,KAAf,EAAsB;AACzBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACK,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBL,KAAxB,EAA+B;AAClCK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACO,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeP,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEK,QAAAA,KAAK,GAAI,MAAKL,KAAK,CAACQ,SAAU,IAAGR,KAAK,CAACS,IAAK,IAAGT,KAAK,CAACU,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOC,CAAP,EAAU,CACR;AACH;;AACD,SAAON,KAAP;AACH,CA3BM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\n/**\n * Will extract the stack from the error, taking the first key found among:\n * `stacktrace`, `stack`, `componentStack` (component tree for component errors,\n * which contains only native components names in production).\n *\n * In last resort and if `sourceURL`, `line` and `column` are present, it will\n * generate a stack from this information.\n */\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
@@ -10,6 +10,7 @@ import { DdSdkConfiguration } from './types';
10
10
  import { InternalLog } from "./InternalLog";
11
11
  import { SdkVerbosity } from "./SdkVerbosity";
12
12
  import { TimeProvider } from "./TimeProvider";
13
+ import { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';
13
14
  const timeProvider = new TimeProvider();
14
15
 
15
16
  class DdLogsWrapper {
@@ -45,14 +46,14 @@ class DdTraceWrapper {
45
46
  }
46
47
 
47
48
  startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
48
- let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
49
+ let spanId = bufferNativeCallReturningId(() => this.nativeTrace.startSpan(operation, context, timestampMs));
49
50
  InternalLog.log("Starting span “" + operation + "” #" + spanId, SdkVerbosity.DEBUG);
50
51
  return spanId;
51
52
  }
52
53
 
53
54
  finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
54
55
  InternalLog.log("Finishing span #" + spanId, SdkVerbosity.DEBUG);
55
- return this.nativeTrace.finishSpan(spanId, context, timestampMs);
56
+ return bufferNativeCallWithId(id => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);
56
57
  }
57
58
 
58
59
  }
@@ -73,12 +74,17 @@ class DdRumWrapper {
73
74
 
74
75
  _defineProperty(this, "getStopActionNativeCall", args => {
75
76
  if (isNewStopActionAPI(args)) {
76
- return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now());
77
+ return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()));
77
78
  }
78
79
 
79
80
  if (isOldStopActionAPI(args)) {
80
81
  if (this.lastActionData) {
81
- return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
82
+ DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
83
+ const {
84
+ type,
85
+ name
86
+ } = this.lastActionData;
87
+ return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));
82
88
  }
83
89
 
84
90
  InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", SdkVerbosity.WARN);
@@ -92,12 +98,12 @@ class DdRumWrapper {
92
98
 
93
99
  startView(key, name, context = {}, timestampMs = timeProvider.now()) {
94
100
  InternalLog.log("Starting RUM View “" + name + "” #" + key, SdkVerbosity.DEBUG);
95
- return this.nativeRum.startView(key, name, context, timestampMs);
101
+ return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));
96
102
  }
97
103
 
98
104
  stopView(key, context = {}, timestampMs = timeProvider.now()) {
99
105
  InternalLog.log("Stopping RUM View #" + key, SdkVerbosity.DEBUG);
100
- return this.nativeRum.stopView(key, context, timestampMs);
106
+ return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));
101
107
  }
102
108
 
103
109
  startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
@@ -106,7 +112,7 @@ class DdRumWrapper {
106
112
  type,
107
113
  name
108
114
  };
109
- return this.nativeRum.startAction(type, name, context, timestampMs);
115
+ return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));
110
116
  }
111
117
 
112
118
  stopAction(...args) {
@@ -118,29 +124,29 @@ class DdRumWrapper {
118
124
 
119
125
  addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
120
126
  InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
121
- return this.nativeRum.addAction(type, name, context, timestampMs);
127
+ return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));
122
128
  }
123
129
 
124
130
  startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
125
131
  InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, SdkVerbosity.DEBUG);
126
- return this.nativeRum.startResource(key, method, url, context, timestampMs);
132
+ return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
127
133
  }
128
134
 
129
135
  stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
130
136
  InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, SdkVerbosity.DEBUG);
131
- return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
137
+ return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));
132
138
  }
133
139
 
134
140
  addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
135
141
  InternalLog.log("Adding RUM Error “" + message + "”", SdkVerbosity.DEBUG);
136
142
  let updatedContext = context;
137
143
  updatedContext["_dd.error.source_type"] = "react-native";
138
- return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
144
+ return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));
139
145
  }
140
146
 
141
147
  addTiming(name) {
142
148
  InternalLog.log("Adding timing “" + name + "” to RUM View", SdkVerbosity.DEBUG);
143
- return this.nativeRum.addTiming(name);
149
+ return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));
144
150
  }
145
151
 
146
152
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AACA,SAASC,kBAAT,QAAiH,SAAjH;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AAGA,MAAMC,YAAY,GAAG,IAAID,YAAJ,EAArB;;AAEA,MAAME,aAAN,CAA0C;AAAA;AAAA,wCAECN,aAAa,CAACO,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,yBAA0BF,OAA1B,GAAoC,GAApD,EAAyDN,YAAY,CAACS,KAAtE;AACA,WAAO,KAAKC,UAAL,CAAgBL,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDI,EAAAA,IAAI,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDN,YAAY,CAACS,KAArE;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBL,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDK,EAAAA,IAAI,CAACN,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDN,YAAY,CAACS,KAArE;AACA,WAAO,KAAKC,UAAL,CAAgBE,IAAhB,CAAqBN,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDM,EAAAA,KAAK,CAACP,OAAD,EAAkBC,OAAe,GAAG,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C,OAAe,GAAG,EAA7E,EAAiFW,WAAmB,GAAGhB,YAAY,CAACiB,GAAb,EAAvG,EAA0I;AAC9IpB,IAAAA,WAAW,CAACS,GAAZ,CAAgB,uBAAuBF,OAAvB,GAAiC,GAAjD,EAAsDN,YAAY,CAACS,KAAnE;AACA,QAAI6C,cAAmB,GAAG/C,OAA1B;AACA+C,IAAAA,cAAc,CAAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,KAAK1B,SAAL,CAAeuB,QAAf,CAAwB7C,OAAxB,EAAiC8C,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqEpC,WAArE,CAAP;AACH;;AAEDqC,EAAAA,SAAS,CAACvB,IAAD,EAA8B;AACnCjC,IAAAA,WAAW,CAACS,GAAZ,CAAgB,oBAAoBwB,IAApB,GAA2B,eAA3C,EAA4DhC,YAAY,CAACS,KAAzE;AACA,WAAO,KAAKmB,SAAL,CAAe2B,SAAf,CAAyBvB,IAAzB,CAAP;AACH;;AArEmC;;AAwExC,MAAMwB,KAAsB,GAAG3D,aAAa,CAAC2D,KAA7C;AACA,MAAMpD,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMa,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAAS5B,kBAAT,EAA6B0D,KAA7B,EAAoCpD,MAApC,EAA4CW,OAA5C,EAAqDY,KAArD","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';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
1
+ {"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","bufferNativeCallReturningId","bufferNativeCallWithId","bufferVoidNativeCall","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","id","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","DdSdk","telemetryDebug","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AACA,SAASC,kBAAT,QAAiH,SAAjH;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AAEA,SAASC,2BAAT,EAAsCC,sBAAtC,EAA8DC,oBAA9D,QAA0F,2CAA1F;AAEA,MAAMC,YAAY,GAAG,IAAIJ,YAAJ,EAArB;;AAEA,MAAMK,aAAN,CAA0C;AAAA;AAAA,wCAECT,aAAa,CAACU,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDX,IAAAA,WAAW,CAACY,GAAZ,CAAgB,yBAA0BF,OAA1B,GAAoC,GAApD,EAAyDT,YAAY,CAACY,KAAtE;AACA,WAAO,KAAKC,UAAL,CAAgBL,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDI,EAAAA,IAAI,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDX,IAAAA,WAAW,CAACY,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDT,YAAY,CAACY,KAArE;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBL,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDK,EAAAA,IAAI,CAACN,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDX,IAAAA,WAAW,CAACY,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,E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H;;AAvEmC;;AA0ExC,MAAMH,KAAsB,GAAGtC,aAAa,CAACsC,KAA7C;AACA,MAAM5B,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMc,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAAShC,kBAAT,EAA6BqC,KAA7B,EAAoC5B,MAApC,EAA4CW,OAA5C,EAAqDa,KAArD","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';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\nimport { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = bufferNativeCallReturningId(() =>this.nativeTrace.startSpan(operation, context, timestampMs));\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId((id) => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()))\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature')\n const {type, name} = this.lastActionData;\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
@@ -3,7 +3,8 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
6
+ import { DatadogProvider } from './DatadogProvider/DatadogProvider';
7
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
7
8
  import { DdSdkReactNative } from './DdSdkReactNative';
8
9
  import { InternalLog } from './InternalLog';
9
10
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -11,5 +12,5 @@ import { SdkVerbosity } from './SdkVerbosity';
11
12
  import { TrackingConsent } from './TrackingConsent';
12
13
  import { DdLogs, DdTrace, DdRum } from './foundation';
13
14
  import { RumActionType, ErrorSource } from './types';
14
- export { DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
15
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["DdSdkReactNativeConfiguration","DdSdkReactNative","InternalLog","ProxyConfiguration","ProxyType","SdkVerbosity","TrackingConsent","DdLogs","DdTrace","DdRum","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,6BAAT,QAA8C,iCAA9C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,sBAA9C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,cAAvC;AACA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,SAA3C;AAEA,SACIJ,MADJ,EAEIC,OAFJ,EAGIC,KAHJ,EAIIC,aAJJ,EAKIC,WALJ,EAMIX,6BANJ,EAOIC,gBAPJ,EAQIC,WARJ,EASIC,kBATJ,EAUIC,SAVJ,EAWIE,eAXJ,EAYID,YAZJ","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 { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["DatadogProvider","DatadogProviderConfiguration","DdSdkReactNativeConfiguration","InitializationMode","DdSdkReactNative","InternalLog","ProxyConfiguration","ProxyType","SdkVerbosity","TrackingConsent","DdLogs","DdTrace","DdRum","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,eAAT,QAAgC,mCAAhC;AACA,SACIC,4BADJ,EAEIC,6BAFJ,EAGIC,kBAHJ,QAIO,iCAJP;AAKA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,sBAA9C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,cAAvC;AACA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,SAA3C;AAEA,SACId,eADJ,EAEIC,4BAFJ,EAGIE,kBAHJ,EAIIO,MAJJ,EAKIC,OALJ,EAMIC,KANJ,EAOIC,aAPJ,EAQIC,WARJ,EASIZ,6BATJ,EAUIE,gBAVJ,EAWIC,WAXJ,EAYIC,kBAZJ,EAaIC,SAbJ,EAcIE,eAdJ,EAeID,YAfJ","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 { DatadogProvider } from './DatadogProvider/DatadogProvider';\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}