@datadog/mobile-react-native 1.0.0-rc8 → 1.1.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 -1
- package/android/build.gradle +73 -3
- package/android/gradle.properties +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
- package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
- package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
- package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/datadog-sourcemaps.gradle +137 -0
- package/ios/Sources/AnyEncodable.swift +138 -0
- package/ios/Sources/Attributes.swift +101 -0
- package/ios/Sources/DdLogs.swift +35 -11
- package/ios/Sources/DdRum.m +3 -1
- package/ios/Sources/DdRum.swift +184 -22
- package/ios/Sources/DdSdk.swift +190 -10
- package/ios/Sources/DdSdkConfiguration.swift +51 -0
- package/ios/Sources/DdTrace.swift +41 -6
- package/ios/Sources/GlobalState.swift +28 -0
- package/ios/Sources/QueueHolder.swift +10 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
- package/lib/commonjs/DdSdkReactNative.js +16 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +36 -2
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +36 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +73 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +40 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +51 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +25 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
- package/lib/commonjs/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +57 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +49 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +45 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{URLHostParser.js → resourceTracking/implementation/URLHostParser.js} +16 -7
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +167 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js +97 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
- package/lib/commonjs/types.js +26 -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 +15 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +36 -2
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +26 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +61 -0
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -0
- package/lib/module/rum/instrumentation/{TraceIdentifier.js → resourceTracking/domain/distributedTracing.js} +35 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +34 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js +16 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.js +2 -0
- package/lib/module/rum/instrumentation/{DdRumXhr.js.map → resourceTracking/domain/interfaces/RumResource.js.map} +0 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +50 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js +40 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js +36 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.js.map +1 -0
- package/{src/rum/instrumentation/URLHostParser.ts → lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js} +15 -8
- package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +151 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js +86 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +1 -0
- package/lib/module/types.js +23 -0
- 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/DdSdkReactNative.d.ts +2 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
- package/lib/typescript/foundation.d.ts +3 -2
- package/lib/typescript/nativeModulesTypes.d.ts +168 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +15 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +18 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +20 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.d.ts +17 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/URLHostParser.d.ts +6 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +25 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +3 -0
- package/lib/typescript/types.d.ts +42 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +7 -5
- package/src/DdSdkReactNative.tsx +21 -1
- package/src/DdSdkReactNativeConfiguration.tsx +20 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +87 -8
- package/src/__tests__/foundation.test.ts +79 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +9 -9
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +1 -1
- package/src/foundation.tsx +40 -11
- package/src/nativeModulesTypes.ts +258 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +67 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +79 -0
- package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/__tests__}/__utils__/XMLHttpRequestMock.ts +0 -0
- package/src/{__tests__/rum/instrumentation/TraceIdentifier.test.tsx → rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts} +1 -1
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +22 -0
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +87 -0
- package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +52 -0
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +15 -0
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +27 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +78 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +83 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +45 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +69 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.ts +50 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.ts +70 -0
- package/src/rum/instrumentation/resourceTracking/implementation/URLHostParser.ts +30 -0
- package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +197 -0
- package/src/{__tests__/rum/instrumentation → rum/instrumentation/resourceTracking/implementation/__tests__}/URLHostParser.test.ts +3 -3
- package/src/{__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx → rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts} +83 -49
- package/src/rum/instrumentation/resourceTracking/implementation/responseSize.ts +83 -0
- package/src/types.tsx +62 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
- package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +0 -356
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -2
- package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +0 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +0 -331
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +0 -1
- package/lib/module/rum/instrumentation/DdRumXhr.js +0 -2
- package/lib/module/rum/instrumentation/TraceIdentifier.js.map +0 -1
- package/lib/module/rum/instrumentation/URLHostParser.js +0 -24
- package/lib/module/rum/instrumentation/URLHostParser.js.map +0 -1
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +0 -40
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +0 -23
- package/lib/typescript/rum/instrumentation/TraceIdentifier.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +0 -6
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +0 -426
- package/src/rum/instrumentation/DdRumXhr.tsx +0 -33
- package/src/rum/instrumentation/TraceIdentifier.tsx +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","DdRumWrapper","DdRum","startView","key","name","nativeRum","stopView","startAction","type","stopAction","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAELC,2BAAcC,MAFT;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;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3B;;AACA,MAAMe,OAAoB,GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMU,KAAgB,GAAG,IAAID,YAAJ,EAAzB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdSdkType, DdLogsType, DdTraceType, DdRumType } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdRumType = NativeModules.DdRum;\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n return this.nativeRum.stopAction(context, timestampMs);\n }\n\n addAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: string, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: string, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
|
|
1
|
+
{"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,2BAAcC,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDC,6BAAYC,GAAZ,CAAgB,yBAA0BH,OAA1B,GAAoC,GAApD,EAAyDI,2BAAaC,KAAtE;;AACA,WAAO,KAAKC,UAA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ository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DdNativeSdkConfiguration = void 0;
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
10
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A configuration object to initialize Datadog's features.
|
|
16
|
+
*/
|
|
17
|
+
class DdNativeSdkConfiguration {
|
|
18
|
+
constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig) {
|
|
19
|
+
this.clientToken = clientToken;
|
|
20
|
+
this.env = env;
|
|
21
|
+
this.applicationId = applicationId;
|
|
22
|
+
this.nativeCrashReportEnabled = nativeCrashReportEnabled;
|
|
23
|
+
this.sampleRate = sampleRate;
|
|
24
|
+
this.site = site;
|
|
25
|
+
this.trackingConsent = trackingConsent;
|
|
26
|
+
this.additionalConfig = additionalConfig;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The entry point to initialize Datadog's features.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.DdNativeSdkConfiguration = DdNativeSdkConfiguration;
|
|
36
|
+
//# sourceMappingURL=nativeModulesTypes.js.map
|
|
@@ -0,0 +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<void>;\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/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\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 level info.\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 level warn.\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 level error.\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/**\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\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"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.DdEventsInterceptor = exports.UNKNOWN_TARGET_NAME = void 0;
|
|
7
7
|
|
|
8
8
|
var _InternalLog = require("../../InternalLog");
|
|
9
9
|
|
|
@@ -11,6 +11,8 @@ var _SdkVerbosity = require("../../SdkVerbosity");
|
|
|
11
11
|
|
|
12
12
|
var _foundation = require("../../foundation");
|
|
13
13
|
|
|
14
|
+
var _types = require("../../types");
|
|
15
|
+
|
|
14
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
17
|
|
|
16
18
|
const UNKNOWN_TARGET_NAME = 'unknown_target';
|
|
@@ -44,7 +46,7 @@ class DdEventsInterceptor {
|
|
|
44
46
|
if (targetNode) {
|
|
45
47
|
const resolvedTargetName = this.resolveTargetName(targetNode);
|
|
46
48
|
|
|
47
|
-
_foundation.DdRum.addAction(RumActionType.TAP
|
|
49
|
+
_foundation.DdRum.addAction(_types.RumActionType.TAP, resolvedTargetName);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -96,23 +98,8 @@ class DdEventsInterceptor {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Describe the type of a RUM Action.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
101
|
|
|
104
102
|
exports.DdEventsInterceptor = DdEventsInterceptor;
|
|
105
103
|
|
|
106
104
|
_defineProperty(DdEventsInterceptor, "ACTION_EVENT_DROPPED_WARN_MESSAGE", 'An action event was dropped because either the `onPress` method arguments' + ' were undefined or they were missing the target information.');
|
|
107
|
-
|
|
108
|
-
let RumActionType;
|
|
109
|
-
exports.RumActionType = RumActionType;
|
|
110
|
-
|
|
111
|
-
(function (RumActionType) {
|
|
112
|
-
RumActionType["TAP"] = "TAP";
|
|
113
|
-
RumActionType["SCROLL"] = "SCROLL";
|
|
114
|
-
RumActionType["SWIPE"] = "SWIPE";
|
|
115
|
-
RumActionType["CLICK"] = "CLICK";
|
|
116
|
-
RumActionType["CUSTOM"] = "CUSTOM";
|
|
117
|
-
})(RumActionType || (exports.RumActionType = RumActionType = {}));
|
|
118
105
|
//# sourceMappingURL=DdEventsInterceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","InternalLog","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","SdkVerbosity","WARN","resolvedTargetName","resolveTargetName","DdRum","addAction","RumActionType","TAP","
|
|
1
|
+
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","InternalLog","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","SdkVerbosity","WARN","resolvedTargetName","resolveTargetName","DdRum","addAction","RumActionType","TAP","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;;;;;;AAMA;;AACA;;AACA;;AACA;;;;AAIO,MAAMA,mBAAmB,GAAG,gBAA5B;;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAqC,GAAG,CAA9C;AACA,MAAMC,mBAAmB,GAAG,gBAA5B;;AAEO,MAAMC,mBAAN,CAAuD;AAAA;AAAA,wDAKrBC,MAAM,CAACC,SALc;AAAA;;AAO1DC,EAAAA,gBAAgB,CAAC,GAAGC,IAAJ,EAAuB;AACnC,QAAIA,IAAI,CAACC,MAAL,GAAc,CAAd,IAAmBD,IAAI,CAAC,CAAD,CAAvB,IAA8BA,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA1C,EAAuD;AACnD,YAAMC,WAAW,GAAGC,IAAI,CAACC,GAAL,EAApB;AACA,YAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAL,CACxBJ,IAAI,CAACC,GAAL,KAAa,KAAKI,0BADM,CAA5B;;AAGA,UAAIH,mBAAmB,GAAGb,8BAA1B,EAA0D;AACtD,cAAMiB,UAAU,GAAGV,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA3B;AACA,aAAKS,iBAAL,CAAuBD,UAAvB,EAFsD,CAGtD;;AACA,aAAKD,0BAAL,GACIN,WAAW,GAAGT,qCADlB;AAEH;AACJ,KAZD,MAYO;AACHkB,+BAAYC,GAAZ,CACIjB,mBA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,EAAyC;AACrC,eAAOqC,KAAK,CAACrC,mBAAD,CAAZ;AACH;;AACDoC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AAtEyD;;;;gBAAjDrC,mB,uCAEL,8EACA,8D","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 { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\nimport { RumActionType } from '../../types';\n\nimport type EventsInterceptor from './EventsInterceptor';\n\nexport const UNKNOWN_TARGET_NAME = 'unknown_target';\nconst DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;\nconst HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;\nconst DD_ACTION_NAME_PROP = 'dd-action-name';\n\nexport class DdEventsInterceptor implements EventsInterceptor {\n static ACTION_EVENT_DROPPED_WARN_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n interceptOnPress(...args: any[]): void {\n if (args.length > 0 && args[0] && args[0]._targetInst) {\n const currentTime = Date.now();\n const timestampDifference = Math.abs(\n Date.now() - this.debouncingStartedTimestamp\n );\n if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {\n const targetNode = args[0]._targetInst;\n this.handleTargetEvent(targetNode);\n // we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function\n this.debouncingStartedTimestamp =\n currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;\n }\n } else {\n InternalLog.log(\n DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE,\n SdkVerbosity.WARN\n );\n }\n }\n\n private handleTargetEvent(targetNode: any | null) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(RumActionType.TAP, resolvedTargetName);\n }\n }\n\n private resolveTargetName(targetNode: any): string {\n const closestActionLabel = this.findClosestActionLabel(targetNode);\n if (closestActionLabel != null) {\n return closestActionLabel;\n }\n const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;\n if (accessibilityLabel != null) {\n return accessibilityLabel;\n }\n const elementTypeName = this.resolveElementTypeName(\n targetNode.elementType\n );\n return elementTypeName || UNKNOWN_TARGET_NAME;\n }\n\n private resolveElementTypeName(elementType: any): string | null {\n let elementTypeName = null;\n if (typeof elementType === 'string') {\n elementTypeName = elementType;\n } else if (elementType && typeof elementType.name === 'string') {\n elementTypeName = elementType.name;\n }\n return elementTypeName;\n }\n\n private findClosestActionLabel(targetNode: any): string | null {\n let currentNode = targetNode;\n while (currentNode) {\n const props = currentNode.memoizedProps;\n if (props && props[DD_ACTION_NAME_PROP]) {\n return props[DD_ACTION_NAME_PROP];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\n}\n"]}
|
|
@@ -11,12 +11,12 @@ var _SdkVerbosity = require("../../SdkVerbosity");
|
|
|
11
11
|
|
|
12
12
|
var _foundation = require("../../foundation");
|
|
13
13
|
|
|
14
|
+
var _types = require("../../types");
|
|
15
|
+
|
|
14
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
17
|
|
|
16
18
|
const EMPTY_MESSAGE = 'Unknown Error';
|
|
17
19
|
const EMPTY_STACK_TRACE = '';
|
|
18
|
-
const TYPE_SOURCE = 'SOURCE';
|
|
19
|
-
const TYPE_CONSOLE = 'CONSOLE';
|
|
20
20
|
/**
|
|
21
21
|
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
22
22
|
*/
|
|
@@ -54,7 +54,7 @@ class DdRumErrorTracking {
|
|
|
54
54
|
const message = DdRumErrorTracking.getErrorMessage(error);
|
|
55
55
|
const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
|
|
56
56
|
|
|
57
|
-
_foundation.DdRum.addError(message,
|
|
57
|
+
_foundation.DdRum.addError(message, _types.ErrorSource.SOURCE, stacktrace, {
|
|
58
58
|
'_dd.error.is_crash': isFatal,
|
|
59
59
|
'_dd.error.raw': error
|
|
60
60
|
}).then(() => {
|
|
@@ -93,7 +93,7 @@ class DdRumErrorTracking {
|
|
|
93
93
|
}
|
|
94
94
|
}).join(' ');
|
|
95
95
|
|
|
96
|
-
_foundation.DdRum.addError(message,
|
|
96
|
+
_foundation.DdRum.addError(message, _types.ErrorSource.CONSOLE, stack).then(() => {
|
|
97
97
|
DdRumErrorTracking.defaultConsoleError.apply(console, params);
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","
|
|
1
|
+
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AAEA;AACA;AACA;;AACO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GA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5B,KAAD,CAAhB;AACH;;AAED,WAAOO,OAAP;AACH;;AAEgC,SAAlBG,kBAAkB,CAACV,KAAD,EAAiC;AAC9D,QAAIkB,KAAK,GAAG/B,iBAAZ;;AAEA,QAAIa,KAAK,KAAK2B,SAAV,IAAuB3B,KAAK,KAAK,IAArC,EAA2C;AACvCkB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOa,KAAP,KAAiB,QAArB,EAA+B;AAClCkB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOa,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,oBAAoBA,KAAxB,EAA+B;AAC3BkB,QAAAA,KAAK,GAAGU,MAAM,CAAC5B,KAAK,CAAC6B,cAAP,CAAd;AACH,OAFD,MAEO,IAAI,gBAAgB7B,KAApB,EAA2B;AAC9BkB,QAAAA,KAAK,GAAGU,MAAM,CAAC5B,KAAK,CAACS,UAAP,CAAd;AACH,OAFM,MAEA,IAAI,WAAWT,KAAf,EAAsB;AACzBkB,QAAAA,KAAK,GAAGU,MAAM,CAAC5B,KAAK,CAACkB,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAelB,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEkB,QAAAA,KAAK,GAAI,MAAKlB,KAAK,CAAC8B,SAAU,IAAG9B,KAAK,CAAC+B,IAAK,IAAG/B,KAAK,CAACgC,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOd,KAAP;AACH;;AAhI2B;;;;gBAAnB9B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAAC6C,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F9C,kB,yBAS4B,CAAC,GAAG+C,OAAJ,KAA2B,CAAG,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 { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\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 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\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 for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DdRumResourceTracking = void 0;
|
|
7
|
+
|
|
8
|
+
var _InternalLog = require("../../../InternalLog");
|
|
9
|
+
|
|
10
|
+
var _SdkVerbosity = require("../../../SdkVerbosity");
|
|
11
|
+
|
|
12
|
+
var _firstPartyHosts = require("./domain/firstPartyHosts");
|
|
13
|
+
|
|
14
|
+
var _ResourceReporter = require("./implementation/DatadogRumResource/ResourceReporter");
|
|
15
|
+
|
|
16
|
+
var _internalDevResourceBlocklist = require("./implementation/DatadogRumResource/internalDevResourceBlocklist");
|
|
17
|
+
|
|
18
|
+
var _XHRProxy = require("./implementation/XHRProxy");
|
|
19
|
+
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
24
|
+
*/
|
|
25
|
+
class DdRumResourceTracking {
|
|
26
|
+
/**
|
|
27
|
+
* Starts tracking resources and sends a RUM Resource event every time a network request is detected.
|
|
28
|
+
*/
|
|
29
|
+
static startTracking({
|
|
30
|
+
tracingSamplingRate,
|
|
31
|
+
firstPartyHosts
|
|
32
|
+
}) {
|
|
33
|
+
// extra safety to avoid proxying the XHR class twice
|
|
34
|
+
if (DdRumResourceTracking.isTracking) {
|
|
35
|
+
_InternalLog.InternalLog.log('Datadog SDK is already tracking XHR resources', _SdkVerbosity.SdkVerbosity.WARN);
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.requestProxy = new _XHRProxy.XHRProxy({
|
|
41
|
+
xhrType: XMLHttpRequest,
|
|
42
|
+
resourceReporter: new _ResourceReporter.ResourceReporter([_internalDevResourceBlocklist.filterDevResource])
|
|
43
|
+
});
|
|
44
|
+
this.requestProxy.onTrackingStart({
|
|
45
|
+
tracingSamplingRate,
|
|
46
|
+
firstPartyHostsRegex: (0, _firstPartyHosts.firstPartyHostsRegexBuilder)(firstPartyHosts)
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_InternalLog.InternalLog.log('Datadog SDK is tracking XHR resources', _SdkVerbosity.SdkVerbosity.INFO);
|
|
50
|
+
|
|
51
|
+
DdRumResourceTracking.isTracking = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static stopTracking() {
|
|
55
|
+
if (DdRumResourceTracking.isTracking) {
|
|
56
|
+
DdRumResourceTracking.isTracking = false;
|
|
57
|
+
|
|
58
|
+
if (this.requestProxy) {
|
|
59
|
+
this.requestProxy.onTrackingStop();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.requestProxy = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.DdRumResourceTracking = DdRumResourceTracking;
|
|
69
|
+
|
|
70
|
+
_defineProperty(DdRumResourceTracking, "isTracking", false);
|
|
71
|
+
|
|
72
|
+
_defineProperty(DdRumResourceTracking, "requestProxy", void 0);
|
|
73
|
+
//# sourceMappingURL=DdRumResourceTracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","InternalLog","log","SdkVerbosity","WARN","requestProxy","XHRProxy","xhrType","XMLHttpRequest","resourceReporter","ResourceReporter","filterDevResource","onTrackingStart","firstPartyHostsRegex","INFO","stopTracking","onTrackingStop"],"mappings":";;;;;;;AAMA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,qBAAN,CAA4B;AAI/B;AACJ;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA,mBADiB;AAEjBC,IAAAA;AAFiB,GAAD,EAMX;AACL;AACA,QAAIH,qBAAqB,CAACI,UAA1B,EAAsC;AAClCC,+BAAYC,GAAZ,CACI,+CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,SAAKC,YAAL,GAAoB,IAAIC,kBAAJ,CAAa;AAC7BC,MAAAA,OAAO,EAAEC,cADoB;AAE7BC,MAAAA,gBAAgB,EAAE,IAAIC,kCAAJ,CAAqB,CAACC,+CAAD,CAArB;AAFW,KAAb,CAApB;AAIA,SAAKN,YAAL,CAAkBO,eAAlB,CAAkC;AAC9Bd,MAAAA,mBAD8B;AAE9Be,MAAAA,oBAAoB,EAAE,kDAA4Bd,eAA5B;AAFQ,KAAlC;;AAKAE,6BAAYC,GAAZ,CACI,uCADJ,EAEIC,2BAAaW,IAFjB;;AAIAlB,IAAAA,qBAAqB,CAACI,UAAtB,GAAmC,IAAnC;AACH;;AAEkB,SAAZe,YAAY,GAAS;AACxB,QAAInB,qBAAqB,CAACI,UAA1B,EAAsC;AAClCJ,MAAAA,qBAAqB,CAACI,UAAtB,GAAmC,KAAnC;;AACA,UAAI,KAAKK,YAAT,EAAuB;AACnB,aAAKA,YAAL,CAAkBW,cAAlB;AACH;;AACD,WAAKX,YAAL,GAAoB,IAApB;AACH;AACJ;;AA/C8B;;;;gBAAtBT,qB,gBACmB,K;;gBADnBA,qB","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 { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\n\nimport { firstPartyHostsRegexBuilder } from './domain/firstPartyHosts';\nimport type { RequestProxy } from './domain/interfaces/RequestProxy';\nimport { ResourceReporter } from './implementation/DatadogRumResource/ResourceReporter';\nimport { filterDevResource } from './implementation/DatadogRumResource/internalDevResourceBlocklist';\nimport { XHRProxy } from './implementation/XHRProxy';\n\n/**\n * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.\n */\nexport class DdRumResourceTracking {\n private static isTracking = false;\n private static requestProxy: RequestProxy | null;\n\n /**\n * Starts tracking resources and sends a RUM Resource event every time a network request is detected.\n */\n static startTracking({\n tracingSamplingRate,\n firstPartyHosts\n }: {\n tracingSamplingRate: number;\n firstPartyHosts: string[];\n }): void {\n // extra safety to avoid proxying the XHR class twice\n if (DdRumResourceTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking XHR resources',\n SdkVerbosity.WARN\n );\n return;\n }\n\n this.requestProxy = new XHRProxy({\n xhrType: XMLHttpRequest,\n resourceReporter: new ResourceReporter([filterDevResource])\n });\n this.requestProxy.onTrackingStart({\n tracingSamplingRate,\n firstPartyHostsRegex: firstPartyHostsRegexBuilder(firstPartyHosts)\n });\n\n InternalLog.log(\n 'Datadog SDK is tracking XHR resources',\n SdkVerbosity.INFO\n );\n DdRumResourceTracking.isTracking = true;\n }\n\n static stopTracking(): void {\n if (DdRumResourceTracking.isTracking) {\n DdRumResourceTracking.isTracking = false;\n if (this.requestProxy) {\n this.requestProxy.onTrackingStop();\n }\n this.requestProxy = null;\n }\n }\n}\n"]}
|
|
@@ -4,16 +4,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateTraceId = generateTraceId;
|
|
7
|
+
exports.getTracingAttributes = void 0;
|
|
8
|
+
|
|
9
|
+
var _firstPartyHosts = require("./firstPartyHosts");
|
|
7
10
|
|
|
8
11
|
/*
|
|
9
12
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
10
13
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
14
|
* Copyright 2016-Present Datadog, Inc.
|
|
12
15
|
*/
|
|
16
|
+
const DISCARDED_TRACE_ATTRIBUTES = {
|
|
17
|
+
samplingPriorityHeader: '0',
|
|
18
|
+
tracingStrategy: 'DISCARD'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getTracingAttributes = ({
|
|
22
|
+
hostname,
|
|
23
|
+
firstPartyHostsRegex,
|
|
24
|
+
tracingSamplingRate
|
|
25
|
+
}) => {
|
|
26
|
+
if (hostname === null) {
|
|
27
|
+
return DISCARDED_TRACE_ATTRIBUTES;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ((0, _firstPartyHosts.isHostFirstParty)(hostname, firstPartyHostsRegex)) {
|
|
31
|
+
return generateTracingAttributesWithSampling(tracingSamplingRate);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return DISCARDED_TRACE_ATTRIBUTES;
|
|
35
|
+
};
|
|
13
36
|
|
|
37
|
+
exports.getTracingAttributes = getTracingAttributes;
|
|
38
|
+
|
|
39
|
+
const generateTracingAttributesWithSampling = tracingSamplingRate => {
|
|
40
|
+
if (Math.random() * 100 <= tracingSamplingRate) {
|
|
41
|
+
return {
|
|
42
|
+
traceId: generateTraceId(),
|
|
43
|
+
spanId: generateTraceId(),
|
|
44
|
+
samplingPriorityHeader: '1',
|
|
45
|
+
tracingStrategy: 'KEEP'
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return DISCARDED_TRACE_ATTRIBUTES;
|
|
50
|
+
};
|
|
14
51
|
/*
|
|
15
52
|
* This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)
|
|
16
53
|
*/
|
|
54
|
+
|
|
55
|
+
|
|
17
56
|
function generateTraceId() {
|
|
18
57
|
const radix = 10;
|
|
19
58
|
const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1
|
|
@@ -40,4 +79,4 @@ function generateTraceId() {
|
|
|
40
79
|
|
|
41
80
|
return str;
|
|
42
81
|
}
|
|
43
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=distributedTracing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegex","tracingSamplingRate","generateTracingAttributesWithSampling","Math","random","traceId","generateTraceId","spanId","radix","MAX_32_BITS_NUMBER","low","floor","high","str","modH","temp","digit","toString"],"mappings":";;;;;;;;AAOA;;AAPA;AACA;AACA;AACA;AACA;AAmBA,MAAMA,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;;AAKO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,oBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,MAAI,uCAAiBI,QAAjB,EAA2BC,oBAA3B,CAAJ,EAAsD;AAClD,WAAOE,qCAAqC,CAACD,mBAAD,CAA5C;AACH;;AACD,SAAON,0BAAP;AACH,CAhBM;;;;AAkBP,MAAMO,qCAAqC,GACvCD,mBAD0C,IAET;AACjC,MAAIE,IAAI,CAACC,MAAL,KAAgB,GAAhB,IAAuBH,mBAA3B,EAAgD;AAC5C,WAAO;AACHI,MAAAA,OAAO,EAAEC,eAAe,EADrB;AAEHC,MAAAA,MAAM,EAAED,eAAe,EAFpB;AAGHV,MAAAA,sBAAsB,EAAE,GAHrB;AAIHC,MAAAA,eAAe,EAAE;AAJd,KAAP;AAMH;;AACD,SAAOF,0BAAP;AACH,CAZD;AAcA;AACA;AACA;;;AACO,SAASW,eAAT,GAAmC;AACtC,QAAME,KAAK,GAAG,EAAd;AACA,QAAMC,kBAAkB,GAAG,UAA3B,CAFsC,CAEC;;AACvC,MAAIC,GAAW,GAAGP,IAAI,CAACQ,KAAL,CAAWR,IAAI,CAACC,MAAL,KAAgBK,kBAA3B,CAAlB;AACA,MAAIG,IAAY,GAAGT,IAAI,CAACQ,KAAL,CAAWR,IAAI,CAACC,MAAL,KAAgBK,kBAA3B,CAAnB;AACA,MAAII,GAAG,GAAG,EAAV;;AAEA,SAAOD,IAAI,GAAG,CAAP,IAAYF,GAAG,GAAG,CAAzB,EAA4B;AACxB;AACA;AACA,UAAMI,IAAI,GAAGF,IAAI,GAAGJ,KAApB;AACA,UAAMO,IAAI,GAAG,CAACD,IAAI,IAAI,EAAT,IAAeJ,GAA5B;AACA,UAAMM,KAAK,GAAGD,IAAI,GAAGP,KAArB,CALwB,CAOxB;;AACAI,IAAAA,IAAI,GAAG,CAACA,IAAI,GAAGE,IAAR,IAAgBN,KAAvB,CARwB,CAQM;AAC9B;;AACAE,IAAAA,GAAG,GAAG,CAACK,IAAI,GAAGC,KAAR,IAAiBR,KAAvB,CAVwB,CAUM;AAE9B;;AACAK,IAAAA,GAAG,GAAGG,KAAK,CAACC,QAAN,KAAmBJ,GAAzB;AACH;;AACD,SAAOA,GAAP;AACH","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 { Hostname } from './firstPartyHosts';\nimport { isHostFirstParty } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: string;\n spanId: string;\n samplingPriorityHeader: '1';\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegex: RegExp;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n if (isHostFirstParty(hostname, firstPartyHostsRegex)) {\n return generateTracingAttributesWithSampling(tracingSamplingRate);\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number\n): DdRumResourceTracingAttributes => {\n if (Math.random() * 100 <= tracingSamplingRate) {\n return {\n traceId: generateTraceId(),\n spanId: generateTraceId(),\n samplingPriorityHeader: '1',\n tracingStrategy: 'KEEP'\n };\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\nexport function generateTraceId(): string {\n const radix = 10;\n const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let str = '';\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix;\n const temp = (modH << 32) + low;\n const digit = temp % radix;\n\n // update the high value\n high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str;\n }\n return str;\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isHostFirstParty = exports.firstPartyHostsRegexBuilder = exports.NO_MATCH_REGEX = void 0;
|
|
7
|
+
|
|
8
|
+
var _InternalLog = require("../../../../InternalLog");
|
|
9
|
+
|
|
10
|
+
var _SdkVerbosity = require("../../../../SdkVerbosity");
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
14
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
15
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
16
|
+
*/
|
|
17
|
+
// This regex does not match anything
|
|
18
|
+
const NO_MATCH_REGEX = new RegExp('a^'); // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
19
|
+
|
|
20
|
+
exports.NO_MATCH_REGEX = NO_MATCH_REGEX;
|
|
21
|
+
|
|
22
|
+
const escapeRegExp = string => {
|
|
23
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const firstPartyHostsRegexBuilder = firstPartyHosts => {
|
|
27
|
+
if (firstPartyHosts.length === 0) {
|
|
28
|
+
return NO_MATCH_REGEX;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
// A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
|
|
33
|
+
// "example.com", "api.example.com", but not "foo.com".
|
|
34
|
+
const firstPartyHostsRegex = new RegExp(`^(.*\\.)*(${firstPartyHosts.map(host => `${escapeRegExp(host)}$`).join('|')})`);
|
|
35
|
+
firstPartyHostsRegex.test('test_the_regex_is_valid');
|
|
36
|
+
return firstPartyHostsRegex;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
_InternalLog.InternalLog.log(`Invalid first party hosts list ${JSON.stringify(firstPartyHosts)}. Regular expressions are not allowed.`, _SdkVerbosity.SdkVerbosity.WARN);
|
|
39
|
+
|
|
40
|
+
return NO_MATCH_REGEX;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.firstPartyHostsRegexBuilder = firstPartyHostsRegexBuilder;
|
|
45
|
+
|
|
46
|
+
const isHostFirstParty = (hostname, firstPartyHostsRegex) => {
|
|
47
|
+
return firstPartyHostsRegex.test(hostname);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.isHostFirstParty = isHostFirstParty;
|
|
51
|
+
//# sourceMappingURL=firstPartyHosts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["firstPartyHosts.ts"],"names":["NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexBuilder","firstPartyHosts","length","firstPartyHostsRegex","map","host","join","test","e","InternalLog","log","JSON","stringify","SdkVerbosity","WARN","isHostFirstParty","hostname"],"mappings":";;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AAOA;AACO,MAAMA,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB,C,CAEP;;;;AACA,MAAMC,YAAY,GAAIC,MAAD,IAAoB;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAe,qBAAf,EAAsC,MAAtC,CAAP,CADqC,CACiB;AACzD,CAFD;;AAIO,MAAMC,2BAA2B,GACpCC,eADuC,IAE9B;AACT,MAAIA,eAAe,CAACC,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOP,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMQ,oBAAoB,GAAG,IAAIP,MAAJ,CACxB,aAAYK,eAAe,CACvBG,GADQ,CACJC,IAAI,IAAK,GAAER,YAAY,CAACQ,IAAD,CAAO,GAD1B,EAERC,IAFQ,CAEH,GAFG,CAEE,GAHU,CAA7B;AAKAH,IAAAA,oBAAoB,CAACI,IAArB,CAA0B,yBAA1B;AACA,WAAOJ,oBAAP;AACH,GAVD,CAUE,OAAOK,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9BX,eAD8B,CAEhC,wCAHN,EAIIY,2BAAaC,IAJjB;;AAMA,WAAOnB,cAAP;AACH;AACJ,CAzBM;;;;AA2BA,MAAMoB,gBAAgB,GAAG,CAC5BC,QAD4B,EAE5Bb,oBAF4B,KAGlB;AACV,SAAOA,oBAAoB,CAACI,IAArB,CAA0BS,QAA1B,CAAP;AACH,CALM","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 { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\nconst escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n};\n\nexport const firstPartyHostsRegexBuilder = (\n firstPartyHosts: string[]\n): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts\n .map(host => `${escapeRegExp(host)}$`)\n .join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const isHostFirstParty = (\n hostname: Hostname,\n firstPartyHostsRegex: RegExp\n): boolean => {\n return firstPartyHostsRegex.test(hostname);\n};\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RequestProxy = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
14
|
+
*/
|
|
15
|
+
class RequestProxy {
|
|
16
|
+
constructor() {
|
|
17
|
+
_defineProperty(this, "onTrackingStart", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "onTrackingStop", void 0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.RequestProxy = RequestProxy;
|
|
25
|
+
//# sourceMappingURL=RequestProxy.js.map
|
package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["RequestProxy.ts"],"names":["RequestProxy"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAOO,MAAeA,YAAf,CAA4B;AAAA;AAAA;;AAAA;AAAA;;AAAA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport interface RequestProxyOptions {\n tracingSamplingRate: number;\n firstPartyHostsRegex: RegExp;\n}\n\nexport abstract class RequestProxy {\n abstract onTrackingStart: (context: RequestProxyOptions) => void;\n abstract onTrackingStop: () => void;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ResourceReporter = void 0;
|
|
7
|
+
|
|
8
|
+
var _foundation = require("../../../../../foundation");
|
|
9
|
+
|
|
10
|
+
var _resourceTiming = require("./resourceTiming");
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
class ResourceReporter {
|
|
15
|
+
constructor(resourceMappers) {
|
|
16
|
+
_defineProperty(this, "mappers", void 0);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "reportResource", resource => {
|
|
19
|
+
let modifiedResource = resource;
|
|
20
|
+
|
|
21
|
+
for (const mapper of this.mappers) {
|
|
22
|
+
modifiedResource = mapper(resource);
|
|
23
|
+
|
|
24
|
+
if (modifiedResource === null) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
reportResource(modifiedResource);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.mappers = resourceMappers;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.ResourceReporter = ResourceReporter;
|
|
38
|
+
|
|
39
|
+
const formatResourceStartContext = tracingAttributes => {
|
|
40
|
+
return tracingAttributes.tracingStrategy === 'DISCARD' ? undefined : {
|
|
41
|
+
'_dd.span_id': tracingAttributes.spanId,
|
|
42
|
+
'_dd.trace_id': tracingAttributes.traceId
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const formatResourceStopContext = timings => {
|
|
47
|
+
return {
|
|
48
|
+
'_dd.resource_timings': timings.responseStartTime !== undefined ? (0, _resourceTiming.createTimings)(timings.startTime, timings.responseStartTime, timings.stopTime) : null
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const reportResource = async resource => {
|
|
53
|
+
await _foundation.DdRum.startResource(resource.key, resource.request.method, resource.request.url, formatResourceStartContext(resource.tracingAttributes), resource.timings.startTime);
|
|
54
|
+
|
|
55
|
+
_foundation.DdRum.stopResource(resource.key, resource.response.statusCode, resource.request.kind, resource.response.size, formatResourceStopContext(resource.timings), resource.timings.stopTime);
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=ResourceReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ResourceReporter.ts"],"names":["ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","DdRum","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;;;;;;AAMA;;AAGA;;;;AAIO,MAAMA,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEO;AACtC,SAAOA,iBAAiB,CAACC,eAAlB,KAAsC,SAAtC,GACDC,SADC,GAED;AACI,mBAAeF,iBAAiB,CAACG,MADrC;AAEI,oBAAgBH,iBAAiB,CAACI;AAFtC,GAFN;AAMH,CATD;;AAWA,MAAMC,yBAAyB,GAC3BC,OAD8B,IAEJ;AAC1B,SAAO;AACH,4BACIA,OAAO,CAACC,iBAAR,KAA8BL,SAA9B,GACM,mCACII,OAAO,CAACE,SADZ,EAEIF,OAAO,CAACC,iBAFZ,EAGID,OAAO,CAACG,QAHZ,CADN,GAMM;AARP,GAAP;AAUH,CAbD;;AAeA,MAAMX,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAMgB,kBAAMC,aAAN,CACFjB,QAAQ,CAACkB,GADP,EAEFlB,QAAQ,CAACmB,OAAT,CAAiBC,MAFf,EAGFpB,QAAQ,CAACmB,OAAT,CAAiBE,GAHf,EAIFhB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACY,OAAT,CAAiBE,SALf,CAAN;;AAQAE,oBAAMM,YAAN,CACItB,QAAQ,CAACkB,GADb,EAEIlB,QAAQ,CAACuB,QAAT,CAAkBC,UAFtB,EAGIxB,QAAQ,CAACmB,OAAT,CAAiBM,IAHrB,EAIIzB,QAAQ,CAACuB,QAAT,CAAkBG,IAJtB,EAKIf,yBAAyB,CAACX,QAAQ,CAACY,OAAV,CAL7B,EAMIZ,QAAQ,CAACY,OAAT,CAAiBG,QANrB;AAQH,CAjBD","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 { DdRum } from '../../../../../foundation';\nimport type { RUMResource } from '../../domain/interfaces/RumResource';\n\nimport { createTimings } from './resourceTiming';\n\ntype ResourceMapper = (resource: RUMResource) => RUMResource | null;\n\nexport class ResourceReporter {\n private mappers: ResourceMapper[];\n\n constructor(resourceMappers: ResourceMapper[]) {\n this.mappers = resourceMappers;\n }\n\n reportResource = (resource: RUMResource) => {\n let modifiedResource: RUMResource | null = resource;\n\n for (const mapper of this.mappers) {\n modifiedResource = mapper(resource);\n if (modifiedResource === null) {\n return;\n }\n }\n\n reportResource(modifiedResource);\n };\n}\n\nconst formatResourceStartContext = (\n tracingAttributes: RUMResource['tracingAttributes']\n): Record<string, unknown> | undefined => {\n return tracingAttributes.tracingStrategy === 'DISCARD'\n ? undefined\n : {\n '_dd.span_id': tracingAttributes.spanId,\n '_dd.trace_id': tracingAttributes.traceId\n };\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings']\n): Record<string, unknown> => {\n return {\n '_dd.resource_timings':\n timings.responseStartTime !== undefined\n ? createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n )\n : null\n };\n};\n\nconst reportResource = async (resource: RUMResource) => {\n await DdRum.startResource(\n resource.key,\n resource.request.method,\n resource.request.url,\n formatResourceStartContext(resource.tracingAttributes),\n resource.timings.startTime\n );\n\n DdRum.stopResource(\n resource.key,\n resource.response.statusCode,\n resource.request.kind,\n resource.response.size,\n formatResourceStopContext(resource.timings),\n resource.timings.stopTime\n );\n};\n"]}
|