@sentry/browser 10.24.0 → 10.26.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/build/npm/cjs/dev/client.js.map +1 -0
- package/build/npm/cjs/dev/debug-build.js.map +1 -0
- package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -0
- package/build/npm/cjs/dev/eventbuilder.js.map +1 -0
- package/build/npm/cjs/dev/feedbackAsync.js.map +1 -0
- package/build/npm/cjs/dev/feedbackSync.js.map +1 -0
- package/build/npm/cjs/dev/helpers.js.map +1 -0
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -0
- package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -0
- package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -0
- package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -0
- package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
- package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
- package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
- package/build/npm/cjs/{integrations → dev/integrations}/globalhandlers.js +1 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -0
- package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -0
- package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -0
- package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -0
- package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -0
- package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -0
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -0
- package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -0
- package/build/npm/cjs/{profiling/lifecycleMode/traceLifecycleProfiler.js → dev/profiling/UIProfiler.js} +73 -75
- package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -0
- package/build/npm/cjs/{profiling → dev/profiling}/integration.js +5 -5
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -0
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -0
- package/build/npm/cjs/dev/profiling/utils.js.map +1 -0
- package/build/npm/cjs/dev/report-dialog.js.map +1 -0
- package/build/npm/cjs/dev/sdk.js +133 -0
- package/build/npm/cjs/dev/sdk.js.map +1 -0
- package/build/npm/cjs/dev/stack-parsers.js.map +1 -0
- package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -0
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -0
- package/build/npm/cjs/{tracing → dev/tracing}/linkedTraces.js +1 -0
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -0
- package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -0
- package/build/npm/cjs/dev/tracing/request.js.map +1 -0
- package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -0
- package/build/npm/cjs/dev/tracing/utils.js.map +1 -0
- package/build/npm/cjs/dev/transports/fetch.js.map +1 -0
- package/build/npm/cjs/dev/transports/offline.js.map +1 -0
- package/build/npm/cjs/dev/userfeedback.js.map +1 -0
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -0
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -0
- package/build/npm/cjs/prod/client.js +125 -0
- package/build/npm/cjs/prod/client.js.map +1 -0
- package/build/npm/cjs/prod/debug-build.js +11 -0
- package/build/npm/cjs/prod/debug-build.js.map +1 -0
- package/build/npm/cjs/prod/diagnose-sdk.js +51 -0
- package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -0
- package/build/npm/cjs/prod/eventbuilder.js +397 -0
- package/build/npm/cjs/prod/eventbuilder.js.map +1 -0
- package/build/npm/cjs/prod/feedbackAsync.js +15 -0
- package/build/npm/cjs/prod/feedbackAsync.js.map +1 -0
- package/build/npm/cjs/prod/feedbackSync.js +12 -0
- package/build/npm/cjs/prod/feedbackSync.js.map +1 -0
- package/build/npm/cjs/prod/helpers.js +185 -0
- package/build/npm/cjs/prod/helpers.js.map +1 -0
- package/build/npm/cjs/prod/index.js +179 -0
- package/build/npm/cjs/prod/index.js.map +1 -0
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +341 -0
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -0
- package/build/npm/cjs/prod/integrations/browserapierrors.js +259 -0
- package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -0
- package/build/npm/cjs/prod/integrations/browsersession.js +44 -0
- package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -0
- package/build/npm/cjs/prod/integrations/contextlines.js +89 -0
- package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -0
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +29 -0
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +55 -0
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +38 -0
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +48 -0
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +74 -0
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
- package/build/npm/cjs/prod/integrations/globalhandlers.js +210 -0
- package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -0
- package/build/npm/cjs/prod/integrations/graphqlClient.js +180 -0
- package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -0
- package/build/npm/cjs/prod/integrations/httpclient.js +395 -0
- package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -0
- package/build/npm/cjs/prod/integrations/httpcontext.js +35 -0
- package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -0
- package/build/npm/cjs/prod/integrations/linkederrors.js +39 -0
- package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -0
- package/build/npm/cjs/prod/integrations/reportingobserver.js +85 -0
- package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -0
- package/build/npm/cjs/prod/integrations/spotlight.js +85 -0
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -0
- package/build/npm/cjs/prod/integrations/webWorker.js +251 -0
- package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -0
- package/build/npm/cjs/prod/profiling/UIProfiler.js +341 -0
- package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -0
- package/build/npm/cjs/prod/profiling/integration.js +150 -0
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -0
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js +144 -0
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -0
- package/build/npm/cjs/prod/profiling/utils.js +786 -0
- package/build/npm/cjs/prod/profiling/utils.js.map +1 -0
- package/build/npm/cjs/prod/report-dialog.js +68 -0
- package/build/npm/cjs/prod/report-dialog.js.map +1 -0
- package/build/npm/cjs/{sdk.js → prod/sdk.js} +5 -2
- package/build/npm/cjs/prod/sdk.js.map +1 -0
- package/build/npm/cjs/prod/stack-parsers.js +202 -0
- package/build/npm/cjs/prod/stack-parsers.js.map +1 -0
- package/build/npm/cjs/prod/tracing/backgroundtab.js +46 -0
- package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -0
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +577 -0
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -0
- package/build/npm/cjs/prod/tracing/linkedTraces.js +227 -0
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -0
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js +18 -0
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -0
- package/build/npm/cjs/prod/tracing/request.js +342 -0
- package/build/npm/cjs/prod/tracing/request.js.map +1 -0
- package/build/npm/cjs/prod/tracing/setActiveSpan.js +68 -0
- package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -0
- package/build/npm/cjs/prod/tracing/utils.js +54 -0
- package/build/npm/cjs/prod/tracing/utils.js.map +1 -0
- package/build/npm/cjs/prod/transports/fetch.js +71 -0
- package/build/npm/cjs/prod/transports/fetch.js.map +1 -0
- package/build/npm/cjs/prod/transports/offline.js +168 -0
- package/build/npm/cjs/prod/transports/offline.js.map +1 -0
- package/build/npm/cjs/prod/userfeedback.js +42 -0
- package/build/npm/cjs/prod/userfeedback.js.map +1 -0
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js +59 -0
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -0
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +106 -0
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -0
- package/build/npm/esm/dev/client.js.map +1 -0
- package/build/npm/esm/dev/debug-build.js.map +1 -0
- package/build/npm/esm/dev/diagnose-sdk.js.map +1 -0
- package/build/npm/esm/dev/eventbuilder.js.map +1 -0
- package/build/npm/esm/dev/feedbackAsync.js.map +1 -0
- package/build/npm/esm/dev/feedbackSync.js.map +1 -0
- package/build/npm/esm/dev/helpers.js.map +1 -0
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -0
- package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -0
- package/build/npm/esm/dev/integrations/browsersession.js.map +1 -0
- package/build/npm/esm/dev/integrations/contextlines.js.map +1 -0
- package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
- package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
- package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
- package/build/npm/esm/{integrations → dev/integrations}/globalhandlers.js +1 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -0
- package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -0
- package/build/npm/esm/dev/integrations/httpclient.js.map +1 -0
- package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -0
- package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -0
- package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -0
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -0
- package/build/npm/esm/dev/integrations/webWorker.js.map +1 -0
- package/build/npm/esm/dev/package.json +1 -0
- package/build/npm/esm/{profiling/lifecycleMode/traceLifecycleProfiler.js → dev/profiling/UIProfiler.js} +74 -76
- package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -0
- package/build/npm/esm/{profiling → dev/profiling}/integration.js +2 -2
- package/build/npm/esm/dev/profiling/integration.js.map +1 -0
- package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -0
- package/build/npm/esm/dev/profiling/utils.js.map +1 -0
- package/build/npm/esm/dev/report-dialog.js.map +1 -0
- package/build/npm/esm/dev/sdk.js +128 -0
- package/build/npm/esm/dev/sdk.js.map +1 -0
- package/build/npm/esm/dev/stack-parsers.js.map +1 -0
- package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -0
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -0
- package/build/npm/esm/{tracing → dev/tracing}/linkedTraces.js +1 -0
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -0
- package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -0
- package/build/npm/esm/dev/tracing/request.js.map +1 -0
- package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -0
- package/build/npm/esm/dev/tracing/utils.js.map +1 -0
- package/build/npm/esm/dev/transports/fetch.js.map +1 -0
- package/build/npm/esm/dev/transports/offline.js.map +1 -0
- package/build/npm/esm/dev/userfeedback.js.map +1 -0
- package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -0
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -0
- package/build/npm/esm/prod/client.js +122 -0
- package/build/npm/esm/prod/client.js.map +1 -0
- package/build/npm/esm/prod/debug-build.js +9 -0
- package/build/npm/esm/prod/debug-build.js.map +1 -0
- package/build/npm/esm/prod/diagnose-sdk.js +49 -0
- package/build/npm/esm/prod/diagnose-sdk.js.map +1 -0
- package/build/npm/esm/prod/eventbuilder.js +390 -0
- package/build/npm/esm/prod/eventbuilder.js.map +1 -0
- package/build/npm/esm/prod/feedbackAsync.js +13 -0
- package/build/npm/esm/prod/feedbackAsync.js.map +1 -0
- package/build/npm/esm/prod/feedbackSync.js +10 -0
- package/build/npm/esm/prod/feedbackSync.js.map +1 -0
- package/build/npm/esm/prod/helpers.js +179 -0
- package/build/npm/esm/prod/helpers.js.map +1 -0
- package/build/npm/esm/prod/index.js +40 -0
- package/build/npm/esm/prod/index.js.map +1 -0
- package/build/npm/esm/prod/integrations/breadcrumbs.js +339 -0
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -0
- package/build/npm/esm/prod/integrations/browserapierrors.js +257 -0
- package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -0
- package/build/npm/esm/prod/integrations/browsersession.js +42 -0
- package/build/npm/esm/prod/integrations/browsersession.js.map +1 -0
- package/build/npm/esm/prod/integrations/contextlines.js +86 -0
- package/build/npm/esm/prod/integrations/contextlines.js.map +1 -0
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +27 -0
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +52 -0
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +35 -0
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +46 -0
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +72 -0
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
- package/build/npm/esm/prod/integrations/globalhandlers.js +206 -0
- package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -0
- package/build/npm/esm/prod/integrations/graphqlClient.js +175 -0
- package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -0
- package/build/npm/esm/prod/integrations/httpclient.js +393 -0
- package/build/npm/esm/prod/integrations/httpclient.js.map +1 -0
- package/build/npm/esm/prod/integrations/httpcontext.js +33 -0
- package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -0
- package/build/npm/esm/prod/integrations/linkederrors.js +37 -0
- package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -0
- package/build/npm/esm/prod/integrations/reportingobserver.js +83 -0
- package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -0
- package/build/npm/esm/prod/integrations/spotlight.js +81 -0
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -0
- package/build/npm/esm/prod/integrations/webWorker.js +247 -0
- package/build/npm/esm/prod/integrations/webWorker.js.map +1 -0
- package/build/npm/esm/prod/package.json +1 -0
- package/build/npm/esm/prod/profiling/UIProfiler.js +339 -0
- package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -0
- package/build/npm/esm/prod/profiling/integration.js +148 -0
- package/build/npm/esm/prod/profiling/integration.js.map +1 -0
- package/build/npm/esm/prod/profiling/startProfileForSpan.js +142 -0
- package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -0
- package/build/npm/esm/prod/profiling/utils.js +763 -0
- package/build/npm/esm/prod/profiling/utils.js.map +1 -0
- package/build/npm/esm/prod/report-dialog.js +66 -0
- package/build/npm/esm/prod/report-dialog.js.map +1 -0
- package/build/npm/esm/{sdk.js → prod/sdk.js} +5 -2
- package/build/npm/esm/prod/sdk.js.map +1 -0
- package/build/npm/esm/prod/stack-parsers.js +194 -0
- package/build/npm/esm/prod/stack-parsers.js.map +1 -0
- package/build/npm/esm/prod/tracing/backgroundtab.js +44 -0
- package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -0
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +571 -0
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -0
- package/build/npm/esm/prod/tracing/linkedTraces.js +218 -0
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -0
- package/build/npm/esm/prod/tracing/reportPageLoaded.js +16 -0
- package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -0
- package/build/npm/esm/prod/tracing/request.js +338 -0
- package/build/npm/esm/prod/tracing/request.js.map +1 -0
- package/build/npm/esm/prod/tracing/setActiveSpan.js +66 -0
- package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -0
- package/build/npm/esm/prod/tracing/utils.js +49 -0
- package/build/npm/esm/prod/tracing/utils.js.map +1 -0
- package/build/npm/esm/prod/transports/fetch.js +69 -0
- package/build/npm/esm/prod/transports/fetch.js.map +1 -0
- package/build/npm/esm/prod/transports/offline.js +162 -0
- package/build/npm/esm/prod/transports/offline.js.map +1 -0
- package/build/npm/esm/prod/userfeedback.js +40 -0
- package/build/npm/esm/prod/userfeedback.js.map +1 -0
- package/build/npm/esm/prod/utils/detectBrowserExtension.js +57 -0
- package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -0
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js +104 -0
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -0
- package/build/npm/types/client.d.ts +11 -0
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/profiling/{lifecycleMode/traceLifecycleProfiler.d.ts → UIProfiler.d.ts} +6 -2
- package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -0
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types-ts3.8/client.d.ts +11 -0
- package/build/npm/types-ts3.8/profiling/{lifecycleMode/traceLifecycleProfiler.d.ts → UIProfiler.d.ts} +6 -2
- package/package.json +21 -16
- package/build/npm/cjs/client.js.map +0 -1
- package/build/npm/cjs/debug-build.js.map +0 -1
- package/build/npm/cjs/diagnose-sdk.js.map +0 -1
- package/build/npm/cjs/eventbuilder.js.map +0 -1
- package/build/npm/cjs/feedbackAsync.js.map +0 -1
- package/build/npm/cjs/feedbackSync.js.map +0 -1
- package/build/npm/cjs/helpers.js.map +0 -1
- package/build/npm/cjs/integrations/breadcrumbs.js.map +0 -1
- package/build/npm/cjs/integrations/browserapierrors.js.map +0 -1
- package/build/npm/cjs/integrations/browsersession.js.map +0 -1
- package/build/npm/cjs/integrations/contextlines.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/growthbook/integration.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/statsig/integration.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/unleash/integration.js.map +0 -1
- package/build/npm/cjs/integrations/globalhandlers.js.map +0 -1
- package/build/npm/cjs/integrations/graphqlClient.js.map +0 -1
- package/build/npm/cjs/integrations/httpclient.js.map +0 -1
- package/build/npm/cjs/integrations/httpcontext.js.map +0 -1
- package/build/npm/cjs/integrations/linkederrors.js.map +0 -1
- package/build/npm/cjs/integrations/reportingobserver.js.map +0 -1
- package/build/npm/cjs/integrations/spotlight.js.map +0 -1
- package/build/npm/cjs/integrations/webWorker.js.map +0 -1
- package/build/npm/cjs/profiling/integration.js.map +0 -1
- package/build/npm/cjs/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
- package/build/npm/cjs/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/cjs/profiling/utils.js.map +0 -1
- package/build/npm/cjs/report-dialog.js.map +0 -1
- package/build/npm/cjs/sdk.js.map +0 -1
- package/build/npm/cjs/stack-parsers.js.map +0 -1
- package/build/npm/cjs/tracing/backgroundtab.js.map +0 -1
- package/build/npm/cjs/tracing/browserTracingIntegration.js.map +0 -1
- package/build/npm/cjs/tracing/linkedTraces.js.map +0 -1
- package/build/npm/cjs/tracing/reportPageLoaded.js.map +0 -1
- package/build/npm/cjs/tracing/request.js.map +0 -1
- package/build/npm/cjs/tracing/setActiveSpan.js.map +0 -1
- package/build/npm/cjs/tracing/utils.js.map +0 -1
- package/build/npm/cjs/transports/fetch.js.map +0 -1
- package/build/npm/cjs/transports/offline.js.map +0 -1
- package/build/npm/cjs/userfeedback.js.map +0 -1
- package/build/npm/cjs/utils/detectBrowserExtension.js.map +0 -1
- package/build/npm/cjs/utils/lazyLoadIntegration.js.map +0 -1
- package/build/npm/esm/client.js.map +0 -1
- package/build/npm/esm/debug-build.js.map +0 -1
- package/build/npm/esm/diagnose-sdk.js.map +0 -1
- package/build/npm/esm/eventbuilder.js.map +0 -1
- package/build/npm/esm/feedbackAsync.js.map +0 -1
- package/build/npm/esm/feedbackSync.js.map +0 -1
- package/build/npm/esm/helpers.js.map +0 -1
- package/build/npm/esm/integrations/breadcrumbs.js.map +0 -1
- package/build/npm/esm/integrations/browserapierrors.js.map +0 -1
- package/build/npm/esm/integrations/browsersession.js.map +0 -1
- package/build/npm/esm/integrations/contextlines.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/growthbook/integration.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/openfeature/integration.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/statsig/integration.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/unleash/integration.js.map +0 -1
- package/build/npm/esm/integrations/globalhandlers.js.map +0 -1
- package/build/npm/esm/integrations/graphqlClient.js.map +0 -1
- package/build/npm/esm/integrations/httpclient.js.map +0 -1
- package/build/npm/esm/integrations/httpcontext.js.map +0 -1
- package/build/npm/esm/integrations/linkederrors.js.map +0 -1
- package/build/npm/esm/integrations/reportingobserver.js.map +0 -1
- package/build/npm/esm/integrations/spotlight.js.map +0 -1
- package/build/npm/esm/integrations/webWorker.js.map +0 -1
- package/build/npm/esm/package.json +0 -1
- package/build/npm/esm/profiling/integration.js.map +0 -1
- package/build/npm/esm/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
- package/build/npm/esm/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/esm/profiling/utils.js.map +0 -1
- package/build/npm/esm/report-dialog.js.map +0 -1
- package/build/npm/esm/sdk.js.map +0 -1
- package/build/npm/esm/stack-parsers.js.map +0 -1
- package/build/npm/esm/tracing/backgroundtab.js.map +0 -1
- package/build/npm/esm/tracing/browserTracingIntegration.js.map +0 -1
- package/build/npm/esm/tracing/linkedTraces.js.map +0 -1
- package/build/npm/esm/tracing/reportPageLoaded.js.map +0 -1
- package/build/npm/esm/tracing/request.js.map +0 -1
- package/build/npm/esm/tracing/setActiveSpan.js.map +0 -1
- package/build/npm/esm/tracing/utils.js.map +0 -1
- package/build/npm/esm/transports/fetch.js.map +0 -1
- package/build/npm/esm/transports/offline.js.map +0 -1
- package/build/npm/esm/userfeedback.js.map +0 -1
- package/build/npm/esm/utils/detectBrowserExtension.js.map +0 -1
- package/build/npm/esm/utils/lazyLoadIntegration.js.map +0 -1
- package/build/npm/types/profiling/lifecycleMode/traceLifecycleProfiler.d.ts.map +0 -1
- /package/build/npm/cjs/{client.js → dev/client.js} +0 -0
- /package/build/npm/cjs/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/npm/cjs/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
- /package/build/npm/cjs/{eventbuilder.js → dev/eventbuilder.js} +0 -0
- /package/build/npm/cjs/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
- /package/build/npm/cjs/{feedbackSync.js → dev/feedbackSync.js} +0 -0
- /package/build/npm/cjs/{helpers.js → dev/helpers.js} +0 -0
- /package/build/npm/cjs/{index.js → dev/index.js} +0 -0
- /package/build/npm/cjs/{index.js.map → dev/index.js.map} +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/breadcrumbs.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/browserapierrors.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/browsersession.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/contextlines.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/graphqlClient.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/httpclient.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/httpcontext.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/linkederrors.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/reportingobserver.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/npm/cjs/{integrations → dev/integrations}/webWorker.js +0 -0
- /package/build/npm/cjs/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
- /package/build/npm/cjs/{profiling → dev/profiling}/utils.js +0 -0
- /package/build/npm/cjs/{report-dialog.js → dev/report-dialog.js} +0 -0
- /package/build/npm/cjs/{stack-parsers.js → dev/stack-parsers.js} +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/backgroundtab.js +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/request.js +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/setActiveSpan.js +0 -0
- /package/build/npm/cjs/{tracing → dev/tracing}/utils.js +0 -0
- /package/build/npm/cjs/{transports → dev/transports}/fetch.js +0 -0
- /package/build/npm/cjs/{transports → dev/transports}/offline.js +0 -0
- /package/build/npm/cjs/{userfeedback.js → dev/userfeedback.js} +0 -0
- /package/build/npm/cjs/{utils → dev/utils}/detectBrowserExtension.js +0 -0
- /package/build/npm/cjs/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
- /package/build/npm/esm/{client.js → dev/client.js} +0 -0
- /package/build/npm/esm/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/npm/esm/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
- /package/build/npm/esm/{eventbuilder.js → dev/eventbuilder.js} +0 -0
- /package/build/npm/esm/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
- /package/build/npm/esm/{feedbackSync.js → dev/feedbackSync.js} +0 -0
- /package/build/npm/esm/{helpers.js → dev/helpers.js} +0 -0
- /package/build/npm/esm/{index.js → dev/index.js} +0 -0
- /package/build/npm/esm/{index.js.map → dev/index.js.map} +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/breadcrumbs.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/browserapierrors.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/browsersession.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/contextlines.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/graphqlClient.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/httpclient.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/httpcontext.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/linkederrors.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/reportingobserver.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/npm/esm/{integrations → dev/integrations}/webWorker.js +0 -0
- /package/build/npm/esm/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
- /package/build/npm/esm/{profiling → dev/profiling}/utils.js +0 -0
- /package/build/npm/esm/{report-dialog.js → dev/report-dialog.js} +0 -0
- /package/build/npm/esm/{stack-parsers.js → dev/stack-parsers.js} +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/backgroundtab.js +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/request.js +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/setActiveSpan.js +0 -0
- /package/build/npm/esm/{tracing → dev/tracing}/utils.js +0 -0
- /package/build/npm/esm/{transports → dev/transports}/fetch.js +0 -0
- /package/build/npm/esm/{transports → dev/transports}/offline.js +0 -0
- /package/build/npm/esm/{userfeedback.js → dev/userfeedback.js} +0 -0
- /package/build/npm/esm/{utils → dev/utils}/detectBrowserExtension.js +0 -0
- /package/build/npm/esm/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const debugBuild = require('../debug-build.js');
|
|
5
|
+
const helpers = require('../helpers.js');
|
|
6
|
+
require('@sentry-internal/browser-utils');
|
|
7
|
+
require('../stack-parsers.js');
|
|
8
|
+
require('../integrations/breadcrumbs.js');
|
|
9
|
+
require('../integrations/browserapierrors.js');
|
|
10
|
+
require('../integrations/browsersession.js');
|
|
11
|
+
require('../integrations/globalhandlers.js');
|
|
12
|
+
require('../integrations/httpcontext.js');
|
|
13
|
+
require('../integrations/linkederrors.js');
|
|
14
|
+
require('../integrations/spotlight.js');
|
|
15
|
+
|
|
16
|
+
// 1h in seconds
|
|
17
|
+
const PREVIOUS_TRACE_MAX_DURATION = 3600;
|
|
18
|
+
|
|
19
|
+
// session storage key
|
|
20
|
+
const PREVIOUS_TRACE_KEY = 'sentry_previous_trace';
|
|
21
|
+
|
|
22
|
+
const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = 'sentry.previous_trace';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Takes care of linking traces and applying the (consistent) sampling behavoiour based on the passed options
|
|
26
|
+
* @param options - options for linking traces and consistent trace sampling (@see BrowserTracingOptions)
|
|
27
|
+
* @param client - Sentry client
|
|
28
|
+
*/
|
|
29
|
+
function linkTraces(
|
|
30
|
+
client,
|
|
31
|
+
{
|
|
32
|
+
linkPreviousTrace,
|
|
33
|
+
consistentTraceSampling,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
,
|
|
37
|
+
) {
|
|
38
|
+
const useSessionStorage = linkPreviousTrace === 'session-storage';
|
|
39
|
+
|
|
40
|
+
let inMemoryPreviousTraceInfo = useSessionStorage ? getPreviousTraceFromSessionStorage() : undefined;
|
|
41
|
+
|
|
42
|
+
client.on('spanStart', span => {
|
|
43
|
+
if (core.getRootSpan(span) !== span) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const oldPropagationContext = core.getCurrentScope().getPropagationContext();
|
|
48
|
+
inMemoryPreviousTraceInfo = addPreviousTraceSpanLink(inMemoryPreviousTraceInfo, span, oldPropagationContext);
|
|
49
|
+
|
|
50
|
+
if (useSessionStorage) {
|
|
51
|
+
storePreviousTraceInSessionStorage(inMemoryPreviousTraceInfo);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let isFirstTraceOnPageload = true;
|
|
56
|
+
if (consistentTraceSampling) {
|
|
57
|
+
/*
|
|
58
|
+
When users opt into `consistentTraceSampling`, we need to ensure that we propagate
|
|
59
|
+
the previous trace's sample rate and rand to the current trace. This is necessary because otherwise, span
|
|
60
|
+
metric extrapolation is inaccurate, as we'd propagate too high of a sample rate for the subsequent traces.
|
|
61
|
+
|
|
62
|
+
So therefore, we pretend that the previous trace was the parent trace of the newly started trace. To do that,
|
|
63
|
+
we mutate the propagation context of the current trace and set the sample rate and sample rand of the previous trace.
|
|
64
|
+
Timing-wise, it is fine because it happens before we even sample the root span.
|
|
65
|
+
|
|
66
|
+
@see https://github.com/getsentry/sentry-javascript/issues/15754
|
|
67
|
+
*/
|
|
68
|
+
client.on('beforeSampling', mutableSamplingContextData => {
|
|
69
|
+
if (!inMemoryPreviousTraceInfo) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const scope = core.getCurrentScope();
|
|
74
|
+
const currentPropagationContext = scope.getPropagationContext();
|
|
75
|
+
|
|
76
|
+
// We do not want to force-continue the sampling decision if we continue a trace
|
|
77
|
+
// that was started on the backend. Most prominently, this will happen in MPAs where
|
|
78
|
+
// users hard-navigate between pages. In this case, the sampling decision of a potentially
|
|
79
|
+
// started trace on the server takes precedence.
|
|
80
|
+
// Why? We want to prioritize inter-trace consistency over intra-trace consistency.
|
|
81
|
+
if (isFirstTraceOnPageload && currentPropagationContext.parentSpanId) {
|
|
82
|
+
isFirstTraceOnPageload = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
scope.setPropagationContext({
|
|
87
|
+
...currentPropagationContext,
|
|
88
|
+
dsc: {
|
|
89
|
+
...currentPropagationContext.dsc,
|
|
90
|
+
sample_rate: String(inMemoryPreviousTraceInfo.sampleRate),
|
|
91
|
+
sampled: String(spanContextSampled(inMemoryPreviousTraceInfo.spanContext)),
|
|
92
|
+
},
|
|
93
|
+
sampleRand: inMemoryPreviousTraceInfo.sampleRand,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
mutableSamplingContextData.parentSampled = spanContextSampled(inMemoryPreviousTraceInfo.spanContext);
|
|
97
|
+
mutableSamplingContextData.parentSampleRate = inMemoryPreviousTraceInfo.sampleRate;
|
|
98
|
+
|
|
99
|
+
mutableSamplingContextData.spanAttributes = {
|
|
100
|
+
...mutableSamplingContextData.spanAttributes,
|
|
101
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE]: inMemoryPreviousTraceInfo.sampleRate,
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Adds a previous_trace span link to the passed span if the passed
|
|
109
|
+
* previousTraceInfo is still valid.
|
|
110
|
+
*
|
|
111
|
+
* @returns the updated previous trace info (based on the current span/trace) to
|
|
112
|
+
* be used on the next call
|
|
113
|
+
*/
|
|
114
|
+
function addPreviousTraceSpanLink(
|
|
115
|
+
previousTraceInfo,
|
|
116
|
+
span,
|
|
117
|
+
oldPropagationContext,
|
|
118
|
+
) {
|
|
119
|
+
const spanJson = core.spanToJSON(span);
|
|
120
|
+
|
|
121
|
+
function getSampleRate() {
|
|
122
|
+
try {
|
|
123
|
+
return (
|
|
124
|
+
Number(oldPropagationContext.dsc?.sample_rate) ?? Number(spanJson.data?.[core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE])
|
|
125
|
+
);
|
|
126
|
+
} catch {
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const updatedPreviousTraceInfo = {
|
|
132
|
+
spanContext: span.spanContext(),
|
|
133
|
+
startTimestamp: spanJson.start_timestamp,
|
|
134
|
+
sampleRate: getSampleRate(),
|
|
135
|
+
sampleRand: oldPropagationContext.sampleRand,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (!previousTraceInfo) {
|
|
139
|
+
return updatedPreviousTraceInfo;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const previousTraceSpanCtx = previousTraceInfo.spanContext;
|
|
143
|
+
if (previousTraceSpanCtx.traceId === spanJson.trace_id) {
|
|
144
|
+
// This means, we're still in the same trace so let's not update the previous trace info
|
|
145
|
+
// or add a link to the current span.
|
|
146
|
+
// Once we move away from the long-lived, route-based trace model, we can remove this cases
|
|
147
|
+
return previousTraceInfo;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Only add the link if the startTimeStamp of the previous trace's root span is within
|
|
151
|
+
// PREVIOUS_TRACE_MAX_DURATION (1h) of the current root span's startTimestamp
|
|
152
|
+
// This is done to
|
|
153
|
+
// - avoid adding links to "stale" traces
|
|
154
|
+
// - enable more efficient querying for previous/next traces in Sentry
|
|
155
|
+
if (Date.now() / 1000 - previousTraceInfo.startTimestamp <= PREVIOUS_TRACE_MAX_DURATION) {
|
|
156
|
+
if (debugBuild.DEBUG_BUILD) {
|
|
157
|
+
core.debug.log(
|
|
158
|
+
`Adding previous_trace ${previousTraceSpanCtx} link to span ${{
|
|
159
|
+
op: spanJson.op,
|
|
160
|
+
...span.spanContext(),
|
|
161
|
+
}}`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
span.addLink({
|
|
166
|
+
context: previousTraceSpanCtx,
|
|
167
|
+
attributes: {
|
|
168
|
+
[core.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
|
|
173
|
+
// can obtain the previous trace information from the EAP store. Long-term, EAP will handle
|
|
174
|
+
// span links and then we should remove this again. Also throwing in a TODO(v11), to remind us
|
|
175
|
+
// to check this at v11 time :)
|
|
176
|
+
span.setAttribute(
|
|
177
|
+
PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE,
|
|
178
|
+
`${previousTraceSpanCtx.traceId}-${previousTraceSpanCtx.spanId}-${
|
|
179
|
+
spanContextSampled(previousTraceSpanCtx) ? 1 : 0
|
|
180
|
+
}`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return updatedPreviousTraceInfo;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Stores @param previousTraceInfo in sessionStorage.
|
|
189
|
+
*/
|
|
190
|
+
function storePreviousTraceInSessionStorage(previousTraceInfo) {
|
|
191
|
+
try {
|
|
192
|
+
helpers.WINDOW.sessionStorage.setItem(PREVIOUS_TRACE_KEY, JSON.stringify(previousTraceInfo));
|
|
193
|
+
} catch (e) {
|
|
194
|
+
// Ignore potential errors (e.g. if sessionStorage is not available)
|
|
195
|
+
debugBuild.DEBUG_BUILD && core.debug.warn('Could not store previous trace in sessionStorage', e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Retrieves the previous trace from sessionStorage if available.
|
|
201
|
+
*/
|
|
202
|
+
function getPreviousTraceFromSessionStorage() {
|
|
203
|
+
try {
|
|
204
|
+
const previousTraceInfo = helpers.WINDOW.sessionStorage?.getItem(PREVIOUS_TRACE_KEY);
|
|
205
|
+
// @ts-expect-error - intentionally risking JSON.parse throwing when previousTraceInfo is null to save bundle size
|
|
206
|
+
return JSON.parse(previousTraceInfo);
|
|
207
|
+
} catch {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* see {@link import('@sentry/core').spanIsSampled}
|
|
214
|
+
*/
|
|
215
|
+
function spanContextSampled(ctx) {
|
|
216
|
+
return ctx.traceFlags === 0x1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.PREVIOUS_TRACE_KEY = PREVIOUS_TRACE_KEY;
|
|
220
|
+
exports.PREVIOUS_TRACE_MAX_DURATION = PREVIOUS_TRACE_MAX_DURATION;
|
|
221
|
+
exports.PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE;
|
|
222
|
+
exports.addPreviousTraceSpanLink = addPreviousTraceSpanLink;
|
|
223
|
+
exports.getPreviousTraceFromSessionStorage = getPreviousTraceFromSessionStorage;
|
|
224
|
+
exports.linkTraces = linkTraces;
|
|
225
|
+
exports.spanContextSampled = spanContextSampled;
|
|
226
|
+
exports.storePreviousTraceInSessionStorage = storePreviousTraceInSessionStorage;
|
|
227
|
+
//# sourceMappingURL=linkedTraces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkedTraces.js","sources":["../../../../../src/tracing/linkedTraces.ts"],"sourcesContent":["import type { Client, PropagationContext, Span } from '@sentry/core';\nimport {\n type SpanContextData,\n debug,\n getCurrentScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE,\n spanToJSON,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../exports';\n\nexport interface PreviousTraceInfo {\n /**\n * Span context of the previous trace's local root span\n */\n spanContext: SpanContextData;\n\n /**\n * Timestamp in seconds when the previous trace was started\n */\n startTimestamp: number;\n\n /**\n * sample rate of the previous trace\n */\n sampleRate: number;\n\n /**\n * The sample rand of the previous trace\n */\n sampleRand: number;\n}\n\n// 1h in seconds\nexport const PREVIOUS_TRACE_MAX_DURATION = 3600;\n\n// session storage key\nexport const PREVIOUS_TRACE_KEY = 'sentry_previous_trace';\n\nexport const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = 'sentry.previous_trace';\n\n/**\n * Takes care of linking traces and applying the (consistent) sampling behavoiour based on the passed options\n * @param options - options for linking traces and consistent trace sampling (@see BrowserTracingOptions)\n * @param client - Sentry client\n */\nexport function linkTraces(\n client: Client,\n {\n linkPreviousTrace,\n consistentTraceSampling,\n }: {\n linkPreviousTrace: 'session-storage' | 'in-memory';\n consistentTraceSampling: boolean;\n },\n): void {\n const useSessionStorage = linkPreviousTrace === 'session-storage';\n\n let inMemoryPreviousTraceInfo = useSessionStorage ? getPreviousTraceFromSessionStorage() : undefined;\n\n client.on('spanStart', span => {\n if (getRootSpan(span) !== span) {\n return;\n }\n\n const oldPropagationContext = getCurrentScope().getPropagationContext();\n inMemoryPreviousTraceInfo = addPreviousTraceSpanLink(inMemoryPreviousTraceInfo, span, oldPropagationContext);\n\n if (useSessionStorage) {\n storePreviousTraceInSessionStorage(inMemoryPreviousTraceInfo);\n }\n });\n\n let isFirstTraceOnPageload = true;\n if (consistentTraceSampling) {\n /*\n When users opt into `consistentTraceSampling`, we need to ensure that we propagate\n the previous trace's sample rate and rand to the current trace. This is necessary because otherwise, span\n metric extrapolation is inaccurate, as we'd propagate too high of a sample rate for the subsequent traces.\n\n So therefore, we pretend that the previous trace was the parent trace of the newly started trace. To do that,\n we mutate the propagation context of the current trace and set the sample rate and sample rand of the previous trace.\n Timing-wise, it is fine because it happens before we even sample the root span.\n\n @see https://github.com/getsentry/sentry-javascript/issues/15754\n */\n client.on('beforeSampling', mutableSamplingContextData => {\n if (!inMemoryPreviousTraceInfo) {\n return;\n }\n\n const scope = getCurrentScope();\n const currentPropagationContext = scope.getPropagationContext();\n\n // We do not want to force-continue the sampling decision if we continue a trace\n // that was started on the backend. Most prominently, this will happen in MPAs where\n // users hard-navigate between pages. In this case, the sampling decision of a potentially\n // started trace on the server takes precedence.\n // Why? We want to prioritize inter-trace consistency over intra-trace consistency.\n if (isFirstTraceOnPageload && currentPropagationContext.parentSpanId) {\n isFirstTraceOnPageload = false;\n return;\n }\n\n scope.setPropagationContext({\n ...currentPropagationContext,\n dsc: {\n ...currentPropagationContext.dsc,\n sample_rate: String(inMemoryPreviousTraceInfo.sampleRate),\n sampled: String(spanContextSampled(inMemoryPreviousTraceInfo.spanContext)),\n },\n sampleRand: inMemoryPreviousTraceInfo.sampleRand,\n });\n\n mutableSamplingContextData.parentSampled = spanContextSampled(inMemoryPreviousTraceInfo.spanContext);\n mutableSamplingContextData.parentSampleRate = inMemoryPreviousTraceInfo.sampleRate;\n\n mutableSamplingContextData.spanAttributes = {\n ...mutableSamplingContextData.spanAttributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE]: inMemoryPreviousTraceInfo.sampleRate,\n };\n });\n }\n}\n\n/**\n * Adds a previous_trace span link to the passed span if the passed\n * previousTraceInfo is still valid.\n *\n * @returns the updated previous trace info (based on the current span/trace) to\n * be used on the next call\n */\nexport function addPreviousTraceSpanLink(\n previousTraceInfo: PreviousTraceInfo | undefined,\n span: Span,\n oldPropagationContext: PropagationContext,\n): PreviousTraceInfo {\n const spanJson = spanToJSON(span);\n\n function getSampleRate(): number {\n try {\n return (\n Number(oldPropagationContext.dsc?.sample_rate) ?? Number(spanJson.data?.[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE])\n );\n } catch {\n return 0;\n }\n }\n\n const updatedPreviousTraceInfo = {\n spanContext: span.spanContext(),\n startTimestamp: spanJson.start_timestamp,\n sampleRate: getSampleRate(),\n sampleRand: oldPropagationContext.sampleRand,\n };\n\n if (!previousTraceInfo) {\n return updatedPreviousTraceInfo;\n }\n\n const previousTraceSpanCtx = previousTraceInfo.spanContext;\n if (previousTraceSpanCtx.traceId === spanJson.trace_id) {\n // This means, we're still in the same trace so let's not update the previous trace info\n // or add a link to the current span.\n // Once we move away from the long-lived, route-based trace model, we can remove this cases\n return previousTraceInfo;\n }\n\n // Only add the link if the startTimeStamp of the previous trace's root span is within\n // PREVIOUS_TRACE_MAX_DURATION (1h) of the current root span's startTimestamp\n // This is done to\n // - avoid adding links to \"stale\" traces\n // - enable more efficient querying for previous/next traces in Sentry\n if (Date.now() / 1000 - previousTraceInfo.startTimestamp <= PREVIOUS_TRACE_MAX_DURATION) {\n if (DEBUG_BUILD) {\n debug.log(\n `Adding previous_trace ${previousTraceSpanCtx} link to span ${{\n op: spanJson.op,\n ...span.spanContext(),\n }}`,\n );\n }\n\n span.addLink({\n context: previousTraceSpanCtx,\n attributes: {\n [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',\n },\n });\n\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n span.setAttribute(\n PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE,\n `${previousTraceSpanCtx.traceId}-${previousTraceSpanCtx.spanId}-${\n spanContextSampled(previousTraceSpanCtx) ? 1 : 0\n }`,\n );\n }\n\n return updatedPreviousTraceInfo;\n}\n\n/**\n * Stores @param previousTraceInfo in sessionStorage.\n */\nexport function storePreviousTraceInSessionStorage(previousTraceInfo: PreviousTraceInfo): void {\n try {\n WINDOW.sessionStorage.setItem(PREVIOUS_TRACE_KEY, JSON.stringify(previousTraceInfo));\n } catch (e) {\n // Ignore potential errors (e.g. if sessionStorage is not available)\n DEBUG_BUILD && debug.warn('Could not store previous trace in sessionStorage', e);\n }\n}\n\n/**\n * Retrieves the previous trace from sessionStorage if available.\n */\nexport function getPreviousTraceFromSessionStorage(): PreviousTraceInfo | undefined {\n try {\n const previousTraceInfo = WINDOW.sessionStorage?.getItem(PREVIOUS_TRACE_KEY);\n // @ts-expect-error - intentionally risking JSON.parse throwing when previousTraceInfo is null to save bundle size\n return JSON.parse(previousTraceInfo);\n } catch {\n return undefined;\n }\n}\n\n/**\n * see {@link import('@sentry/core').spanIsSampled}\n */\nexport function spanContextSampled(ctx: SpanContextData): boolean {\n return ctx.traceFlags === 0x1;\n}\n"],"names":["getRootSpan","getCurrentScope","SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","DEBUG_BUILD","debug","SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE","WINDOW"],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Manually report the end of the page load, resulting in the SDK ending the pageload span.
|
|
7
|
+
* This only works if {@link BrowserTracingOptions.enableReportPageLoaded} is set to `true`.
|
|
8
|
+
* Otherwise, the pageload span will end itself based on the {@link BrowserTracingOptions.finalTimeout},
|
|
9
|
+
* {@link BrowserTracingOptions.idleTimeout} and {@link BrowserTracingOptions.childSpanTimeout}.
|
|
10
|
+
*
|
|
11
|
+
* @param client - The client to use. If not provided, the global client will be used.
|
|
12
|
+
*/
|
|
13
|
+
function reportPageLoaded(client = core.getClient()) {
|
|
14
|
+
client?.emit('endPageloadSpan');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.reportPageLoaded = reportPageLoaded;
|
|
18
|
+
//# sourceMappingURL=reportPageLoaded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportPageLoaded.js","sources":["../../../../../src/tracing/reportPageLoaded.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { getClient } from '@sentry/core';\n\n/**\n * Manually report the end of the page load, resulting in the SDK ending the pageload span.\n * This only works if {@link BrowserTracingOptions.enableReportPageLoaded} is set to `true`.\n * Otherwise, the pageload span will end itself based on the {@link BrowserTracingOptions.finalTimeout},\n * {@link BrowserTracingOptions.idleTimeout} and {@link BrowserTracingOptions.childSpanTimeout}.\n *\n * @param client - The client to use. If not provided, the global client will be used.\n */\nexport function reportPageLoaded(client: Client | undefined = getClient()): void {\n client?.emit('endPageloadSpan');\n}\n"],"names":["getClient"],"mappings":";;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,GAAuBA,cAAS,EAAE,EAAQ;AACjF,EAAE,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC;AACjC;;;;"}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const browserUtils = require('@sentry-internal/browser-utils');
|
|
5
|
+
const utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
/** Options for Request Instrumentation */
|
|
8
|
+
|
|
9
|
+
const responseToSpanId = new WeakMap();
|
|
10
|
+
const spanIdToEndTimestamp = new Map();
|
|
11
|
+
|
|
12
|
+
const defaultRequestInstrumentationOptions = {
|
|
13
|
+
traceFetch: true,
|
|
14
|
+
traceXHR: true,
|
|
15
|
+
enableHTTPTimings: true,
|
|
16
|
+
trackFetchStreamPerformance: false,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Registers span creators for xhr and fetch requests */
|
|
20
|
+
function instrumentOutgoingRequests(client, _options) {
|
|
21
|
+
const {
|
|
22
|
+
traceFetch,
|
|
23
|
+
traceXHR,
|
|
24
|
+
trackFetchStreamPerformance,
|
|
25
|
+
shouldCreateSpanForRequest,
|
|
26
|
+
enableHTTPTimings,
|
|
27
|
+
tracePropagationTargets,
|
|
28
|
+
onRequestSpanStart,
|
|
29
|
+
onRequestSpanEnd,
|
|
30
|
+
} = {
|
|
31
|
+
...defaultRequestInstrumentationOptions,
|
|
32
|
+
..._options,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const shouldCreateSpan =
|
|
36
|
+
typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_) => true;
|
|
37
|
+
|
|
38
|
+
const shouldAttachHeadersWithTargets = (url) => shouldAttachHeaders(url, tracePropagationTargets);
|
|
39
|
+
|
|
40
|
+
const spans = {};
|
|
41
|
+
|
|
42
|
+
const propagateTraceparent = (client ).getOptions().propagateTraceparent;
|
|
43
|
+
|
|
44
|
+
if (traceFetch) {
|
|
45
|
+
// Keeping track of http requests, whose body payloads resolved later than the initial resolved request
|
|
46
|
+
// e.g. streaming using server sent events (SSE)
|
|
47
|
+
client.addEventProcessor(event => {
|
|
48
|
+
if (event.type === 'transaction' && event.spans) {
|
|
49
|
+
event.spans.forEach(span => {
|
|
50
|
+
if (span.op === 'http.client') {
|
|
51
|
+
const updatedTimestamp = spanIdToEndTimestamp.get(span.span_id);
|
|
52
|
+
if (updatedTimestamp) {
|
|
53
|
+
span.timestamp = updatedTimestamp / 1000;
|
|
54
|
+
spanIdToEndTimestamp.delete(span.span_id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return event;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (trackFetchStreamPerformance) {
|
|
63
|
+
core.addFetchEndInstrumentationHandler(handlerData => {
|
|
64
|
+
if (handlerData.response) {
|
|
65
|
+
const span = responseToSpanId.get(handlerData.response);
|
|
66
|
+
if (span && handlerData.endTimestamp) {
|
|
67
|
+
spanIdToEndTimestamp.set(span, handlerData.endTimestamp);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
core.addFetchInstrumentationHandler(handlerData => {
|
|
74
|
+
const createdSpan = core.instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans, {
|
|
75
|
+
propagateTraceparent,
|
|
76
|
+
onRequestSpanEnd,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (handlerData.response && handlerData.fetchData.__span) {
|
|
80
|
+
responseToSpanId.set(handlerData.response, handlerData.fetchData.__span);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// We cannot use `window.location` in the generic fetch instrumentation,
|
|
84
|
+
// but we need it for reliable `server.address` attribute.
|
|
85
|
+
// so we extend this in here
|
|
86
|
+
if (createdSpan) {
|
|
87
|
+
const fullUrl = utils.getFullURL(handlerData.fetchData.url);
|
|
88
|
+
const host = fullUrl ? core.parseUrl(fullUrl).host : undefined;
|
|
89
|
+
createdSpan.setAttributes({
|
|
90
|
+
'http.url': fullUrl,
|
|
91
|
+
'server.address': host,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (enableHTTPTimings) {
|
|
95
|
+
addHTTPTimings(createdSpan);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onRequestSpanStart?.(createdSpan, { headers: handlerData.headers });
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (traceXHR) {
|
|
104
|
+
browserUtils.addXhrInstrumentationHandler(handlerData => {
|
|
105
|
+
const createdSpan = xhrCallback(
|
|
106
|
+
handlerData,
|
|
107
|
+
shouldCreateSpan,
|
|
108
|
+
shouldAttachHeadersWithTargets,
|
|
109
|
+
spans,
|
|
110
|
+
propagateTraceparent,
|
|
111
|
+
onRequestSpanEnd,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
if (createdSpan) {
|
|
115
|
+
if (enableHTTPTimings) {
|
|
116
|
+
addHTTPTimings(createdSpan);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onRequestSpanStart?.(createdSpan, {
|
|
120
|
+
headers: utils.createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Creates a temporary observer to listen to the next fetch/xhr resourcing timings,
|
|
129
|
+
* so that when timings hit their per-browser limit they don't need to be removed.
|
|
130
|
+
*
|
|
131
|
+
* @param span A span that has yet to be finished, must contain `url` on data.
|
|
132
|
+
*/
|
|
133
|
+
function addHTTPTimings(span) {
|
|
134
|
+
const { url } = core.spanToJSON(span).data;
|
|
135
|
+
|
|
136
|
+
if (!url || typeof url !== 'string') {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const cleanup = browserUtils.addPerformanceInstrumentationHandler('resource', ({ entries }) => {
|
|
141
|
+
entries.forEach(entry => {
|
|
142
|
+
if (utils.isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {
|
|
143
|
+
span.setAttributes(browserUtils.resourceTimingToSpanAttributes(entry));
|
|
144
|
+
// In the next tick, clean this handler up
|
|
145
|
+
// We have to wait here because otherwise this cleans itself up before it is fully done
|
|
146
|
+
setTimeout(cleanup);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A function that determines whether to attach tracing headers to a request.
|
|
154
|
+
* We only export this function for testing purposes.
|
|
155
|
+
*/
|
|
156
|
+
function shouldAttachHeaders(
|
|
157
|
+
targetUrl,
|
|
158
|
+
tracePropagationTargets,
|
|
159
|
+
) {
|
|
160
|
+
// window.location.href not being defined is an edge case in the browser but we need to handle it.
|
|
161
|
+
// Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj
|
|
162
|
+
const href = core.getLocationHref();
|
|
163
|
+
|
|
164
|
+
if (!href) {
|
|
165
|
+
// If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`
|
|
166
|
+
// BIG DISCLAIMER: Users can call URLs with a double slash (fetch("//example.com/api")), this is a shorthand for "send to the same protocol",
|
|
167
|
+
// so we need a to exclude those requests, because they might be cross origin.
|
|
168
|
+
const isRelativeSameOriginRequest = !!targetUrl.match(/^\/(?!\/)/);
|
|
169
|
+
if (!tracePropagationTargets) {
|
|
170
|
+
return isRelativeSameOriginRequest;
|
|
171
|
+
} else {
|
|
172
|
+
return core.stringMatchesSomePattern(targetUrl, tracePropagationTargets);
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
let resolvedUrl;
|
|
176
|
+
let currentOrigin;
|
|
177
|
+
|
|
178
|
+
// URL parsing may fail, we default to not attaching trace headers in that case.
|
|
179
|
+
try {
|
|
180
|
+
resolvedUrl = new URL(targetUrl, href);
|
|
181
|
+
currentOrigin = new URL(href).origin;
|
|
182
|
+
} catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const isSameOriginRequest = resolvedUrl.origin === currentOrigin;
|
|
187
|
+
if (!tracePropagationTargets) {
|
|
188
|
+
return isSameOriginRequest;
|
|
189
|
+
} else {
|
|
190
|
+
return (
|
|
191
|
+
core.stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||
|
|
192
|
+
(isSameOriginRequest && core.stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Create and track xhr request spans
|
|
200
|
+
*
|
|
201
|
+
* @returns Span if a span was created, otherwise void.
|
|
202
|
+
*/
|
|
203
|
+
function xhrCallback(
|
|
204
|
+
handlerData,
|
|
205
|
+
shouldCreateSpan,
|
|
206
|
+
shouldAttachHeaders,
|
|
207
|
+
spans,
|
|
208
|
+
propagateTraceparent,
|
|
209
|
+
onRequestSpanEnd,
|
|
210
|
+
) {
|
|
211
|
+
const xhr = handlerData.xhr;
|
|
212
|
+
const sentryXhrData = xhr?.[browserUtils.SENTRY_XHR_DATA_KEY];
|
|
213
|
+
|
|
214
|
+
if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const { url, method } = sentryXhrData;
|
|
219
|
+
|
|
220
|
+
const shouldCreateSpanResult = core.hasSpansEnabled() && shouldCreateSpan(url);
|
|
221
|
+
|
|
222
|
+
// check first if the request has finished and is tracked by an existing span which should now end
|
|
223
|
+
if (handlerData.endTimestamp && shouldCreateSpanResult) {
|
|
224
|
+
const spanId = xhr.__sentry_xhr_span_id__;
|
|
225
|
+
if (!spanId) return;
|
|
226
|
+
|
|
227
|
+
const span = spans[spanId];
|
|
228
|
+
if (span && sentryXhrData.status_code !== undefined) {
|
|
229
|
+
core.setHttpStatus(span, sentryXhrData.status_code);
|
|
230
|
+
span.end();
|
|
231
|
+
|
|
232
|
+
onRequestSpanEnd?.(span, {
|
|
233
|
+
headers: utils.createHeadersSafely(browserUtils.parseXhrResponseHeaders(xhr )),
|
|
234
|
+
error: handlerData.error,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
238
|
+
delete spans[spanId];
|
|
239
|
+
}
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const fullUrl = utils.getFullURL(url);
|
|
244
|
+
const parsedUrl = fullUrl ? core.parseUrl(fullUrl) : core.parseUrl(url);
|
|
245
|
+
|
|
246
|
+
const urlForSpanName = core.stripUrlQueryAndFragment(url);
|
|
247
|
+
|
|
248
|
+
const hasParent = !!core.getActiveSpan();
|
|
249
|
+
|
|
250
|
+
const span =
|
|
251
|
+
shouldCreateSpanResult && hasParent
|
|
252
|
+
? core.startInactiveSpan({
|
|
253
|
+
name: `${method} ${urlForSpanName}`,
|
|
254
|
+
attributes: {
|
|
255
|
+
url,
|
|
256
|
+
type: 'xhr',
|
|
257
|
+
'http.method': method,
|
|
258
|
+
'http.url': fullUrl,
|
|
259
|
+
'server.address': parsedUrl?.host,
|
|
260
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',
|
|
261
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
|
|
262
|
+
...(parsedUrl?.search && { 'http.query': parsedUrl?.search }),
|
|
263
|
+
...(parsedUrl?.hash && { 'http.fragment': parsedUrl?.hash }),
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
: new core.SentryNonRecordingSpan();
|
|
267
|
+
|
|
268
|
+
xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;
|
|
269
|
+
spans[xhr.__sentry_xhr_span_id__] = span;
|
|
270
|
+
|
|
271
|
+
if (shouldAttachHeaders(url)) {
|
|
272
|
+
addTracingHeadersToXhrRequest(
|
|
273
|
+
xhr,
|
|
274
|
+
// If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),
|
|
275
|
+
// we do not want to use the span as base for the trace headers,
|
|
276
|
+
// which means that the headers will be generated from the scope and the sampling decision is deferred
|
|
277
|
+
core.hasSpansEnabled() && hasParent ? span : undefined,
|
|
278
|
+
propagateTraceparent,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const client = core.getClient();
|
|
283
|
+
if (client) {
|
|
284
|
+
client.emit('beforeOutgoingRequestSpan', span, handlerData );
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return span;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function addTracingHeadersToXhrRequest(
|
|
291
|
+
xhr,
|
|
292
|
+
span,
|
|
293
|
+
propagateTraceparent,
|
|
294
|
+
) {
|
|
295
|
+
const { 'sentry-trace': sentryTrace, baggage, traceparent } = core.getTraceData({ span, propagateTraceparent });
|
|
296
|
+
|
|
297
|
+
if (sentryTrace) {
|
|
298
|
+
setHeaderOnXhr(xhr, sentryTrace, baggage, traceparent);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function setHeaderOnXhr(
|
|
303
|
+
xhr,
|
|
304
|
+
sentryTraceHeader,
|
|
305
|
+
sentryBaggageHeader,
|
|
306
|
+
traceparentHeader,
|
|
307
|
+
) {
|
|
308
|
+
const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;
|
|
309
|
+
|
|
310
|
+
if (originalHeaders?.['sentry-trace'] || !xhr.setRequestHeader) {
|
|
311
|
+
// bail if a sentry-trace header is already set
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
xhr.setRequestHeader('sentry-trace', sentryTraceHeader);
|
|
317
|
+
|
|
318
|
+
if (traceparentHeader && !originalHeaders?.['traceparent']) {
|
|
319
|
+
xhr.setRequestHeader('traceparent', traceparentHeader);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (sentryBaggageHeader) {
|
|
323
|
+
// only add our headers if
|
|
324
|
+
// - no pre-existing baggage header exists
|
|
325
|
+
// - or it is set and doesn't yet contain sentry values
|
|
326
|
+
const originalBaggageHeader = originalHeaders?.['baggage'];
|
|
327
|
+
if (!originalBaggageHeader || !utils.baggageHeaderHasSentryValues(originalBaggageHeader)) {
|
|
328
|
+
// From MDN: "If this method is called several times with the same header, the values are merged into one single request header."
|
|
329
|
+
// We can therefore simply set a baggage header without checking what was there before
|
|
330
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
|
|
331
|
+
xhr.setRequestHeader('baggage', sentryBaggageHeader);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} catch {
|
|
335
|
+
// Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
exports.defaultRequestInstrumentationOptions = defaultRequestInstrumentationOptions;
|
|
340
|
+
exports.instrumentOutgoingRequests = instrumentOutgoingRequests;
|
|
341
|
+
exports.shouldAttachHeaders = shouldAttachHeaders;
|
|
342
|
+
//# sourceMappingURL=request.js.map
|