@datadog/mobile-react-native 1.7.0 → 1.8.0-rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +14 -1
- package/android/build.gradle +20 -7
- package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
- package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
- package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
- package/ios/Sources/DdLogs.h +24 -0
- package/ios/Sources/DdLogs.mm +149 -0
- package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
- package/ios/Sources/DdRum.h +24 -0
- package/ios/Sources/DdRum.mm +188 -0
- package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
- package/ios/Sources/DdSdk.h +24 -0
- package/ios/Sources/DdSdk.mm +119 -0
- package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
- package/ios/Sources/DdTrace.h +24 -0
- package/ios/Sources/DdTrace.mm +66 -0
- package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
- package/ios/Sources/QueueHolder.swift +8 -0
- package/jest/mock.js +6 -1
- package/lib/commonjs/DdSdkReactNative.js +32 -49
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +33 -40
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +13 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +104 -106
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/DdSdk.js +3 -3
- package/lib/commonjs/sdk/DdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdLogs.js +20 -0
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
- package/lib/commonjs/specs/NativeDdRum.js +20 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js +20 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
- package/lib/commonjs/specs/NativeDdTrace.js +20 -0
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
- package/lib/commonjs/trace/DdTrace.js +10 -12
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +27 -44
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +33 -39
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +13 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +100 -101
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/DdSdk.js +3 -2
- package/lib/module/sdk/DdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdLogs.js +14 -0
- package/lib/module/specs/NativeDdLogs.js.map +1 -0
- package/lib/module/specs/NativeDdRum.js +14 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js +14 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -0
- package/lib/module/specs/NativeDdTrace.js +14 -0
- package/lib/module/specs/NativeDdTrace.js.map +1 -0
- package/lib/module/trace/DdTrace.js +10 -11
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +4 -4
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
- package/lib/typescript/logs/DdLogs.d.ts +4 -4
- package/lib/typescript/nativeModulesTypes.d.ts +28 -168
- package/lib/typescript/rum/DdRum.d.ts +12 -12
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
- package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +10 -2
- package/src/DdSdkReactNative.tsx +12 -10
- package/src/DdSdkReactNativeConfiguration.tsx +22 -0
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/longTasksUtils.test.ts +5 -0
- package/src/__tests__/mock.test.ts +89 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
- package/src/logs/DdLogs.ts +11 -11
- package/src/logs/__tests__/DdLogs.test.ts +1 -1
- package/src/nativeModulesTypes.ts +49 -254
- package/src/rum/DdRum.ts +36 -32
- package/src/rum/eventMappers/errorEventMapper.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
- package/src/sdk/DdSdk.ts +2 -3
- package/src/specs/NativeDdLogs.ts +110 -0
- package/src/specs/NativeDdRum.ts +151 -0
- package/src/specs/NativeDdSdk.ts +62 -0
- package/src/specs/NativeDdTrace.ts +42 -0
- package/src/trace/DdTrace.ts +9 -9
- package/src/version.ts +1 -1
- package/ios/Sources/DdLogs.m +0 -62
- package/ios/Sources/DdRum.m +0 -82
- package/ios/Sources/DdSdk.m +0 -41
- package/ios/Sources/DdTrace.m +0 -23
|
@@ -1 +1 @@
|
|
|
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,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rByC,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEJ,QAAQ,CAAC3C;AAA3C,GADqB,EAErBmD,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACnB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAClB;AAFpB,GADqB,EAKrB0B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACjB;AAFpB,GADqB,EAKrByB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAChB;AAFpB,GADqB,EAKrBwB,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;;;;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"]}
|
|
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","actionNameAttribute","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,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CAAC3C;AAA3C,GADqB,EAErBmD,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACnB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAClB;AAFpB,GADqB,EAKrB0B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACjB;AAFpB,GADqB,EAKrByB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAAChB;AAFpB,GADqB,EAKrBwB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEJ,QAAQ,CAACY;AAFpB,GADqB,EAKrBJ,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CA7EM;;;;AA+EA,MAAMK,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport enum UploadFrequency {\n /**\n * Upload data every 1000ms.\n */\n FREQUENT = 'FREQUENT',\n /**\n * Upload data every 5000ms.\n */\n AVERAGE = 'AVERAGE',\n /**\n * Upload data every 10000ms.\n */\n RARE = 'RARE'\n}\n\nexport enum BatchSize {\n /**\n * Upload less frequent, larger batches of data\n */\n LARGE = 'LARGE',\n /**\n * Use default size for batches of data\n */\n MEDIUM = 'MEDIUM',\n /**\n * Upload more frequent, smaller batches of data\n */\n SMALL = 'SMALL'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [PropagatorType.DATADOG]\n };\n }\n return host;\n });\n};\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: true,\n uploadFrequency: UploadFrequency.AVERAGE,\n batchSize: BatchSize.MEDIUM,\n trackBackgroundEvents: false\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n /**\n * Sets the preferred frequency for uploading batches of data.\n */\n public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;\n\n /**\n * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.\n * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.\n */\n public batchSize: BatchSize = DEFAULTS.batchSize;\n\n /**\n * Enables tracking of RUM event when no RUM View is active.\n *\n * By default, background events are not tracked. Enabling this feature might increase the\n * number of sessions tracked and impact your billing.\n */\n public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;\n\n /**\n * Specifies a custom prop to name RUM actions on elements having an `onPress` prop.\n *\n * For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:\n *\n * ```js\n * <TouchableOpacity testID=\"Dismiss notification\" onPress={() => dismiss()}>\n * ```\n *\n * `dd-action-name` is favored when both attributes are present on an element.\n */\n public actionNameAttribute?: string;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\n readonly actionNameAttribute?: string;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly nativeInteractionTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\n readonly uploadFrequency?: UploadFrequency;\n readonly batchSize?: BatchSize;\n readonly trackBackgroundEvents?: boolean;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionNameAttribute',\n value: features.actionNameAttribute\n },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.DdLogs = void 0;
|
|
7
7
|
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _InternalLog = require("../InternalLog");
|
|
11
9
|
|
|
12
10
|
var _SdkVerbosity = require("../SdkVerbosity");
|
|
@@ -30,10 +28,42 @@ const isLogWithError = args => {
|
|
|
30
28
|
|
|
31
29
|
class DdLogsWrapper {
|
|
32
30
|
constructor() {
|
|
33
|
-
_defineProperty(this, "nativeLogs",
|
|
31
|
+
_defineProperty(this, "nativeLogs", require('../specs/NativeDdLogs').default);
|
|
34
32
|
|
|
35
33
|
_defineProperty(this, "logEventMapper", (0, _eventMapper.generateEventMapper)(undefined));
|
|
36
34
|
|
|
35
|
+
_defineProperty(this, "debug", (...args) => {
|
|
36
|
+
if (isLogWithError(args)) {
|
|
37
|
+
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'debug');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this.log(args[0], args[1] || {}, 'debug');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "info", (...args) => {
|
|
44
|
+
if (isLogWithError(args)) {
|
|
45
|
+
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'info');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return this.log(args[0], args[1] || {}, 'info');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "warn", (...args) => {
|
|
52
|
+
if (isLogWithError(args)) {
|
|
53
|
+
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'warn');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this.log(args[0], args[1] || {}, 'warn');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
_defineProperty(this, "error", (...args) => {
|
|
60
|
+
if (isLogWithError(args)) {
|
|
61
|
+
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'error');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return this.log(args[0], args[1] || {}, 'error');
|
|
65
|
+
});
|
|
66
|
+
|
|
37
67
|
_defineProperty(this, "printLogDroppedSdkNotInitialized", (message, status) => {
|
|
38
68
|
if (__DEV__) {
|
|
39
69
|
console.warn(`${_InternalLog.DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: "${message}"`);
|
|
@@ -110,43 +140,6 @@ class DdLogsWrapper {
|
|
|
110
140
|
});
|
|
111
141
|
}
|
|
112
142
|
|
|
113
|
-
debug(...args) {
|
|
114
|
-
if (isLogWithError(args)) {
|
|
115
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'debug');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return this.log(args[0], args[1] || {}, 'debug');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
info(...args) {
|
|
122
|
-
if (isLogWithError(args)) {
|
|
123
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'info');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return this.log(args[0], args[1] || {}, 'info');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
warn(...args) {
|
|
130
|
-
if (isLogWithError(args)) {
|
|
131
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'warn');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return this.log(args[0], args[1] || {}, 'warn');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
error(...args) {
|
|
138
|
-
if (isLogWithError(args)) {
|
|
139
|
-
return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'error');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return this.log(args[0], args[1] || {}, 'error');
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Since the InternalLog does not have a verbosity set yet in this case,
|
|
146
|
-
* we use console.warn to warn the user in dev mode.
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
143
|
registerLogEventMapper(logEventMapper) {
|
|
151
144
|
this.logEventMapper = (0, _eventMapper.generateEventMapper)(logEventMapper);
|
|
152
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdLogs.ts"],"names":["SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","NativeModules","DdLogs","undefined","message","status","__DEV__","console","warn","DATADOG_MESSAGE_PREFIX","InternalLog","log","SdkVerbosity","DEBUG","context","event","logEventMapper","applyEventMapper","printlogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","debug","logWithError","info","registerLogEventMapper","unregisterLogEventMapper"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAGA;;;;AASA,MAAMA,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;AAEA;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAChBC,IADmB,IAEa;AAChC,SACI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IACA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QADnB,IAEA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAFnB,IA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;AAEDsB,EAAAA,KAAK,CAAC,GAAGtB,IAAJ,EAA+D;AAChE,QAAID,cAAc,CAACC,IAAD,CAAlB,EAA0B;AACtB,aAAO,KAAK4B,YAAL,CACH5B,IAAI,CAAC,CAAD,CADD,EAEHA,IAAI,CAAC,CAAD,CAFD,EAGHA,IAAI,CAAC,CAAD,CAHD,EAIHA,IAAI,CAAC,CAAD,CAJD,EAKHA,IAAI,CAAC,CAAD,CAAJ,IAAW,EALR,EAMH,OANG,CAAP;AAQH;;AACD,WAAO,KAAKY,GAAL,CAASZ,IAAI,CAAC,CAAD,CAAb,EAAkBA,IAAI,CAAC,CAAD,CAAJ,IAAW,EAA7B,EAAiC,OAAjC,CAAP;AACH;AAED;AACJ;AACA;AACA;;;AAwGI8B,EAAAA,sBAAsB,CAACb,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsB,sCAAoBA,cAApB,CAAtB;AACH;;AAEDc,EAAAA,wBAAwB,GAAG;AACvB,SAAKd,cAAL,GAAsB,sCAAoBb,SAApB,CAAtB;AACH;;AA7KqC;;AAgLnC,MAAMD,MAAM,GAAG,IAAIF,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n private logEventMapper = generateEventMapper(undefined);\n\n debug(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n }\n\n info(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n }\n\n warn(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n }\n\n error(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n }\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printlogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
|
|
1
|
+
{"version":3,"sources":["DdLogs.ts"],"names":["SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","require","default","undefined","logWithError","log","message","status","__DEV__","console","warn","DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","DEBUG","context","event","logEventMapper","applyEventMapper","printlogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","registerLogEventMapper","unregisterLogEventMapper","DdLogs"],"mappings":";;;;;;;AAMA;;AACA;;AAGA;;;;AASA,MAAMA,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;AAEA;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAChBC,IADmB,IAEa;AAChC,SACI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IACA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QADnB,IAEA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAFnB,IAGA,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAJvB;AAMH,CATD;;AAWA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,OAAO,CAAC,uBAAD,CAAP,CAClCC,OAHiC;;AAAA,4CAIb,sCAAoBC,SAApB,CAJa;;AAAA,mCAM9B,CAAC,GAAGJ,IAAJ,KAAkE;AACtE,UAAID,cAAc,CAACC,IAAD,CAAlB,EAA0B;AACtB,eAAO,KAAKK,YAAL,CACHL,IAAI,CAAC,CAAD,CADD,EAEHA,IAAI,CAAC,CAAD,CAFD,EAGHA,IAAI,CAAC,CAAD,CAHD,EAIHA,IAAI,CAAC,CAAD,CAJD,EAKHA,IAAI,CAAC,CAAD,CAAJ,IAAW,EALR,EAMH,OANG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KtCK,EAAAA,sBAAsB,CAACV,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsB,sCAAoBA,cAApB,CAAtB;AACH;;AAEDW,EAAAA,wBAAwB,GAAG;AACvB,SAAKX,cAAL,GAAsB,sCAAoBd,SAApB,CAAtB;AACH;;AA/KqC;;AAkLnC,MAAM0B,MAAM,GAAG,IAAI7B,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeLogs: DdNativeLogsType = require('../specs/NativeDdLogs')\n .default;\n private logEventMapper = generateEventMapper(undefined);\n\n debug = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n };\n\n info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n };\n\n warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n };\n\n error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n };\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printlogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
|
|
@@ -11,6 +11,19 @@ exports.DdNativeSdkConfiguration = void 0;
|
|
|
11
11
|
* Copyright 2016-Present Datadog, Inc.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* In this file, native modules types extend the specs for TurboModules.
|
|
16
|
+
* As we cannot use enums or classes in the specs, we override methods using them here.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The entry point to use Datadog's Logs feature.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The entry point to use Datadog's Trace feature.
|
|
25
|
+
*/
|
|
26
|
+
|
|
14
27
|
/**
|
|
15
28
|
* A configuration object to initialize Datadog's features.
|
|
16
29
|
*/
|
|
@@ -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 /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: object): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
1
|
+
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;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\nimport type { Spec as NativeDdLogs } from './specs/NativeDdLogs';\nimport type { Spec as NativeDdRum } from './specs/NativeDdRum';\nimport type { Spec as NativeDdSdk } from './specs/NativeDdSdk';\nimport type { Spec as NativeDdTrace } from './specs/NativeDdTrace';\n\n/**\n * In this file, native modules types extend the specs for TurboModules.\n * As we cannot use enums or classes in the specs, we override methods using them here.\n */\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = NativeDdLogs;\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = NativeDdTrace;\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport interface DdNativeSdkType extends NativeDdSdk {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n}\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport interface DdNativeRumType extends NativeDdRum {\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number,\n context: object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object,\n timestampMs: number\n ): Promise<void>;\n}\n"]}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.DdRum = void 0;
|
|
7
7
|
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _InternalLog = require("../InternalLog");
|
|
11
9
|
|
|
12
10
|
var _SdkVerbosity = require("../SdkVerbosity");
|
|
@@ -31,7 +29,7 @@ const generateEmptyPromise = () => new Promise(resolve => resolve());
|
|
|
31
29
|
|
|
32
30
|
class DdRumWrapper {
|
|
33
31
|
constructor() {
|
|
34
|
-
_defineProperty(this, "nativeRum",
|
|
32
|
+
_defineProperty(this, "nativeRum", require('../specs/NativeDdRum').default);
|
|
35
33
|
|
|
36
34
|
_defineProperty(this, "lastActionData", void 0);
|
|
37
35
|
|
|
@@ -41,6 +39,41 @@ class DdRumWrapper {
|
|
|
41
39
|
|
|
42
40
|
_defineProperty(this, "actionEventMapper", (0, _actionEventMapper.generateActionEventMapper)(undefined));
|
|
43
41
|
|
|
42
|
+
_defineProperty(this, "startView", (key, name, context = {}, timestampMs = timeProvider.now()) => {
|
|
43
|
+
_InternalLog.InternalLog.log(`Starting RUM View “${name}” #${key}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
44
|
+
|
|
45
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startView(key, name, context, timestampMs));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
_defineProperty(this, "stopView", (key, context = {}, timestampMs = timeProvider.now()) => {
|
|
49
|
+
_InternalLog.InternalLog.log(`Stopping RUM View #${key}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
50
|
+
|
|
51
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopView(key, context, timestampMs));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
_defineProperty(this, "startAction", (type, name, context = {}, timestampMs = timeProvider.now()) => {
|
|
55
|
+
_InternalLog.InternalLog.log(`Starting RUM Action “${name}” (${type})`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
56
|
+
|
|
57
|
+
this.lastActionData = {
|
|
58
|
+
type,
|
|
59
|
+
name
|
|
60
|
+
};
|
|
61
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startAction(type, name, context, timestampMs));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
_defineProperty(this, "stopAction", (...args) => {
|
|
65
|
+
_InternalLog.InternalLog.log('Stopping current RUM Action', _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
66
|
+
|
|
67
|
+
const nativeCallArgs = this.getStopActionNativeCallArgs(args);
|
|
68
|
+
this.lastActionData = undefined;
|
|
69
|
+
|
|
70
|
+
if (!nativeCallArgs) {
|
|
71
|
+
return generateEmptyPromise();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return this.callNativeStopAction(...nativeCallArgs);
|
|
75
|
+
});
|
|
76
|
+
|
|
44
77
|
_defineProperty(this, "callNativeStopAction", (type, name, context, timestampMs) => {
|
|
45
78
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
46
79
|
type,
|
|
@@ -81,132 +114,97 @@ class DdRumWrapper {
|
|
|
81
114
|
|
|
82
115
|
return null;
|
|
83
116
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
startView(key, name, context = {}, timestampMs = timeProvider.now()) {
|
|
87
|
-
_InternalLog.InternalLog.log(`Starting RUM View “${name}” #${key}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
88
117
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
99
|
-
_InternalLog.InternalLog.log(`Starting RUM Action “${name}” (${type})`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
100
|
-
|
|
101
|
-
this.lastActionData = {
|
|
102
|
-
type,
|
|
103
|
-
name
|
|
104
|
-
};
|
|
105
|
-
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startAction(type, name, context, timestampMs));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
stopAction(...args) {
|
|
109
|
-
_InternalLog.InternalLog.log('Stopping current RUM Action', _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
110
|
-
|
|
111
|
-
const nativeCallArgs = this.getStopActionNativeCallArgs(args);
|
|
112
|
-
this.lastActionData = undefined;
|
|
118
|
+
_defineProperty(this, "addAction", (type, name, context = {}, timestampMs = timeProvider.now(), actionContext) => {
|
|
119
|
+
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
120
|
+
type,
|
|
121
|
+
name,
|
|
122
|
+
context,
|
|
123
|
+
timestampMs,
|
|
124
|
+
actionContext
|
|
125
|
+
});
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
if (!mappedEvent) {
|
|
128
|
+
return generateEmptyPromise();
|
|
129
|
+
}
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
}
|
|
131
|
+
_InternalLog.InternalLog.log(`Adding RUM Action “${name}” (${type})`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
123
|
-
type,
|
|
124
|
-
name,
|
|
125
|
-
context,
|
|
126
|
-
timestampMs,
|
|
127
|
-
actionContext
|
|
133
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addAction(mappedEvent.type, mappedEvent.name, mappedEvent.context, mappedEvent.timestampMs));
|
|
128
134
|
});
|
|
129
135
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
136
|
+
_defineProperty(this, "startResource", (key, method, url, context = {}, timestampMs = timeProvider.now()) => {
|
|
137
|
+
_InternalLog.InternalLog.log(`Starting RUM Resource #${key} ${method}: ${url}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
|
|
140
|
+
});
|
|
135
141
|
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
_defineProperty(this, "stopResource", (key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now(), resourceContext) => {
|
|
143
|
+
const mappedEvent = this.resourceEventMapper.applyEventMapper({
|
|
144
|
+
key,
|
|
145
|
+
statusCode,
|
|
146
|
+
kind,
|
|
147
|
+
size,
|
|
148
|
+
context,
|
|
149
|
+
timestampMs,
|
|
150
|
+
resourceContext
|
|
151
|
+
});
|
|
138
152
|
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
if (!mappedEvent) {
|
|
154
|
+
/**
|
|
155
|
+
* To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.
|
|
156
|
+
* It will be picked up by the resource mappers we implement on the native side that will drop the resource.
|
|
157
|
+
* This ensures we don't have any "started" resource left in memory on the native side.
|
|
158
|
+
*/
|
|
159
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopResource(key, statusCode, kind, size, {
|
|
160
|
+
'_dd.resource.drop_resource': true
|
|
161
|
+
}, timestampMs));
|
|
162
|
+
}
|
|
141
163
|
|
|
142
|
-
|
|
143
|
-
}
|
|
164
|
+
_InternalLog.InternalLog.log(`Stopping RUM Resource #${key} status:${statusCode}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
144
165
|
|
|
145
|
-
|
|
146
|
-
const mappedEvent = this.resourceEventMapper.applyEventMapper({
|
|
147
|
-
key,
|
|
148
|
-
statusCode,
|
|
149
|
-
kind,
|
|
150
|
-
size,
|
|
151
|
-
context,
|
|
152
|
-
timestampMs,
|
|
153
|
-
resourceContext
|
|
166
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopResource(mappedEvent.key, mappedEvent.statusCode, mappedEvent.kind, mappedEvent.size, mappedEvent.context, mappedEvent.timestampMs));
|
|
154
167
|
});
|
|
155
168
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}, timestampMs));
|
|
165
|
-
}
|
|
169
|
+
_defineProperty(this, "addError", (message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) => {
|
|
170
|
+
const mappedEvent = this.errorEventMapper.applyEventMapper({
|
|
171
|
+
message,
|
|
172
|
+
source,
|
|
173
|
+
stacktrace,
|
|
174
|
+
context,
|
|
175
|
+
timestampMs
|
|
176
|
+
});
|
|
166
177
|
|
|
167
|
-
|
|
178
|
+
if (!mappedEvent) {
|
|
179
|
+
return generateEmptyPromise();
|
|
180
|
+
}
|
|
168
181
|
|
|
169
|
-
|
|
170
|
-
}
|
|
182
|
+
_InternalLog.InternalLog.log(`Adding RUM Error “${message}”`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
171
183
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
message,
|
|
175
|
-
source,
|
|
176
|
-
stacktrace,
|
|
177
|
-
context,
|
|
178
|
-
timestampMs
|
|
184
|
+
const updatedContext = mappedEvent.context;
|
|
185
|
+
updatedContext['_dd.error.source_type'] = 'react-native';
|
|
186
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addError(mappedEvent.message, mappedEvent.source, mappedEvent.stacktrace, updatedContext, mappedEvent.timestampMs));
|
|
179
187
|
});
|
|
180
188
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
_InternalLog.InternalLog.log(`Adding RUM Error “${message}”`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
186
|
-
|
|
187
|
-
const updatedContext = mappedEvent.context;
|
|
188
|
-
updatedContext['_dd.error.source_type'] = 'react-native';
|
|
189
|
-
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addError(mappedEvent.message, mappedEvent.source, mappedEvent.stacktrace, updatedContext, mappedEvent.timestampMs));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
addTiming(name) {
|
|
193
|
-
_InternalLog.InternalLog.log(`Adding timing “${name}” to RUM View`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
189
|
+
_defineProperty(this, "addTiming", name => {
|
|
190
|
+
_InternalLog.InternalLog.log(`Adding timing “${name}” to RUM View`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
194
191
|
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addTiming(name));
|
|
193
|
+
});
|
|
197
194
|
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
_defineProperty(this, "stopSession", () => {
|
|
196
|
+
_InternalLog.InternalLog.log('Stopping RUM Session', _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
200
197
|
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopSession());
|
|
199
|
+
});
|
|
203
200
|
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
_defineProperty(this, "addFeatureFlagEvaluation", (name, value) => {
|
|
202
|
+
_InternalLog.InternalLog.log(`Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(value)}`, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
206
203
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addFeatureFlagEvaluation(name, {
|
|
205
|
+
value
|
|
206
|
+
}));
|
|
207
|
+
});
|
|
210
208
|
}
|
|
211
209
|
|
|
212
210
|
registerErrorEventMapper(errorEventMapper) {
|