@datadog/mobile-react-native 1.6.0 → 1.7.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 +2 -2
- package/android/build.gradle +2 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +16 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +6 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +6 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +17 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +120 -28
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +17 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +15 -0
- package/ios/Sources/DdRum.m +5 -0
- package/ios/Sources/DdRum.swift +10 -0
- package/ios/Sources/DdSdk.swift +38 -0
- package/ios/Sources/DdSdkConfiguration.swift +12 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +6 -0
- package/lib/commonjs/DdSdkReactNative.js +1 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +45 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +8 -0
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -2
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/types.js +4 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +1 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +42 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +7 -0
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +4 -2
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +47 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/nativeModulesTypes.d.ts +7 -0
- package/lib/typescript/rum/DdRum.d.ts +1 -0
- package/lib/typescript/types.d.ts +4 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +3 -0
- package/src/DdSdkReactNativeConfiguration.tsx +56 -1
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +20 -3
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +47 -25
- package/src/index.tsx +6 -2
- package/src/nativeModulesTypes.ts +8 -0
- package/src/rum/DdRum.ts +12 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +5 -2
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +3 -0
- package/src/types.tsx +3 -0
- package/src/version.ts +1 -1
|
@@ -232,7 +232,7 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
|
|
|
232
232
|
|
|
233
233
|
_InternalLog.InternalLog.verbosity = configuration.verbosity;
|
|
234
234
|
DdSdkReactNative.buildConfiguration(configuration);
|
|
235
|
-
await _DdSdk.DdSdk.initialize(new _types.DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.nativeLongTaskThresholdMs), (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.longTaskThresholdMs), configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig, configuration.telemetrySampleRate, configuration.vitalsUpdateFrequency, configuration.trackFrustrations, {
|
|
235
|
+
await _DdSdk.DdSdk.initialize(new _types.DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.nativeLongTaskThresholdMs), (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.longTaskThresholdMs), configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig, configuration.telemetrySampleRate, configuration.vitalsUpdateFrequency, configuration.uploadFrequency, configuration.batchSize, configuration.trackFrustrations, configuration.trackBackgroundEvents, {
|
|
236
236
|
initializationType: params.initializationModeForTelemetry,
|
|
237
237
|
trackErrors: configuration.trackErrors,
|
|
238
238
|
trackInteractions: configuration.trackInteractions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","initializationType","trackNetworkRequests","reactNativeVersion","require","version","reactVersion","INFO","BufferSingleton","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,gBAAN,CAAuB;AAY1B;;AAWA;AACJ;AACA;AACA;AACA;AAC2B,eAAVC,UAAU,CACnBC,aADmB,EAEN;AACb,UAAMF,gBAAgB,CAACG,mBAAjB,CAAqCD,aAArC,EAAoD;AACtDE,MAAAA,8BAA8B,EAAE;AADsB,KAApD,CAAN;AAGAJ,IAAAA,gBAAgB,CAACK,cAAjB,CAAgCH,aAAhC;AACH;;AA4DD;AACJ;AACA;AAC+C,eAA9BI,8BAA8B,CACvCJ,aADuC,EAE1B;AACbF,IAAAA,gBAAg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Q,QADhB;AAEH;AACJ;AACJ;;AAED,MAAItG,aAAa,CAAC6G,WAAlB,EAA+B;AAC3B7G,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAACgH,eAAhD,IACI9G,aAAa,CAAC6G,WADlB;AAEH;;AAED,MAAI7G,aAAa,CAACiF,OAAlB,EAA2B;AACvBjF,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAACiH,UAAhD,IAA+D,GAC3D/G,aAAa,CAACiF,OACjB,GACGjF,aAAa,CAACgH,aAAd,GACO,IAAGhH,aAAa,CAACgH,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAIhH,aAAa,CAACgH,aAAd,IAA+B,CAAChH,aAAa,CAACiF,OAAlD,EAA2D;AACvDjF,IAAAA,aAAa,CAACyE,gBAAd,CACI3E,gBAAgB,CAACmH,iBADrB,IAEK,IAAGjH,aAAa,CAACgH,aAAc,EAFpC;AAGH;;AAEDhH,EAAAA,aAAa,CAACyE,gBAAd,CACI,uBADJ,IAEI,0DAAsBzE,aAAa,CAACwC,eAApC,CAFJ;AAGH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.trackFrustrations,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\n ) => {\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(configuration.firstPartyHosts);\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","initializationType","trackNetworkRequests","reactNativeVersion","require","version","reactVersion","INFO","BufferSingleton","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME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AAGH;;AAEDnH,EAAAA,aAAa,CAACyE,gBAAd,CACI,uBADJ,IAEI,0DAAsBzE,aAAa,CAACwC,eAApC,CAFJ;AAGH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\n ) => {\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(configuration.firstPartyHosts);\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.formatFirstPartyHosts = exports.VitalsUpdateFrequency = void 0;
|
|
6
|
+
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.formatFirstPartyHosts = exports.BatchSize = exports.UploadFrequency = exports.VitalsUpdateFrequency = void 0;
|
|
7
7
|
|
|
8
8
|
var _TrackingConsent = require("./TrackingConsent");
|
|
9
9
|
|
|
@@ -21,6 +21,24 @@ exports.VitalsUpdateFrequency = VitalsUpdateFrequency;
|
|
|
21
21
|
VitalsUpdateFrequency["NEVER"] = "NEVER";
|
|
22
22
|
})(VitalsUpdateFrequency || (exports.VitalsUpdateFrequency = VitalsUpdateFrequency = {}));
|
|
23
23
|
|
|
24
|
+
let UploadFrequency;
|
|
25
|
+
exports.UploadFrequency = UploadFrequency;
|
|
26
|
+
|
|
27
|
+
(function (UploadFrequency) {
|
|
28
|
+
UploadFrequency["FREQUENT"] = "FREQUENT";
|
|
29
|
+
UploadFrequency["AVERAGE"] = "AVERAGE";
|
|
30
|
+
UploadFrequency["RARE"] = "RARE";
|
|
31
|
+
})(UploadFrequency || (exports.UploadFrequency = UploadFrequency = {}));
|
|
32
|
+
|
|
33
|
+
let BatchSize;
|
|
34
|
+
exports.BatchSize = BatchSize;
|
|
35
|
+
|
|
36
|
+
(function (BatchSize) {
|
|
37
|
+
BatchSize["LARGE"] = "LARGE";
|
|
38
|
+
BatchSize["MEDIUM"] = "MEDIUM";
|
|
39
|
+
BatchSize["SMALL"] = "SMALL";
|
|
40
|
+
})(BatchSize || (exports.BatchSize = BatchSize = {}));
|
|
41
|
+
|
|
24
42
|
const isLegacyFirstPartyHost = firstPartyHost => {
|
|
25
43
|
return typeof firstPartyHost === 'string';
|
|
26
44
|
};
|
|
@@ -62,7 +80,10 @@ const DEFAULTS = {
|
|
|
62
80
|
errorEventMapper: null,
|
|
63
81
|
resourceEventMapper: null,
|
|
64
82
|
actionEventMapper: null,
|
|
65
|
-
trackFrustrations: true
|
|
83
|
+
trackFrustrations: true,
|
|
84
|
+
uploadFrequency: UploadFrequency.AVERAGE,
|
|
85
|
+
batchSize: BatchSize.MEDIUM,
|
|
86
|
+
trackBackgroundEvents: false
|
|
66
87
|
};
|
|
67
88
|
/**
|
|
68
89
|
* The SDK configuration class.
|
|
@@ -165,6 +186,22 @@ class DdSdkReactNativeConfiguration {
|
|
|
165
186
|
/**
|
|
166
187
|
* Enables tracking of frustration signals (error taps). Defaults to `true`.
|
|
167
188
|
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Sets the preferred frequency for uploading batches of data.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.
|
|
196
|
+
* Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Enables tracking of RUM event when no RUM View is active.
|
|
201
|
+
*
|
|
202
|
+
* By default, background events are not tracked. Enabling this feature might increase the
|
|
203
|
+
* number of sessions tracked and impact your billing.
|
|
204
|
+
*/
|
|
168
205
|
constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
|
|
169
206
|
this.clientToken = clientToken;
|
|
170
207
|
this.env = env;
|
|
@@ -210,6 +247,12 @@ class DdSdkReactNativeConfiguration {
|
|
|
210
247
|
|
|
211
248
|
_defineProperty(this, "trackFrustrations", DEFAULTS.trackFrustrations);
|
|
212
249
|
|
|
250
|
+
_defineProperty(this, "uploadFrequency", DEFAULTS.uploadFrequency);
|
|
251
|
+
|
|
252
|
+
_defineProperty(this, "batchSize", DEFAULTS.batchSize);
|
|
253
|
+
|
|
254
|
+
_defineProperty(this, "trackBackgroundEvents", DEFAULTS.trackBackgroundEvents);
|
|
255
|
+
|
|
213
256
|
_defineProperty(this, "logEventMapper", DEFAULTS.logEventMapper);
|
|
214
257
|
|
|
215
258
|
_defineProperty(this, "errorEventMapper", DEFAULTS.errorEventMapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","PropagatorType","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;AAMA;;;;IAEYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAcZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACnB,SAAOA,eAAe,CAACC,GAAhB,CAAoBC,IAAI,IAAI;AAC/B,QAAIL,sBAAsB,CAACK,IAAD,CAA1B,EAAkC;AAC9B,aAAO;AACHC,QAAAA,KAAK,EAAED,IADJ;AAEHE,QAAAA,eAAe,EAAE,CAACC,sBAAeC,OAAhB;AAFd,OAAP;AAIH;;AACD,WAAOJ,IAAP;AACH,GARM,CAAP;AASH,CAZM;;;AAcP,MAAMK,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAA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AAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [PropagatorType.DATADOG]\n };\n }\n return host;\n });\n};\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: 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 plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","UploadFrequency","BatchSize","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","PropagatorType","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","uploadFrequency","batchSize","MEDIUM","trackBackgroundEvents","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;AAMA;;;;IAEYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;IAOAC,e;;;WAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;GAAAA,e,+BAAAA,e;;IAeAC,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAsBZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACnB,SAAOA,eAAe,CAACC,GAAhB,CAAoBC,IAAI,IAAI;AAC/B,QAAIL,sBAAsB,CAACK,IAAD,CAA1B,EAAkC;AAC9B,aAAO;AACHC,QAAAA,KAAK,EAAED,IADJ;AAEHE,QAAAA,eAAe,EAAE,CAACC,sBAAeC,OAAhB;AAFd,OAAP;AAIH;;AACD,WAAOJ,IAAP;AACH,GARM,CAAP;AASH,CAZM;;;AAcP,MAAMK,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,yBAAyB,EAAE,KARd;AASbC,EAAAA,kBAAkB,EAAE,MAAM,EATb;AAUbC,EA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CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;;;;AAwEA,MAAMI,4BAAN,SAA2CtB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BuB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [PropagatorType.DATADOG]\n };\n }\n return host;\n });\n};\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -27,6 +27,18 @@ Object.defineProperty(exports, "VitalsUpdateFrequency", {
|
|
|
27
27
|
return _DdSdkReactNativeConfiguration.VitalsUpdateFrequency;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "UploadFrequency", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _DdSdkReactNativeConfiguration.UploadFrequency;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "BatchSize", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _DdSdkReactNativeConfiguration.BatchSize;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
30
42
|
Object.defineProperty(exports, "DdSdkReactNative", {
|
|
31
43
|
enumerable: true,
|
|
32
44
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode,\n VitalsUpdateFrequency,\n UploadFrequency,\n BatchSize\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { RumActionType, ErrorSource, PropagatorType } from './rum/types';\nimport { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';\nimport { DdTrace } from './trace/DdTrace';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity,\n VitalsUpdateFrequency,\n PropagatorType,\n UploadFrequency,\n BatchSize\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n debugWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n infoWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n warnWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n errorWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
1
|
+
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n debugWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n infoWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n warnWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n errorWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: object): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
@@ -201,6 +201,14 @@ class DdRumWrapper {
|
|
|
201
201
|
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopSession());
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
addFeatureFlagEvaluation(name, value) {
|
|
205
|
+
_InternalLog.InternalLog.log(`Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(value)}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
206
|
+
|
|
207
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addFeatureFlagEvaluation(name, {
|
|
208
|
+
value
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
|
|
204
212
|
registerErrorEventMapper(errorEventMapper) {
|
|
205
213
|
this.errorEventMapper = (0, _errorEventMapper.generateErrorEventMapper)(errorEventMapper);
|
|
206
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRum.ts"],"names":["timeProvider","TimeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","NativeModules","DdRum","undefined","type","name","context","timestampMs","mappedEvent","actionEventMapper","applyEventMapper","nativeRum","stopAction","args","isNewStopActionAPI","now","isOldStopActionAPI","lastActionData","DdSdk","telemetryDebug","InternalLog","log","SdkVerbosity","WARN","startView","key","DEBUG","stopView","startAction","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","addAction","actionContext","startResource","method","url","stopResource","statusCode","kind","size","resourceContext","resourceEventMapper","addError","message","source","stacktrace","errorEventMapper","updatedContext","addTiming","stopSession","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper"],"mappings":";;;;;;;AAOA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;AAEA;;AAEA;;;;AAQA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,YAAN,CAAwC;AAAA;AAAA,uCACCC,2BAAcC,KADf;;AAAA;;AAAA,8CAGT,gDAAyBC,SAAzB,CAHS;;AAAA,iDAIN,sDAA4BA,SAA5B,CAJM;;AAAA,+CAKR,kDAA0BA,SAA1B,CALQ;;AAAA,kDAoEL,CAC3BC,IAD2B,EAE3BC,IAF2B,EAG3BC,OAH2B,EAI3BC,WAJ2B,KAKX;AAChB,YAAMC,WAAW,GAAG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DACvBA,mBADuB,CAA3B;AAGH;;AAEDY,EAAAA,6BAA6B,GAAG;AAC5B,SAAKZ,mBAAL,GAA2B,sDAA4BvC,SAA5B,CAA3B;AACH;;AAEDoD,EAAAA,yBAAyB,CAAC9C,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyB,kDAA0BA,iBAA1B,CAAzB;AACH;;AAED+C,EAAAA,2BAA2B,GAAG;AAC1B,SAAK/C,iBAAL,GAAyB,kDAA0BN,SAA1B,CAAzB;AACH;;AApUmC;;AAuUxC,MAAMW,kBAAkB,GACpBD,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMG,kBAAkB,GACpBH,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaO,MAAMX,KAAK,GAAG,IAAIF,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView(\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n }\n\n stopView(\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n }\n\n startAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n }\n\n stopAction(\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n }\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n startResource(\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n }\n\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n\n stopSession(): Promise<void> {\n InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopSession());\n }\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
1
|
+
{"version":3,"sources":["DdRum.ts"],"names":["timeProvider","TimeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","NativeModules","DdRum","undefined","type","name","context","timestampMs","mappedEvent","actionEventMapper","applyEventMapper","nativeRum","stopAction","args","isNewStopActionAPI","now","isOldStopActionAPI","lastActionData","DdSdk","telemetryDebug","InternalLog","log","SdkVerbosity","WARN","startView","key","DEBUG","stopView","startAction","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","addAction","actionContext","startResource","method","url","stopResource","statusCode","kind","size","resourceContext","resourceEventMapper","addError","message","source","stacktrace","errorEventMapper","updatedContext","addTiming","stopSession","addFeatureFlagEvaluation","value","JSON","stringify","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper"],"mappings":";;;;;;;AAOA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;AAEA;;AAEA;;;;AAQA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,YAAN,CAAwC;AAAA;AAAA,uCACCC,2BAAcC,KADf;;AAAA;;AAAA,8CAGT,gDAAyBC,SAAzB,CAHS;;AAAA,iDAIN,sDAA4BA,SAA5B,CAJM;;AAAA,+CAKR,kDAA0BA,SAA1B,CALQ;;AAAA,kDAoEL,CAC3BC,IAD2B,EAE3BC,IAF2B,EAG3BC,OAH2B,EAI3BC,WAJ2B,KAKX;AAChB,YAAMC,WAAW,GAAG,KAAKC,iBAAL,CAAuBC,gBAAvB,CAAwC;AACxDN,QAAAA,IADwD;AAExDC,QAAAA,IAFwD;AAGxDC,QAAAA,OAHwD;AAIxDC,QAAAA;AAJwD,OAAxC,CAApB;;AAMA,UAAI,CAACC,WAAL,EAAkB;AACd,eAAO,4CAAqB,MACxB,KAAKG,SAAL,CAAeC,UAAf,CACIR,IADJ,EAEIC,IAFJ,EAGI;AACI,oCAA0B;AAD9B,SAHJ,EAMIE,WANJ,CADG,CAAP;AAUH;;AAED,aAAO,4CAAqB,MACxB,KAAKI,SAAL,CAAeC,UAAf,CACIJ,WAAW,CAACJ,IADhB,EAEII,W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4BvC,SAA5B,CAA3B;AACH;;AAEDwD,EAAAA,yBAAyB,CAAClD,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyB,kDAA0BA,iBAA1B,CAAzB;AACH;;AAEDmD,EAAAA,2BAA2B,GAAG;AAC1B,SAAKnD,iBAAL,GAAyB,kDAA0BN,SAA1B,CAAzB;AACH;;AAhVmC;;AAmVxC,MAAMW,kBAAkB,GACpBD,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMG,kBAAkB,GACpBH,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaO,MAAMX,KAAK,GAAG,IAAIF,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView(\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n }\n\n stopView(\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n }\n\n startAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n }\n\n stopAction(\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n }\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n startResource(\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n }\n\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n\n stopSession(): Promise<void> {\n InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopSession());\n }\n\n addFeatureFlagEvaluation(name: string, value: unknown): Promise<void> {\n InternalLog.log(\n `Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(\n value\n )}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addFeatureFlagEvaluation(name, { value })\n );\n }\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
@@ -119,7 +119,9 @@ _defineProperty(DdRumErrorTracking, "onConsoleError", (...params) => {
|
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
_defineProperty(DdRumErrorTracking, "reportError", (message, source, stacktrace, errorName, context) => {
|
|
123
|
-
return Promise.all([_DdRum.DdRum.addError(message, source, stacktrace, context), _DdLogs.DdLogs.error(message, errorName, message, stacktrace, context
|
|
122
|
+
_defineProperty(DdRumErrorTracking, "reportError", (message, source, stacktrace, errorName, context = {}) => {
|
|
123
|
+
return Promise.all([_DdRum.DdRum.addError(message, source, stacktrace, context), _DdLogs.DdLogs.error(message, errorName, message, stacktrace, { ...context,
|
|
124
|
+
'_dd.error_log.is_crash': true
|
|
125
|
+
})]);
|
|
124
126
|
});
|
|
125
127
|
//# sourceMappingURL=DdRumErrorTracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","_error","_isFatal","_params","isFatal","message","stacktrace","errorName","reportError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","EMPTY_STACK_TRACE","DEFAULT_ERROR_NAME","i","length","param","paramStack","paramErrorName","map","join","CONSOLE","apply","source","context","Promise","all","DdRum","addError","DdLogs"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AAOA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAT,MAAAA,kBAAkB,CAACU,mBAAn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racking.tsx"],"names":["DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","_error","_isFatal","_params","isFatal","message","stacktrace","errorName","reportError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","EMPTY_STACK_TRACE","DEFAULT_ERROR_NAME","i","length","param","paramStack","paramErrorName","map","join","CONSOLE","apply","source","context","Promise","all","DdRum","addError","DdLogs"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AAOA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAT,MAAAA,kBAAkB,CAACU,mBAAnB,GAAyCC,OAAO,CAACC,KAAjD;AAEAL,MAAAA,UAAU,CAACM,gBAAX,CAA4Bb,kBAAkB,CAACc,aAA/C;AACAH,MAAAA,OAAO,CAACC,KAAR,GAAgBZ,kBAAkB,CAACe,cAAnC;AAEAf,MAAAA,kBAAkB,CAACE,UAAnB,GAAgC,IAAhC;;AACAC,+BAAYC,GAAZ,CACI,gCADJ,EAEIC,2BAAaW,IAFjB;AAIH,KAZD,MAYO;AACHb,+BAAYC,GAAZ,CACI,4DADJ,EAEIC,2BAAaY,KAFjB;AAIH;AACJ;;AA1C2B;;;;gBAAnBjB,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAACkB,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1FnB,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8BAAvB,EAA2C;AACvCT,MAAAA,SAAS,GAAGc,cAAZ;AACH;;AAED,QACId,SAAS,KAAKS,8BAAd,IACAF,KAAK,KAAKC,6BAFd,EAGE;AACE;AACH;AACJ;;AAED,QAAMV,OAAO,GAAGQ,MAAM,CACjBS,GADW,CACPH,KAAK,IAAI;AACV,QAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC3B,aAAOA,KAAP;AACH,KAFD,MAEO;AACH,aAAO,iCAAgBA,KAAhB,CAAP;AACH;AACJ,GAPW,EAQXI,IARW,CAQN,GARM,CAAhB;AAzFKxC,EAAAA,kBAmGL,CAAKyB,WAAL,CAAiBH,OAAjB,EAA0BI,mBAAYe,OAAtC,EAA+CV,KAA/C,EAAsDP,SAAtD,EAAiEI,IAAjE,CACI,MAAM;AACF5B,IAAAA,kBAAkB,CAACU,mBAAnB,CAAuCgC,KAAvC,CAA6C/B,OAA7C,EAAsDmB,MAAtD;AACH,GAHL;AAKH,C;;gBAxGQ9B,kB,iBA0GoB,CACzBsB,OADyB,EAEzBqB,MAFyB,EAGzBpB,UAHyB,EAIzBC,SAJyB,EAKzBoB,OAAe,GAAG,EALO,KAMD;AACxB,SAAOC,OAAO,CAACC,GAAR,CAAY,CACfC,aAAMC,QAAN,CAAe1B,OAAf,EAAwBqB,MAAxB,EAAgCpB,UAAhC,EAA4CqB,OAA5C,CADe,EAEfK,eAAOrC,KAAP,CAAaU,OAAb,EAAsBE,SAAtB,EAAiCF,OAAjC,EAA0CC,UAA1C,EAAsD,EAClD,GAAGqB,OAD+C;AAElD,8BAA0B;AAFwB,GAAtD,CAFe,CAAZ,CAAP;AAOH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport {\n getErrorMessage,\n getErrorStackTrace,\n EMPTY_STACK_TRACE,\n getErrorName,\n DEFAULT_ERROR_NAME\n} from '../../errorUtils';\nimport { DdLogs } from '../../logs/DdLogs';\nimport { DdRum } from '../DdRum';\nimport { ErrorSource } from '../types';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n static onGlobalError = (error: any, isFatal?: boolean): void => {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n const errorName = getErrorName(error);\n this.reportError(message, ErrorSource.SOURCE, stacktrace, errorName, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n };\n\n static onConsoleError = (...params: unknown[]): void => {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n let errorName: string = DEFAULT_ERROR_NAME;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n }\n\n const paramErrorName = getErrorName(param);\n if (paramErrorName !== DEFAULT_ERROR_NAME) {\n errorName = paramErrorName;\n }\n\n if (\n errorName !== DEFAULT_ERROR_NAME &&\n stack !== EMPTY_STACK_TRACE\n ) {\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return getErrorMessage(param);\n }\n })\n .join(' ');\n\n this.reportError(message, ErrorSource.CONSOLE, stack, errorName).then(\n () => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n }\n );\n };\n\n private static reportError = (\n message: string,\n source: ErrorSource,\n stacktrace: string,\n errorName: string,\n context: object = {}\n ): Promise<[void, void]> => {\n return Promise.all([\n DdRum.addError(message, source, stacktrace, context),\n DdLogs.error(message, errorName, message, stacktrace, {\n ...context,\n '_dd.error_log.is_crash': true\n })\n ]);\n };\n}\n"]}
|