@datadog/mobile-react-native 2.3.5 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +6 -6
- package/android/build.gradle +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +15 -0
- package/android/src/test/resources/input/complete-configuration.json +5 -1
- package/datadog-configuration.schema.json +54 -9
- package/datadog-sourcemaps.gradle +64 -1
- package/ios/Sources/DatadogSDKWrapper.swift +3 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +2 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +10 -8
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +50 -48
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +182 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -57
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +18 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +4 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +4 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/argsUtils.js +43 -0
- package/lib/commonjs/utils/argsUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +2 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +9 -8
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/DdRum.js +48 -47
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +169 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +3 -54
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +13 -8
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +3 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/trace/DdTrace.js +3 -2
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/argsUtils.js +30 -0
- package/lib/module/utils/argsUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -1
- package/lib/typescript/rum/DdRum.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +12 -3
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +2 -3
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +111 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +1 -24
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +2 -0
- package/lib/typescript/utils/argsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +4 -1
- package/src/DdSdkReactNativeConfiguration.tsx +10 -4
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +32 -0
- package/src/logs/DdLogs.ts +9 -8
- package/src/logs/__tests__/DdLogs.test.ts +543 -0
- package/src/rum/DdRum.ts +112 -94
- package/src/rum/__tests__/DdRum.test.ts +552 -0
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +23 -7
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx +227 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/__utils__/TracingIdentifierUtils.ts +64 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +314 -42
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +4 -59
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +33 -19
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +7 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +134 -11
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +3 -0
- package/src/trace/DdTrace.ts +12 -2
- package/src/trace/__tests__/DdTrace.test.ts +146 -0
- package/src/utils/__tests__/argsUtils.test.ts +66 -0
- package/src/utils/argsUtils.ts +35 -0
- package/src/version.ts +1 -1
|
@@ -95,7 +95,8 @@ export class DdSdkReactNative {
|
|
|
95
95
|
|
|
96
96
|
if (configuration.trackInteractions) {
|
|
97
97
|
DdRumUserInteractionTracking.startTracking({
|
|
98
|
-
actionNameAttribute: configuration.actionNameAttribute
|
|
98
|
+
actionNameAttribute: configuration.actionNameAttribute,
|
|
99
|
+
useAccessibilityLabel: configuration.useAccessibilityLabel
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","SdkVerbosity","DdLogs","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","FileBasedConfiguration","UserInfoSingleton","DdSdkConfiguration","adaptLongTaskThreshold","version","sdkVersion","DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","initializeNativeSDK","initializationModeForTelemetry","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","isInitialized","_isInitialized","wasAutoInstrumented","log","WARN","trackInteractions","startTracking","actionNameAttribute","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","__DEV__","telemetryDebug","Promise","resolve","verbosity","initialize","buildConfiguration","INFO","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","getInstance","user","setUser","setUserInfo","consent","setTrackingConsent","clearAllData","additionalConfiguration","DD_SOURCE_KEY","DD_SDK_VERSION","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","nativeViewTracking","nativeInteractionTracking","proxyConfig","serviceName","bundleLogsWithRum","bundleLogsWithTraces"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,wEAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,mBAAT,QAAoC,+C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CAACqE,eAXX,EAYHrE,aAAa,CAACqD,uBAZX,EAaHrD,aAAa,CAACsE,mBAbX,EAcHtE,aAAa,CAACuE,qBAdX,EAeHvE,aAAa,CAACwE,eAfX,EAgBHxE,aAAa,CAACyE,SAhBX,EAiBHzE,aAAa,CAAC0E,iBAjBX,EAkBH1E,aAAa,CAAC2E,qBAlBX,EAmBH3E,aAAa,CAAC4E,eAnBX,EAoBH;AACIC,IAAAA,kBAAkB,EAAE9C,MAAM,CAAC5B,8BAD/B;AAEImB,IAAAA,WAAW,EAAEtB,aAAa,CAACsB,WAF/B;AAGIP,IAAAA,iBAAiB,EAAEf,aAAa,CAACe,iBAHrC;AAII+D,IAAAA,oBAAoB,EAAE9E,aAAa,CAACkB,cAJxC;AAKI;AACA6D,IAAAA,kBAAkB,EAAEC,OAAO,CAAC,2BAAD,CAAP,CACfpF,OAPT;AAQI;AACAqF,IAAAA,YAAY,EAAED,OAAO,CAAC,oBAAD,CAAP,CAA8BpF;AAThD,GApBG,EA+BHI,aAAa,CAACkF,kBA/BX,EAgCHlF,aAAa,CAACmF,yBAhCX,EAiCHnF,aAAa,CAACoC,SAjCX,EAkCHpC,aAAa,CAACoF,WAlCX,EAmCHpF,aAAa,CAACqF,WAnCX,EAoCHxG,qBAAqB,CAACmB,aAAa,CAACqB,eAAf,CApClB,EAqCHrB,aAAa,CAACsF,iBArCX,EAsCHtF,aAAa,CAACuF,oBAtCX,CAAP;AAwCH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\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_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n private static _isInitialized = 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 = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative._isInitialized) {\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 await DdSdk.initialize(\n DdSdkReactNative.buildConfiguration(configuration, params)\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative._isInitialized = 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 instanceof FileBasedConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'FILE'\n });\n }\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n };\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n };\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n };\n\n /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\n };\n\n /**\n * Returns `true` if the SDK was initialized, `false` otherwise.\n */\n public static isInitialized() {\n return DdSdkReactNative._isInitialized;\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): DdSdkConfiguration => {\n configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n\n if (configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\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.additionalConfiguration[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n return 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.additionalConfiguration,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n },\n configuration.nativeViewTracking,\n configuration.nativeInteractionTracking,\n configuration.verbosity,\n configuration.proxyConfig,\n configuration.serviceName,\n formatFirstPartyHosts(configuration.firstPartyHosts),\n configuration.bundleLogsWithRum,\n configuration.bundleLogsWithTraces\n );\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking({\n actionNameAttribute: configuration.actionNameAttribute\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","SdkVerbosity","DdLogs","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","FileBasedConfiguration","UserInfoSingleton","DdSdkConfiguration","adaptLongTaskThreshold","version","sdkVersion","DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","initializeNativeSDK","initializationModeForTelemetry","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","isInitialized","_isInitialized","wasAutoInstrumented","log","WARN","trackInteractions","startTracking","actionNameAttribute","useAccessibilityLabel","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","__DEV__","telemetryDebug","Promise","resolve","verbosity","initialize","buildConfiguration","INFO","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","getInstance","user","setUser","setUserInfo","consent","setTrackingConsent","clearAllData","additionalConfiguration","DD_SOURCE_KEY","DD_SDK_VERSION","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","nativeViewTracking","nativeInteractionTracking","proxyConfig","serviceName","bundleLogsWithRum","bundleLogsWithTraces"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,wEAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,mBAAT,QAAoC,+CAApC;AAEA,SAASC,eAAT,QAAgC,8CAAhC;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,sBAAT,QA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AAa,CAACsD,uBAZX,EAaHtD,aAAa,CAACuE,mBAbX,EAcHvE,aAAa,CAACwE,qBAdX,EAeHxE,aAAa,CAACyE,eAfX,EAgBHzE,aAAa,CAAC0E,SAhBX,EAiBH1E,aAAa,CAAC2E,iBAjBX,EAkBH3E,aAAa,CAAC4E,qBAlBX,EAmBH5E,aAAa,CAAC6E,eAnBX,EAoBH;AACIC,IAAAA,kBAAkB,EAAE9C,MAAM,CAAC7B,8BAD/B;AAEIoB,IAAAA,WAAW,EAAEvB,aAAa,CAACuB,WAF/B;AAGIR,IAAAA,iBAAiB,EAAEf,aAAa,CAACe,iBAHrC;AAIIgE,IAAAA,oBAAoB,EAAE/E,aAAa,CAACmB,cAJxC;AAKI;AACA6D,IAAAA,kBAAkB,EAAEC,OAAO,CAAC,2BAAD,CAAP,CACfrF,OAPT;AAQI;AACAsF,IAAAA,YAAY,EAAED,OAAO,CAAC,oBAAD,CAAP,CAA8BrF;AAThD,GApBG,EA+BHI,aAAa,CAACmF,kBA/BX,EAgCHnF,aAAa,CAACoF,yBAhCX,EAiCHpF,aAAa,CAACqC,SAjCX,EAkCHrC,aAAa,CAACqF,WAlCX,EAmCHrF,aAAa,CAACsF,WAnCX,EAoCHzG,qBAAqB,CAACmB,aAAa,CAACsB,eAAf,CApClB,EAqCHtB,aAAa,CAACuF,iBArCX,EAsCHvF,aAAa,CAACwF,oBAtCX,CAAP;AAwCH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\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_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n private static _isInitialized = 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 = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative._isInitialized) {\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 await DdSdk.initialize(\n DdSdkReactNative.buildConfiguration(configuration, params)\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative._isInitialized = 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 instanceof FileBasedConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'FILE'\n });\n }\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n };\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n };\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n };\n\n /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\n };\n\n /**\n * Returns `true` if the SDK was initialized, `false` otherwise.\n */\n public static isInitialized() {\n return DdSdkReactNative._isInitialized;\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): DdSdkConfiguration => {\n configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n\n if (configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\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.additionalConfiguration[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n return 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.additionalConfiguration,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n },\n configuration.nativeViewTracking,\n configuration.nativeInteractionTracking,\n configuration.verbosity,\n configuration.proxyConfig,\n configuration.serviceName,\n formatFirstPartyHosts(configuration.firstPartyHosts),\n configuration.bundleLogsWithRum,\n configuration.bundleLogsWithTraces\n );\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\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking({\n actionNameAttribute: configuration.actionNameAttribute,\n useAccessibilityLabel: configuration.useAccessibilityLabel\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
@@ -76,7 +76,8 @@ export const DEFAULTS = {
|
|
|
76
76
|
trackBackgroundEvents: false,
|
|
77
77
|
getCustomEndpoints: () => ({}),
|
|
78
78
|
bundleLogsWithRum: true,
|
|
79
|
-
bundleLogsWithTraces: true
|
|
79
|
+
bundleLogsWithTraces: true,
|
|
80
|
+
useAccessibilityLabel: true
|
|
80
81
|
};
|
|
81
82
|
/**
|
|
82
83
|
* The SDK configuration class.
|
|
@@ -219,7 +220,7 @@ export class DdSdkReactNativeConfiguration {
|
|
|
219
220
|
*
|
|
220
221
|
* `dd-action-name` is favored when both attributes are present on an element.
|
|
221
222
|
*/
|
|
222
|
-
constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
|
|
223
|
+
constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent, useAccessibilityLabel = DEFAULTS.useAccessibilityLabel) {
|
|
223
224
|
this.clientToken = clientToken;
|
|
224
225
|
this.env = env;
|
|
225
226
|
this.applicationId = applicationId;
|
|
@@ -227,6 +228,7 @@ export class DdSdkReactNativeConfiguration {
|
|
|
227
228
|
this.trackResources = trackResources;
|
|
228
229
|
this.trackErrors = trackErrors;
|
|
229
230
|
this.trackingConsent = trackingConsent;
|
|
231
|
+
this.useAccessibilityLabel = useAccessibilityLabel;
|
|
230
232
|
|
|
231
233
|
_defineProperty(this, "nativeCrashReportEnabled", DEFAULTS.nativeCrashReportEnabled);
|
|
232
234
|
|
|
@@ -306,7 +308,8 @@ export const addDefaultValuesToAutoInstrumentationConfiguration = features => {
|
|
|
306
308
|
logEventMapper: features.logEventMapper === undefined ? DEFAULTS.logEventMapper : features.logEventMapper,
|
|
307
309
|
errorEventMapper: features.errorEventMapper === undefined ? DEFAULTS.errorEventMapper : features.errorEventMapper,
|
|
308
310
|
resourceEventMapper: features.resourceEventMapper === undefined ? DEFAULTS.resourceEventMapper : features.resourceEventMapper,
|
|
309
|
-
actionEventMapper: features.actionEventMapper === undefined ? DEFAULTS.actionEventMapper : features.actionEventMapper
|
|
311
|
+
actionEventMapper: features.actionEventMapper === undefined ? DEFAULTS.actionEventMapper : features.actionEventMapper,
|
|
312
|
+
useAccessibilityLabel: DEFAULTS.useAccessibilityLabel
|
|
310
313
|
};
|
|
311
314
|
};
|
|
312
315
|
|
|
@@ -323,7 +326,7 @@ export const buildConfigurationFromPartialConfiguration = (features, configurati
|
|
|
323
326
|
applicationId,
|
|
324
327
|
...remainingConfiguration
|
|
325
328
|
} = configuration;
|
|
326
|
-
const SdkConfiguration = new DdSdkReactNativeConfiguration(clientToken, env, applicationId, features.trackInteractions, features.trackResources, features.trackErrors, configuration.trackingConsent);
|
|
329
|
+
const SdkConfiguration = new DdSdkReactNativeConfiguration(clientToken, env, applicationId, features.trackInteractions, features.trackResources, features.trackErrors, configuration.trackingConsent, features.useAccessibilityLabel);
|
|
327
330
|
Object.keys(remainingConfiguration).forEach(name => {
|
|
328
331
|
setConfigurationAttribute({
|
|
329
332
|
value: remainingConfiguration[name],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","PropagatorType","VitalsUpdateFrequency","UploadFrequency","BatchSize","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","DATADOG","TRACECONTEXT","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfiguration","trackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","uploadFrequency","batchSize","MEDIUM","trackBackgroundEvents","getCustomEndpoints","bundleLogsWithRum","bundleLogsWithTraces","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","actionNameAttribute","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAMA,SAASC,cAAT,QAA+B,aAA/B;AAEA,WAAYC,qBAAZ;;WAAYA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;G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,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACpB;AAFpB,GADqB,EAKrB4B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACnB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACY;AAFpB,GADqB,EAKrBJ,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CA7EM;AA+EP,OAAO,MAAMK,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;AAIhF,WAAYD,kBAAZ;;WAAYA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,KAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\nexport type CustomEndpoints = {\n rum?: string;\n logs?: string;\n trace?: string;\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [\n PropagatorType.DATADOG,\n PropagatorType.TRACECONTEXT\n ]\n };\n }\n return host;\n });\n};\n\nexport const DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfiguration: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false,\n getCustomEndpoints: () => ({}),\n bundleLogsWithRum: true,\n bundleLogsWithTraces: true\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 platforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\n\n /**\n * Enables RUM correlation with logs.\n *\n * By default, RUM is enabled for logs.\n */\n public bundleLogsWithRum: boolean = DEFAULTS.bundleLogsWithRum;\n\n /**\n * Enables Traces correlation with logs.\n *\n * By default, Traces is enabled for logs.\n */\n public bundleLogsWithTraces: boolean = DEFAULTS.bundleLogsWithTraces;\n\n /**\n * Specifies a custom prop to name RUM actions on elements having an `onPress` prop.\n *\n * For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:\n *\n * ```js\n * <TouchableOpacity testID=\"Dismiss notification\" onPress={() => dismiss()}>\n * ```\n *\n * `dd-action-name` is favored when both attributes are present on an element.\n */\n public actionNameAttribute?: string;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfiguration: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfiguration();\n\n public customEndpoints: CustomEndpoints = DEFAULTS.getCustomEndpoints();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfiguration?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\n readonly customEndpoints?: CustomEndpoints;\n readonly bundleLogsWithRum?: boolean;\n readonly bundleLogsWithTraces?: boolean;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionNameAttribute',\n value: features.actionNameAttribute\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL'\n | 'FILE';\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","PropagatorType","VitalsUpdateFrequency","UploadFrequency","BatchSize","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","DATADOG","TRACECONTEXT","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfiguration","trackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","uploadFrequency","batchSize","MEDIUM","trackBackgroundEvents","getCustomEndpoints","bundleLogsWithRum","bundleLogsWithTraces","useAccessibilityLabel","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","actionNameAttribute","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;AAAA;AACA;AACA;AACA;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A,KAAK,EAAEJ,QAAQ,CAAC9C;AAA3C,GADqB,EAErBsD,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACvB;AAFpB,GADqB,EAKrB+B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACtB;AAFpB,GADqB,EAKrB8B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACrB;AAFpB,GADqB,EAKrB6B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACpB;AAFpB,GADqB,EAKrB4B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACY;AAFpB,GADqB,EAKrBJ,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CA9EM;AAgFP,OAAO,MAAMK,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;AAIhF,WAAYD,kBAAZ;;WAAYA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,KAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\nexport type CustomEndpoints = {\n rum?: string;\n logs?: string;\n trace?: string;\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [\n PropagatorType.DATADOG,\n PropagatorType.TRACECONTEXT\n ]\n };\n }\n return host;\n });\n};\n\nexport const DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfiguration: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false,\n getCustomEndpoints: () => ({}),\n bundleLogsWithRum: true,\n bundleLogsWithTraces: true,\n useAccessibilityLabel: true\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 platforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\n\n /**\n * Enables RUM correlation with logs.\n *\n * By default, RUM is enabled for logs.\n */\n public bundleLogsWithRum: boolean = DEFAULTS.bundleLogsWithRum;\n\n /**\n * Enables Traces correlation with logs.\n *\n * By default, Traces is enabled for logs.\n */\n public bundleLogsWithTraces: boolean = DEFAULTS.bundleLogsWithTraces;\n\n /**\n * Specifies a custom prop to name RUM actions on elements having an `onPress` prop.\n *\n * For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:\n *\n * ```js\n * <TouchableOpacity testID=\"Dismiss notification\" onPress={() => dismiss()}>\n * ```\n *\n * `dd-action-name` is favored when both attributes are present on an element.\n */\n public actionNameAttribute?: string;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfiguration: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfiguration();\n\n public customEndpoints: CustomEndpoints = DEFAULTS.getCustomEndpoints();\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 readonly useAccessibilityLabel: boolean = DEFAULTS.useAccessibilityLabel\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n readonly useAccessibilityLabel?: boolean;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n readonly useAccessibilityLabel: boolean;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper,\n useAccessibilityLabel: DEFAULTS.useAccessibilityLabel\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfiguration?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\n readonly customEndpoints?: CustomEndpoints;\n readonly bundleLogsWithRum?: boolean;\n readonly bundleLogsWithTraces?: boolean;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent,\n features.useAccessibilityLabel\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionNameAttribute',\n value: features.actionNameAttribute\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL'\n | 'FILE';\n"]}
|
|
@@ -7,6 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
*/
|
|
8
8
|
import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
|
|
9
9
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
10
|
+
import { validateContext } from '../utils/argsUtils';
|
|
10
11
|
import { generateEventMapper } from './eventMapper';
|
|
11
12
|
const SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';
|
|
12
13
|
|
|
@@ -29,34 +30,34 @@ class DdLogsWrapper {
|
|
|
29
30
|
|
|
30
31
|
_defineProperty(this, "debug", (...args) => {
|
|
31
32
|
if (isLogWithError(args)) {
|
|
32
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4]
|
|
33
|
+
return this.logWithError(args[0], args[1], args[2], args[3], validateContext(args[4]), 'debug');
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
return this.log(args[0], args[1]
|
|
36
|
+
return this.log(args[0], validateContext(args[1]), 'debug');
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
_defineProperty(this, "info", (...args) => {
|
|
39
40
|
if (isLogWithError(args)) {
|
|
40
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4]
|
|
41
|
+
return this.logWithError(args[0], args[1], args[2], args[3], validateContext(args[4]), 'info');
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
return this.log(args[0], args[1]
|
|
44
|
+
return this.log(args[0], validateContext(args[1]), 'info');
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
_defineProperty(this, "warn", (...args) => {
|
|
47
48
|
if (isLogWithError(args)) {
|
|
48
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4]
|
|
49
|
+
return this.logWithError(args[0], args[1], args[2], args[3], validateContext(args[4]), 'warn');
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
return this.log(args[0], args[1]
|
|
52
|
+
return this.log(args[0], validateContext(args[1]), 'warn');
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
_defineProperty(this, "error", (...args) => {
|
|
55
56
|
if (isLogWithError(args)) {
|
|
56
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4]
|
|
57
|
+
return this.logWithError(args[0], args[1], args[2], args[3], validateContext(args[4]), 'error');
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
return this.log(args[0], args[1]
|
|
60
|
+
return this.log(args[0], validateContext(args[1]), 'error');
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
_defineProperty(this, "printLogDroppedSdkNotInitialized", (message, status) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdLogs.ts"],"names":["DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","generateEventMapper","SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","require","default","undefined","logWithError","log","message","status","__DEV__","console","warn","DEBUG","context","event","logEventMapper","applyEventMapper","printLogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","registerLogEventMapper","unregisterLogEventMapper","DdLogs"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,sBAAT,EAAiCC,WAAjC,QAAoD,gBAApD;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAGA,SAASC,mBAAT,QAAoC,eAApC;AASA,MAAMC,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;AAEA;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAChBC,IADmB,IAEa;AAChC,SACI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IACA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QADnB,IAEA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAFnB,IAGA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAJvB;AAMH,CATD;;AAWA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,OAAO,CAAC,uBAAD,CAAP,CAClCC,OAHiC;;AAAA,4CAIbT,mBAAmB,CAACU,SAAD,CAJN;;AAAA,mCAM9B,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,KAAK,CAACD,OAAX;AAAoB,mCAAyB;AAA7C,SALS,CAAb;AAOH,OARD,CAQE,OAAOO,KAAP,EAAc;AACZ;AACA;AACA,YAAIA,KAAK,CAACb,OAAN,KAAkBZ,2BAAtB,EAAmD;AAC/C,eAAK0B,gCAAL,CAAsCd,OAAtC,EAA+CC,MAA/C;AACA,iBAAOZ,oBAAoB,EAA3B;AACH;;AAED,cAAMwB,KAAN;AACH;AACJ,KAvKqC;AAAA;;AAyKtCK,EAAAA,sBAAsB,CAACV,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsBrB,mBAAmB,CAACqB,cAAD,CAAzC;AACH;;AAEDW,EAAAA,wBAAwB,GAAG;AACvB,SAAKX,cAAL,GAAsBrB,mBAAmB,CAACU,SAAD,CAAzC;AACH;;AA/KqC;;AAkL1C,OAAO,MAAMuB,MAAM,GAAG,IAAI1B,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeLogs: DdNativeLogsType = require('../specs/NativeDdLogs')\n .default;\n private logEventMapper = generateEventMapper(undefined);\n\n debug = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n };\n\n info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n };\n\n warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n };\n\n error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n };\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printLogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printLogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printLogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
|
|
1
|
+
{"version":3,"sources":["DdLogs.ts"],"names":["DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","validateContext","generateEventMapper","SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","require","default","undefined","logWithError","log","message","status","__DEV__","console","warn","DEBUG","context","event","logEventMapper","applyEventMapper","printLogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","registerLogEventMapper","unregisterLogEventMapper","DdLogs"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,sBAAT,EAAiCC,WAAjC,QAAoD,gBAApD;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,eAAT,QAAgC,oBAAhC;AAEA,SAASC,mBAAT,QAAoC,eAApC;AASA,MAAMC,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;AAEA;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAChBC,IADmB,IAEa;AAChC,SACI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IACA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QADnB,IAEA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAFnB,IAGA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAJvB;AAMH,CATD;;AAWA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,OAAO,CAAC,uBAAD,CAAP,CAClCC,OAHiC;;AAAA,4CAIbT,mBAAmB,CAACU,SAAD,CAJN;;AAAA,mCAM9B,CAAC,GAAGJ,IAAJ,KAAkE;AACtE,UAAID,cAAc,CAACC,IAAD,CAAlB,EAA0B;AACtB,eAAO,KAAKK,YAAL,CACHL,IAAI,CAAC,CAAD,CADD,EAEHA,IAAI,CAAC,CAAD,CAFD,EAGHA,IAAI,CAAC,CAAD,CAHD,EAIHA,IAAI,CAAC,CAAD,CAJD,EA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AAsCd,OAAtC,EAA+CC,MAA/C;AACA,iBAAOZ,oBAAoB,EAA3B;AACH;;AAED,cAAMwB,KAAN;AACH;AACJ,KAvKqC;AAAA;;AAyKtCK,EAAAA,sBAAsB,CAACV,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsBrB,mBAAmB,CAACqB,cAAD,CAAzC;AACH;;AAEDW,EAAAA,wBAAwB,GAAG;AACvB,SAAKX,cAAL,GAAsBrB,mBAAmB,CAACU,SAAD,CAAzC;AACH;;AA/KqC;;AAkL1C,OAAO,MAAMuB,MAAM,GAAG,IAAI1B,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\nimport { validateContext } from '../utils/argsUtils';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeLogs: DdNativeLogsType = require('../specs/NativeDdLogs')\n .default;\n private logEventMapper = generateEventMapper(undefined);\n\n debug = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n validateContext(args[4]),\n 'debug'\n );\n }\n return this.log(args[0], validateContext(args[1]), 'debug');\n };\n\n info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n validateContext(args[4]),\n 'info'\n );\n }\n return this.log(args[0], validateContext(args[1]), 'info');\n };\n\n warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n validateContext(args[4]),\n 'warn'\n );\n }\n return this.log(args[0], validateContext(args[1]), 'warn');\n };\n\n error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n validateContext(args[4]),\n 'error'\n );\n }\n return this.log(args[0], validateContext(args[1]), 'error');\n };\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printLogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printLogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printLogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
|
package/lib/module/rum/DdRum.js
CHANGED
|
@@ -10,6 +10,7 @@ import { InternalLog } from '../InternalLog';
|
|
|
10
10
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
11
11
|
import { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';
|
|
12
12
|
import { DdSdk } from '../sdk/DdSdk';
|
|
13
|
+
import { validateContext } from '../utils/argsUtils';
|
|
13
14
|
import { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';
|
|
14
15
|
import { generateActionEventMapper } from './eventMappers/actionEventMapper';
|
|
15
16
|
import { generateErrorEventMapper } from './eventMappers/errorEventMapper';
|
|
@@ -33,12 +34,12 @@ class DdRumWrapper {
|
|
|
33
34
|
|
|
34
35
|
_defineProperty(this, "startView", (key, name, context = {}, timestampMs = this.timeProvider.now()) => {
|
|
35
36
|
InternalLog.log(`Starting RUM View “${name}” #${key}`, SdkVerbosity.DEBUG);
|
|
36
|
-
return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));
|
|
37
|
+
return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, validateContext(context), timestampMs));
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
_defineProperty(this, "stopView", (key, context = {}, timestampMs = this.timeProvider.now()) => {
|
|
40
41
|
InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);
|
|
41
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));
|
|
42
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopView(key, validateContext(context), timestampMs));
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
_defineProperty(this, "startAction", (type, name, context = {}, timestampMs = this.timeProvider.now()) => {
|
|
@@ -47,7 +48,7 @@ class DdRumWrapper {
|
|
|
47
48
|
type,
|
|
48
49
|
name
|
|
49
50
|
};
|
|
50
|
-
return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));
|
|
51
|
+
return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, validateContext(context), timestampMs));
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
_defineProperty(this, "stopAction", (...args) => {
|
|
@@ -66,51 +67,11 @@ class DdRumWrapper {
|
|
|
66
67
|
this.timeProvider = timeProvider;
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
_defineProperty(this, "callNativeStopAction", (type, name, context, timestampMs) => {
|
|
70
|
-
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
71
|
-
type,
|
|
72
|
-
name,
|
|
73
|
-
context,
|
|
74
|
-
timestampMs
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (!mappedEvent) {
|
|
78
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, {
|
|
79
|
-
'_dd.action.drop_action': true
|
|
80
|
-
}, timestampMs));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopAction(mappedEvent.type, mappedEvent.name, mappedEvent.context, mappedEvent.timestampMs));
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
_defineProperty(this, "getStopActionNativeCallArgs", args => {
|
|
87
|
-
if (isNewStopActionAPI(args)) {
|
|
88
|
-
return [args[0], args[1], args[2] || {}, args[3] || this.timeProvider.now()];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (isOldStopActionAPI(args)) {
|
|
92
|
-
if (this.lastActionData) {
|
|
93
|
-
DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
|
|
94
|
-
const {
|
|
95
|
-
type,
|
|
96
|
-
name
|
|
97
|
-
} = this.lastActionData;
|
|
98
|
-
return [type, name, args[0] || {}, args[1] || this.timeProvider.now()];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
InternalLog.log('DdRum.startAction needs to be called before DdRum.stopAction', SdkVerbosity.WARN);
|
|
102
|
-
} else {
|
|
103
|
-
InternalLog.log('DdRum.stopAction was called with wrong arguments', SdkVerbosity.WARN);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return null;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
70
|
_defineProperty(this, "addAction", (type, name, context = {}, timestampMs = this.timeProvider.now(), actionContext) => {
|
|
110
71
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
111
72
|
type,
|
|
112
73
|
name,
|
|
113
|
-
context,
|
|
74
|
+
context: validateContext(context),
|
|
114
75
|
timestampMs,
|
|
115
76
|
actionContext
|
|
116
77
|
});
|
|
@@ -125,7 +86,7 @@ class DdRumWrapper {
|
|
|
125
86
|
|
|
126
87
|
_defineProperty(this, "startResource", (key, method, url, context = {}, timestampMs = this.timeProvider.now()) => {
|
|
127
88
|
InternalLog.log(`Starting RUM Resource #${key} ${method}: ${url}`, SdkVerbosity.DEBUG);
|
|
128
|
-
return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
|
|
89
|
+
return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, validateContext(context), timestampMs));
|
|
129
90
|
});
|
|
130
91
|
|
|
131
92
|
_defineProperty(this, "stopResource", (key, statusCode, kind, size = -1, context = {}, timestampMs = this.timeProvider.now(), resourceContext) => {
|
|
@@ -134,7 +95,7 @@ class DdRumWrapper {
|
|
|
134
95
|
statusCode,
|
|
135
96
|
kind,
|
|
136
97
|
size,
|
|
137
|
-
context,
|
|
98
|
+
context: validateContext(context),
|
|
138
99
|
timestampMs,
|
|
139
100
|
resourceContext
|
|
140
101
|
});
|
|
@@ -159,7 +120,7 @@ class DdRumWrapper {
|
|
|
159
120
|
message,
|
|
160
121
|
source,
|
|
161
122
|
stacktrace,
|
|
162
|
-
context,
|
|
123
|
+
context: validateContext(context),
|
|
163
124
|
timestampMs
|
|
164
125
|
});
|
|
165
126
|
|
|
@@ -189,6 +150,46 @@ class DdRumWrapper {
|
|
|
189
150
|
value
|
|
190
151
|
}));
|
|
191
152
|
});
|
|
153
|
+
|
|
154
|
+
_defineProperty(this, "callNativeStopAction", (type, name, context, timestampMs) => {
|
|
155
|
+
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
156
|
+
type,
|
|
157
|
+
name,
|
|
158
|
+
context: validateContext(context),
|
|
159
|
+
timestampMs
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (!mappedEvent) {
|
|
163
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, {
|
|
164
|
+
'_dd.action.drop_action': true
|
|
165
|
+
}, timestampMs));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopAction(mappedEvent.type, mappedEvent.name, mappedEvent.context, mappedEvent.timestampMs));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
_defineProperty(this, "getStopActionNativeCallArgs", args => {
|
|
172
|
+
if (isNewStopActionAPI(args)) {
|
|
173
|
+
return [args[0], args[1], validateContext(args[2]), args[3] || this.timeProvider.now()];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (isOldStopActionAPI(args)) {
|
|
177
|
+
if (this.lastActionData) {
|
|
178
|
+
DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
|
|
179
|
+
const {
|
|
180
|
+
type,
|
|
181
|
+
name
|
|
182
|
+
} = this.lastActionData;
|
|
183
|
+
return [type, name, validateContext(args[0]), args[1] || this.timeProvider.now()];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
InternalLog.log('DdRum.startAction needs to be called before DdRum.stopAction', SdkVerbosity.WARN);
|
|
187
|
+
} else {
|
|
188
|
+
InternalLog.log('DdRum.stopAction was called with wrong arguments', SdkVerbosity.WARN);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return null;
|
|
192
|
+
});
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
async getCurrentSessionId() {
|