@sentry/browser 10.51.0 → 10.53.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 +7 -7
- package/build/npm/cjs/dev/client.js.map +1 -1
- package/build/npm/cjs/dev/diagnose-sdk.js +3 -3
- package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -1
- package/build/npm/cjs/dev/eventbuilder.js +23 -23
- package/build/npm/cjs/dev/eventbuilder.js.map +1 -1
- package/build/npm/cjs/dev/feedbackAsync.js.map +1 -1
- package/build/npm/cjs/dev/feedbackSync.js.map +1 -1
- package/build/npm/cjs/dev/helpers.js +10 -10
- package/build/npm/cjs/dev/helpers.js.map +1 -1
- package/build/npm/cjs/dev/index.js +84 -84
- package/build/npm/cjs/dev/integrations/breadcrumbs.js +29 -29
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/dev/integrations/browserapierrors.js +16 -16
- package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/dev/integrations/browsersession.js +9 -9
- package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/dev/integrations/contextlines.js +5 -5
- package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/dev/integrations/culturecontext.js +3 -3
- package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js +2 -2
- package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js +5 -5
- package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js +7 -7
- package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js +5 -5
- package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js +7 -7
- package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js +16 -16
- package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/dev/integrations/graphqlClient.js +9 -9
- package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpclient.js +14 -14
- package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpcontext.js +3 -3
- package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/linkederrors.js +3 -3
- package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js +7 -7
- package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spanstreaming.js +10 -10
- package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spotlight.js +13 -24
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js +3 -3
- package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/dev/integrations/webWorker.js +18 -18
- package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -1
- package/build/npm/cjs/dev/profiling/UIProfiler.js +43 -33
- package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/dev/profiling/index.js +7 -7
- package/build/npm/cjs/dev/profiling/index.js.map +1 -1
- package/build/npm/cjs/dev/profiling/integration.js +20 -18
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js +14 -11
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/dev/profiling/utils.js +39 -68
- package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
- package/build/npm/cjs/dev/report-dialog.js +7 -7
- package/build/npm/cjs/dev/report-dialog.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +8 -8
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/stack-parsers.js +10 -10
- package/build/npm/cjs/dev/stack-parsers.js.map +1 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js +7 -7
- package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +52 -52
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js +11 -11
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/dev/tracing/reportPageLoaded.js +2 -2
- package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/cjs/dev/tracing/request.js +31 -29
- package/build/npm/cjs/dev/tracing/request.js.map +1 -1
- package/build/npm/cjs/dev/tracing/setActiveSpan.js +5 -5
- package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/cjs/dev/transports/fetch.js +3 -3
- package/build/npm/cjs/dev/transports/fetch.js.map +1 -1
- package/build/npm/cjs/dev/transports/offline.js +5 -5
- package/build/npm/cjs/dev/transports/offline.js.map +1 -1
- package/build/npm/cjs/dev/userfeedback.js +3 -3
- package/build/npm/cjs/dev/userfeedback.js.map +1 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js +3 -3
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +3 -3
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/cjs/prod/client.js +7 -7
- package/build/npm/cjs/prod/client.js.map +1 -1
- package/build/npm/cjs/prod/diagnose-sdk.js +3 -3
- package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -1
- package/build/npm/cjs/prod/eventbuilder.js +23 -23
- package/build/npm/cjs/prod/eventbuilder.js.map +1 -1
- package/build/npm/cjs/prod/feedbackAsync.js.map +1 -1
- package/build/npm/cjs/prod/feedbackSync.js.map +1 -1
- package/build/npm/cjs/prod/helpers.js +10 -10
- package/build/npm/cjs/prod/helpers.js.map +1 -1
- package/build/npm/cjs/prod/index.js +84 -84
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +29 -29
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/prod/integrations/browserapierrors.js +16 -16
- package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/prod/integrations/browsersession.js +9 -9
- package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/prod/integrations/contextlines.js +5 -5
- package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/prod/integrations/culturecontext.js +3 -3
- package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +2 -2
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +5 -5
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +7 -7
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +5 -5
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +7 -7
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/globalhandlers.js +16 -16
- package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/prod/integrations/graphqlClient.js +9 -9
- package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpclient.js +14 -14
- package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpcontext.js +3 -3
- package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/linkederrors.js +3 -3
- package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js +7 -7
- package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spanstreaming.js +10 -10
- package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spotlight.js +13 -24
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js +3 -3
- package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/prod/integrations/webWorker.js +18 -18
- package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -1
- package/build/npm/cjs/prod/profiling/UIProfiler.js +43 -33
- package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/prod/profiling/index.js +7 -7
- package/build/npm/cjs/prod/profiling/index.js.map +1 -1
- package/build/npm/cjs/prod/profiling/integration.js +20 -18
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js +14 -11
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/prod/profiling/utils.js +39 -68
- package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
- package/build/npm/cjs/prod/report-dialog.js +7 -7
- package/build/npm/cjs/prod/report-dialog.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +8 -8
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/stack-parsers.js +10 -10
- package/build/npm/cjs/prod/stack-parsers.js.map +1 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js +7 -7
- package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +52 -52
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js +11 -11
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js +2 -2
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/cjs/prod/tracing/request.js +31 -29
- package/build/npm/cjs/prod/tracing/request.js.map +1 -1
- package/build/npm/cjs/prod/tracing/setActiveSpan.js +5 -5
- package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/cjs/prod/transports/fetch.js +3 -3
- package/build/npm/cjs/prod/transports/fetch.js.map +1 -1
- package/build/npm/cjs/prod/transports/offline.js +5 -5
- package/build/npm/cjs/prod/transports/offline.js.map +1 -1
- package/build/npm/cjs/prod/userfeedback.js +3 -3
- package/build/npm/cjs/prod/userfeedback.js.map +1 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js +3 -3
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +3 -3
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/dev/client.js +1 -1
- package/build/npm/esm/dev/client.js.map +1 -1
- package/build/npm/esm/dev/diagnose-sdk.js +1 -1
- package/build/npm/esm/dev/diagnose-sdk.js.map +1 -1
- package/build/npm/esm/dev/eventbuilder.js +1 -1
- package/build/npm/esm/dev/eventbuilder.js.map +1 -1
- package/build/npm/esm/dev/feedbackAsync.js.map +1 -1
- package/build/npm/esm/dev/feedbackSync.js.map +1 -1
- package/build/npm/esm/dev/helpers.js +1 -1
- package/build/npm/esm/dev/helpers.js.map +1 -1
- package/build/npm/esm/dev/index.js +1 -1
- package/build/npm/esm/dev/integrations/breadcrumbs.js +1 -1
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/dev/integrations/browserapierrors.js +1 -1
- package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/dev/integrations/browsersession.js +1 -1
- package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/dev/integrations/contextlines.js +1 -1
- package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/dev/integrations/culturecontext.js +1 -1
- package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js +1 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/dev/integrations/graphqlClient.js +1 -1
- package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpclient.js +1 -1
- package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpcontext.js +1 -1
- package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/linkederrors.js +1 -1
- package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js +1 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js +1 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -1
- package/build/npm/esm/dev/integrations/spotlight.js +8 -19
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js +1 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/dev/integrations/webWorker.js +1 -1
- package/build/npm/esm/dev/integrations/webWorker.js.map +1 -1
- package/build/npm/esm/dev/package.json +1 -1
- package/build/npm/esm/dev/profiling/UIProfiler.js +12 -2
- package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/dev/profiling/index.js +1 -1
- package/build/npm/esm/dev/profiling/index.js.map +1 -1
- package/build/npm/esm/dev/profiling/integration.js +9 -7
- package/build/npm/esm/dev/profiling/integration.js.map +1 -1
- package/build/npm/esm/dev/profiling/startProfileForSpan.js +5 -2
- package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/dev/profiling/utils.js +6 -36
- package/build/npm/esm/dev/profiling/utils.js.map +1 -1
- package/build/npm/esm/dev/report-dialog.js +1 -1
- package/build/npm/esm/dev/report-dialog.js.map +1 -1
- package/build/npm/esm/dev/sdk.js +1 -1
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/stack-parsers.js +1 -1
- package/build/npm/esm/dev/stack-parsers.js.map +1 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js +1 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js +2 -2
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/tracing/reportPageLoaded.js +1 -1
- package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/esm/dev/tracing/request.js +6 -4
- package/build/npm/esm/dev/tracing/request.js.map +1 -1
- package/build/npm/esm/dev/tracing/setActiveSpan.js +1 -1
- package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/esm/dev/transports/fetch.js +1 -1
- package/build/npm/esm/dev/transports/fetch.js.map +1 -1
- package/build/npm/esm/dev/transports/offline.js +1 -1
- package/build/npm/esm/dev/transports/offline.js.map +1 -1
- package/build/npm/esm/dev/userfeedback.js +1 -1
- package/build/npm/esm/dev/userfeedback.js.map +1 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js +1 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js +1 -1
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/prod/client.js +1 -1
- package/build/npm/esm/prod/client.js.map +1 -1
- package/build/npm/esm/prod/diagnose-sdk.js +1 -1
- package/build/npm/esm/prod/diagnose-sdk.js.map +1 -1
- package/build/npm/esm/prod/eventbuilder.js +1 -1
- package/build/npm/esm/prod/eventbuilder.js.map +1 -1
- package/build/npm/esm/prod/feedbackAsync.js.map +1 -1
- package/build/npm/esm/prod/feedbackSync.js.map +1 -1
- package/build/npm/esm/prod/helpers.js +1 -1
- package/build/npm/esm/prod/helpers.js.map +1 -1
- package/build/npm/esm/prod/index.js +1 -1
- package/build/npm/esm/prod/integrations/breadcrumbs.js +1 -1
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/prod/integrations/browserapierrors.js +1 -1
- package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/prod/integrations/browsersession.js +1 -1
- package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/prod/integrations/contextlines.js +1 -1
- package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/prod/integrations/culturecontext.js +1 -1
- package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js +1 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/prod/integrations/graphqlClient.js +1 -1
- package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpclient.js +1 -1
- package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpcontext.js +1 -1
- package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/linkederrors.js +1 -1
- package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js +1 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js +1 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -1
- package/build/npm/esm/prod/integrations/spotlight.js +8 -19
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js +1 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/prod/integrations/webWorker.js +1 -1
- package/build/npm/esm/prod/integrations/webWorker.js.map +1 -1
- package/build/npm/esm/prod/package.json +1 -1
- package/build/npm/esm/prod/profiling/UIProfiler.js +12 -2
- package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/prod/profiling/index.js +1 -1
- package/build/npm/esm/prod/profiling/index.js.map +1 -1
- package/build/npm/esm/prod/profiling/integration.js +9 -7
- package/build/npm/esm/prod/profiling/integration.js.map +1 -1
- package/build/npm/esm/prod/profiling/startProfileForSpan.js +5 -2
- package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/prod/profiling/utils.js +6 -36
- package/build/npm/esm/prod/profiling/utils.js.map +1 -1
- package/build/npm/esm/prod/report-dialog.js +1 -1
- package/build/npm/esm/prod/report-dialog.js.map +1 -1
- package/build/npm/esm/prod/sdk.js +1 -1
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/stack-parsers.js +1 -1
- package/build/npm/esm/prod/stack-parsers.js.map +1 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js +1 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js +2 -2
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/tracing/reportPageLoaded.js +1 -1
- package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/esm/prod/tracing/request.js +6 -4
- package/build/npm/esm/prod/tracing/request.js.map +1 -1
- package/build/npm/esm/prod/tracing/setActiveSpan.js +1 -1
- package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/esm/prod/transports/fetch.js +1 -1
- package/build/npm/esm/prod/transports/fetch.js.map +1 -1
- package/build/npm/esm/prod/transports/offline.js +1 -1
- package/build/npm/esm/prod/transports/offline.js.map +1 -1
- package/build/npm/esm/prod/userfeedback.js +1 -1
- package/build/npm/esm/prod/userfeedback.js.map +1 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js +1 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js +1 -1
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/types/client.d.ts +2 -2
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/eventbuilder.d.ts +1 -1
- package/build/npm/types/eventbuilder.d.ts.map +1 -1
- package/build/npm/types/exports.d.ts +3 -3
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/feedbackAsync.d.ts +2 -7
- package/build/npm/types/feedbackAsync.d.ts.map +1 -1
- package/build/npm/types/feedbackSync.d.ts +2 -7
- package/build/npm/types/feedbackSync.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts +2 -2
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +2 -2
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts +1 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +2 -2
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +3 -3
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/contextlines.d.ts +1 -1
- package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
- package/build/npm/types/integrations/globalhandlers.d.ts +1 -1
- package/build/npm/types/integrations/globalhandlers.d.ts.map +1 -1
- package/build/npm/types/integrations/spotlight.d.ts +4 -5
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/integrations/view-hierarchy.d.ts +1 -1
- package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -1
- package/build/npm/types/integrations/webWorker.d.ts +1 -1
- package/build/npm/types/integrations/webWorker.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.captureconsole.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.captureconsole.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.createlangchaincallbackhandler.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.createlangchaincallbackhandler.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.dedupe.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.dedupe.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.feedback.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.feedback.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentanthropicaiclient.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentanthropicaiclient.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentgooglegenaiclient.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentgooglegenaiclient.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentlangchainembeddings.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentlangchainembeddings.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentlanggraph.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentlanggraph.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentopenaiclient.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.instrumentopenaiclient.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts +1 -1
- package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts.map +1 -1
- package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts +1 -1
- package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts.map +1 -1
- package/build/npm/types/profiling/UIProfiler.d.ts +1 -1
- package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -1
- package/build/npm/types/profiling/index.d.ts +1 -1
- package/build/npm/types/profiling/index.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts +1 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts +3 -5
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/report-dialog.d.ts +1 -1
- package/build/npm/types/report-dialog.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/stack-parsers.d.ts +1 -1
- package/build/npm/types/stack-parsers.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/linkedTraces.d.ts +2 -2
- package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
- package/build/npm/types/tracing/reportPageLoaded.d.ts +1 -1
- package/build/npm/types/tracing/reportPageLoaded.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts +1 -1
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types/tracing/setActiveSpan.d.ts +1 -1
- package/build/npm/types/tracing/setActiveSpan.d.ts.map +1 -1
- package/build/npm/types/transports/fetch.d.ts +1 -1
- package/build/npm/types/transports/fetch.d.ts.map +1 -1
- package/build/npm/types/transports/offline.d.ts +1 -1
- package/build/npm/types/transports/offline.d.ts.map +1 -1
- package/build/npm/types/transports/types.d.ts +1 -1
- package/build/npm/types/transports/types.d.ts.map +1 -1
- package/build/npm/types/userfeedback.d.ts +1 -1
- package/build/npm/types/userfeedback.d.ts.map +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
- package/build/npm/types-ts3.8/client.d.ts +2 -2
- package/build/npm/types-ts3.8/eventbuilder.d.ts +1 -1
- package/build/npm/types-ts3.8/exports.d.ts +3 -3
- package/build/npm/types-ts3.8/feedbackAsync.d.ts +2 -7
- package/build/npm/types-ts3.8/feedbackSync.d.ts +2 -7
- package/build/npm/types-ts3.8/helpers.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.logs.metrics.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.replay.logs.metrics.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +2 -2
- package/build/npm/types-ts3.8/index.d.ts +3 -3
- package/build/npm/types-ts3.8/integrations/contextlines.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/globalhandlers.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/spotlight.d.ts +4 -5
- package/build/npm/types-ts3.8/integrations/view-hierarchy.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/webWorker.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.captureconsole.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.createlangchaincallbackhandler.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.dedupe.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.extraerrordata.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.feedback.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.instrumentanthropicaiclient.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.instrumentgooglegenaiclient.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.instrumentlangchainembeddings.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.instrumentlanggraph.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.instrumentopenaiclient.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.modulemetadata.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations-bundle/index.rewriteframes.d.ts +1 -1
- package/build/npm/types-ts3.8/pluggable-exports-bundle/index.multiplexedtransport.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/UIProfiler.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/index.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/startProfileForSpan.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/utils.d.ts +3 -5
- package/build/npm/types-ts3.8/report-dialog.d.ts +1 -1
- package/build/npm/types-ts3.8/sdk.d.ts +1 -1
- package/build/npm/types-ts3.8/stack-parsers.d.ts +1 -1
- package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +1 -1
- package/build/npm/types-ts3.8/tracing/linkedTraces.d.ts +2 -2
- package/build/npm/types-ts3.8/tracing/reportPageLoaded.d.ts +1 -1
- package/build/npm/types-ts3.8/tracing/request.d.ts +1 -1
- package/build/npm/types-ts3.8/tracing/setActiveSpan.d.ts +1 -1
- package/build/npm/types-ts3.8/transports/fetch.d.ts +1 -1
- package/build/npm/types-ts3.8/transports/offline.d.ts +1 -1
- package/build/npm/types-ts3.8/transports/types.d.ts +1 -1
- package/build/npm/types-ts3.8/userfeedback.d.ts +1 -1
- package/build/npm/types-ts3.8/utils/lazyLoadIntegration.d.ts +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpclient.js","sources":["../../../../../src/integrations/httpclient.ts"],"sourcesContent":["import type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/core';\nimport {\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n captureEvent,\n debug,\n defineIntegration,\n getClient,\n GLOBAL_OBJ,\n isSentryRequestUrl,\n supportsNativeFetch,\n} from '@sentry/core';\nimport { addXhrInstrumentationHandler, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n error?: unknown,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n error,\n type: 'fetch',\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch {\n // ignore it if parsing fails\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n error?: unknown,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch {\n // ignore it if parsing fails\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch {\n // ignore it if parsing fails\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n error,\n type: 'xhr',\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args, error, virtualError } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit, error || virtualError);\n }, false);\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { error, virtualError } = handlerData;\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers, error || virtualError);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n type: 'fetch' | 'xhr';\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n error?: unknown;\n}): SentryEvent {\n const client = getClient();\n const virtualStackTrace = client && data.error && data.error instanceof Error ? data.error.stack : undefined;\n // Remove the first frame from the stack as it's the HttpClient call\n const stack = virtualStackTrace && client ? client.getOptions().stackParser(virtualStackTrace, 0, 1) : undefined;\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n stacktrace: stack ? { frames: stack } : undefined,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: `auto.http.client.${data.type}`,\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":[],"mappings":";;;;AAkBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAQ;AACxB,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;AAClC,MAAM,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;MACa,qBAAA,GAAwB,iBAAiB,CAAC,sBAAsB;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,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AACA,MAAA,GAAA,EAAA,IAAA,CAAA,GAAA;AACA,MAAA,MAAA,EAAA,IAAA,CAAA,MAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,KAAA;AACA,IAAA,QAAA,EAAA;AACA,MAAA,QAAA,EAAA;AACA,QAAA,WAAA,EAAA,IAAA,CAAA,MAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,SAAA,EAAA,2BAAA,CAAA,IAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,qBAAA,CAAA,KAAA,EAAA;AACA,IAAA,IAAA,EAAA,CAAA,iBAAA,EAAA,IAAA,CAAA,IAAA,CAAA,CAAA;AACA,IAAA,OAAA,EAAA,KAAA;AACA,GAAA,CAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,WAAA,CAAA,WAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,CAAA,WAAA,IAAA,WAAA,YAAA,OAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA,EAAA;;AAEA;AACA;AACA;AACA,EAAA,IAAA,WAAA,YAAA,OAAA,IAAA,WAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA,EAAA;;AAEA,EAAA,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAA,SAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"httpclient.js","sources":["../../../../../src/integrations/httpclient.ts"],"sourcesContent":["import type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/core/browser';\nimport {\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n captureEvent,\n debug,\n defineIntegration,\n getClient,\n GLOBAL_OBJ,\n isSentryRequestUrl,\n supportsNativeFetch,\n} from '@sentry/core/browser';\nimport { addXhrInstrumentationHandler, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n error?: unknown,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n error,\n type: 'fetch',\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch {\n // ignore it if parsing fails\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n error?: unknown,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch {\n // ignore it if parsing fails\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch {\n // ignore it if parsing fails\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n error,\n type: 'xhr',\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args, error, virtualError } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit, error || virtualError);\n }, false);\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { error, virtualError } = handlerData;\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers, error || virtualError);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n type: 'fetch' | 'xhr';\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n error?: unknown;\n}): SentryEvent {\n const client = getClient();\n const virtualStackTrace = client && data.error && data.error instanceof Error ? data.error.stack : undefined;\n // Remove the first frame from the stack as it's the HttpClient call\n const stack = virtualStackTrace && client ? client.getOptions().stackParser(virtualStackTrace, 0, 1) : undefined;\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n stacktrace: stack ? { frames: stack } : undefined,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: `auto.http.client.${data.type}`,\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":[],"mappings":";;;;AAkBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OA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,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAA,SAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpcontext.js","sources":["../../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import { defineIntegration, safeSetSpanJSONAttributes } from '@sentry/core';\nimport { getHttpRequestData, WINDOW } from '../helpers';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext',\n preprocessEvent(event) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n const headers = {\n ...reqData.headers,\n ...event.request?.headers,\n };\n\n event.request = {\n ...reqData,\n ...event.request,\n headers,\n };\n },\n processSegmentSpan(span) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n\n safeSetSpanJSONAttributes(span, {\n // Coerce empty string to undefined so the helper's nullish check drops it,\n // rather than writing an empty `url.full` attribute onto the span.\n 'url.full': reqData.url || undefined,\n 'http.request.header.user_agent': reqData.headers['User-Agent'],\n 'http.request.header.referer': reqData.headers['Referer'],\n });\n },\n };\n});\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;MACa,sBAAA,GAAyB,iBAAiB,CAAC,MAAM;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;AACvB,IAAI,eAAe,CAAC,KAAK,EAAE;AAC3B;AACA,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE;AACrE,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,OAAA,GAAU,kBAAkB,EAAE;AAC1C,MAAM,MAAM,UAAU;AACtB,QAAQ,GAAG,OAAO,CAAC,OAAO;AAC1B,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO;AACjC,OAAO;;AAEP,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,OAAO;AAClB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,OAAO;AACf,OAAO;AACP,IAAI,CAAC;AACL,IAAI,kBAAkB,CAAC,IAAI,EAAE;AAC7B;AACA,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE;AACrE,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,OAAA,GAAU,kBAAkB,EAAE;;AAE1C,MAAM,yBAAyB,CAAC,IAAI,EAAE;AACtC;AACA;AACA,QAAQ,UAAU,EAAE,OAAO,CAAC,GAAA,IAAO,SAAS;AAC5C,QAAQ,gCAAgC,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;AACvE,QAAQ,6BAA6B,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;AACjE,OAAO,CAAC;AACR,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"httpcontext.js","sources":["../../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import { defineIntegration, safeSetSpanJSONAttributes } from '@sentry/core/browser';\nimport { getHttpRequestData, WINDOW } from '../helpers';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext',\n preprocessEvent(event) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n const headers = {\n ...reqData.headers,\n ...event.request?.headers,\n };\n\n event.request = {\n ...reqData,\n ...event.request,\n headers,\n };\n },\n processSegmentSpan(span) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n\n safeSetSpanJSONAttributes(span, {\n // Coerce empty string to undefined so the helper's nullish check drops it,\n // rather than writing an empty `url.full` attribute onto the span.\n 'url.full': reqData.url || undefined,\n 'http.request.header.user_agent': reqData.headers['User-Agent'],\n 'http.request.header.referer': reqData.headers['Referer'],\n });\n },\n };\n});\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;MACa,sBAAA,GAAyB,iBAAiB,CAAC,MAAM;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;AACvB,IAAI,eAAe,CAAC,KAAK,EAAE;AAC3B;AACA,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE;AACrE,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,OAAA,GAAU,kBAAkB,EAAE;AAC1C,MAAM,MAAM,UAAU;AACtB,QAAQ,GAAG,OAAO,CAAC,OAAO;AAC1B,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO;AACjC,OAAO;;AAEP,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,OAAO;AAClB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,OAAO;AACf,OAAO;AACP,IAAI,CAAC;AACL,IAAI,kBAAkB,CAAC,IAAI,EAAE;AAC7B;AACA,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE;AACrE,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,OAAA,GAAU,kBAAkB,EAAE;;AAE1C,MAAM,yBAAyB,CAAC,IAAI,EAAE;AACtC;AACA;AACA,QAAQ,UAAU,EAAE,OAAO,CAAC,GAAA,IAAO,SAAS;AAC5C,QAAQ,gCAAgC,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;AACvE,QAAQ,6BAA6B,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;AACjE,OAAO,CAAC;AACR,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkederrors.js","sources":["../../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { applyAggregateErrorsToEvent, defineIntegration } from '@sentry/core';\nimport { exceptionFromError } from '../eventbuilder';\n\ninterface LinkedErrorsOptions {\n key?: string;\n limit?: number;\n}\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Aggregrate linked errors in an event.\n */\nexport const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n"],"names":[],"mappings":";;;AASA,MAAM,WAAA,GAAc,OAAO;AAC3B,MAAM,aAAA,GAAgB,CAAC;;AAEvB,MAAM,gBAAA,GAAmB,cAAc;;AAEvC,MAAM,wBAAA,IAA4B,CAAC,OAAO,GAAwB,EAAE,KAAK;AACzE,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,aAAa;AAC9C,EAAE,MAAM,GAAA,GAAM,OAAO,CAAC,GAAA,IAAO,WAAW;;AAExC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;AACzC,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAE;;AAEzC,MAAM,2BAA2B;AACjC;AACA,QAAQ,kBAAkB;AAC1B,QAAQ,OAAO,CAAC,WAAW;AAC3B,QAAQ,GAAG;AACX,QAAQ,KAAK;AACb,QAAQ,KAAK;AACb,QAAQ,IAAI;AACZ,OAAO;AACP,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;MACa,uBAAA,GAA0B,iBAAiB,CAAC,wBAAwB;;;;"}
|
|
1
|
+
{"version":3,"file":"linkederrors.js","sources":["../../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core/browser';\nimport { applyAggregateErrorsToEvent, defineIntegration } from '@sentry/core/browser';\nimport { exceptionFromError } from '../eventbuilder';\n\ninterface LinkedErrorsOptions {\n key?: string;\n limit?: number;\n}\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Aggregrate linked errors in an event.\n */\nexport const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n"],"names":[],"mappings":";;;AASA,MAAM,WAAA,GAAc,OAAO;AAC3B,MAAM,aAAA,GAAgB,CAAC;;AAEvB,MAAM,gBAAA,GAAmB,cAAc;;AAEvC,MAAM,wBAAA,IAA4B,CAAC,OAAO,GAAwB,EAAE,KAAK;AACzE,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,aAAa;AAC9C,EAAE,MAAM,GAAA,GAAM,OAAO,CAAC,GAAA,IAAO,WAAW;;AAExC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;AACzC,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAE;;AAEzC,MAAM,2BAA2B;AACjC;AACA,QAAQ,kBAAkB;AAC1B,QAAQ,OAAO,CAAC,WAAW;AAC3B,QAAQ,GAAG;AACX,QAAQ,KAAK;AACb,QAAQ,KAAK;AACb,QAAQ,IAAI;AACZ,OAAO;AACP,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;MACa,uBAAA,GAA0B,iBAAiB,CAAC,wBAAwB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineIntegration, supportsReportingObserver, GLOBAL_OBJ, getClient, withScope, captureMessage } from '@sentry/core';
|
|
1
|
+
import { defineIntegration, supportsReportingObserver, GLOBAL_OBJ, getClient, withScope, captureMessage } from '@sentry/core/browser';
|
|
2
2
|
|
|
3
3
|
const WINDOW = GLOBAL_OBJ ;
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportingobserver.js","sources":["../../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport {\n captureMessage,\n defineIntegration,\n getClient,\n GLOBAL_OBJ,\n supportsReportingObserver,\n withScope,\n} from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst INTEGRATION_NAME = 'ReportingObserver';\n\ninterface Report {\n [key: string]: unknown;\n type: ReportTypes;\n url: string;\n body?: ReportBody;\n}\n\ntype ReportTypes = 'crash' | 'deprecation' | 'intervention';\n\ntype ReportBody = CrashReportBody | DeprecationReportBody | InterventionReportBody;\n\ninterface CrashReportBody {\n [key: string]: unknown;\n crashId: string;\n reason?: string;\n}\n\ninterface DeprecationReportBody {\n [key: string]: unknown;\n id: string;\n anticipatedRemoval?: Date;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface InterventionReportBody {\n [key: string]: unknown;\n id: string;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface ReportingObserverOptions {\n types?: ReportTypes[];\n}\n\n/** This is experimental and the types are not included with TypeScript, sadly. */\ninterface ReportingObserverClass {\n new (\n handler: (reports: Report[]) => void,\n options: { buffered?: boolean; types?: ReportTypes[] },\n ): {\n observe: () => void;\n };\n}\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {\n const types = options.types || ['crash', 'deprecation', 'intervention'];\n\n /** Handler for the reporting observer. */\n function handler(reports: Report[]): void {\n if (!SETUP_CLIENTS.has(getClient() as Client)) {\n return;\n }\n\n for (const report of reports) {\n withScope(scope => {\n scope.setExtra('url', report.url);\n\n const label = `ReportingObserver [${report.type}]`;\n let details = 'No details available';\n\n if (report.body) {\n // Object.keys doesn't work on ReportBody, as all properties are inherited\n const plainBody: {\n [key: string]: unknown;\n } = {};\n\n // eslint-disable-next-line guard-for-in\n for (const prop in report.body) {\n plainBody[prop] = report.body[prop];\n }\n\n scope.setExtra('body', plainBody);\n\n if (report.type === 'crash') {\n const body = report.body as CrashReportBody;\n // A fancy way to create a message out of crashId OR reason OR both OR fallback\n details = [body.crashId || '', body.reason || ''].join(' ').trim() || details;\n } else {\n const body = report.body as DeprecationReportBody | InterventionReportBody;\n details = body.message || details;\n }\n }\n\n captureMessage(`${label}: ${details}`);\n });\n }\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!supportsReportingObserver()) {\n return;\n }\n\n const observer = new (WINDOW as typeof WINDOW & { ReportingObserver: ReportingObserverClass }).ReportingObserver(\n handler,\n {\n buffered: true,\n types,\n },\n );\n\n observer.observe();\n },\n\n setup(client): void {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Reporting API integration - https://w3c.github.io/reporting/\n */\nexport const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);\n"],"names":[],"mappings":";;AAUA,MAAM,MAAA,GAAS,UAAA;;AAEf,MAAM,gBAAA,GAAmB,mBAAmB;;AAoD5C,MAAM,aAAA,GAAgB,IAAI,OAAO,EAAmB;;AAEpD,MAAM,6BAAA,IAAiC,CAAC,OAAO,GAA6B,EAAE,KAAK;AACnF,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC;;AAEzE;AACA,EAAE,SAAS,OAAO,CAAC,OAAO,EAAkB;AAC5C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAC,EAAY,EAAE;AACnD,MAAM;AACN,IAAI;;AAEJ,IAAI,KAAK,MAAM,MAAA,IAAU,OAAO,EAAE;AAClC,MAAM,SAAS,CAAC,KAAA,IAAS;AACzB,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;;AAEzC,QAAQ,MAAM,KAAA,GAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,QAAQ,IAAI,OAAA,GAAU,sBAAsB;;AAE5C,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE;AACzB;AACA,UAAU,MAAM;;AAEN,GAAI,EAAE;;AAEhB;AACA,UAAU,KAAK,MAAM,IAAA,IAAQ,MAAM,CAAC,IAAI,EAAE;AAC1C,YAAY,SAAS,CAAC,IAAI,CAAA,GAAI,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observer.js","sources":["../../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core/browser';\nimport {\n captureMessage,\n defineIntegration,\n getClient,\n GLOBAL_OBJ,\n supportsReportingObserver,\n withScope,\n} from '@sentry/core/browser';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst INTEGRATION_NAME = 'ReportingObserver';\n\ninterface Report {\n [key: string]: unknown;\n type: ReportTypes;\n url: string;\n body?: ReportBody;\n}\n\ntype ReportTypes = 'crash' | 'deprecation' | 'intervention';\n\ntype ReportBody = CrashReportBody | DeprecationReportBody | InterventionReportBody;\n\ninterface CrashReportBody {\n [key: string]: unknown;\n crashId: string;\n reason?: string;\n}\n\ninterface DeprecationReportBody {\n [key: string]: unknown;\n id: string;\n anticipatedRemoval?: Date;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface InterventionReportBody {\n [key: string]: unknown;\n id: string;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface ReportingObserverOptions {\n types?: ReportTypes[];\n}\n\n/** This is experimental and the types are not included with TypeScript, sadly. */\ninterface ReportingObserverClass {\n new (\n handler: (reports: Report[]) => void,\n options: { buffered?: boolean; types?: ReportTypes[] },\n ): {\n observe: () => void;\n };\n}\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {\n const types = options.types || ['crash', 'deprecation', 'intervention'];\n\n /** Handler for the reporting observer. */\n function handler(reports: Report[]): void {\n if (!SETUP_CLIENTS.has(getClient() as Client)) {\n return;\n }\n\n for (const report of reports) {\n withScope(scope => {\n scope.setExtra('url', report.url);\n\n const label = `ReportingObserver [${report.type}]`;\n let details = 'No details available';\n\n if (report.body) {\n // Object.keys doesn't work on ReportBody, as all properties are inherited\n const plainBody: {\n [key: string]: unknown;\n } = {};\n\n // eslint-disable-next-line guard-for-in\n for (const prop in report.body) {\n plainBody[prop] = report.body[prop];\n }\n\n scope.setExtra('body', plainBody);\n\n if (report.type === 'crash') {\n const body = report.body as CrashReportBody;\n // A fancy way to create a message out of crashId OR reason OR both OR fallback\n details = [body.crashId || '', body.reason || ''].join(' ').trim() || details;\n } else {\n const body = report.body as DeprecationReportBody | InterventionReportBody;\n details = body.message || details;\n }\n }\n\n captureMessage(`${label}: ${details}`);\n });\n }\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!supportsReportingObserver()) {\n return;\n }\n\n const observer = new (WINDOW as typeof WINDOW & { ReportingObserver: ReportingObserverClass }).ReportingObserver(\n handler,\n {\n buffered: true,\n types,\n },\n );\n\n observer.observe();\n },\n\n setup(client): void {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Reporting API integration - https://w3c.github.io/reporting/\n */\nexport const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);\n"],"names":[],"mappings":";;AAUA,MAAM,MAAA,GAAS,UAAA;;AAEf,MAAM,gBAAA,GAAmB,mBAAmB;;AAoD5C,MAAM,aAAA,GAAgB,IAAI,OAAO,EAAmB;;AAEpD,MAAM,6BAAA,IAAiC,CAAC,OAAO,GAA6B,EAAE,KAAK;AACnF,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC;;AAEzE;AACA,EAAE,SAAS,OAAO,CAAC,OAAO,EAAkB;AAC5C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAC,EAAY,EAAE;AACnD,MAAM;AACN,IAAI;;AAEJ,IAAI,KAAK,MAAM,MAAA,IAAU,OAAO,EAAE;AAClC,MAAM,SAAS,CAAC,KAAA,IAAS;AACzB,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;;AAEzC,QAAQ,MAAM,KAAA,GAAQ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,OAAA;;AAEA,MAAA,QAAA,CAAA,OAAA,EAAA;AACA,IAAA,CAAA;;AAEA,IAAA,KAAA,CAAA,MAAA,EAAA;AACA,MAAA,aAAA,CAAA,GAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,4BAAA,GAAA,iBAAA,CAAA,6BAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineIntegration, hasSpanStreamingEnabled, debug, isStreamedBeforeSendSpanCallback, SpanBuffer, spanIsSampled, captureSpan } from '@sentry/core';
|
|
1
|
+
import { defineIntegration, hasSpanStreamingEnabled, debug, isStreamedBeforeSendSpanCallback, SpanBuffer, spanIsSampled, captureSpan } from '@sentry/core/browser';
|
|
2
2
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
3
|
|
|
4
4
|
const spanStreamingIntegration = defineIntegration(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spanstreaming.js","sources":["../../../../../src/integrations/spanstreaming.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport {\n captureSpan,\n debug,\n defineIntegration,\n hasSpanStreamingEnabled,\n isStreamedBeforeSendSpanCallback,\n SpanBuffer,\n spanIsSampled,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport const spanStreamingIntegration = defineIntegration(() => {\n return {\n name: 'SpanStreaming',\n\n beforeSetup(client) {\n // If users only set spanStreamingIntegration, without traceLifecycle, we set it to \"stream\" for them.\n // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK.\n const clientOptions = client.getOptions();\n if (!clientOptions.traceLifecycle) {\n DEBUG_BUILD && debug.log('[SpanStreaming] setting `traceLifecycle` to \"stream\"');\n clientOptions.traceLifecycle = 'stream';\n }\n },\n\n setup(client) {\n const initialMessage = 'SpanStreaming integration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n const clientOptions = client.getOptions();\n\n if (!hasSpanStreamingEnabled(client)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n const beforeSendSpan = clientOptions.beforeSendSpan;\n // If users misconfigure their SDK by opting into span streaming but\n // using an incompatible beforeSendSpan callback, we fall back to the static trace lifecycle.\n if (beforeSendSpan && !isStreamedBeforeSendSpanCallback(beforeSendSpan)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamedSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client);\n\n client.on('afterSpanEnd', span => {\n // Negatively sampled spans must not be captured.\n // This happens because OTel and we create non-recording spans for negatively sampled spans\n // that go through the same life cycle as recording spans.\n if (!spanIsSampled(span)) {\n return;\n }\n buffer.add(captureSpan(span, client));\n });\n\n // In addition to capturing the span, we also flush the trace when the segment\n // span ends to ensure things are sent timely. We never know when the browser\n // is closed, users navigate away, etc.\n client.on('afterSegmentSpanEnd', segmentSpan => {\n const traceId = segmentSpan.spanContext().traceId;\n setTimeout(() => {\n buffer.flush(traceId);\n }, 500);\n });\n },\n };\n}) satisfies IntegrationFn;\n"],"names":[],"mappings":";;;MAYa,wBAAA,GAA2B,iBAAiB,CAAC,MAAM;AAChE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;;AAEzB,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB;AACA;AACA,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC,QAAQ,eAAe,KAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC;AACxF,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,MAAM;AACN,IAAI,CAAC;;AAEL,IAAI,KAAK,CA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AA,GAAA,CAAA;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"spanstreaming.js","sources":["../../../../../src/integrations/spanstreaming.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core/browser';\nimport {\n captureSpan,\n debug,\n defineIntegration,\n hasSpanStreamingEnabled,\n isStreamedBeforeSendSpanCallback,\n SpanBuffer,\n spanIsSampled,\n} from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport const spanStreamingIntegration = defineIntegration(() => {\n return {\n name: 'SpanStreaming',\n\n beforeSetup(client) {\n // If users only set spanStreamingIntegration, without traceLifecycle, we set it to \"stream\" for them.\n // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK.\n const clientOptions = client.getOptions();\n if (!clientOptions.traceLifecycle) {\n DEBUG_BUILD && debug.log('[SpanStreaming] setting `traceLifecycle` to \"stream\"');\n clientOptions.traceLifecycle = 'stream';\n }\n },\n\n setup(client) {\n const initialMessage = 'SpanStreaming integration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n const clientOptions = client.getOptions();\n\n if (!hasSpanStreamingEnabled(client)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n const beforeSendSpan = clientOptions.beforeSendSpan;\n // If users misconfigure their SDK by opting into span streaming but\n // using an incompatible beforeSendSpan callback, we fall back to the static trace lifecycle.\n if (beforeSendSpan && !isStreamedBeforeSendSpanCallback(beforeSendSpan)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamedSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client);\n\n client.on('afterSpanEnd', span => {\n // Negatively sampled spans must not be captured.\n // This happens because OTel and we create non-recording spans for negatively sampled spans\n // that go through the same life cycle as recording spans.\n if (!spanIsSampled(span)) {\n return;\n }\n buffer.add(captureSpan(span, client));\n });\n\n // In addition to capturing the span, we also flush the trace when the segment\n // span ends to ensure things are sent timely. We never know when the browser\n // is closed, users navigate away, etc.\n client.on('afterSegmentSpanEnd', segmentSpan => {\n const traceId = segmentSpan.spanContext().traceId;\n setTimeout(() => {\n buffer.flush(traceId);\n }, 500);\n });\n },\n };\n}) satisfies IntegrationFn;\n"],"names":[],"mappings":";;;MAYa,wBAAA,GAA2B,iBAAiB,CAAC,MAAM;AAChE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;;AAEzB,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB;AACA;AACA,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC,QAAQ,eAAe,KAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC;AACxF,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,MAAM;AACN,IAAI,CAAC;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,cAAA,GAAiB,oCAAoC;AACjE,MAAM,MAAM,WAAA,GAAc,yCAAyC;AACnE,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;;AAE/C,MAAM,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE;AAC5C,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,QAAQ,eAAe,KAAK,CAAC,IAAI,CAAC,CAAC,EAAA,cAAA,CAAA,2CAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,cAAA,GAAA,aAAA,CAAA,cAAA;AACA;AACA;AACA,MAAA,IAAA,cAAA,IAAA,CAAA,gCAAA,CAAA,cAAA,CAAA,EAAA;AACA,QAAA,aAAA,CAAA,cAAA,GAAA,QAAA;AACA,QAAA,WAAA;AACA,UAAA,KAAA,CAAA,IAAA,CAAA,CAAA,EAAA,cAAA,CAAA,uDAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,MAAA,GAAA,IAAA,UAAA,CAAA,MAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,cAAA,EAAA,IAAA,IAAA;AACA;AACA;AACA;AACA,QAAA,IAAA,CAAA,aAAA,CAAA,IAAA,CAAA,EAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA,MAAA,CAAA,GAAA,CAAA,WAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,MAAA,CAAA,EAAA,CAAA,qBAAA,EAAA,WAAA,IAAA;AACA,QAAA,MAAA,OAAA,GAAA,WAAA,CAAA,WAAA,EAAA,CAAA,OAAA;AACA,QAAA,UAAA,CAAA,MAAA;AACA,UAAA,MAAA,CAAA,KAAA,CAAA,OAAA,CAAA;AACA,QAAA,CAAA,EAAA,GAAA,CAAA;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { defineIntegration, debug, serializeEnvelope } from '@sentry/core';
|
|
1
|
+
import { defineIntegration, debug, serializeEnvelope } from '@sentry/core/browser';
|
|
2
2
|
import { getNativeImplementation } from '@sentry-internal/browser-utils';
|
|
3
3
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
4
4
|
|
|
5
5
|
const INTEGRATION_NAME = 'SpotlightBrowser';
|
|
6
6
|
|
|
7
|
+
const SPOTLIGHT_IGNORE_SPANS = [{ op: 'ui.interaction.click', name: '#sentry-spotlight' }];
|
|
8
|
+
|
|
7
9
|
const _spotlightIntegration = ((options = {}) => {
|
|
8
10
|
const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';
|
|
9
11
|
|
|
@@ -12,10 +14,10 @@ const _spotlightIntegration = ((options = {}) => {
|
|
|
12
14
|
setup: () => {
|
|
13
15
|
DEBUG_BUILD && debug.log('Using Sidecar URL', sidecarUrl);
|
|
14
16
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
beforeSetup(client) {
|
|
18
|
+
const opts = client.getOptions();
|
|
19
|
+
opts.ignoreSpans = [...(opts.ignoreSpans || []), ...SPOTLIGHT_IGNORE_SPANS];
|
|
20
|
+
},
|
|
19
21
|
afterAllSetup: (client) => {
|
|
20
22
|
setupSidecarForwarding(client, sidecarUrl);
|
|
21
23
|
},
|
|
@@ -64,18 +66,5 @@ function setupSidecarForwarding(client, sidecarUrl) {
|
|
|
64
66
|
*/
|
|
65
67
|
const spotlightBrowserIntegration = defineIntegration(_spotlightIntegration);
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
* Flags if the event is a transaction created from an interaction with the spotlight UI.
|
|
69
|
-
*/
|
|
70
|
-
function isSpotlightInteraction(event) {
|
|
71
|
-
return Boolean(
|
|
72
|
-
event.type === 'transaction' &&
|
|
73
|
-
event.spans &&
|
|
74
|
-
event.contexts?.trace &&
|
|
75
|
-
event.contexts.trace.op === 'ui.action.click' &&
|
|
76
|
-
event.spans.some(({ description }) => description?.includes('#sentry-spotlight')),
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { INTEGRATION_NAME, isSpotlightInteraction, spotlightBrowserIntegration };
|
|
69
|
+
export { INTEGRATION_NAME, SPOTLIGHT_IGNORE_SPANS, spotlightBrowserIntegration };
|
|
81
70
|
//# sourceMappingURL=spotlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotlight.js","sources":["../../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope,
|
|
1
|
+
{"version":3,"file":"spotlight.js","sources":["../../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope, IntegrationFn } from '@sentry/core/browser';\nimport { debug, defineIntegration, serializeEnvelope } from '@sentry/core/browser';\nimport { getNativeImplementation } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { WINDOW } from '../helpers';\n\nexport type SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969\n * By default, the Url is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'SpotlightBrowser';\n\nexport const SPOTLIGHT_IGNORE_SPANS = [{ op: 'ui.interaction.click', name: '#sentry-spotlight' }];\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup: () => {\n DEBUG_BUILD && debug.log('Using Sidecar URL', sidecarUrl);\n },\n beforeSetup(client: Client) {\n const opts = client.getOptions();\n opts.ignoreSpans = [...(opts.ignoreSpans || []), ...SPOTLIGHT_IGNORE_SPANS];\n },\n afterAllSetup: (client: Client) => {\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const makeFetch: typeof WINDOW.fetch | undefined = getNativeImplementation('fetch');\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n debug.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);\n return;\n }\n\n makeFetch(sidecarUrl, {\n method: 'POST',\n body: serializeEnvelope(envelope),\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n mode: 'cors',\n }).then(\n res => {\n if (res.status >= 200 && res.status < 400) {\n // Reset failed requests counter on success\n failCount = 0;\n }\n },\n err => {\n failCount++;\n debug.error(\n \"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/\",\n err,\n );\n },\n );\n });\n}\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n */\nexport const spotlightBrowserIntegration = defineIntegration(_spotlightIntegration);\n"],"names":[],"mappings":";;;;AAcO,MAAM,gBAAA,GAAmB;;AAEzB,MAAM,sBAAA,GAAyB,CAAC,EAAE,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,mBAAA,EAAqB;;AAEhG,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAwC,EAAE,KAAK;AACtF,EAAE,MAAM,UAAA,GAAa,OAAO,CAAC,UAAA,IAAc,8BAA8B;;AAEzE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,EAAE,MAAM;AACjB,MAAM,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC;AAC/D,IAAI,CAAC;AACL,IAAI,WAAW,CAAC,MAAM,EAAU;AAChC,MAAM,MAAM,IAAA,GAAO,MAAM,CAAC,UAAU,EAAE;AACtC,MAAM,IAAI,CAAC,WAAA,GAAc,CAAC,IAAI,IAAI,CAAC,WAAA,IAAe,EAAE,CAAC,EAAE,GAAG,sBAAsB,CAAC;AACjF,IAAI,CAAC;AACL,IAAI,aAAa,EAAE,CAAC,MAAM,KAAa;AACvC,MAAM,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC;AAChD,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED,SAAS,sBAAsB,CAAC,MAAM,EAAU,UAAU,EAAgB;AAC1E,EAAE,MAAM,SAAS,GAAoC,uBAAuB,CAAC,OAAO,CAAC;AACrF,EAAE,IAAI,SAAA,GAAY,CAAC;;AAEnB,EAAE,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAQ,KAAe;AACtD,IAAI,IAAI,SAAA,GAAY,CAAC,EAAE;AACvB,MAAM,KAAK,CAAC,IAAI,CAAC,uFAAuF,EAAE,SAAS,CAAC;AACpH,MAAM;AACN,IAAI;;AAEJ,IAAI,SAAS,CAAC,UAAU,EAAE;AAC1B,MAAM,MAAM,EAAE,MAAM;AACpB,MAAM,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC;AACvC,MAAM,OAAO,EAAE;AACf,QAAQ,cAAc,EAAE,+BAA+B;AACvD,OAAO;AACP,MAAM,IAAI,EAAE,MAAM;AAClB,KAAK,CAAC,CAAC,IAAI;AACX,MAAM,OAAO;AACb,QAAQ,IAAI,GAAG,CAAC,MAAA,IAAU,GAAA,IAAO,GAAG,CAAC,MAAA,GAAS,GAAG,EAAE;AACnD;AACA,UAAU,SAAA,GAAY,CAAC;AACvB,QAAQ;AACR,MAAM,CAAC;AACP,MAAM,OAAO;AACb,QAAQ,SAAS,EAAE;AACnB,QAAQ,KAAK,CAAC,KAAK;AACnB,UAAU,8FAA8F;AACxG,UAAU,GAAG;AACb,SAAS;AACT,MAAM,CAAC;AACP,KAAK;AACL,EAAE,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;MACa,2BAAA,GAA8B,iBAAiB,CAAC,qBAAqB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-hierarchy.js","sources":["../../../../../src/integrations/view-hierarchy.ts"],"sourcesContent":["import type { Attachment, Event, EventHint, ViewHierarchyData, ViewHierarchyWindow } from '@sentry/core';\nimport { defineIntegration, getComponentName } from '@sentry/core';\nimport { WINDOW } from '../helpers';\n\ninterface OnElementArgs {\n /**\n * The element being processed.\n */\n element: HTMLElement;\n /**\n * Lowercase tag name of the element.\n */\n tagName: string;\n /**\n * The component name of the element.\n */\n componentName?: string;\n\n /**\n * The current depth of the element in the view hierarchy. The root element will have a depth of 0.\n *\n * This allows you to limit the traversal depth for large DOM trees.\n */\n depth?: number;\n}\n\ninterface Options {\n /**\n * Whether to attach the view hierarchy to the event.\n *\n * Default: Always attach.\n */\n shouldAttach?: (event: Event, hint: EventHint) => boolean;\n\n /**\n * A function that returns the root element to start walking the DOM from.\n *\n * Default: `window.document.body`\n */\n rootElement?: () => HTMLElement | undefined;\n\n /**\n * Called for each HTMLElement as we walk the DOM.\n *\n * Return an object to include the element with any additional properties.\n * Return `skip` to exclude the element and its children.\n * Return `children` to skip the element but include its children.\n */\n onElement?: (prop: OnElementArgs) => Record<string, string | number | boolean> | 'skip' | 'children';\n}\n\n/**\n * An integration to include a view hierarchy attachment which contains the DOM.\n */\nexport const viewHierarchyIntegration = defineIntegration((options: Options = {}) => {\n const skipHtmlTags = ['script'];\n\n /** Walk an element */\n function walk(element: HTMLElement, windows: ViewHierarchyWindow[], depth = 0): void {\n if (!element) {\n return;\n }\n\n // With Web Components, we need to walk into shadow DOMs\n const children = 'shadowRoot' in element && element.shadowRoot ? element.shadowRoot.children : element.children;\n\n for (const child of children) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n\n const componentName = getComponentName(child, 1) || undefined;\n const tagName = child.tagName.toLowerCase();\n\n if (skipHtmlTags.includes(tagName)) {\n continue;\n }\n\n const result = options.onElement?.({ element: child, componentName, tagName, depth }) || {};\n\n if (result === 'skip') {\n continue;\n }\n\n // Skip this element but include its children\n if (result === 'children') {\n walk(child, windows, depth + 1);\n continue;\n }\n\n const { x, y, width, height } = child.getBoundingClientRect();\n\n const window: ViewHierarchyWindow = {\n identifier: (child.id || undefined) as string,\n type: componentName || tagName,\n visible: true,\n alpha: 1,\n height,\n width,\n x,\n y,\n ...result,\n };\n\n const children: ViewHierarchyWindow[] = [];\n window.children = children;\n\n // Recursively walk the children\n walk(child, window.children, depth + 1);\n\n windows.push(window);\n }\n }\n\n return {\n name: 'ViewHierarchy',\n processEvent: (event, hint) => {\n // only capture for error events\n if (event.type !== undefined || options.shouldAttach?.(event, hint) === false) {\n return event;\n }\n\n const root: ViewHierarchyData = {\n rendering_system: 'DOM',\n positioning: 'absolute',\n windows: [],\n };\n\n walk(options.rootElement?.() || WINDOW.document.body, root.windows);\n\n const attachment: Attachment = {\n filename: 'view-hierarchy.json',\n attachmentType: 'event.view_hierarchy',\n contentType: 'application/json',\n data: JSON.stringify(root),\n };\n\n hint.attachments = hint.attachments || [];\n hint.attachments.push(attachment);\n\n return event;\n },\n };\n});\n"],"names":[],"mappings":";;;AAmDA;AACA;AACA;AACO,MAAM,wBAAA,GAA2B,iBAAiB,CAAC,CAAC,OAAO,GAAY,EAAE,KAAK;AACrF,EAAE,MAAM,YAAA,GAAe,CAAC,QAAQ,CAAC;;AAEjC;AACA,EAAE,SAAS,IAAI,CAAC,OAAO,EAAe,OAAO,EAAyB,KAAA,GAAQ,CAAC,EAAQ;AACvF,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,MAAM;AACN,IAAI;;AAEJ;AACA,IAAI,MAAM,QAAA,GAAW,gBAAgB,OAAA,IAAW,OAAO,CAAC,aAAa,OAAO,CAAC,UAAU,CAAC,WAAW,OAAO,CAAC,QAAQ;;AAEnH,IAAI,KAAK,MAAM,KAAA,IAAS,QAAQ,EAAE;AAClC,MAAM,IAAI,EAAE,iBAAiB,WAAW,CAAC,EAAE;AAC3C,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,aAAA,GAAgB,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAA,IAAK,SAAS;AACnE,MAAM,MAAM,UAAU,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE;;AAEjD,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AAC1C,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,SAAS,OAAO,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAA,IAAK,EAAE;;AAEjG,MAAM,IAAI,MAAA,KAAW,MAAM,EAAE;AAC7B,QAAQ;AACR,MAAM;;AAEN;AACA,MAAM,IAAI,MAAA,KAAW,UAAU,EAAE;AACjC,QAAQ,IAAI,CAAC,KAAK,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I,CAAC,OAAO,CAAC;;AAEzE,MAAM,MAAM,UAAU,GAAe;AACrC,QAAQ,QAAQ,EAAE,qBAAqB;AACvC,QAAQ,cAAc,EAAE,sBAAsB;AAC9C,QAAQ,WAAW,EAAE,kBAAkB;AACvC,QAAQ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAClC,OAAO;;AAEP,MAAM,IAAI,CAAC,WAAA,GAAc,IAAI,CAAC,WAAA,IAAe,EAAE;AAC/C,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;;AAEvC,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"view-hierarchy.js","sources":["../../../../../src/integrations/view-hierarchy.ts"],"sourcesContent":["import type { Attachment, Event, EventHint, ViewHierarchyData, ViewHierarchyWindow } from '@sentry/core/browser';\nimport { defineIntegration, getComponentName } from '@sentry/core/browser';\nimport { WINDOW } from '../helpers';\n\ninterface OnElementArgs {\n /**\n * The element being processed.\n */\n element: HTMLElement;\n /**\n * Lowercase tag name of the element.\n */\n tagName: string;\n /**\n * The component name of the element.\n */\n componentName?: string;\n\n /**\n * The current depth of the element in the view hierarchy. The root element will have a depth of 0.\n *\n * This allows you to limit the traversal depth for large DOM trees.\n */\n depth?: number;\n}\n\ninterface Options {\n /**\n * Whether to attach the view hierarchy to the event.\n *\n * Default: Always attach.\n */\n shouldAttach?: (event: Event, hint: EventHint) => boolean;\n\n /**\n * A function that returns the root element to start walking the DOM from.\n *\n * Default: `window.document.body`\n */\n rootElement?: () => HTMLElement | undefined;\n\n /**\n * Called for each HTMLElement as we walk the DOM.\n *\n * Return an object to include the element with any additional properties.\n * Return `skip` to exclude the element and its children.\n * Return `children` to skip the element but include its children.\n */\n onElement?: (prop: OnElementArgs) => Record<string, string | number | boolean> | 'skip' | 'children';\n}\n\n/**\n * An integration to include a view hierarchy attachment which contains the DOM.\n */\nexport const viewHierarchyIntegration = defineIntegration((options: Options = {}) => {\n const skipHtmlTags = ['script'];\n\n /** Walk an element */\n function walk(element: HTMLElement, windows: ViewHierarchyWindow[], depth = 0): void {\n if (!element) {\n return;\n }\n\n // With Web Components, we need to walk into shadow DOMs\n const children = 'shadowRoot' in element && element.shadowRoot ? element.shadowRoot.children : element.children;\n\n for (const child of children) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n\n const componentName = getComponentName(child, 1) || undefined;\n const tagName = child.tagName.toLowerCase();\n\n if (skipHtmlTags.includes(tagName)) {\n continue;\n }\n\n const result = options.onElement?.({ element: child, componentName, tagName, depth }) || {};\n\n if (result === 'skip') {\n continue;\n }\n\n // Skip this element but include its children\n if (result === 'children') {\n walk(child, windows, depth + 1);\n continue;\n }\n\n const { x, y, width, height } = child.getBoundingClientRect();\n\n const window: ViewHierarchyWindow = {\n identifier: (child.id || undefined) as string,\n type: componentName || tagName,\n visible: true,\n alpha: 1,\n height,\n width,\n x,\n y,\n ...result,\n };\n\n const children: ViewHierarchyWindow[] = [];\n window.children = children;\n\n // Recursively walk the children\n walk(child, window.children, depth + 1);\n\n windows.push(window);\n }\n }\n\n return {\n name: 'ViewHierarchy',\n processEvent: (event, hint) => {\n // only capture for error events\n if (event.type !== undefined || options.shouldAttach?.(event, hint) === false) {\n return event;\n }\n\n const root: ViewHierarchyData = {\n rendering_system: 'DOM',\n positioning: 'absolute',\n windows: [],\n };\n\n walk(options.rootElement?.() || WINDOW.document.body, root.windows);\n\n const attachment: Attachment = {\n filename: 'view-hierarchy.json',\n attachmentType: 'event.view_hierarchy',\n contentType: 'application/json',\n data: JSON.stringify(root),\n };\n\n hint.attachments = hint.attachments || [];\n hint.attachments.push(attachment);\n\n return event;\n },\n };\n});\n"],"names":[],"mappings":";;;AAmDA;AACA;AACA;AACO,MAAM,wBAAA,GAA2B,iBAAiB,CAAC,CAAC,OAAO,GAAY,EAAE,KAAK;AACrF,EAAE,MAAM,YAAA,GAAe,CAAC,QAAQ,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CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;;AAEvC,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineIntegration, debug, isPlainObject, getClient, isPrimitive, captureEvent } from '@sentry/core';
|
|
1
|
+
import { defineIntegration, debug, isPlainObject, getClient, isPrimitive, captureEvent } from '@sentry/core/browser';
|
|
2
2
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
3
|
import { eventFromUnknownInput } from '../eventbuilder.js';
|
|
4
4
|
import { WINDOW } from '../helpers.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webWorker.js","sources":["../../../../../src/integrations/webWorker.ts"],"sourcesContent":["import type { DebugImage, Integration, IntegrationFn } from '@sentry/core';\nimport { captureEvent, debug, defineIntegration, getClient, isPlainObject, isPrimitive } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { WINDOW } from '../helpers';\nimport { _eventFromRejectionWithPrimitive, _getUnhandledRejectionError } from './globalhandlers';\n\nexport const INTEGRATION_NAME = 'WebWorker';\n\ninterface WebWorkerMessage {\n _sentryMessage: boolean;\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n _sentryWorkerError?: SerializedWorkerError;\n _sentryWasmImages?: Array<DebugImage>;\n}\n\ninterface SerializedWorkerError {\n reason: unknown;\n filename?: string;\n}\n\ninterface WebWorkerIntegrationOptions {\n worker: Worker | Array<Worker>;\n}\n\ninterface WebWorkerIntegration extends Integration {\n addWorker: (worker: Worker) => void;\n}\n\n/**\n * Use this integration to set up Sentry with web workers.\n *\n * IMPORTANT: This integration must be added **before** you start listening to\n * any messages from the worker. Otherwise, your message handlers will receive\n * messages from the Sentry SDK which you need to ignore.\n *\n * This integration only has an effect, if you call `Sentry.registerWebWorker(self)`\n * from within the worker(s) you're adding to the integration.\n *\n * Given that you want to initialize the SDK as early as possible, you most likely\n * want to add this integration **after** initializing the SDK:\n *\n * @example:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // some time earlier:\n * Sentry.init(...)\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Add the integration\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * If you initialize multiple workers at the same time, you can also pass an array of workers\n * to the integration:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: [worker1, worker2] });\n * Sentry.addIntegration(webWorkerIntegration);\n * ```\n *\n * If you have any additional workers that you initialize at a later point,\n * you can add them to the integration as follows:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: worker1 });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // sometime later:\n * webWorkerIntegration.addWorker(worker2);\n * ```\n *\n * Of course, you can also directly add the integration in Sentry.init:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Initialize the SDK\n * Sentry.init({\n * integrations: [Sentry.webWorkerIntegration({ worker })]\n * });\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * @param options {WebWorkerIntegrationOptions} Integration options:\n * - `worker`: The worker instance.\n */\nexport const webWorkerIntegration = defineIntegration(({ worker }: WebWorkerIntegrationOptions) => ({\n name: INTEGRATION_NAME,\n setupOnce: () => {\n (Array.isArray(worker) ? worker : [worker]).forEach(w => listenForSentryMessages(w));\n },\n addWorker: (worker: Worker) => listenForSentryMessages(worker),\n})) as IntegrationFn<WebWorkerIntegration>;\n\nfunction listenForSentryMessages(worker: Worker): void {\n worker.addEventListener('message', event => {\n if (isSentryMessage(event.data)) {\n event.stopImmediatePropagation(); // other listeners should not receive this message\n\n // Handle debug IDs\n if (event.data._sentryDebugIds) {\n DEBUG_BUILD && debug.log('Sentry debugId web worker message received', event.data);\n WINDOW._sentryDebugIds = {\n ...event.data._sentryDebugIds,\n // debugIds of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryDebugIds,\n };\n }\n\n // Handle module metadata\n if (event.data._sentryModuleMetadata) {\n DEBUG_BUILD && debug.log('Sentry module metadata web worker message received', event.data);\n // Merge worker's raw metadata into the global object\n // It will be parsed lazily when needed by getMetadataForUrl\n WINDOW._sentryModuleMetadata = {\n ...event.data._sentryModuleMetadata,\n // Module metadata of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryModuleMetadata,\n };\n }\n\n // Handle WASM images from worker\n if (event.data._sentryWasmImages) {\n DEBUG_BUILD && debug.log('Sentry WASM images web worker message received', event.data);\n const existingImages =\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages || [];\n const newImages = event.data._sentryWasmImages.filter(\n (newImg: unknown) =>\n isPlainObject(newImg) &&\n typeof newImg.code_file === 'string' &&\n !existingImages.some(existing => existing.code_file === newImg.code_file),\n );\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages = [\n ...existingImages,\n ...newImages,\n ];\n }\n\n // Handle unhandled rejections forwarded from worker\n if (event.data._sentryWorkerError) {\n DEBUG_BUILD && debug.log('Sentry worker rejection message received', event.data._sentryWorkerError);\n handleForwardedWorkerRejection(event.data._sentryWorkerError);\n }\n }\n });\n}\n\nfunction handleForwardedWorkerRejection(workerError: SerializedWorkerError): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const stackParser = client.getOptions().stackParser;\n const attachStacktrace = client.getOptions().attachStacktrace;\n\n const error = workerError.reason;\n\n // Follow same pattern as globalHandlers for unhandledrejection\n // Handle both primitives and errors the same way\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n // Add worker-specific context\n if (workerError.filename) {\n event.contexts = {\n ...event.contexts,\n worker: {\n filename: workerError.filename,\n },\n };\n }\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.web_worker.onunhandledrejection',\n },\n });\n\n DEBUG_BUILD && debug.log('Captured worker unhandled rejection', error);\n}\n\n/**\n * Minimal interface for DedicatedWorkerGlobalScope, only requiring the postMessage method.\n * (which is the only thing we need from the worker's global object)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope\n *\n * We can't use the actual type because it breaks everyone who doesn't have {\"lib\": [\"WebWorker\"]}\n * but uses {\"skipLibCheck\": true} in their tsconfig.json.\n */\ninterface MinimalDedicatedWorkerGlobalScope {\n postMessage: (message: unknown) => void;\n addEventListener: (type: string, listener: (event: unknown) => void) => void;\n location?: { href?: string };\n}\n\ninterface RegisterWebWorkerOptions {\n self: MinimalDedicatedWorkerGlobalScope & {\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n };\n}\n\n/**\n * Use this function to register the worker with the Sentry SDK.\n *\n * This function will:\n * - Send debug IDs to the parent thread\n * - Send module metadata to the parent thread (for thirdPartyErrorFilterIntegration)\n * - Set up a handler for unhandled rejections in the worker\n * - Forward unhandled rejections to the parent thread for capture\n *\n * Note: Synchronous errors in workers are already captured by globalHandlers.\n * This only handles unhandled promise rejections which don't bubble to the parent.\n *\n * @example\n * ```ts filename={worker.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // Do this as early as possible in your worker.\n * Sentry.registerWebWorker({ self });\n *\n * // continue setting up your worker\n * self.postMessage(...)\n * ```\n * @param options {RegisterWebWorkerOptions} Integration options:\n * - `self`: The worker instance you're calling this function from (self).\n */\nexport function registerWebWorker({ self }: RegisterWebWorkerOptions): void {\n // Send debug IDs and raw module metadata to parent thread\n // The metadata will be parsed lazily on the main thread when needed\n self.postMessage({\n _sentryMessage: true,\n _sentryDebugIds: self._sentryDebugIds ?? undefined,\n _sentryModuleMetadata: self._sentryModuleMetadata ?? undefined,\n });\n\n // Set up unhandledrejection handler inside the worker\n // Following the same pattern as globalHandlers\n // unhandled rejections don't bubble to the parent thread, so we need to handle them here\n self.addEventListener('unhandledrejection', (event: unknown) => {\n const reason = _getUnhandledRejectionError(event);\n\n // Forward the raw reason to parent thread\n // The parent will handle primitives vs errors the same way globalHandlers does\n const serializedError: SerializedWorkerError = {\n reason: reason,\n filename: self.location?.href,\n };\n\n // Forward to parent thread\n self.postMessage({\n _sentryMessage: true,\n _sentryWorkerError: serializedError,\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Forwarding unhandled rejection to parent', serializedError);\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Registered worker with unhandled rejection handling');\n}\n\nfunction isSentryMessage(eventData: unknown): eventData is WebWorkerMessage {\n if (!isPlainObject(eventData) || eventData._sentryMessage !== true) {\n return false;\n }\n\n // Must have at least one of: debug IDs, module metadata, worker error, or WASM images\n const hasDebugIds = '_sentryDebugIds' in eventData;\n const hasModuleMetadata = '_sentryModuleMetadata' in eventData;\n const hasWorkerError = '_sentryWorkerError' in eventData;\n const hasWasmImages = '_sentryWasmImages' in eventData;\n\n if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError && !hasWasmImages) {\n return false;\n }\n\n // Validate debug IDs if present\n if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {\n return false;\n }\n\n // Validate module metadata if present\n if (\n hasModuleMetadata &&\n !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)\n ) {\n return false;\n }\n\n // Validate worker error if present\n if (hasWorkerError && !isPlainObject(eventData._sentryWorkerError)) {\n return false;\n }\n\n // Validate WASM images if present\n if (\n hasWasmImages &&\n (!Array.isArray(eventData._sentryWasmImages) ||\n !eventData._sentryWasmImages.every(\n (img: unknown) => isPlainObject(img) && typeof (img as { code_file?: unknown }).code_file === 'string',\n ))\n ) {\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;;;;AAOO,MAAM,gBAAA,GAAmB;;AAuBhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oBAAA,GAAuB,iBAAiB,CAAC,CAAC,EAAE,MAAA,EAAQ,MAAmC;AACpG,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,SAAS,EAAE,MAAM;AACnB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAA,GAAI,MAAA,GAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA,IAAK,uBAAuB,CAAC,CAAC,CAAC,CAAC;AACxF,EAAE,CAAC;AACH,EAAE,SAAS,EAAE,CAAC,MAAM,KAAa,uBAAuB,CAAC,MAAM,CAAC;AAChE,CAAC,CAAC,CAAA;;AAEF,SAAS,uBAAuB,CAAC,MAAM,EAAgB;AACvD,EAAE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS;AAC9C,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AACrC,MAAM,KAAK,CAAC,wBAAwB,EAAE,CAAA;;AA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+
{"version":3,"file":"webWorker.js","sources":["../../../../../src/integrations/webWorker.ts"],"sourcesContent":["import type { DebugImage, Integration, IntegrationFn } from '@sentry/core/browser';\nimport { captureEvent, debug, defineIntegration, getClient, isPlainObject, isPrimitive } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { WINDOW } from '../helpers';\nimport { _eventFromRejectionWithPrimitive, _getUnhandledRejectionError } from './globalhandlers';\n\nexport const INTEGRATION_NAME = 'WebWorker';\n\ninterface WebWorkerMessage {\n _sentryMessage: boolean;\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n _sentryWorkerError?: SerializedWorkerError;\n _sentryWasmImages?: Array<DebugImage>;\n}\n\ninterface SerializedWorkerError {\n reason: unknown;\n filename?: string;\n}\n\ninterface WebWorkerIntegrationOptions {\n worker: Worker | Array<Worker>;\n}\n\ninterface WebWorkerIntegration extends Integration {\n addWorker: (worker: Worker) => void;\n}\n\n/**\n * Use this integration to set up Sentry with web workers.\n *\n * IMPORTANT: This integration must be added **before** you start listening to\n * any messages from the worker. Otherwise, your message handlers will receive\n * messages from the Sentry SDK which you need to ignore.\n *\n * This integration only has an effect, if you call `Sentry.registerWebWorker(self)`\n * from within the worker(s) you're adding to the integration.\n *\n * Given that you want to initialize the SDK as early as possible, you most likely\n * want to add this integration **after** initializing the SDK:\n *\n * @example:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // some time earlier:\n * Sentry.init(...)\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Add the integration\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * If you initialize multiple workers at the same time, you can also pass an array of workers\n * to the integration:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: [worker1, worker2] });\n * Sentry.addIntegration(webWorkerIntegration);\n * ```\n *\n * If you have any additional workers that you initialize at a later point,\n * you can add them to the integration as follows:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: worker1 });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // sometime later:\n * webWorkerIntegration.addWorker(worker2);\n * ```\n *\n * Of course, you can also directly add the integration in Sentry.init:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Initialize the SDK\n * Sentry.init({\n * integrations: [Sentry.webWorkerIntegration({ worker })]\n * });\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * @param options {WebWorkerIntegrationOptions} Integration options:\n * - `worker`: The worker instance.\n */\nexport const webWorkerIntegration = defineIntegration(({ worker }: WebWorkerIntegrationOptions) => ({\n name: INTEGRATION_NAME,\n setupOnce: () => {\n (Array.isArray(worker) ? worker : [worker]).forEach(w => listenForSentryMessages(w));\n },\n addWorker: (worker: Worker) => listenForSentryMessages(worker),\n})) as IntegrationFn<WebWorkerIntegration>;\n\nfunction listenForSentryMessages(worker: Worker): void {\n worker.addEventListener('message', event => {\n if (isSentryMessage(event.data)) {\n event.stopImmediatePropagation(); // other listeners should not receive this message\n\n // Handle debug IDs\n if (event.data._sentryDebugIds) {\n DEBUG_BUILD && debug.log('Sentry debugId web worker message received', event.data);\n WINDOW._sentryDebugIds = {\n ...event.data._sentryDebugIds,\n // debugIds of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryDebugIds,\n };\n }\n\n // Handle module metadata\n if (event.data._sentryModuleMetadata) {\n DEBUG_BUILD && debug.log('Sentry module metadata web worker message received', event.data);\n // Merge worker's raw metadata into the global object\n // It will be parsed lazily when needed by getMetadataForUrl\n WINDOW._sentryModuleMetadata = {\n ...event.data._sentryModuleMetadata,\n // Module metadata of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryModuleMetadata,\n };\n }\n\n // Handle WASM images from worker\n if (event.data._sentryWasmImages) {\n DEBUG_BUILD && debug.log('Sentry WASM images web worker message received', event.data);\n const existingImages =\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages || [];\n const newImages = event.data._sentryWasmImages.filter(\n (newImg: unknown) =>\n isPlainObject(newImg) &&\n typeof newImg.code_file === 'string' &&\n !existingImages.some(existing => existing.code_file === newImg.code_file),\n );\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages = [\n ...existingImages,\n ...newImages,\n ];\n }\n\n // Handle unhandled rejections forwarded from worker\n if (event.data._sentryWorkerError) {\n DEBUG_BUILD && debug.log('Sentry worker rejection message received', event.data._sentryWorkerError);\n handleForwardedWorkerRejection(event.data._sentryWorkerError);\n }\n }\n });\n}\n\nfunction handleForwardedWorkerRejection(workerError: SerializedWorkerError): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const stackParser = client.getOptions().stackParser;\n const attachStacktrace = client.getOptions().attachStacktrace;\n\n const error = workerError.reason;\n\n // Follow same pattern as globalHandlers for unhandledrejection\n // Handle both primitives and errors the same way\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n // Add worker-specific context\n if (workerError.filename) {\n event.contexts = {\n ...event.contexts,\n worker: {\n filename: workerError.filename,\n },\n };\n }\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.web_worker.onunhandledrejection',\n },\n });\n\n DEBUG_BUILD && debug.log('Captured worker unhandled rejection', error);\n}\n\n/**\n * Minimal interface for DedicatedWorkerGlobalScope, only requiring the postMessage method.\n * (which is the only thing we need from the worker's global object)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope\n *\n * We can't use the actual type because it breaks everyone who doesn't have {\"lib\": [\"WebWorker\"]}\n * but uses {\"skipLibCheck\": true} in their tsconfig.json.\n */\ninterface MinimalDedicatedWorkerGlobalScope {\n postMessage: (message: unknown) => void;\n addEventListener: (type: string, listener: (event: unknown) => void) => void;\n location?: { href?: string };\n}\n\ninterface RegisterWebWorkerOptions {\n self: MinimalDedicatedWorkerGlobalScope & {\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n };\n}\n\n/**\n * Use this function to register the worker with the Sentry SDK.\n *\n * This function will:\n * - Send debug IDs to the parent thread\n * - Send module metadata to the parent thread (for thirdPartyErrorFilterIntegration)\n * - Set up a handler for unhandled rejections in the worker\n * - Forward unhandled rejections to the parent thread for capture\n *\n * Note: Synchronous errors in workers are already captured by globalHandlers.\n * This only handles unhandled promise rejections which don't bubble to the parent.\n *\n * @example\n * ```ts filename={worker.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // Do this as early as possible in your worker.\n * Sentry.registerWebWorker({ self });\n *\n * // continue setting up your worker\n * self.postMessage(...)\n * ```\n * @param options {RegisterWebWorkerOptions} Integration options:\n * - `self`: The worker instance you're calling this function from (self).\n */\nexport function registerWebWorker({ self }: RegisterWebWorkerOptions): void {\n // Send debug IDs and raw module metadata to parent thread\n // The metadata will be parsed lazily on the main thread when needed\n self.postMessage({\n _sentryMessage: true,\n _sentryDebugIds: self._sentryDebugIds ?? undefined,\n _sentryModuleMetadata: self._sentryModuleMetadata ?? undefined,\n });\n\n // Set up unhandledrejection handler inside the worker\n // Following the same pattern as globalHandlers\n // unhandled rejections don't bubble to the parent thread, so we need to handle them here\n self.addEventListener('unhandledrejection', (event: unknown) => {\n const reason = _getUnhandledRejectionError(event);\n\n // Forward the raw reason to parent thread\n // The parent will handle primitives vs errors the same way globalHandlers does\n const serializedError: SerializedWorkerError = {\n reason: reason,\n filename: self.location?.href,\n };\n\n // Forward to parent thread\n self.postMessage({\n _sentryMessage: true,\n _sentryWorkerError: serializedError,\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Forwarding unhandled rejection to parent', serializedError);\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Registered worker with unhandled rejection handling');\n}\n\nfunction isSentryMessage(eventData: unknown): eventData is WebWorkerMessage {\n if (!isPlainObject(eventData) || eventData._sentryMessage !== true) {\n return false;\n }\n\n // Must have at least one of: debug IDs, module metadata, worker error, or WASM images\n const hasDebugIds = '_sentryDebugIds' in eventData;\n const hasModuleMetadata = '_sentryModuleMetadata' in eventData;\n const hasWorkerError = '_sentryWorkerError' in eventData;\n const hasWasmImages = '_sentryWasmImages' in eventData;\n\n if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError && !hasWasmImages) {\n return false;\n }\n\n // Validate debug IDs if present\n if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {\n return false;\n }\n\n // Validate module metadata if present\n if (\n hasModuleMetadata &&\n !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)\n ) {\n return false;\n }\n\n // Validate worker error if present\n if (hasWorkerError && !isPlainObject(eventData._sentryWorkerError)) {\n return false;\n }\n\n // Validate WASM images if present\n if (\n hasWasmImages &&\n (!Array.isArray(eventData._sentryWasmImages) ||\n !eventData._sentryWasmImages.every(\n (img: unknown) => isPlainObject(img) && typeof (img as { code_file?: unknown }).code_file === 'string',\n ))\n ) {\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;;;;AAOO,MAAM,gBAAA,GAAmB;;AAuBhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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I,WAAA,IAAe,EAAE,aAAa,CAAC,SAAS,CAAC,eAAe,CAAA,IAAK,SAAS,CAAC,oBAAoB,SAAS,CAAC,EAAE;AAC7G,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE;AACF,IAAI,iBAAA;AACJ,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,qBAAqB,CAAA,IAAK,SAAS,CAAC,qBAAA,KAA0B,SAAS;AACrG,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE,IAAI,cAAA,IAAkB,CAAC,aAAa,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE;AACtE,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE;AACF,IAAI,aAAA;AACJ,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAA;AAC/C,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK;AACxC,QAAQ,CAAC,GAAG,KAAc,aAAa,CAAC,GAAG,CAAA,IAAK,OAAO,CAAC,GAAA,GAAgC,SAAA,KAAc,QAAQ;AAC9G,OAAO;AACP,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,IAAI;AACb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.53.0","sideEffects":false}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { debug, uuid4, getGlobalScope, getRootSpan, getSdkMetadataForEnvelopeHeader, createEnvelope, dsnToString } from '@sentry/core';
|
|
1
|
+
import { debug, uuid4, getGlobalScope, getRootSpan, getSdkMetadataForEnvelopeHeader, createEnvelope, dsnToString } from '@sentry/core/browser';
|
|
2
2
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
|
-
import { shouldProfileSession, startJSSelfProfile, createProfileChunkPayload, validateProfileChunk } from './utils.js';
|
|
3
|
+
import { shouldProfileSession, setThreadAttributes, startJSSelfProfile, createProfileChunkPayload, validateProfileChunk } from './utils.js';
|
|
4
4
|
|
|
5
5
|
const CHUNK_INTERVAL_MS = 60000; // 1 minute
|
|
6
6
|
// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)
|
|
@@ -61,6 +61,12 @@ class UIProfiler {
|
|
|
61
61
|
if (lifecycleMode === 'trace') {
|
|
62
62
|
this._setupTraceLifecycleListeners(client);
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
client.on('spanStart', span => {
|
|
66
|
+
if (this._isRunning) {
|
|
67
|
+
setThreadAttributes(span);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
/** Starts UI profiling (only effective in 'manual' mode and when sampled). */
|
|
@@ -125,6 +131,10 @@ class UIProfiler {
|
|
|
125
131
|
|
|
126
132
|
this._beginProfiling();
|
|
127
133
|
}
|
|
134
|
+
|
|
135
|
+
if (this._isRunning) {
|
|
136
|
+
setThreadAttributes(rootSpan);
|
|
137
|
+
}
|
|
128
138
|
}
|
|
129
139
|
|
|
130
140
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIProfiler.js","sources":["../../../../../src/profiling/UIProfiler.ts"],"sourcesContent":["import type { Client, ContinuousProfiler, ProfileChunk, ProfileChunkEnvelope, Span } from '@sentry/core';\nimport {\n createEnvelope,\n debug,\n dsnToString,\n getGlobalScope,\n getRootSpan,\n getSdkMetadataForEnvelopeHeader,\n uuid4,\n} from '@sentry/core';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from './../debug-build';\nimport type { JSSelfProfiler } from './jsSelfProfiling';\nimport { createProfileChunkPayload, shouldProfileSession, startJSSelfProfile, validateProfileChunk } from './utils';\n\nconst CHUNK_INTERVAL_MS = 60_000; // 1 minute\n// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)\nconst MAX_ROOT_SPAN_PROFILE_MS = 300_000; // 5 minutes max per root span in trace mode\n\n/**\n * UIProfiler (Profiling V2):\n * Supports two lifecycle modes:\n * - 'manual': controlled explicitly via start()/stop()\n * - 'trace': automatically runs while there are active sampled root spans\n *\n * Profiles are emitted as standalone `profile_chunk` envelopes either when:\n * - there are no more sampled root spans, or\n * - the 60s chunk timer elapses while profiling is running.\n */\nexport class UIProfiler implements ContinuousProfiler<Client> {\n private _client: Client | undefined;\n private _profiler: JSSelfProfiler | undefined;\n private _chunkTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Manual + Trace\n private _profilerId: string | undefined; // one per Profiler session\n private _isRunning: boolean; // current profiler instance active flag\n private _sessionSampled: boolean; // sampling decision for entire session\n private _lifecycleMode: 'manual' | 'trace' | undefined;\n\n // Trace-only\n private _activeRootSpanIds: Set<string>;\n private _rootSpanTimeouts: Map<string, ReturnType<typeof setTimeout>>;\n\n public constructor() {\n this._client = undefined;\n this._profiler = undefined;\n this._chunkTimer = undefined;\n\n this._profilerId = undefined;\n this._isRunning = false;\n this._sessionSampled = false;\n this._lifecycleMode = undefined;\n\n this._activeRootSpanIds = new Set();\n this._rootSpanTimeouts = new Map();\n }\n\n /**\n * Initialize the profiler with client, session sampling and lifecycle mode.\n */\n public initialize(client: Client): void {\n const lifecycleMode = (client.getOptions() as BrowserOptions).profileLifecycle;\n const sessionSampled = shouldProfileSession(client.getOptions());\n\n DEBUG_BUILD && debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);\n\n if (!sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');\n }\n\n // One Profiler ID per profiling session (user session)\n this._profilerId = uuid4();\n this._client = client;\n this._sessionSampled = sessionSampled;\n this._lifecycleMode = lifecycleMode;\n\n if (lifecycleMode === 'trace') {\n this._setupTraceLifecycleListeners(client);\n }\n }\n\n /** Starts UI profiling (only effective in 'manual' mode and when sampled). */\n public start(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.start()` are ignored in trace mode.',\n );\n return;\n }\n\n if (this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n if (!this._sessionSampled) {\n DEBUG_BUILD && debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n this._beginProfiling();\n }\n\n /** Stops UI profiling (only effective in 'manual' mode). */\n public stop(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.stop()` are ignored in trace mode.',\n );\n return;\n }\n\n if (!this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');\n return;\n }\n\n this._endProfiling();\n }\n\n /** Handle an already-active root span at integration setup time (used only in trace mode). */\n public notifyRootSpanActive(rootSpan: Span): void {\n if (this._lifecycleMode !== 'trace' || !this._sessionSampled) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);\n\n this._beginProfiling();\n }\n }\n\n /**\n * Begin profiling if not already running.\n */\n private _beginProfiling(): void {\n if (this._isRunning) {\n return;\n }\n this._isRunning = true;\n\n DEBUG_BUILD && debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);\n\n // Expose profiler_id to match root spans with profiles\n getGlobalScope().setContext('profile', { profiler_id: this._profilerId });\n\n this._startProfilerInstance();\n\n if (!this._profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler; stopping.');\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n\n /** End profiling session; final chunk will be collected and sent. */\n private _endProfiling(): void {\n if (!this._isRunning) {\n return;\n }\n this._isRunning = false;\n\n if (this._chunkTimer) {\n clearTimeout(this._chunkTimer);\n this._chunkTimer = undefined;\n }\n\n this._clearAllRootSpanTimeouts();\n\n // Collect whatever was currently recording\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);\n });\n\n // Manual: Clear profiling context so spans outside start()/stop() aren't marked as profiled\n // Trace: Profile context is kept for the whole session duration\n if (this._lifecycleMode === 'manual') {\n getGlobalScope().setContext('profile', {});\n }\n }\n\n /** Trace-mode: attach spanStart/spanEnd listeners. */\n private _setupTraceLifecycleListeners(client: Client): void {\n client.on('spanStart', span => {\n if (!this._sessionSampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');\n return;\n }\n if (span !== getRootSpan(span)) {\n return; // only care about root spans\n }\n // Only count sampled root spans\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return;\n }\n\n const spanId = span.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span ${spanId} started. Profiling active while there are active root spans (count=${rootSpanCount}).`,\n );\n this._beginProfiling();\n }\n });\n\n client.on('spanEnd', span => {\n if (!this._sessionSampled) {\n return;\n }\n const spanId = span.spanContext().spanId;\n if (!spanId || !this._activeRootSpanIds.has(spanId)) {\n return;\n }\n this._activeRootSpanIds.delete(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n if (rootSpanCount === 0) {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);\n });\n this._endProfiling();\n }\n });\n }\n\n /**\n * Resets profiling information from scope and resets running state (used on failure)\n */\n private _resetProfilerInfo(): void {\n this._isRunning = false;\n getGlobalScope().setContext('profile', {});\n }\n\n /**\n * Clear and reset all per-root-span timeouts.\n */\n private _clearAllRootSpanTimeouts(): void {\n this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));\n this._rootSpanTimeouts.clear();\n }\n\n /** Keep track of root spans and schedule safeguard timeout (trace mode). */\n private _registerTraceRootSpan(spanId: string): void {\n this._activeRootSpanIds.add(spanId);\n const timeout = setTimeout(() => this._onRootSpanTimeout(spanId), MAX_ROOT_SPAN_PROFILE_MS);\n this._rootSpanTimeouts.set(spanId, timeout);\n }\n\n /**\n * Start a profiler instance if needed.\n */\n private _startProfilerInstance(): void {\n if (this._profiler?.stopped === false) {\n return; // already running\n }\n const profiler = startJSSelfProfile();\n if (!profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler.');\n return;\n }\n this._profiler = profiler;\n }\n\n /**\n * Schedule the next 60s chunk while running.\n * Each tick collects a chunk and restarts the profiler.\n * A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.\n */\n private _startPeriodicChunking(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._chunkTimer = setTimeout(() => {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);\n });\n\n if (this._isRunning) {\n this._startProfilerInstance();\n\n if (!this._profiler) {\n // If restart failed, stop scheduling further chunks and reset context.\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n }, CHUNK_INTERVAL_MS);\n }\n\n /**\n * Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.\n * If this was the last active root span, collect the current chunk and stop profiling.\n */\n private _onRootSpanTimeout(rootSpanId: string): void {\n // If span already ended, ignore\n if (!this._rootSpanTimeouts.has(rootSpanId)) {\n return;\n }\n this._rootSpanTimeouts.delete(rootSpanId);\n\n if (!this._activeRootSpanIds.has(rootSpanId)) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \\`.end()\\`.`,\n );\n\n this._activeRootSpanIds.delete(rootSpanId);\n\n if (this._activeRootSpanIds.size === 0) {\n this._endProfiling();\n }\n }\n\n /**\n * Stop current profiler instance, convert profile to chunk & send.\n */\n private async _collectCurrentChunk(): Promise<void> {\n const prevProfiler = this._profiler;\n this._profiler = undefined;\n\n if (!prevProfiler) {\n return;\n }\n\n try {\n const profile = await prevProfiler.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const chunk = createProfileChunkPayload(profile, this._client!, this._profilerId);\n\n // Validate chunk before sending\n const validationReturn = validateProfileChunk(chunk);\n if ('reason' in validationReturn) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',\n validationReturn.reason,\n );\n return;\n }\n\n this._sendProfileChunk(chunk);\n\n DEBUG_BUILD && debug.log('[Profiling] Collected browser profile chunk.');\n } catch (e) {\n DEBUG_BUILD && debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);\n }\n }\n\n /**\n * Send a profile chunk as a standalone envelope.\n */\n private _sendProfileChunk(chunk: ProfileChunk): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const client = this._client!;\n\n const sdkInfo = getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());\n const dsn = client.getDsn();\n const tunnel = client.getOptions().tunnel;\n\n const envelope = createEnvelope<ProfileChunkEnvelope>(\n {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n },\n [[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],\n );\n\n client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);\n });\n }\n}\n"],"names":[],"mappings":";;;;AAeA,MAAM,iBAAA,GAAoB,KAAM,CAAA;AAChC;AACA,MAAM,wBAAA,GAA2B,MAAO,CAAA;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAiD;;AAK9D;AACA;AACA;AACA;;AAGA;;AAIA,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,OAAA,GAAU,SAAS;AAC5B,IAAI,IAAI,CAAC,SAAA,GAAY,SAAS;AAC9B,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;;AAEhC,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;AAChC,IAAI,IAAI,CAAC,UAAA,GAAa,KAAK;AAC3B,IAAI,IAAI,CAAC,eAAA,GAAkB,KAAK;AAChC,IAAI,IAAI,CAAC,cAAA,GAAiB,SAAS;;AAEnC,IAAI,IAAI,CAAC,kBAAA,GAAqB,IAAI,GAAG,EAAE;AACvC,IAAI,IAAI,CAAC,iBAAA,GAAoB,IAAI,GAAG,EAAE;AACtC,EAAE;;AAEF;AACA;AACA;AACA,GAAS,UAAU,CAAC,MAAM,EAAgB;AAC1C,IAAI,MAAM,aAAA,GAAgB,CAAC,MAAM,CAAC,UAAU,EAAC,GAAqB,gBAAgB;AAClF,IAAI,MAAM,cAAA,GAAiB,oBAAoB,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;;AAEpE,IAAI,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,CAAC,8CAA8C,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;;AAEjG,IAAI,IAAI,CAAC,cAAc,EAAE;AACzB,MAAM,eAAe,KAAK,CAAC,GAAG,CAAC,8EAA8E,CAAC;AAC9G,IAAI;;AAEJ;AACA,IAAI,IAAI,CA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IAAI,EAAE,CAAC,WAAW,EAAE;AACzC,QAAQ,IAAI,OAAA,IAAW,EAAE,GAAG,EAAE,OAAA,EAAS,CAAC;AACxC,QAAQ,IAAI,CAAC,CAAC,MAAA,IAAU,GAAA,IAAO,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,CAAA,EAAG,CAAC;AACzD,OAAO;AACP,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAA,EAAc,EAAE,KAAK,CAAC,CAAC;AAClE,KAAK;;AAEL,IAAI,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAA,IAAU;AACvD,MAAM,WAAA,IAAe,KAAK,CAAC,KAAK,CAAC,6CAA6C,EAAE,MAAM,CAAC;AACvF,IAAI,CAAC,CAAC;AACN,EAAE;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"UIProfiler.js","sources":["../../../../../src/profiling/UIProfiler.ts"],"sourcesContent":["import type { Client, ContinuousProfiler, ProfileChunk, ProfileChunkEnvelope, Span } from '@sentry/core/browser';\nimport {\n createEnvelope,\n debug,\n dsnToString,\n getGlobalScope,\n getRootSpan,\n getSdkMetadataForEnvelopeHeader,\n uuid4,\n} from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from './../debug-build';\nimport type { JSSelfProfiler } from './jsSelfProfiling';\nimport {\n createProfileChunkPayload,\n setThreadAttributes,\n shouldProfileSession,\n startJSSelfProfile,\n validateProfileChunk,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 60_000; // 1 minute\n// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)\nconst MAX_ROOT_SPAN_PROFILE_MS = 300_000; // 5 minutes max per root span in trace mode\n\n/**\n * UIProfiler (Profiling V2):\n * Supports two lifecycle modes:\n * - 'manual': controlled explicitly via start()/stop()\n * - 'trace': automatically runs while there are active sampled root spans\n *\n * Profiles are emitted as standalone `profile_chunk` envelopes either when:\n * - there are no more sampled root spans, or\n * - the 60s chunk timer elapses while profiling is running.\n */\nexport class UIProfiler implements ContinuousProfiler<Client> {\n private _client: Client | undefined;\n private _profiler: JSSelfProfiler | undefined;\n private _chunkTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Manual + Trace\n private _profilerId: string | undefined; // one per Profiler session\n private _isRunning: boolean; // current profiler instance active flag\n private _sessionSampled: boolean; // sampling decision for entire session\n private _lifecycleMode: 'manual' | 'trace' | undefined;\n\n // Trace-only\n private _activeRootSpanIds: Set<string>;\n private _rootSpanTimeouts: Map<string, ReturnType<typeof setTimeout>>;\n\n public constructor() {\n this._client = undefined;\n this._profiler = undefined;\n this._chunkTimer = undefined;\n\n this._profilerId = undefined;\n this._isRunning = false;\n this._sessionSampled = false;\n this._lifecycleMode = undefined;\n\n this._activeRootSpanIds = new Set();\n this._rootSpanTimeouts = new Map();\n }\n\n /**\n * Initialize the profiler with client, session sampling and lifecycle mode.\n */\n public initialize(client: Client): void {\n const lifecycleMode = (client.getOptions() as BrowserOptions).profileLifecycle;\n const sessionSampled = shouldProfileSession(client.getOptions());\n\n DEBUG_BUILD && debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);\n\n if (!sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');\n }\n\n // One Profiler ID per profiling session (user session)\n this._profilerId = uuid4();\n this._client = client;\n this._sessionSampled = sessionSampled;\n this._lifecycleMode = lifecycleMode;\n\n if (lifecycleMode === 'trace') {\n this._setupTraceLifecycleListeners(client);\n }\n\n client.on('spanStart', span => {\n if (this._isRunning) {\n setThreadAttributes(span);\n }\n });\n }\n\n /** Starts UI profiling (only effective in 'manual' mode and when sampled). */\n public start(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.start()` are ignored in trace mode.',\n );\n return;\n }\n\n if (this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n if (!this._sessionSampled) {\n DEBUG_BUILD && debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n this._beginProfiling();\n }\n\n /** Stops UI profiling (only effective in 'manual' mode). */\n public stop(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.stop()` are ignored in trace mode.',\n );\n return;\n }\n\n if (!this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');\n return;\n }\n\n this._endProfiling();\n }\n\n /** Handle an already-active root span at integration setup time (used only in trace mode). */\n public notifyRootSpanActive(rootSpan: Span): void {\n if (this._lifecycleMode !== 'trace' || !this._sessionSampled) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);\n\n this._beginProfiling();\n }\n\n if (this._isRunning) {\n setThreadAttributes(rootSpan);\n }\n }\n\n /**\n * Begin profiling if not already running.\n */\n private _beginProfiling(): void {\n if (this._isRunning) {\n return;\n }\n this._isRunning = true;\n\n DEBUG_BUILD && debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);\n\n // Expose profiler_id to match root spans with profiles\n getGlobalScope().setContext('profile', { profiler_id: this._profilerId });\n\n this._startProfilerInstance();\n\n if (!this._profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler; stopping.');\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n\n /** End profiling session; final chunk will be collected and sent. */\n private _endProfiling(): void {\n if (!this._isRunning) {\n return;\n }\n this._isRunning = false;\n\n if (this._chunkTimer) {\n clearTimeout(this._chunkTimer);\n this._chunkTimer = undefined;\n }\n\n this._clearAllRootSpanTimeouts();\n\n // Collect whatever was currently recording\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);\n });\n\n // Manual: Clear profiling context so spans outside start()/stop() aren't marked as profiled\n // Trace: Profile context is kept for the whole session duration\n if (this._lifecycleMode === 'manual') {\n getGlobalScope().setContext('profile', {});\n }\n }\n\n /** Trace-mode: attach spanStart/spanEnd listeners. */\n private _setupTraceLifecycleListeners(client: Client): void {\n client.on('spanStart', span => {\n if (!this._sessionSampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');\n return;\n }\n if (span !== getRootSpan(span)) {\n return; // only care about root spans\n }\n // Only count sampled root spans\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return;\n }\n\n const spanId = span.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span ${spanId} started. Profiling active while there are active root spans (count=${rootSpanCount}).`,\n );\n this._beginProfiling();\n }\n });\n\n client.on('spanEnd', span => {\n if (!this._sessionSampled) {\n return;\n }\n const spanId = span.spanContext().spanId;\n if (!spanId || !this._activeRootSpanIds.has(spanId)) {\n return;\n }\n this._activeRootSpanIds.delete(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n if (rootSpanCount === 0) {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);\n });\n this._endProfiling();\n }\n });\n }\n\n /**\n * Resets profiling information from scope and resets running state (used on failure)\n */\n private _resetProfilerInfo(): void {\n this._isRunning = false;\n getGlobalScope().setContext('profile', {});\n }\n\n /**\n * Clear and reset all per-root-span timeouts.\n */\n private _clearAllRootSpanTimeouts(): void {\n this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));\n this._rootSpanTimeouts.clear();\n }\n\n /** Keep track of root spans and schedule safeguard timeout (trace mode). */\n private _registerTraceRootSpan(spanId: string): void {\n this._activeRootSpanIds.add(spanId);\n const timeout = setTimeout(() => this._onRootSpanTimeout(spanId), MAX_ROOT_SPAN_PROFILE_MS);\n this._rootSpanTimeouts.set(spanId, timeout);\n }\n\n /**\n * Start a profiler instance if needed.\n */\n private _startProfilerInstance(): void {\n if (this._profiler?.stopped === false) {\n return; // already running\n }\n const profiler = startJSSelfProfile();\n if (!profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler.');\n return;\n }\n this._profiler = profiler;\n }\n\n /**\n * Schedule the next 60s chunk while running.\n * Each tick collects a chunk and restarts the profiler.\n * A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.\n */\n private _startPeriodicChunking(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._chunkTimer = setTimeout(() => {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);\n });\n\n if (this._isRunning) {\n this._startProfilerInstance();\n\n if (!this._profiler) {\n // If restart failed, stop scheduling further chunks and reset context.\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n }, CHUNK_INTERVAL_MS);\n }\n\n /**\n * Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.\n * If this was the last active root span, collect the current chunk and stop profiling.\n */\n private _onRootSpanTimeout(rootSpanId: string): void {\n // If span already ended, ignore\n if (!this._rootSpanTimeouts.has(rootSpanId)) {\n return;\n }\n this._rootSpanTimeouts.delete(rootSpanId);\n\n if (!this._activeRootSpanIds.has(rootSpanId)) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \\`.end()\\`.`,\n );\n\n this._activeRootSpanIds.delete(rootSpanId);\n\n if (this._activeRootSpanIds.size === 0) {\n this._endProfiling();\n }\n }\n\n /**\n * Stop current profiler instance, convert profile to chunk & send.\n */\n private async _collectCurrentChunk(): Promise<void> {\n const prevProfiler = this._profiler;\n this._profiler = undefined;\n\n if (!prevProfiler) {\n return;\n }\n\n try {\n const profile = await prevProfiler.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const chunk = createProfileChunkPayload(profile, this._client!, this._profilerId);\n\n // Validate chunk before sending\n const validationReturn = validateProfileChunk(chunk);\n if ('reason' in validationReturn) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',\n validationReturn.reason,\n );\n return;\n }\n\n this._sendProfileChunk(chunk);\n\n DEBUG_BUILD && debug.log('[Profiling] Collected browser profile chunk.');\n } catch (e) {\n DEBUG_BUILD && debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);\n }\n }\n\n /**\n * Send a profile chunk as a standalone envelope.\n */\n private _sendProfileChunk(chunk: ProfileChunk): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const client = this._client!;\n\n const sdkInfo = getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());\n const dsn = client.getDsn();\n const tunnel = client.getOptions().tunnel;\n\n const envelope = createEnvelope<ProfileChunkEnvelope>(\n {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n },\n [[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],\n );\n\n client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);\n });\n }\n}\n"],"names":[],"mappings":";;;;AAqBA,MAAM,iBAAA,GAAoB,KAAM,CAAA;AAChC;AACA,MAAM,wBAAA,GAA2B,MAAO,CAAA;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAiD;;AAK9D;AACA;AACA;AACA;;AAGA;;AAIA,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,OAAA,GAAU,SAAS;AAC5B,IAAI,IAAI,CAAC,SAAA,GAAY,SAAS;AAC9B,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;;AAEhC,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;AAChC,IAAI,IAAI,CAAC,UAAA,GAAa,KAAK;AAC3B,IAAI,IAAI,CAAC,eAAA,GAAkB,KAAK;AAChC,IAAI,IAAI,CAAC,cAAA,GAAiB,SAAS;;AAEnC,IAAI,IAAI,CAAC,kBAAA,GAAqB,IAAI,GAAG,EAAE;AACvC,IAAI,IAAI,CAAC,iBAAA,GAAoB,IAAI,GAAG,EAAE;AACtC,EAAE;;AAEF;AACA;AACA;AACA,GAAS,UAAU,CAAC,MAAM,EAAgB;AAC1C,IAAI,MAAM,aAAA,GAAgB,CAAC,MAAM,CAAC,UAAU,EAAC,GAAqB,gBAAgB;AAClF,IAAI,MAAM,cAAA,GAAiB,oBAAoB,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;;AAEpE,IAAI,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,CAAC,8CAA8C,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;;AAEjG,IAAI,IAAI,CAAC,cAAc,EAAE;AACzB,MAAM,eAAe,KAAK,CAAC,GAAG,CAAC,8EAA8E,CAAC;AAC9G,IAAI;;AAEJ;AACA,IAAI,IAAI,CAAC,WAAA,GAAc,KAAK,EAAE;AAC9B,IAAI,IAAI,CAA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