@kubesense/kubesense-browser-rum-core 1.0.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/LICENSE +201 -0
- package/README.md +3 -0
- package/cjs/boot/preStartRum.d.ts +7 -0
- package/cjs/boot/preStartRum.js +190 -0
- package/cjs/boot/preStartRum.js.map +1 -0
- package/cjs/boot/rumPublicApi.d.ts +409 -0
- package/cjs/boot/rumPublicApi.js +168 -0
- package/cjs/boot/rumPublicApi.js.map +1 -0
- package/cjs/boot/startRum.d.ts +109 -0
- package/cjs/boot/startRum.js +153 -0
- package/cjs/boot/startRum.js.map +1 -0
- package/cjs/browser/cookieObservable.d.ts +8 -0
- package/cjs/browser/cookieObservable.js +39 -0
- package/cjs/browser/cookieObservable.js.map +1 -0
- package/cjs/browser/domMutationObservable.d.ts +27 -0
- package/cjs/browser/domMutationObservable.js +58 -0
- package/cjs/browser/domMutationObservable.js.map +1 -0
- package/cjs/browser/firstInputPolyfill.d.ts +8 -0
- package/cjs/browser/firstInputPolyfill.js +68 -0
- package/cjs/browser/firstInputPolyfill.js.map +1 -0
- package/cjs/browser/htmlDomUtils.d.ts +13 -0
- package/cjs/browser/htmlDomUtils.js +46 -0
- package/cjs/browser/htmlDomUtils.js.map +1 -0
- package/cjs/browser/locationChangeObservable.d.ts +7 -0
- package/cjs/browser/locationChangeObservable.js +51 -0
- package/cjs/browser/locationChangeObservable.js.map +1 -0
- package/cjs/browser/performanceObservable.d.ts +174 -0
- package/cjs/browser/performanceObservable.js +126 -0
- package/cjs/browser/performanceObservable.js.map +1 -0
- package/cjs/browser/performanceUtils.d.ts +7 -0
- package/cjs/browser/performanceUtils.js +42 -0
- package/cjs/browser/performanceUtils.js.map +1 -0
- package/cjs/browser/scroll.d.ts +2 -0
- package/cjs/browser/scroll.js +33 -0
- package/cjs/browser/scroll.js.map +1 -0
- package/cjs/browser/viewportObservable.d.ts +10 -0
- package/cjs/browser/viewportObservable.js +37 -0
- package/cjs/browser/viewportObservable.js.map +1 -0
- package/cjs/browser/windowOpenObservable.d.ts +5 -0
- package/cjs/browser/windowOpenObservable.js +10 -0
- package/cjs/browser/windowOpenObservable.js.map +1 -0
- package/cjs/domain/action/actionCollection.d.ts +21 -0
- package/cjs/domain/action/actionCollection.js +96 -0
- package/cjs/domain/action/actionCollection.js.map +1 -0
- package/cjs/domain/action/actionNameConstants.d.ts +18 -0
- package/cjs/domain/action/actionNameConstants.js +11 -0
- package/cjs/domain/action/actionNameConstants.js.map +1 -0
- package/cjs/domain/action/clickChain.d.ts +8 -0
- package/cjs/domain/action/clickChain.js +61 -0
- package/cjs/domain/action/clickChain.js.map +1 -0
- package/cjs/domain/action/computeFrustration.d.ts +6 -0
- package/cjs/domain/action/computeFrustration.js +70 -0
- package/cjs/domain/action/computeFrustration.js.map +1 -0
- package/cjs/domain/action/getActionNameFromElement.d.ts +4 -0
- package/cjs/domain/action/getActionNameFromElement.js +239 -0
- package/cjs/domain/action/getActionNameFromElement.js.map +1 -0
- package/cjs/domain/action/interactionSelectorCache.d.ts +5 -0
- package/cjs/domain/action/interactionSelectorCache.js +23 -0
- package/cjs/domain/action/interactionSelectorCache.js.map +1 -0
- package/cjs/domain/action/listenActionEvents.d.ts +19 -0
- package/cjs/domain/action/listenActionEvents.js +61 -0
- package/cjs/domain/action/listenActionEvents.js.map +1 -0
- package/cjs/domain/action/trackClickActions.d.ts +81 -0
- package/cjs/domain/action/trackClickActions.js +237 -0
- package/cjs/domain/action/trackClickActions.js.map +1 -0
- package/cjs/domain/assembly.d.ts +5 -0
- package/cjs/domain/assembly.js +102 -0
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration/configuration.d.ts +325 -0
- package/cjs/domain/configuration/configuration.js +205 -0
- package/cjs/domain/configuration/configuration.js.map +1 -0
- package/cjs/domain/configuration/index.d.ts +2 -0
- package/cjs/domain/configuration/index.js +19 -0
- package/cjs/domain/configuration/index.js.map +1 -0
- package/cjs/domain/configuration/jsonPathParser.d.ts +28 -0
- package/cjs/domain/configuration/jsonPathParser.js +159 -0
- package/cjs/domain/configuration/jsonPathParser.js.map +1 -0
- package/cjs/domain/configuration/remoteConfiguration.d.ts +39 -0
- package/cjs/domain/configuration/remoteConfiguration.js +243 -0
- package/cjs/domain/configuration/remoteConfiguration.js.map +1 -0
- package/cjs/domain/configuration/remoteConfiguration.types.d.ts +138 -0
- package/cjs/domain/configuration/remoteConfiguration.types.js +7 -0
- package/cjs/domain/configuration/remoteConfiguration.types.js.map +1 -0
- package/cjs/domain/contexts/ciVisibilityContext.d.ts +12 -0
- package/cjs/domain/contexts/ciVisibilityContext.js +34 -0
- package/cjs/domain/contexts/ciVisibilityContext.js.map +1 -0
- package/cjs/domain/contexts/connectivityContext.d.ts +2 -0
- package/cjs/domain/contexts/connectivityContext.js +11 -0
- package/cjs/domain/contexts/connectivityContext.js.map +1 -0
- package/cjs/domain/contexts/defaultContext.d.ts +4 -0
- package/cjs/domain/contexts/defaultContext.js +34 -0
- package/cjs/domain/contexts/defaultContext.js.map +1 -0
- package/cjs/domain/contexts/displayContext.d.ts +6 -0
- package/cjs/domain/contexts/displayContext.js +28 -0
- package/cjs/domain/contexts/displayContext.js.map +1 -0
- package/cjs/domain/contexts/featureFlagContext.d.ts +19 -0
- package/cjs/domain/contexts/featureFlagContext.js +53 -0
- package/cjs/domain/contexts/featureFlagContext.js.map +1 -0
- package/cjs/domain/contexts/internalContext.d.ts +12 -0
- package/cjs/domain/contexts/internalContext.js +26 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/contexts/pageStateHistory.d.ts +23 -0
- package/cjs/domain/contexts/pageStateHistory.js +104 -0
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -0
- package/cjs/domain/contexts/sessionContext.d.ts +5 -0
- package/cjs/domain/contexts/sessionContext.js +47 -0
- package/cjs/domain/contexts/sessionContext.js.map +1 -0
- package/cjs/domain/contexts/syntheticsContext.d.ts +2 -0
- package/cjs/domain/contexts/syntheticsContext.js +25 -0
- package/cjs/domain/contexts/syntheticsContext.js.map +1 -0
- package/cjs/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/cjs/domain/contexts/trackingConsentContext.js +14 -0
- package/cjs/domain/contexts/trackingConsentContext.js.map +1 -0
- package/cjs/domain/contexts/urlContexts.d.ts +22 -0
- package/cjs/domain/contexts/urlContexts.js +64 -0
- package/cjs/domain/contexts/urlContexts.js.map +1 -0
- package/cjs/domain/contexts/userAgentDataContext.d.ts +2 -0
- package/cjs/domain/contexts/userAgentDataContext.js +31 -0
- package/cjs/domain/contexts/userAgentDataContext.js.map +1 -0
- package/cjs/domain/contexts/viewHistory.d.ts +17 -0
- package/cjs/domain/contexts/viewHistory.js +48 -0
- package/cjs/domain/contexts/viewHistory.js.map +1 -0
- package/cjs/domain/discardNegativeDuration.d.ts +2 -0
- package/cjs/domain/discardNegativeDuration.js +8 -0
- package/cjs/domain/discardNegativeDuration.js.map +1 -0
- package/cjs/domain/error/errorCollection.d.ts +17 -0
- package/cjs/domain/error/errorCollection.js +74 -0
- package/cjs/domain/error/errorCollection.js.map +1 -0
- package/cjs/domain/error/trackConsoleError.d.ts +4 -0
- package/cjs/domain/error/trackConsoleError.js +13 -0
- package/cjs/domain/error/trackConsoleError.js.map +1 -0
- package/cjs/domain/error/trackReportError.d.ts +5 -0
- package/cjs/domain/error/trackReportError.js +16 -0
- package/cjs/domain/error/trackReportError.js.map +1 -0
- package/cjs/domain/event/eventCollection.d.ts +10 -0
- package/cjs/domain/event/eventCollection.js +27 -0
- package/cjs/domain/event/eventCollection.js.map +1 -0
- package/cjs/domain/getSelectorFromElement.d.ts +64 -0
- package/cjs/domain/getSelectorFromElement.js +218 -0
- package/cjs/domain/getSelectorFromElement.js.map +1 -0
- package/cjs/domain/getSessionReplayUrl.d.ts +9 -0
- package/cjs/domain/getSessionReplayUrl.js +34 -0
- package/cjs/domain/getSessionReplayUrl.js.map +1 -0
- package/cjs/domain/hooks.d.ts +23 -0
- package/cjs/domain/hooks.js +6 -0
- package/cjs/domain/hooks.js.map +1 -0
- package/cjs/domain/lifeCycle.d.ts +73 -0
- package/cjs/domain/lifeCycle.js +6 -0
- package/cjs/domain/lifeCycle.js.map +1 -0
- package/cjs/domain/limitModification.d.ts +8 -0
- package/cjs/domain/limitModification.js +46 -0
- package/cjs/domain/limitModification.js.map +1 -0
- package/cjs/domain/longTask/longTaskCollection.d.ts +18 -0
- package/cjs/domain/longTask/longTaskCollection.js +91 -0
- package/cjs/domain/longTask/longTaskCollection.js.map +1 -0
- package/cjs/domain/plugins.d.ts +40 -0
- package/cjs/domain/plugins.js +15 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/privacy.d.ts +44 -0
- package/cjs/domain/privacy.js +313 -0
- package/cjs/domain/privacy.js.map +1 -0
- package/cjs/domain/privacyConstants.d.ts +23 -0
- package/cjs/domain/privacyConstants.js +39 -0
- package/cjs/domain/privacyConstants.js.map +1 -0
- package/cjs/domain/requestCollection.d.ts +54 -0
- package/cjs/domain/requestCollection.js +111 -0
- package/cjs/domain/requestCollection.js.map +1 -0
- package/cjs/domain/resource/graphql.d.ts +23 -0
- package/cjs/domain/resource/graphql.js +97 -0
- package/cjs/domain/resource/graphql.js.map +1 -0
- package/cjs/domain/resource/matchRequestResourceEntry.d.ts +16 -0
- package/cjs/domain/resource/matchRequestResourceEntry.js +49 -0
- package/cjs/domain/resource/matchRequestResourceEntry.js.map +1 -0
- package/cjs/domain/resource/requestRegistry.d.ts +9 -0
- package/cjs/domain/resource/requestRegistry.js +41 -0
- package/cjs/domain/resource/requestRegistry.js.map +1 -0
- package/cjs/domain/resource/resourceCollection.d.ts +7 -0
- package/cjs/domain/resource/resourceCollection.js +190 -0
- package/cjs/domain/resource/resourceCollection.js.map +1 -0
- package/cjs/domain/resource/resourceUtils.d.ts +55 -0
- package/cjs/domain/resource/resourceUtils.js +259 -0
- package/cjs/domain/resource/resourceUtils.js.map +1 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +4 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js +24 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/cjs/domain/rumSessionManager.d.ts +36 -0
- package/cjs/domain/rumSessionManager.js +77 -0
- package/cjs/domain/rumSessionManager.js.map +1 -0
- package/cjs/domain/sampler/sampler.d.ts +10 -0
- package/cjs/domain/sampler/sampler.js +63 -0
- package/cjs/domain/sampler/sampler.js.map +1 -0
- package/cjs/domain/startCustomerDataTelemetry.d.ts +4 -0
- package/cjs/domain/startCustomerDataTelemetry.js +56 -0
- package/cjs/domain/startCustomerDataTelemetry.js.map +1 -0
- package/cjs/domain/tracing/getDocumentTraceId.d.ts +12 -0
- package/cjs/domain/tracing/getDocumentTraceId.js +76 -0
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/cjs/domain/tracing/identifier.d.ts +13 -0
- package/cjs/domain/tracing/identifier.js +55 -0
- package/cjs/domain/tracing/identifier.js.map +1 -0
- package/cjs/domain/tracing/sampler.d.ts +10 -0
- package/cjs/domain/tracing/sampler.js +69 -0
- package/cjs/domain/tracing/sampler.js.map +1 -0
- package/cjs/domain/tracing/tracer.d.ts +30 -0
- package/cjs/domain/tracing/tracer.js +161 -0
- package/cjs/domain/tracing/tracer.js.map +1 -0
- package/cjs/domain/tracing/tracer.types.d.ts +12 -0
- package/cjs/domain/tracing/tracer.types.js +3 -0
- package/cjs/domain/tracing/tracer.types.js.map +1 -0
- package/cjs/domain/trackEventCounts.d.ts +17 -0
- package/cjs/domain/trackEventCounts.js +50 -0
- package/cjs/domain/trackEventCounts.js.map +1 -0
- package/cjs/domain/view/bfCacheSupport.d.ts +2 -0
- package/cjs/domain/view/bfCacheSupport.js +13 -0
- package/cjs/domain/view/bfCacheSupport.js.map +1 -0
- package/cjs/domain/view/trackViewEventCounts.d.ts +5 -0
- package/cjs/domain/view/trackViewEventCounts.js +16 -0
- package/cjs/domain/view/trackViewEventCounts.js.map +1 -0
- package/cjs/domain/view/trackViews.d.ts +65 -0
- package/cjs/domain/view/trackViews.js +275 -0
- package/cjs/domain/view/trackViews.js.map +1 -0
- package/cjs/domain/view/viewCollection.d.ts +18 -0
- package/cjs/domain/view/viewCollection.js +153 -0
- package/cjs/domain/view/viewCollection.js.map +1 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.d.ts +6 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js +32 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +1 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.d.ts +18 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js +44 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js.map +1 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +6 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +44 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +8 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js +17 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +21 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js +37 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +37 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js +135 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +13 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js +39 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.d.ts +10 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.js +33 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.d.ts +19 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.js +43 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +15 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js +41 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +25 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js +155 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +18 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js +61 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.d.ts +14 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.js +50 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.d.ts +14 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.js +43 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.d.ts +25 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.js +78 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.js.map +1 -0
- package/cjs/domain/vital/vitalCollection.d.ts +55 -0
- package/cjs/domain/vital/vitalCollection.js +113 -0
- package/cjs/domain/vital/vitalCollection.js.map +1 -0
- package/cjs/domain/waitPageActivityEnd.d.ts +54 -0
- package/cjs/domain/waitPageActivityEnd.js +129 -0
- package/cjs/domain/waitPageActivityEnd.js.map +1 -0
- package/cjs/domainContext.types.d.ts +39 -0
- package/cjs/domainContext.types.js +6 -0
- package/cjs/domainContext.types.js.map +1 -0
- package/cjs/index.d.ts +41 -0
- package/cjs/index.js +59 -0
- package/cjs/index.js.map +1 -0
- package/cjs/rawRumEvent.types.d.ts +326 -0
- package/cjs/rawRumEvent.types.js +34 -0
- package/cjs/rawRumEvent.types.js.map +1 -0
- package/cjs/rumEvent.types.d.ts +2026 -0
- package/cjs/rumEvent.types.js +7 -0
- package/cjs/rumEvent.types.js.map +1 -0
- package/cjs/transport/formDataTransport.d.ts +16 -0
- package/cjs/transport/formDataTransport.js +46 -0
- package/cjs/transport/formDataTransport.js.map +1 -0
- package/cjs/transport/startRumBatch.d.ts +5 -0
- package/cjs/transport/startRumBatch.js +33 -0
- package/cjs/transport/startRumBatch.js.map +1 -0
- package/cjs/transport/startRumEventBridge.d.ts +2 -0
- package/cjs/transport/startRumEventBridge.js +11 -0
- package/cjs/transport/startRumEventBridge.js.map +1 -0
- package/esm/boot/preStartRum.d.ts +7 -0
- package/esm/boot/preStartRum.js +187 -0
- package/esm/boot/preStartRum.js.map +1 -0
- package/esm/boot/rumPublicApi.d.ts +409 -0
- package/esm/boot/rumPublicApi.js +165 -0
- package/esm/boot/rumPublicApi.js.map +1 -0
- package/esm/boot/startRum.d.ts +109 -0
- package/esm/boot/startRum.js +149 -0
- package/esm/boot/startRum.js.map +1 -0
- package/esm/browser/cookieObservable.d.ts +8 -0
- package/esm/browser/cookieObservable.js +35 -0
- package/esm/browser/cookieObservable.js.map +1 -0
- package/esm/browser/domMutationObservable.d.ts +27 -0
- package/esm/browser/domMutationObservable.js +54 -0
- package/esm/browser/domMutationObservable.js.map +1 -0
- package/esm/browser/firstInputPolyfill.d.ts +8 -0
- package/esm/browser/firstInputPolyfill.js +65 -0
- package/esm/browser/firstInputPolyfill.js.map +1 -0
- package/esm/browser/htmlDomUtils.d.ts +13 -0
- package/esm/browser/htmlDomUtils.js +36 -0
- package/esm/browser/htmlDomUtils.js.map +1 -0
- package/esm/browser/locationChangeObservable.d.ts +7 -0
- package/esm/browser/locationChangeObservable.js +48 -0
- package/esm/browser/locationChangeObservable.js.map +1 -0
- package/esm/browser/performanceObservable.d.ts +174 -0
- package/esm/browser/performanceObservable.js +121 -0
- package/esm/browser/performanceObservable.js.map +1 -0
- package/esm/browser/performanceUtils.d.ts +7 -0
- package/esm/browser/performanceUtils.js +38 -0
- package/esm/browser/performanceUtils.js.map +1 -0
- package/esm/browser/scroll.d.ts +2 -0
- package/esm/browser/scroll.js +29 -0
- package/esm/browser/scroll.js.map +1 -0
- package/esm/browser/viewportObservable.d.ts +10 -0
- package/esm/browser/viewportObservable.js +32 -0
- package/esm/browser/viewportObservable.js.map +1 -0
- package/esm/browser/windowOpenObservable.d.ts +5 -0
- package/esm/browser/windowOpenObservable.js +7 -0
- package/esm/browser/windowOpenObservable.js.map +1 -0
- package/esm/domain/action/actionCollection.d.ts +21 -0
- package/esm/domain/action/actionCollection.js +93 -0
- package/esm/domain/action/actionCollection.js.map +1 -0
- package/esm/domain/action/actionNameConstants.d.ts +18 -0
- package/esm/domain/action/actionNameConstants.js +8 -0
- package/esm/domain/action/actionNameConstants.js.map +1 -0
- package/esm/domain/action/clickChain.d.ts +8 -0
- package/esm/domain/action/clickChain.js +57 -0
- package/esm/domain/action/clickChain.js.map +1 -0
- package/esm/domain/action/computeFrustration.d.ts +6 -0
- package/esm/domain/action/computeFrustration.js +65 -0
- package/esm/domain/action/computeFrustration.js.map +1 -0
- package/esm/domain/action/getActionNameFromElement.d.ts +4 -0
- package/esm/domain/action/getActionNameFromElement.js +236 -0
- package/esm/domain/action/getActionNameFromElement.js.map +1 -0
- package/esm/domain/action/interactionSelectorCache.d.ts +5 -0
- package/esm/domain/action/interactionSelectorCache.js +18 -0
- package/esm/domain/action/interactionSelectorCache.js.map +1 -0
- package/esm/domain/action/listenActionEvents.d.ts +19 -0
- package/esm/domain/action/listenActionEvents.js +58 -0
- package/esm/domain/action/listenActionEvents.js.map +1 -0
- package/esm/domain/action/trackClickActions.d.ts +81 -0
- package/esm/domain/action/trackClickActions.js +232 -0
- package/esm/domain/action/trackClickActions.js.map +1 -0
- package/esm/domain/assembly.d.ts +5 -0
- package/esm/domain/assembly.js +99 -0
- package/esm/domain/assembly.js.map +1 -0
- package/esm/domain/configuration/configuration.d.ts +325 -0
- package/esm/domain/configuration/configuration.js +200 -0
- package/esm/domain/configuration/configuration.js.map +1 -0
- package/esm/domain/configuration/index.d.ts +2 -0
- package/esm/domain/configuration/index.js +3 -0
- package/esm/domain/configuration/index.js.map +1 -0
- package/esm/domain/configuration/jsonPathParser.d.ts +28 -0
- package/esm/domain/configuration/jsonPathParser.js +156 -0
- package/esm/domain/configuration/jsonPathParser.js.map +1 -0
- package/esm/domain/configuration/remoteConfiguration.d.ts +39 -0
- package/esm/domain/configuration/remoteConfiguration.js +236 -0
- package/esm/domain/configuration/remoteConfiguration.js.map +1 -0
- package/esm/domain/configuration/remoteConfiguration.types.d.ts +138 -0
- package/esm/domain/configuration/remoteConfiguration.types.js +6 -0
- package/esm/domain/configuration/remoteConfiguration.types.js.map +1 -0
- package/esm/domain/contexts/ciVisibilityContext.d.ts +12 -0
- package/esm/domain/contexts/ciVisibilityContext.js +30 -0
- package/esm/domain/contexts/ciVisibilityContext.js.map +1 -0
- package/esm/domain/contexts/connectivityContext.d.ts +2 -0
- package/esm/domain/contexts/connectivityContext.js +8 -0
- package/esm/domain/contexts/connectivityContext.js.map +1 -0
- package/esm/domain/contexts/defaultContext.d.ts +4 -0
- package/esm/domain/contexts/defaultContext.js +31 -0
- package/esm/domain/contexts/defaultContext.js.map +1 -0
- package/esm/domain/contexts/displayContext.d.ts +6 -0
- package/esm/domain/contexts/displayContext.js +25 -0
- package/esm/domain/contexts/displayContext.js.map +1 -0
- package/esm/domain/contexts/featureFlagContext.d.ts +19 -0
- package/esm/domain/contexts/featureFlagContext.js +49 -0
- package/esm/domain/contexts/featureFlagContext.js.map +1 -0
- package/esm/domain/contexts/internalContext.d.ts +12 -0
- package/esm/domain/contexts/internalContext.js +23 -0
- package/esm/domain/contexts/internalContext.js.map +1 -0
- package/esm/domain/contexts/pageStateHistory.d.ts +23 -0
- package/esm/domain/contexts/pageStateHistory.js +100 -0
- package/esm/domain/contexts/pageStateHistory.js.map +1 -0
- package/esm/domain/contexts/sessionContext.d.ts +5 -0
- package/esm/domain/contexts/sessionContext.js +44 -0
- package/esm/domain/contexts/sessionContext.js.map +1 -0
- package/esm/domain/contexts/syntheticsContext.d.ts +2 -0
- package/esm/domain/contexts/syntheticsContext.js +22 -0
- package/esm/domain/contexts/syntheticsContext.js.map +1 -0
- package/esm/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/esm/domain/contexts/trackingConsentContext.js +11 -0
- package/esm/domain/contexts/trackingConsentContext.js.map +1 -0
- package/esm/domain/contexts/urlContexts.d.ts +22 -0
- package/esm/domain/contexts/urlContexts.js +60 -0
- package/esm/domain/contexts/urlContexts.js.map +1 -0
- package/esm/domain/contexts/userAgentDataContext.d.ts +2 -0
- package/esm/domain/contexts/userAgentDataContext.js +28 -0
- package/esm/domain/contexts/userAgentDataContext.js.map +1 -0
- package/esm/domain/contexts/viewHistory.d.ts +17 -0
- package/esm/domain/contexts/viewHistory.js +44 -0
- package/esm/domain/contexts/viewHistory.js.map +1 -0
- package/esm/domain/discardNegativeDuration.d.ts +2 -0
- package/esm/domain/discardNegativeDuration.js +5 -0
- package/esm/domain/discardNegativeDuration.js.map +1 -0
- package/esm/domain/error/errorCollection.d.ts +17 -0
- package/esm/domain/error/errorCollection.js +70 -0
- package/esm/domain/error/errorCollection.js.map +1 -0
- package/esm/domain/error/trackConsoleError.d.ts +4 -0
- package/esm/domain/error/trackConsoleError.js +10 -0
- package/esm/domain/error/trackConsoleError.js.map +1 -0
- package/esm/domain/error/trackReportError.d.ts +5 -0
- package/esm/domain/error/trackReportError.js +13 -0
- package/esm/domain/error/trackReportError.js.map +1 -0
- package/esm/domain/event/eventCollection.d.ts +10 -0
- package/esm/domain/event/eventCollection.js +24 -0
- package/esm/domain/event/eventCollection.js.map +1 -0
- package/esm/domain/getSelectorFromElement.d.ts +64 -0
- package/esm/domain/getSelectorFromElement.js +213 -0
- package/esm/domain/getSelectorFromElement.js.map +1 -0
- package/esm/domain/getSessionReplayUrl.d.ts +9 -0
- package/esm/domain/getSessionReplayUrl.js +30 -0
- package/esm/domain/getSessionReplayUrl.js.map +1 -0
- package/esm/domain/hooks.d.ts +23 -0
- package/esm/domain/hooks.js +3 -0
- package/esm/domain/hooks.js.map +1 -0
- package/esm/domain/lifeCycle.d.ts +73 -0
- package/esm/domain/lifeCycle.js +3 -0
- package/esm/domain/lifeCycle.js.map +1 -0
- package/esm/domain/limitModification.d.ts +8 -0
- package/esm/domain/limitModification.js +43 -0
- package/esm/domain/limitModification.js.map +1 -0
- package/esm/domain/longTask/longTaskCollection.d.ts +18 -0
- package/esm/domain/longTask/longTaskCollection.js +87 -0
- package/esm/domain/longTask/longTaskCollection.js.map +1 -0
- package/esm/domain/plugins.d.ts +40 -0
- package/esm/domain/plugins.js +12 -0
- package/esm/domain/plugins.js.map +1 -0
- package/esm/domain/privacy.d.ts +44 -0
- package/esm/domain/privacy.js +302 -0
- package/esm/domain/privacy.js.map +1 -0
- package/esm/domain/privacyConstants.d.ts +23 -0
- package/esm/domain/privacyConstants.js +35 -0
- package/esm/domain/privacyConstants.js.map +1 -0
- package/esm/domain/requestCollection.d.ts +54 -0
- package/esm/domain/requestCollection.js +106 -0
- package/esm/domain/requestCollection.js.map +1 -0
- package/esm/domain/resource/graphql.d.ts +23 -0
- package/esm/domain/resource/graphql.js +91 -0
- package/esm/domain/resource/graphql.js.map +1 -0
- package/esm/domain/resource/matchRequestResourceEntry.d.ts +16 -0
- package/esm/domain/resource/matchRequestResourceEntry.js +46 -0
- package/esm/domain/resource/matchRequestResourceEntry.js.map +1 -0
- package/esm/domain/resource/requestRegistry.d.ts +9 -0
- package/esm/domain/resource/requestRegistry.js +37 -0
- package/esm/domain/resource/requestRegistry.js.map +1 -0
- package/esm/domain/resource/resourceCollection.d.ts +7 -0
- package/esm/domain/resource/resourceCollection.js +187 -0
- package/esm/domain/resource/resourceCollection.js.map +1 -0
- package/esm/domain/resource/resourceUtils.d.ts +55 -0
- package/esm/domain/resource/resourceUtils.js +244 -0
- package/esm/domain/resource/resourceUtils.js.map +1 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +4 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js +21 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/esm/domain/rumSessionManager.d.ts +36 -0
- package/esm/domain/rumSessionManager.js +72 -0
- package/esm/domain/rumSessionManager.js.map +1 -0
- package/esm/domain/sampler/sampler.d.ts +10 -0
- package/esm/domain/sampler/sampler.js +58 -0
- package/esm/domain/sampler/sampler.js.map +1 -0
- package/esm/domain/startCustomerDataTelemetry.d.ts +4 -0
- package/esm/domain/startCustomerDataTelemetry.js +52 -0
- package/esm/domain/startCustomerDataTelemetry.js.map +1 -0
- package/esm/domain/tracing/getDocumentTraceId.d.ts +12 -0
- package/esm/domain/tracing/getDocumentTraceId.js +68 -0
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/esm/domain/tracing/identifier.d.ts +13 -0
- package/esm/domain/tracing/identifier.js +50 -0
- package/esm/domain/tracing/identifier.js.map +1 -0
- package/esm/domain/tracing/sampler.d.ts +10 -0
- package/esm/domain/tracing/sampler.js +64 -0
- package/esm/domain/tracing/sampler.js.map +1 -0
- package/esm/domain/tracing/tracer.d.ts +30 -0
- package/esm/domain/tracing/tracer.js +156 -0
- package/esm/domain/tracing/tracer.js.map +1 -0
- package/esm/domain/tracing/tracer.types.d.ts +12 -0
- package/esm/domain/tracing/tracer.types.js +2 -0
- package/esm/domain/tracing/tracer.types.js.map +1 -0
- package/esm/domain/trackEventCounts.d.ts +17 -0
- package/esm/domain/trackEventCounts.js +47 -0
- package/esm/domain/trackEventCounts.js.map +1 -0
- package/esm/domain/view/bfCacheSupport.d.ts +2 -0
- package/esm/domain/view/bfCacheSupport.js +10 -0
- package/esm/domain/view/bfCacheSupport.js.map +1 -0
- package/esm/domain/view/trackViewEventCounts.d.ts +5 -0
- package/esm/domain/view/trackViewEventCounts.js +13 -0
- package/esm/domain/view/trackViewEventCounts.js.map +1 -0
- package/esm/domain/view/trackViews.d.ts +65 -0
- package/esm/domain/view/trackViews.js +271 -0
- package/esm/domain/view/trackViews.js.map +1 -0
- package/esm/domain/view/viewCollection.d.ts +18 -0
- package/esm/domain/view/viewCollection.js +150 -0
- package/esm/domain/view/viewCollection.js.map +1 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.d.ts +6 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js +28 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +1 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.d.ts +18 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.js +39 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.js.map +1 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +6 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +41 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +8 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js +14 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +21 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js +34 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +37 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js +130 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +13 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js +34 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.d.ts +10 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.js +30 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.d.ts +19 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.js +40 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +15 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js +38 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +25 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js +149 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +18 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js +57 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.d.ts +14 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.js +47 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.d.ts +14 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.js +40 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.d.ts +25 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.js +72 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.js.map +1 -0
- package/esm/domain/vital/vitalCollection.d.ts +55 -0
- package/esm/domain/vital/vitalCollection.js +107 -0
- package/esm/domain/vital/vitalCollection.js.map +1 -0
- package/esm/domain/waitPageActivityEnd.d.ts +54 -0
- package/esm/domain/waitPageActivityEnd.js +123 -0
- package/esm/domain/waitPageActivityEnd.js.map +1 -0
- package/esm/domainContext.types.d.ts +39 -0
- package/esm/domainContext.types.js +5 -0
- package/esm/domainContext.types.js.map +1 -0
- package/esm/index.d.ts +41 -0
- package/esm/index.js +21 -0
- package/esm/index.js.map +1 -0
- package/esm/rawRumEvent.types.d.ts +326 -0
- package/esm/rawRumEvent.types.js +31 -0
- package/esm/rawRumEvent.types.js.map +1 -0
- package/esm/rumEvent.types.d.ts +2026 -0
- package/esm/rumEvent.types.js +6 -0
- package/esm/rumEvent.types.js.map +1 -0
- package/esm/transport/formDataTransport.d.ts +16 -0
- package/esm/transport/formDataTransport.js +43 -0
- package/esm/transport/formDataTransport.js.map +1 -0
- package/esm/transport/startRumBatch.d.ts +5 -0
- package/esm/transport/startRumBatch.js +30 -0
- package/esm/transport/startRumBatch.js.map +1 -0
- package/esm/transport/startRumEventBridge.d.ts +2 -0
- package/esm/transport/startRumEventBridge.js +8 -0
- package/esm/transport/startRumEventBridge.js.map +1 -0
- package/package.json +29 -0
- package/src/boot/preStartRum.ts +298 -0
- package/src/boot/rumPublicApi.ts +830 -0
- package/src/boot/startRum.ts +280 -0
- package/src/browser/cookieObservable.ts +63 -0
- package/src/browser/domMutationObservable.ts +98 -0
- package/src/browser/firstInputPolyfill.ts +87 -0
- package/src/browser/htmlDomUtils.ts +45 -0
- package/src/browser/locationChangeObservable.ts +69 -0
- package/src/browser/performanceObservable.ts +324 -0
- package/src/browser/performanceUtils.ts +50 -0
- package/src/browser/scroll.ts +25 -0
- package/src/browser/viewportObservable.ts +44 -0
- package/src/browser/windowOpenObservable.ts +7 -0
- package/src/domain/action/actionCollection.ts +146 -0
- package/src/domain/action/actionNameConstants.ts +20 -0
- package/src/domain/action/clickChain.ts +83 -0
- package/src/domain/action/computeFrustration.ts +77 -0
- package/src/domain/action/getActionNameFromElement.ts +337 -0
- package/src/domain/action/interactionSelectorCache.ts +21 -0
- package/src/domain/action/listenActionEvents.ts +119 -0
- package/src/domain/action/trackClickActions.ts +388 -0
- package/src/domain/assembly.ts +141 -0
- package/src/domain/configuration/configuration.ts +548 -0
- package/src/domain/configuration/index.ts +2 -0
- package/src/domain/configuration/jsonPathParser.ts +214 -0
- package/src/domain/configuration/remoteConfiguration.ts +304 -0
- package/src/domain/configuration/remoteConfiguration.types.ts +147 -0
- package/src/domain/contexts/ciVisibilityContext.ts +50 -0
- package/src/domain/contexts/connectivityContext.ts +12 -0
- package/src/domain/contexts/defaultContext.ts +43 -0
- package/src/domain/contexts/displayContext.ts +38 -0
- package/src/domain/contexts/featureFlagContext.ts +71 -0
- package/src/domain/contexts/internalContext.ts +34 -0
- package/src/domain/contexts/pageStateHistory.ts +171 -0
- package/src/domain/contexts/sessionContext.ts +59 -0
- package/src/domain/contexts/syntheticsContext.ts +33 -0
- package/src/domain/contexts/trackingConsentContext.ts +15 -0
- package/src/domain/contexts/urlContexts.ts +97 -0
- package/src/domain/contexts/userAgentDataContext.ts +36 -0
- package/src/domain/contexts/viewHistory.ts +70 -0
- package/src/domain/discardNegativeDuration.ts +6 -0
- package/src/domain/error/errorCollection.ts +107 -0
- package/src/domain/error/trackConsoleError.ts +14 -0
- package/src/domain/error/trackReportError.ts +16 -0
- package/src/domain/event/eventCollection.ts +53 -0
- package/src/domain/getSelectorFromElement.ts +268 -0
- package/src/domain/getSessionReplayUrl.ts +47 -0
- package/src/domain/hooks.ts +31 -0
- package/src/domain/lifeCycle.ts +103 -0
- package/src/domain/limitModification.ts +66 -0
- package/src/domain/longTask/longTaskCollection.ts +133 -0
- package/src/domain/plugins.ts +59 -0
- package/src/domain/privacy.ts +355 -0
- package/src/domain/privacyConstants.ts +43 -0
- package/src/domain/requestCollection.ts +179 -0
- package/src/domain/resource/graphql.ts +135 -0
- package/src/domain/resource/matchRequestResourceEntry.ts +68 -0
- package/src/domain/resource/requestRegistry.ts +52 -0
- package/src/domain/resource/resourceCollection.ts +273 -0
- package/src/domain/resource/resourceUtils.ts +355 -0
- package/src/domain/resource/retrieveInitialDocumentResourceTiming.ts +27 -0
- package/src/domain/rumSessionManager.ts +134 -0
- package/src/domain/sampler/sampler.ts +63 -0
- package/src/domain/startCustomerDataTelemetry.ts +83 -0
- package/src/domain/tracing/getDocumentTraceId.ts +90 -0
- package/src/domain/tracing/identifier.ts +69 -0
- package/src/domain/tracing/sampler.ts +69 -0
- package/src/domain/tracing/tracer.ts +248 -0
- package/src/domain/tracing/tracer.types.ts +13 -0
- package/src/domain/trackEventCounts.ts +67 -0
- package/src/domain/view/bfCacheSupport.ts +20 -0
- package/src/domain/view/trackViewEventCounts.ts +15 -0
- package/src/domain/view/trackViews.ts +431 -0
- package/src/domain/view/viewCollection.ts +203 -0
- package/src/domain/view/viewMetrics/getClsAttributionImpactedArea.ts +34 -0
- package/src/domain/view/viewMetrics/interactionCountPolyfill.ts +55 -0
- package/src/domain/view/viewMetrics/startInitialViewMetricsTelemetry.ts +70 -0
- package/src/domain/view/viewMetrics/trackBfcacheMetrics.ts +20 -0
- package/src/domain/view/viewMetrics/trackCommonViewMetrics.ts +78 -0
- package/src/domain/view/viewMetrics/trackCumulativeLayoutShift.ts +180 -0
- package/src/domain/view/viewMetrics/trackFirstContentfulPaint.ts +47 -0
- package/src/domain/view/viewMetrics/trackFirstHidden.ts +53 -0
- package/src/domain/view/viewMetrics/trackFirstInput.ts +59 -0
- package/src/domain/view/viewMetrics/trackInitialViewMetrics.ts +66 -0
- package/src/domain/view/viewMetrics/trackInteractionToNextPaint.ts +193 -0
- package/src/domain/view/viewMetrics/trackLargestContentfulPaint.ts +87 -0
- package/src/domain/view/viewMetrics/trackLoadingTime.ts +69 -0
- package/src/domain/view/viewMetrics/trackNavigationTimings.ts +66 -0
- package/src/domain/view/viewMetrics/trackScrollMetrics.ts +119 -0
- package/src/domain/vital/vitalCollection.ts +207 -0
- package/src/domain/waitPageActivityEnd.ts +189 -0
- package/src/domainContext.types.ts +61 -0
- package/src/index.ts +76 -0
- package/src/rawRumEvent.types.ts +409 -0
- package/src/rumEvent.types.ts +2151 -0
- package/src/transport/formDataTransport.ts +85 -0
- package/src/transport/startRumBatch.ts +46 -0
- package/src/transport/startRumEventBridge.ts +12 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { isElementNode, getParentNode, isTextNode } from '../browser/htmlDomUtils'
|
|
2
|
+
import {
|
|
3
|
+
NodePrivacyLevel,
|
|
4
|
+
FORM_PRIVATE_TAG_NAMES,
|
|
5
|
+
CENSORED_STRING_MARK,
|
|
6
|
+
getPrivacySelector,
|
|
7
|
+
TEXT_MASKING_CHAR,
|
|
8
|
+
PRIVACY_ATTR_NAME,
|
|
9
|
+
} from './privacyConstants'
|
|
10
|
+
import { STABLE_ATTRIBUTES } from './getSelectorFromElement'
|
|
11
|
+
import type { RumConfiguration } from './configuration'
|
|
12
|
+
|
|
13
|
+
export type NodePrivacyLevelCache = Map<Node, NodePrivacyLevel>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get node privacy level by iterating over its ancestors. When the direct parent privacy level is
|
|
17
|
+
* know, it is best to use something like:
|
|
18
|
+
*
|
|
19
|
+
* derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
|
|
20
|
+
*/
|
|
21
|
+
export function getNodePrivacyLevel(
|
|
22
|
+
node: Node,
|
|
23
|
+
defaultPrivacyLevel: NodePrivacyLevel,
|
|
24
|
+
cache?: NodePrivacyLevelCache
|
|
25
|
+
): NodePrivacyLevel {
|
|
26
|
+
if (cache && cache.has(node)) {
|
|
27
|
+
return cache.get(node)!
|
|
28
|
+
}
|
|
29
|
+
const parentNode = getParentNode(node)
|
|
30
|
+
const parentNodePrivacyLevel = parentNode
|
|
31
|
+
? getNodePrivacyLevel(parentNode, defaultPrivacyLevel, cache)
|
|
32
|
+
: defaultPrivacyLevel
|
|
33
|
+
const selfNodePrivacyLevel = getNodeSelfPrivacyLevel(node)
|
|
34
|
+
const nodePrivacyLevel = reducePrivacyLevel(selfNodePrivacyLevel, parentNodePrivacyLevel)
|
|
35
|
+
if (cache) {
|
|
36
|
+
cache.set(node, nodePrivacyLevel)
|
|
37
|
+
}
|
|
38
|
+
return nodePrivacyLevel
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reduces the next privacy level based on self + parent privacy levels
|
|
43
|
+
*/
|
|
44
|
+
export function reducePrivacyLevel(
|
|
45
|
+
childPrivacyLevel: NodePrivacyLevel | undefined,
|
|
46
|
+
parentNodePrivacyLevel: NodePrivacyLevel
|
|
47
|
+
): NodePrivacyLevel {
|
|
48
|
+
switch (parentNodePrivacyLevel) {
|
|
49
|
+
// These values cannot be overridden
|
|
50
|
+
case NodePrivacyLevel.HIDDEN:
|
|
51
|
+
case NodePrivacyLevel.IGNORE:
|
|
52
|
+
return parentNodePrivacyLevel
|
|
53
|
+
}
|
|
54
|
+
switch (childPrivacyLevel) {
|
|
55
|
+
case NodePrivacyLevel.ALLOW:
|
|
56
|
+
case NodePrivacyLevel.MASK:
|
|
57
|
+
case NodePrivacyLevel.MASK_USER_INPUT:
|
|
58
|
+
case NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED:
|
|
59
|
+
case NodePrivacyLevel.HIDDEN:
|
|
60
|
+
case NodePrivacyLevel.IGNORE:
|
|
61
|
+
return childPrivacyLevel
|
|
62
|
+
default:
|
|
63
|
+
return parentNodePrivacyLevel
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Determines the node's own privacy level without checking for ancestors.
|
|
69
|
+
*/
|
|
70
|
+
export function getNodeSelfPrivacyLevel(node: Node): NodePrivacyLevel | undefined {
|
|
71
|
+
// Only Element types can have a privacy level set
|
|
72
|
+
if (!isElementNode(node)) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Overrules for replay purpose
|
|
77
|
+
if (node.tagName === 'BASE') {
|
|
78
|
+
return NodePrivacyLevel.ALLOW
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Overrules to enforce end-user protection
|
|
82
|
+
if (node.tagName === 'INPUT') {
|
|
83
|
+
const inputElement = node as HTMLInputElement
|
|
84
|
+
if (inputElement.type === 'password' || inputElement.type === 'email' || inputElement.type === 'tel') {
|
|
85
|
+
return NodePrivacyLevel.MASK
|
|
86
|
+
}
|
|
87
|
+
if (inputElement.type === 'hidden') {
|
|
88
|
+
return NodePrivacyLevel.MASK
|
|
89
|
+
}
|
|
90
|
+
const autocomplete = inputElement.getAttribute('autocomplete')
|
|
91
|
+
// Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year/new-password/current-password]
|
|
92
|
+
if (autocomplete && (autocomplete.startsWith('cc-') || autocomplete.endsWith('-password'))) {
|
|
93
|
+
return NodePrivacyLevel.MASK
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check HTML privacy attributes and classes
|
|
98
|
+
if (node.matches(getPrivacySelector(NodePrivacyLevel.HIDDEN))) {
|
|
99
|
+
return NodePrivacyLevel.HIDDEN
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (node.matches(getPrivacySelector(NodePrivacyLevel.MASK))) {
|
|
103
|
+
return NodePrivacyLevel.MASK
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (node.matches(getPrivacySelector(NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED))) {
|
|
107
|
+
return NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (node.matches(getPrivacySelector(NodePrivacyLevel.MASK_USER_INPUT))) {
|
|
111
|
+
return NodePrivacyLevel.MASK_USER_INPUT
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (node.matches(getPrivacySelector(NodePrivacyLevel.ALLOW))) {
|
|
115
|
+
return NodePrivacyLevel.ALLOW
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (shouldIgnoreElement(node)) {
|
|
119
|
+
return NodePrivacyLevel.IGNORE
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Helper aiming to unify `mask` and `mask-user-input` privacy levels:
|
|
125
|
+
*
|
|
126
|
+
* In the `mask` case, it is trivial: we should mask the element.
|
|
127
|
+
*
|
|
128
|
+
* In the `mask-user-input` case, we should mask the element only if it is a "form" element or the
|
|
129
|
+
* direct parent is a form element for text nodes).
|
|
130
|
+
*
|
|
131
|
+
* Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
|
|
132
|
+
* node if it is ignored or hidden? it doesn't matter since it won't be serialized).
|
|
133
|
+
*/
|
|
134
|
+
export function shouldMaskNode(node: Node, privacyLevel: NodePrivacyLevel) {
|
|
135
|
+
switch (privacyLevel) {
|
|
136
|
+
case NodePrivacyLevel.MASK:
|
|
137
|
+
case NodePrivacyLevel.HIDDEN:
|
|
138
|
+
case NodePrivacyLevel.IGNORE:
|
|
139
|
+
return true
|
|
140
|
+
case NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED:
|
|
141
|
+
if (isTextNode(node)) {
|
|
142
|
+
// Always return true if our parent is a form element, like MASK_USER_INPUT.
|
|
143
|
+
// Otherwise, decide whether to mask based on the allowlist.
|
|
144
|
+
return isFormElement(node.parentNode) ? true : !isAllowlisted(node.textContent || '')
|
|
145
|
+
}
|
|
146
|
+
// Always return true if we're a form element, like MASK_USER_INPUT.
|
|
147
|
+
// Otherwise, return false; MASK_UNLESS_ALLOWLISTED only directly masks text nodes.
|
|
148
|
+
return isFormElement(node)
|
|
149
|
+
case NodePrivacyLevel.MASK_USER_INPUT:
|
|
150
|
+
return isTextNode(node) ? isFormElement(node.parentNode) : isFormElement(node)
|
|
151
|
+
default:
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function shouldMaskAttribute(
|
|
157
|
+
tagName: string,
|
|
158
|
+
attributeName: string,
|
|
159
|
+
attributeValue: string | null,
|
|
160
|
+
nodePrivacyLevel: NodePrivacyLevel,
|
|
161
|
+
configuration: RumConfiguration
|
|
162
|
+
) {
|
|
163
|
+
if (nodePrivacyLevel !== NodePrivacyLevel.MASK && nodePrivacyLevel !== NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED) {
|
|
164
|
+
return false
|
|
165
|
+
}
|
|
166
|
+
if (
|
|
167
|
+
attributeName === PRIVACY_ATTR_NAME ||
|
|
168
|
+
STABLE_ATTRIBUTES.includes(attributeName) ||
|
|
169
|
+
attributeName === configuration.actionNameAttribute
|
|
170
|
+
) {
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
switch (attributeName) {
|
|
175
|
+
case 'title':
|
|
176
|
+
case 'alt':
|
|
177
|
+
case 'placeholder':
|
|
178
|
+
case 'aria-label':
|
|
179
|
+
case 'name':
|
|
180
|
+
return true
|
|
181
|
+
}
|
|
182
|
+
if (tagName === 'A' && attributeName === 'href') {
|
|
183
|
+
return true
|
|
184
|
+
}
|
|
185
|
+
if (tagName === 'IFRAME' && attributeName === 'srcdoc') {
|
|
186
|
+
return true
|
|
187
|
+
}
|
|
188
|
+
if (attributeValue && attributeName.startsWith('data-')) {
|
|
189
|
+
return true
|
|
190
|
+
}
|
|
191
|
+
if ((tagName === 'IMG' || tagName === 'SOURCE') && (attributeName === 'src' || attributeName === 'srcset')) {
|
|
192
|
+
return true
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return false
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isFormElement(node: Node | null): boolean {
|
|
199
|
+
if (!node || node.nodeType !== node.ELEMENT_NODE) {
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
const element = node as HTMLInputElement
|
|
203
|
+
if (element.tagName === 'INPUT') {
|
|
204
|
+
switch (element.type) {
|
|
205
|
+
case 'button':
|
|
206
|
+
case 'color':
|
|
207
|
+
case 'reset':
|
|
208
|
+
case 'submit':
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return !!FORM_PRIVATE_TAG_NAMES[element.tagName]
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Text censoring non-destructively maintains whitespace characters in order to preserve text shape
|
|
217
|
+
* during replay.
|
|
218
|
+
*/
|
|
219
|
+
const censorText = (text: string) => text.replace(/\S/g, TEXT_MASKING_CHAR)
|
|
220
|
+
|
|
221
|
+
export function getTextContent(textNode: Node, parentNodePrivacyLevel: NodePrivacyLevel): string | undefined {
|
|
222
|
+
// The parent node may not be a html element which has a tagName attribute.
|
|
223
|
+
// So just let it be undefined which is ok in this use case.
|
|
224
|
+
const parentTagName = textNode.parentElement?.tagName
|
|
225
|
+
let textContent = textNode.textContent || ''
|
|
226
|
+
|
|
227
|
+
const shouldIgnoreWhiteSpace = parentTagName === 'HEAD'
|
|
228
|
+
if (shouldIgnoreWhiteSpace && !textContent.trim()) {
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const nodePrivacyLevel = parentNodePrivacyLevel
|
|
233
|
+
|
|
234
|
+
const isScript = parentTagName === 'SCRIPT'
|
|
235
|
+
|
|
236
|
+
if (isScript) {
|
|
237
|
+
// For perf reasons, we don't record script (heuristic)
|
|
238
|
+
textContent = CENSORED_STRING_MARK
|
|
239
|
+
} else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
240
|
+
// Should never occur, but just in case, we set to CENSORED_MARK.
|
|
241
|
+
textContent = CENSORED_STRING_MARK
|
|
242
|
+
} else if (shouldMaskNode(textNode, nodePrivacyLevel)) {
|
|
243
|
+
if (
|
|
244
|
+
// Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
|
|
245
|
+
parentTagName === 'DATALIST' ||
|
|
246
|
+
parentTagName === 'SELECT' ||
|
|
247
|
+
parentTagName === 'OPTGROUP'
|
|
248
|
+
) {
|
|
249
|
+
if (!textContent.trim()) {
|
|
250
|
+
return
|
|
251
|
+
}
|
|
252
|
+
} else if (parentTagName === 'OPTION') {
|
|
253
|
+
// <Option> has low entropy in charset + text length, so use `CENSORED_STRING_MARK` when masked
|
|
254
|
+
textContent = CENSORED_STRING_MARK
|
|
255
|
+
} else if (nodePrivacyLevel === NodePrivacyLevel.MASK_UNLESS_ALLOWLISTED) {
|
|
256
|
+
textContent = maskDisallowedTextContent(textContent)
|
|
257
|
+
} else {
|
|
258
|
+
textContent = censorText(textContent)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return textContent
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* TODO: Preserve CSS element order, and record the presence of the tag, just don't render
|
|
266
|
+
* We don't need this logic on the recorder side.
|
|
267
|
+
* For security related meta's, customer can mask themmanually given they
|
|
268
|
+
* are easy to identify in the HEAD tag.
|
|
269
|
+
*/
|
|
270
|
+
export function shouldIgnoreElement(element: Element): boolean {
|
|
271
|
+
if (element.nodeName === 'SCRIPT') {
|
|
272
|
+
return true
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (element.nodeName === 'LINK') {
|
|
276
|
+
const relAttribute = getLowerCaseAttribute('rel')
|
|
277
|
+
return (
|
|
278
|
+
// Link as script - Ignore only when rel=preload, modulepreload or prefetch
|
|
279
|
+
(/preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script') ||
|
|
280
|
+
// Favicons
|
|
281
|
+
relAttribute === 'shortcut icon' ||
|
|
282
|
+
relAttribute === 'icon'
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (element.nodeName === 'META') {
|
|
287
|
+
const nameAttribute = getLowerCaseAttribute('name')
|
|
288
|
+
const relAttribute = getLowerCaseAttribute('rel')
|
|
289
|
+
const propertyAttribute = getLowerCaseAttribute('property')
|
|
290
|
+
return (
|
|
291
|
+
// Favicons
|
|
292
|
+
/^msapplication-tile(image|color)$/.test(nameAttribute) ||
|
|
293
|
+
nameAttribute === 'application-name' ||
|
|
294
|
+
relAttribute === 'icon' ||
|
|
295
|
+
relAttribute === 'apple-touch-icon' ||
|
|
296
|
+
relAttribute === 'shortcut icon' ||
|
|
297
|
+
// Description
|
|
298
|
+
nameAttribute === 'keywords' ||
|
|
299
|
+
nameAttribute === 'description' ||
|
|
300
|
+
// Social
|
|
301
|
+
/^(og|twitter|fb):/.test(propertyAttribute) ||
|
|
302
|
+
/^(og|twitter):/.test(nameAttribute) ||
|
|
303
|
+
nameAttribute === 'pinterest' ||
|
|
304
|
+
// Robots
|
|
305
|
+
nameAttribute === 'robots' ||
|
|
306
|
+
nameAttribute === 'googlebot' ||
|
|
307
|
+
nameAttribute === 'bingbot' ||
|
|
308
|
+
// Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
|
|
309
|
+
// X-Translated-By
|
|
310
|
+
element.hasAttribute('http-equiv') ||
|
|
311
|
+
// Authorship
|
|
312
|
+
nameAttribute === 'author' ||
|
|
313
|
+
nameAttribute === 'generator' ||
|
|
314
|
+
nameAttribute === 'framework' ||
|
|
315
|
+
nameAttribute === 'publisher' ||
|
|
316
|
+
nameAttribute === 'progid' ||
|
|
317
|
+
/^article:/.test(propertyAttribute) ||
|
|
318
|
+
/^product:/.test(propertyAttribute) ||
|
|
319
|
+
// Verification
|
|
320
|
+
nameAttribute === 'google-site-verification' ||
|
|
321
|
+
nameAttribute === 'yandex-verification' ||
|
|
322
|
+
nameAttribute === 'csrf-token' ||
|
|
323
|
+
nameAttribute === 'p:domain_verify' ||
|
|
324
|
+
nameAttribute === 'verify-v1' ||
|
|
325
|
+
nameAttribute === 'verification' ||
|
|
326
|
+
nameAttribute === 'shopify-checkout-api-token'
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function getLowerCaseAttribute(name: string) {
|
|
331
|
+
return (element.getAttribute(name) || '').toLowerCase()
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return false
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface BrowserWindow extends Window {
|
|
338
|
+
$KUBESENSE_ALLOW?: Set<string>
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function isAllowlisted(text: string): boolean {
|
|
342
|
+
if (!text || !text.trim()) {
|
|
343
|
+
return true
|
|
344
|
+
}
|
|
345
|
+
// We are using toLocaleLowerCase when adding to the allowlist to avoid case sensitivity
|
|
346
|
+
// so we need to do the same here
|
|
347
|
+
return (window as BrowserWindow).$KUBESENSE_ALLOW?.has(text.toLocaleLowerCase()) || false
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function maskDisallowedTextContent(text: string, fixedMask?: string): string {
|
|
351
|
+
if (isAllowlisted(text)) {
|
|
352
|
+
return text
|
|
353
|
+
}
|
|
354
|
+
return fixedMask || censorText(text)
|
|
355
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DefaultPrivacyLevel } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
|
|
3
|
+
export const NodePrivacyLevel = {
|
|
4
|
+
IGNORE: 'ignore',
|
|
5
|
+
HIDDEN: 'hidden',
|
|
6
|
+
ALLOW: DefaultPrivacyLevel.ALLOW,
|
|
7
|
+
MASK: DefaultPrivacyLevel.MASK,
|
|
8
|
+
MASK_USER_INPUT: DefaultPrivacyLevel.MASK_USER_INPUT,
|
|
9
|
+
MASK_UNLESS_ALLOWLISTED: DefaultPrivacyLevel.MASK_UNLESS_ALLOWLISTED,
|
|
10
|
+
} as const
|
|
11
|
+
export type NodePrivacyLevel = (typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel]
|
|
12
|
+
|
|
13
|
+
export const PRIVACY_ATTR_NAME = 'data-kubesense-privacy'
|
|
14
|
+
|
|
15
|
+
// Privacy Attrs
|
|
16
|
+
export const PRIVACY_ATTR_VALUE_ALLOW = 'allow'
|
|
17
|
+
export const PRIVACY_ATTR_VALUE_MASK = 'mask'
|
|
18
|
+
export const PRIVACY_ATTR_VALUE_MASK_USER_INPUT = 'mask-user-input'
|
|
19
|
+
export const PRIVACY_ATTR_VALUE_MASK_UNLESS_ALLOWLISTED = 'mask-unless-allowlisted'
|
|
20
|
+
export const PRIVACY_ATTR_VALUE_HIDDEN = 'hidden'
|
|
21
|
+
|
|
22
|
+
// Privacy Classes - not all customers can set plain HTML attributes, so support classes too
|
|
23
|
+
export const PRIVACY_CLASS_PREFIX = 'kubesense-privacy-'
|
|
24
|
+
|
|
25
|
+
// Private Replacement Templates
|
|
26
|
+
export const CENSORED_STRING_MARK = '***'
|
|
27
|
+
export const CENSORED_IMG_MARK = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='
|
|
28
|
+
|
|
29
|
+
export const FORM_PRIVATE_TAG_NAMES: { [tagName: string]: true } = {
|
|
30
|
+
INPUT: true,
|
|
31
|
+
OUTPUT: true,
|
|
32
|
+
TEXTAREA: true,
|
|
33
|
+
SELECT: true,
|
|
34
|
+
OPTION: true,
|
|
35
|
+
DATALIST: true,
|
|
36
|
+
OPTGROUP: true,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const TEXT_MASKING_CHAR = 'x'
|
|
40
|
+
|
|
41
|
+
export function getPrivacySelector(privacyLevel: string) {
|
|
42
|
+
return `[${PRIVACY_ATTR_NAME}="${privacyLevel}"], .${PRIVACY_CLASS_PREFIX}${privacyLevel}`
|
|
43
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Duration,
|
|
3
|
+
XhrCompleteContext,
|
|
4
|
+
XhrStartContext,
|
|
5
|
+
ClocksState,
|
|
6
|
+
FetchStartContext,
|
|
7
|
+
FetchResolveContext,
|
|
8
|
+
ContextManager,
|
|
9
|
+
} from '@kubesense/kubesense-browser-core'
|
|
10
|
+
import {
|
|
11
|
+
RequestType,
|
|
12
|
+
ResponseBodyAction,
|
|
13
|
+
elapsed,
|
|
14
|
+
initFetchObservable,
|
|
15
|
+
initXhrObservable,
|
|
16
|
+
timeStampNow,
|
|
17
|
+
} from '@kubesense/kubesense-browser-core'
|
|
18
|
+
import type { RumSessionManager } from '..'
|
|
19
|
+
import type { RumConfiguration } from './configuration'
|
|
20
|
+
import type { LifeCycle } from './lifeCycle'
|
|
21
|
+
import { LifeCycleEventType } from './lifeCycle'
|
|
22
|
+
import { isAllowedRequestUrl } from './resource/resourceUtils'
|
|
23
|
+
import type { Tracer } from './tracing/tracer'
|
|
24
|
+
import { startTracer } from './tracing/tracer'
|
|
25
|
+
import type { SpanIdentifier, TraceIdentifier } from './tracing/identifier'
|
|
26
|
+
import { findGraphQlConfiguration } from './resource/graphql'
|
|
27
|
+
|
|
28
|
+
export interface CustomContext {
|
|
29
|
+
requestIndex: number
|
|
30
|
+
spanId?: SpanIdentifier
|
|
31
|
+
traceId?: TraceIdentifier
|
|
32
|
+
traceSampled?: boolean
|
|
33
|
+
}
|
|
34
|
+
export interface RumFetchStartContext extends FetchStartContext, CustomContext {}
|
|
35
|
+
export interface RumFetchResolveContext extends FetchResolveContext, CustomContext {}
|
|
36
|
+
export interface RumXhrStartContext extends XhrStartContext, CustomContext {}
|
|
37
|
+
export interface RumXhrCompleteContext extends XhrCompleteContext, CustomContext {}
|
|
38
|
+
|
|
39
|
+
export interface RequestStartEvent {
|
|
40
|
+
requestIndex: number
|
|
41
|
+
url: string
|
|
42
|
+
}
|
|
43
|
+
export interface RequestCompleteEvent {
|
|
44
|
+
requestIndex: number
|
|
45
|
+
type: RequestType
|
|
46
|
+
method: string
|
|
47
|
+
url: string
|
|
48
|
+
status: number
|
|
49
|
+
responseType?: string
|
|
50
|
+
startClocks: ClocksState
|
|
51
|
+
duration: Duration
|
|
52
|
+
spanId?: SpanIdentifier
|
|
53
|
+
traceId?: TraceIdentifier
|
|
54
|
+
traceSampled?: boolean
|
|
55
|
+
xhr?: XMLHttpRequest
|
|
56
|
+
response?: Response
|
|
57
|
+
input?: unknown
|
|
58
|
+
init?: RequestInit
|
|
59
|
+
error?: Error
|
|
60
|
+
isAborted: boolean
|
|
61
|
+
handlingStack?: string
|
|
62
|
+
requestBody?: unknown
|
|
63
|
+
responseBody?: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let nextRequestIndex = 1
|
|
67
|
+
|
|
68
|
+
export function startRequestCollection(
|
|
69
|
+
lifeCycle: LifeCycle,
|
|
70
|
+
configuration: RumConfiguration,
|
|
71
|
+
sessionManager: RumSessionManager,
|
|
72
|
+
userContext: ContextManager,
|
|
73
|
+
accountContext: ContextManager
|
|
74
|
+
) {
|
|
75
|
+
const tracer = startTracer(configuration, sessionManager, userContext, accountContext)
|
|
76
|
+
trackXhr(lifeCycle, configuration, tracer)
|
|
77
|
+
trackFetch(lifeCycle, configuration, tracer)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function trackXhr(lifeCycle: LifeCycle, configuration: RumConfiguration, tracer: Tracer) {
|
|
81
|
+
const subscription = initXhrObservable(configuration).subscribe((rawContext) => {
|
|
82
|
+
const context = rawContext as RumXhrStartContext | RumXhrCompleteContext
|
|
83
|
+
if (!isAllowedRequestUrl(context.url)) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
switch (context.state) {
|
|
88
|
+
case 'start':
|
|
89
|
+
tracer.traceXhr(context, context.xhr)
|
|
90
|
+
context.requestIndex = getNextRequestIndex()
|
|
91
|
+
|
|
92
|
+
lifeCycle.notify(LifeCycleEventType.REQUEST_STARTED, {
|
|
93
|
+
requestIndex: context.requestIndex,
|
|
94
|
+
url: context.url,
|
|
95
|
+
})
|
|
96
|
+
break
|
|
97
|
+
case 'complete':
|
|
98
|
+
tracer.clearTracingIfNeeded(context)
|
|
99
|
+
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, {
|
|
100
|
+
duration: context.duration,
|
|
101
|
+
method: context.method,
|
|
102
|
+
requestIndex: context.requestIndex,
|
|
103
|
+
spanId: context.spanId,
|
|
104
|
+
startClocks: context.startClocks,
|
|
105
|
+
status: context.status,
|
|
106
|
+
traceId: context.traceId,
|
|
107
|
+
traceSampled: context.traceSampled,
|
|
108
|
+
type: RequestType.XHR,
|
|
109
|
+
url: context.url,
|
|
110
|
+
xhr: context.xhr,
|
|
111
|
+
isAborted: context.isAborted,
|
|
112
|
+
handlingStack: context.handlingStack,
|
|
113
|
+
requestBody: context.requestBody,
|
|
114
|
+
responseBody: context.responseBody,
|
|
115
|
+
})
|
|
116
|
+
break
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
return { stop: () => subscription.unsubscribe() }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function trackFetch(lifeCycle: LifeCycle, configuration: RumConfiguration, tracer: Tracer) {
|
|
124
|
+
const subscription = initFetchObservable({
|
|
125
|
+
responseBodyAction: (context) => {
|
|
126
|
+
if (findGraphQlConfiguration(context.url, configuration)?.trackResponseErrors) {
|
|
127
|
+
return ResponseBodyAction.COLLECT
|
|
128
|
+
}
|
|
129
|
+
return ResponseBodyAction.WAIT
|
|
130
|
+
},
|
|
131
|
+
}).subscribe((rawContext) => {
|
|
132
|
+
const context = rawContext as RumFetchResolveContext | RumFetchStartContext
|
|
133
|
+
if (!isAllowedRequestUrl(context.url)) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
switch (context.state) {
|
|
138
|
+
case 'start':
|
|
139
|
+
tracer.traceFetch(context)
|
|
140
|
+
context.requestIndex = getNextRequestIndex()
|
|
141
|
+
|
|
142
|
+
lifeCycle.notify(LifeCycleEventType.REQUEST_STARTED, {
|
|
143
|
+
requestIndex: context.requestIndex,
|
|
144
|
+
url: context.url,
|
|
145
|
+
})
|
|
146
|
+
break
|
|
147
|
+
case 'resolve':
|
|
148
|
+
tracer.clearTracingIfNeeded(context)
|
|
149
|
+
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, {
|
|
150
|
+
duration: elapsed(context.startClocks.timeStamp, timeStampNow()),
|
|
151
|
+
method: context.method,
|
|
152
|
+
requestIndex: context.requestIndex,
|
|
153
|
+
responseType: context.responseType,
|
|
154
|
+
spanId: context.spanId,
|
|
155
|
+
startClocks: context.startClocks,
|
|
156
|
+
status: context.status,
|
|
157
|
+
traceId: context.traceId,
|
|
158
|
+
traceSampled: context.traceSampled,
|
|
159
|
+
type: RequestType.FETCH,
|
|
160
|
+
url: context.url,
|
|
161
|
+
response: context.response,
|
|
162
|
+
init: context.init,
|
|
163
|
+
input: context.input,
|
|
164
|
+
isAborted: context.isAborted,
|
|
165
|
+
handlingStack: context.handlingStack,
|
|
166
|
+
requestBody: context.init?.body,
|
|
167
|
+
responseBody: context.responseBody,
|
|
168
|
+
})
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
return { stop: () => subscription.unsubscribe() }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function getNextRequestIndex() {
|
|
176
|
+
const result = nextRequestIndex
|
|
177
|
+
nextRequestIndex += 1
|
|
178
|
+
return result
|
|
179
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { isNonEmptyArray, matchList, ONE_KIBI_BYTE, safeTruncate } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { RumConfiguration, GraphQlUrlOption } from '../configuration'
|
|
3
|
+
import type { RequestCompleteEvent } from '../requestCollection'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* arbitrary value, byte precision not needed
|
|
7
|
+
*/
|
|
8
|
+
const GRAPHQL_PAYLOAD_LIMIT = 32 * ONE_KIBI_BYTE
|
|
9
|
+
|
|
10
|
+
export interface GraphQlError {
|
|
11
|
+
message: string
|
|
12
|
+
code?: string
|
|
13
|
+
locations?: Array<{ line: number; column: number }>
|
|
14
|
+
path?: Array<string | number>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GraphQlMetadata {
|
|
18
|
+
operationType?: 'query' | 'mutation' | 'subscription'
|
|
19
|
+
operationName?: string
|
|
20
|
+
variables?: string
|
|
21
|
+
payload?: string
|
|
22
|
+
error_count?: number
|
|
23
|
+
errors?: GraphQlError[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function extractGraphQlMetadata(
|
|
27
|
+
request: RequestCompleteEvent,
|
|
28
|
+
graphQlConfig: GraphQlUrlOption
|
|
29
|
+
): GraphQlMetadata | undefined {
|
|
30
|
+
const metadata = extractGraphQlRequestMetadata(request.requestBody, graphQlConfig.trackPayload)
|
|
31
|
+
if (!metadata) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (graphQlConfig.trackResponseErrors && request.responseBody) {
|
|
36
|
+
const responseErrors = parseGraphQlResponse(request.responseBody)
|
|
37
|
+
if (responseErrors) {
|
|
38
|
+
metadata.error_count = responseErrors.length
|
|
39
|
+
metadata.errors = responseErrors
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return metadata
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function parseGraphQlResponse(responseText: string): GraphQlError[] | undefined {
|
|
47
|
+
let response: unknown
|
|
48
|
+
try {
|
|
49
|
+
response = JSON.parse(responseText)
|
|
50
|
+
} catch {
|
|
51
|
+
// Invalid JSON response
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!response || typeof response !== 'object') {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const responseObj = response as Record<string, unknown>
|
|
60
|
+
|
|
61
|
+
if (!isNonEmptyArray(responseObj.errors)) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const errors = (responseObj.errors as Array<Record<string, unknown>>).map((error) => {
|
|
66
|
+
const graphqlError: GraphQlError = {
|
|
67
|
+
message: error.message as string,
|
|
68
|
+
path: error.path as Array<string | number>,
|
|
69
|
+
locations: error.locations as Array<{ line: number; column: number }>,
|
|
70
|
+
code: (error.extensions as Record<string, unknown> | undefined)?.code as string,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return graphqlError
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return errors
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function findGraphQlConfiguration(url: string, configuration: RumConfiguration): GraphQlUrlOption | undefined {
|
|
80
|
+
return configuration.allowedGraphQlUrls.find((graphQlOption) => matchList([graphQlOption.match], url))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function extractGraphQlRequestMetadata(
|
|
84
|
+
requestBody: unknown,
|
|
85
|
+
trackPayload: boolean = false
|
|
86
|
+
): GraphQlMetadata | undefined {
|
|
87
|
+
if (!requestBody || typeof requestBody !== 'string') {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let graphqlBody: {
|
|
92
|
+
query?: string
|
|
93
|
+
operationName?: string
|
|
94
|
+
variables?: unknown
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
graphqlBody = JSON.parse(requestBody)
|
|
99
|
+
} catch {
|
|
100
|
+
// Not valid JSON
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!graphqlBody) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let operationType: 'query' | 'mutation' | 'subscription' | undefined
|
|
109
|
+
let payload: string | undefined
|
|
110
|
+
|
|
111
|
+
if (graphqlBody.query) {
|
|
112
|
+
const trimmedQuery = graphqlBody.query.trim()
|
|
113
|
+
operationType = getOperationType(trimmedQuery)
|
|
114
|
+
if (trackPayload) {
|
|
115
|
+
payload = safeTruncate(trimmedQuery, GRAPHQL_PAYLOAD_LIMIT, '...')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const operationName = graphqlBody.operationName
|
|
120
|
+
let variables: string | undefined
|
|
121
|
+
if (graphqlBody.variables) {
|
|
122
|
+
variables = JSON.stringify(graphqlBody.variables)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
operationType,
|
|
127
|
+
operationName,
|
|
128
|
+
variables,
|
|
129
|
+
payload,
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getOperationType(query: string) {
|
|
134
|
+
return query.match(/^\s*(query|mutation|subscription)\b/i)?.[1] as 'query' | 'mutation' | 'subscription' | undefined
|
|
135
|
+
}
|