@sentry/browser 10.53.1 → 10.54.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 +15 -54
- package/build/npm/cjs/dev/client.js.map +1 -1
- package/build/npm/cjs/dev/debug-build.js +0 -5
- package/build/npm/cjs/dev/debug-build.js.map +1 -1
- package/build/npm/cjs/dev/diagnose-sdk.js +15 -37
- package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -1
- package/build/npm/cjs/dev/eventbuilder.js +59 -217
- package/build/npm/cjs/dev/eventbuilder.js.map +1 -1
- package/build/npm/cjs/dev/feedbackAsync.js +1 -5
- package/build/npm/cjs/dev/feedbackAsync.js.map +1 -1
- package/build/npm/cjs/dev/feedbackSync.js +1 -2
- package/build/npm/cjs/dev/feedbackSync.js.map +1 -1
- package/build/npm/cjs/dev/helpers.js +24 -102
- package/build/npm/cjs/dev/helpers.js.map +1 -1
- package/build/npm/cjs/dev/index.js +2 -0
- package/build/npm/cjs/dev/index.js.map +1 -1
- package/build/npm/cjs/dev/integrations/breadcrumbs.js +52 -134
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/dev/integrations/browserapierrors.js +45 -111
- package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/dev/integrations/browsersession.js +7 -35
- package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/dev/integrations/contextlines.js +9 -45
- package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/dev/integrations/culturecontext.js +11 -36
- package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js +1 -22
- package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js +6 -31
- package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js +6 -12
- package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js +5 -30
- package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js +10 -47
- package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js +60 -0
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js.map +1 -0
- package/build/npm/cjs/dev/integrations/globalhandlers.js +38 -99
- package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/dev/integrations/graphqlClient.js +31 -119
- package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpclient.js +43 -203
- package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpcontext.js +7 -17
- package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/linkederrors.js +7 -15
- package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js +19 -44
- package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spanstreaming.js +11 -29
- package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spotlight.js +17 -30
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js +19 -46
- package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/dev/integrations/webWorker.js +40 -211
- package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -1
- package/build/npm/cjs/dev/profiling/UIProfiler.js +87 -190
- package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/dev/profiling/index.js +9 -30
- package/build/npm/cjs/dev/profiling/index.js.map +1 -1
- package/build/npm/cjs/dev/profiling/integration.js +30 -64
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js +28 -84
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/dev/profiling/utils.js +131 -398
- package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
- package/build/npm/cjs/dev/report-dialog.js +10 -25
- package/build/npm/cjs/dev/report-dialog.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +8 -76
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/stack-parsers.js +42 -126
- package/build/npm/cjs/dev/stack-parsers.js.map +1 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js +4 -16
- package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +102 -291
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js +25 -116
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/dev/tracing/reportPageLoaded.js +1 -9
- package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/cjs/dev/tracing/request.js +58 -223
- package/build/npm/cjs/dev/tracing/request.js.map +1 -1
- package/build/npm/cjs/dev/tracing/setActiveSpan.js +1 -48
- package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/cjs/dev/tracing/utils.js +4 -27
- package/build/npm/cjs/dev/tracing/utils.js.map +1 -1
- package/build/npm/cjs/dev/transports/fetch.js +10 -23
- package/build/npm/cjs/dev/transports/fetch.js.map +1 -1
- package/build/npm/cjs/dev/transports/offline.js +27 -84
- package/build/npm/cjs/dev/transports/offline.js.map +1 -1
- package/build/npm/cjs/dev/userfeedback.js +12 -22
- package/build/npm/cjs/dev/userfeedback.js.map +1 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js +5 -26
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +40 -75
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/cjs/prod/client.js +15 -54
- package/build/npm/cjs/prod/client.js.map +1 -1
- package/build/npm/cjs/prod/debug-build.js +0 -5
- package/build/npm/cjs/prod/debug-build.js.map +1 -1
- package/build/npm/cjs/prod/diagnose-sdk.js +15 -37
- package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -1
- package/build/npm/cjs/prod/eventbuilder.js +59 -217
- package/build/npm/cjs/prod/eventbuilder.js.map +1 -1
- package/build/npm/cjs/prod/feedbackAsync.js +1 -5
- package/build/npm/cjs/prod/feedbackAsync.js.map +1 -1
- package/build/npm/cjs/prod/feedbackSync.js +1 -2
- package/build/npm/cjs/prod/feedbackSync.js.map +1 -1
- package/build/npm/cjs/prod/helpers.js +24 -102
- package/build/npm/cjs/prod/helpers.js.map +1 -1
- package/build/npm/cjs/prod/index.js +2 -0
- package/build/npm/cjs/prod/index.js.map +1 -1
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +52 -134
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/prod/integrations/browserapierrors.js +45 -111
- package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/prod/integrations/browsersession.js +7 -35
- package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/prod/integrations/contextlines.js +9 -45
- package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/prod/integrations/culturecontext.js +11 -36
- package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +1 -22
- package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +6 -31
- package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +6 -12
- package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +5 -30
- package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +10 -47
- package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js +60 -0
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js.map +1 -0
- package/build/npm/cjs/prod/integrations/globalhandlers.js +38 -99
- package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/prod/integrations/graphqlClient.js +31 -119
- package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpclient.js +43 -203
- package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpcontext.js +7 -17
- package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/linkederrors.js +7 -15
- package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js +19 -44
- package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spanstreaming.js +11 -29
- package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spotlight.js +17 -30
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js +19 -46
- package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/prod/integrations/webWorker.js +40 -211
- package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -1
- package/build/npm/cjs/prod/profiling/UIProfiler.js +87 -190
- package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/prod/profiling/index.js +9 -30
- package/build/npm/cjs/prod/profiling/index.js.map +1 -1
- package/build/npm/cjs/prod/profiling/integration.js +30 -64
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js +28 -84
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/prod/profiling/utils.js +131 -398
- package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
- package/build/npm/cjs/prod/report-dialog.js +10 -25
- package/build/npm/cjs/prod/report-dialog.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +5 -73
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/stack-parsers.js +42 -126
- package/build/npm/cjs/prod/stack-parsers.js.map +1 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js +4 -16
- package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +102 -291
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js +25 -117
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js +1 -9
- package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/cjs/prod/tracing/request.js +58 -223
- package/build/npm/cjs/prod/tracing/request.js.map +1 -1
- package/build/npm/cjs/prod/tracing/setActiveSpan.js +1 -48
- package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/cjs/prod/tracing/utils.js +4 -27
- package/build/npm/cjs/prod/tracing/utils.js.map +1 -1
- package/build/npm/cjs/prod/transports/fetch.js +10 -23
- package/build/npm/cjs/prod/transports/fetch.js.map +1 -1
- package/build/npm/cjs/prod/transports/offline.js +27 -84
- package/build/npm/cjs/prod/transports/offline.js.map +1 -1
- package/build/npm/cjs/prod/userfeedback.js +12 -22
- package/build/npm/cjs/prod/userfeedback.js.map +1 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js +5 -26
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +40 -75
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/dev/client.js +15 -54
- package/build/npm/esm/dev/client.js.map +1 -1
- package/build/npm/esm/dev/debug-build.js +0 -5
- package/build/npm/esm/dev/debug-build.js.map +1 -1
- package/build/npm/esm/dev/diagnose-sdk.js +15 -37
- package/build/npm/esm/dev/diagnose-sdk.js.map +1 -1
- package/build/npm/esm/dev/eventbuilder.js +59 -217
- package/build/npm/esm/dev/eventbuilder.js.map +1 -1
- package/build/npm/esm/dev/feedbackAsync.js +1 -5
- package/build/npm/esm/dev/feedbackAsync.js.map +1 -1
- package/build/npm/esm/dev/feedbackSync.js +1 -2
- package/build/npm/esm/dev/feedbackSync.js.map +1 -1
- package/build/npm/esm/dev/helpers.js +24 -102
- package/build/npm/esm/dev/helpers.js.map +1 -1
- package/build/npm/esm/dev/index.js +1 -0
- package/build/npm/esm/dev/index.js.map +1 -1
- package/build/npm/esm/dev/integrations/breadcrumbs.js +52 -134
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/dev/integrations/browserapierrors.js +45 -111
- package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/dev/integrations/browsersession.js +7 -35
- package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/dev/integrations/contextlines.js +9 -45
- package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/dev/integrations/culturecontext.js +11 -36
- package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js +1 -22
- package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js +6 -31
- package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js +6 -12
- package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js +5 -30
- package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js +10 -47
- package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js +58 -0
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js.map +1 -0
- package/build/npm/esm/dev/integrations/globalhandlers.js +38 -99
- package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/dev/integrations/graphqlClient.js +31 -119
- package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpclient.js +43 -203
- package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpcontext.js +7 -17
- package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/linkederrors.js +7 -15
- package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js +19 -44
- package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js +11 -29
- package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -1
- package/build/npm/esm/dev/integrations/spotlight.js +17 -30
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js +19 -46
- package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/dev/integrations/webWorker.js +40 -211
- 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 +87 -190
- package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/dev/profiling/index.js +9 -30
- package/build/npm/esm/dev/profiling/index.js.map +1 -1
- package/build/npm/esm/dev/profiling/integration.js +30 -64
- package/build/npm/esm/dev/profiling/integration.js.map +1 -1
- package/build/npm/esm/dev/profiling/startProfileForSpan.js +28 -84
- package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/dev/profiling/utils.js +131 -398
- package/build/npm/esm/dev/profiling/utils.js.map +1 -1
- package/build/npm/esm/dev/report-dialog.js +10 -25
- package/build/npm/esm/dev/report-dialog.js.map +1 -1
- package/build/npm/esm/dev/sdk.js +8 -76
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/stack-parsers.js +42 -126
- package/build/npm/esm/dev/stack-parsers.js.map +1 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js +4 -16
- package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +102 -291
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js +25 -116
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/tracing/reportPageLoaded.js +1 -9
- package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/esm/dev/tracing/request.js +59 -224
- package/build/npm/esm/dev/tracing/request.js.map +1 -1
- package/build/npm/esm/dev/tracing/setActiveSpan.js +1 -48
- package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/esm/dev/tracing/utils.js +4 -27
- package/build/npm/esm/dev/tracing/utils.js.map +1 -1
- package/build/npm/esm/dev/transports/fetch.js +10 -23
- package/build/npm/esm/dev/transports/fetch.js.map +1 -1
- package/build/npm/esm/dev/transports/offline.js +27 -84
- package/build/npm/esm/dev/transports/offline.js.map +1 -1
- package/build/npm/esm/dev/userfeedback.js +12 -22
- package/build/npm/esm/dev/userfeedback.js.map +1 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js +5 -26
- package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js +40 -75
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/prod/client.js +15 -54
- package/build/npm/esm/prod/client.js.map +1 -1
- package/build/npm/esm/prod/debug-build.js +0 -5
- package/build/npm/esm/prod/debug-build.js.map +1 -1
- package/build/npm/esm/prod/diagnose-sdk.js +15 -37
- package/build/npm/esm/prod/diagnose-sdk.js.map +1 -1
- package/build/npm/esm/prod/eventbuilder.js +59 -217
- package/build/npm/esm/prod/eventbuilder.js.map +1 -1
- package/build/npm/esm/prod/feedbackAsync.js +1 -5
- package/build/npm/esm/prod/feedbackAsync.js.map +1 -1
- package/build/npm/esm/prod/feedbackSync.js +1 -2
- package/build/npm/esm/prod/feedbackSync.js.map +1 -1
- package/build/npm/esm/prod/helpers.js +24 -102
- package/build/npm/esm/prod/helpers.js.map +1 -1
- package/build/npm/esm/prod/index.js +1 -0
- package/build/npm/esm/prod/index.js.map +1 -1
- package/build/npm/esm/prod/integrations/breadcrumbs.js +52 -134
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/prod/integrations/browserapierrors.js +45 -111
- package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/prod/integrations/browsersession.js +7 -35
- package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/prod/integrations/contextlines.js +9 -45
- package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/prod/integrations/culturecontext.js +11 -36
- package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +1 -22
- package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +6 -31
- package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +6 -12
- package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +5 -30
- package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +10 -47
- package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js +58 -0
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js.map +1 -0
- package/build/npm/esm/prod/integrations/globalhandlers.js +38 -99
- package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/prod/integrations/graphqlClient.js +31 -119
- package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpclient.js +43 -203
- package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpcontext.js +7 -17
- package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/linkederrors.js +7 -15
- package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js +19 -44
- package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js +11 -29
- package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -1
- package/build/npm/esm/prod/integrations/spotlight.js +17 -30
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js +19 -46
- package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/prod/integrations/webWorker.js +40 -211
- 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 +87 -190
- package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/prod/profiling/index.js +9 -30
- package/build/npm/esm/prod/profiling/index.js.map +1 -1
- package/build/npm/esm/prod/profiling/integration.js +30 -64
- package/build/npm/esm/prod/profiling/integration.js.map +1 -1
- package/build/npm/esm/prod/profiling/startProfileForSpan.js +28 -84
- package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/prod/profiling/utils.js +131 -398
- package/build/npm/esm/prod/profiling/utils.js.map +1 -1
- package/build/npm/esm/prod/report-dialog.js +10 -25
- package/build/npm/esm/prod/report-dialog.js.map +1 -1
- package/build/npm/esm/prod/sdk.js +5 -73
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/stack-parsers.js +42 -126
- package/build/npm/esm/prod/stack-parsers.js.map +1 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js +4 -16
- package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +102 -291
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js +25 -117
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/tracing/reportPageLoaded.js +1 -9
- package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -1
- package/build/npm/esm/prod/tracing/request.js +59 -224
- package/build/npm/esm/prod/tracing/request.js.map +1 -1
- package/build/npm/esm/prod/tracing/setActiveSpan.js +1 -48
- package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -1
- package/build/npm/esm/prod/tracing/utils.js +4 -27
- package/build/npm/esm/prod/tracing/utils.js.map +1 -1
- package/build/npm/esm/prod/transports/fetch.js +10 -23
- package/build/npm/esm/prod/transports/fetch.js.map +1 -1
- package/build/npm/esm/prod/transports/offline.js +27 -84
- package/build/npm/esm/prod/transports/offline.js.map +1 -1
- package/build/npm/esm/prod/userfeedback.js +12 -22
- package/build/npm/esm/prod/userfeedback.js.map +1 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js +5 -26
- package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js +40 -75
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/types/eventbuilder.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.bundle.d.ts +2 -2
- package/build/npm/types/index.bundle.d.ts.map +1 -1
- package/build/npm/types/index.bundle.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts +2 -2
- package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts +1 -0
- package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +1 -0
- 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 -0
- 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 -0
- 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 -0
- 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 +1 -0
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +1 -0
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/fetchStreamPerformance.d.ts +14 -0
- package/build/npm/types/integrations/fetchStreamPerformance.d.ts.map +1 -0
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +3 -0
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts +3 -0
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types-ts3.8/index.bundle.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.feedback.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.logs.metrics.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.replay.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.replay.feedback.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.replay.logs.metrics.d.ts +2 -2
- package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +1 -0
- package/build/npm/types-ts3.8/index.d.ts +1 -0
- package/build/npm/types-ts3.8/integrations/fetchStreamPerformance.d.ts +14 -0
- package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +3 -0
- package/build/npm/types-ts3.8/tracing/request.d.ts +3 -0
- package/package.json +7 -7
|
@@ -3,56 +3,35 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const browser = require('@sentry/core/browser');
|
|
4
4
|
const debugBuild = require('../debug-build.js');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Starts the Sentry UI profiler.
|
|
8
|
-
* This mode is exclusive with the transaction profiler and will only work if the profilesSampleRate is set to a falsy value.
|
|
9
|
-
* In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.
|
|
10
|
-
*/
|
|
11
6
|
function startProfiler() {
|
|
12
7
|
const client = browser.getClient();
|
|
13
8
|
if (!client) {
|
|
14
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
9
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn("No Sentry client available, profiling is not started");
|
|
15
10
|
return;
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
const integration = client.getIntegrationByName('BrowserProfiling');
|
|
19
|
-
|
|
12
|
+
const integration = client.getIntegrationByName("BrowserProfiling");
|
|
20
13
|
if (!integration) {
|
|
21
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
14
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn("BrowserProfiling integration is not available");
|
|
22
15
|
return;
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
client.emit('startUIProfiler');
|
|
17
|
+
client.emit("startUIProfiler");
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Stops the Sentry UI profiler.
|
|
30
|
-
* Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.
|
|
31
|
-
*/
|
|
32
19
|
function stopProfiler() {
|
|
33
20
|
const client = browser.getClient();
|
|
34
21
|
if (!client) {
|
|
35
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
22
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn("No Sentry client available, profiling is not started");
|
|
36
23
|
return;
|
|
37
24
|
}
|
|
38
|
-
|
|
39
|
-
const integration = client.getIntegrationByName('BrowserProfiling');
|
|
25
|
+
const integration = client.getIntegrationByName("BrowserProfiling");
|
|
40
26
|
if (!integration) {
|
|
41
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
27
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn("ProfilingIntegration is not available");
|
|
42
28
|
return;
|
|
43
29
|
}
|
|
44
|
-
|
|
45
|
-
client.emit('stopUIProfiler');
|
|
30
|
+
client.emit("stopUIProfiler");
|
|
46
31
|
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Profiler namespace for controlling the JS profiler in 'manual' mode.
|
|
50
|
-
*
|
|
51
|
-
* Requires the `browserProfilingIntegration` from the `@sentry/browser` package.
|
|
52
|
-
*/
|
|
53
32
|
const uiProfiler = {
|
|
54
33
|
startProfiler,
|
|
55
|
-
stopProfiler
|
|
34
|
+
stopProfiler
|
|
56
35
|
};
|
|
57
36
|
|
|
58
37
|
exports.uiProfiler = uiProfiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/profiling/index.ts"],"sourcesContent":["import type { Profiler } from '@sentry/core/browser';\nimport { debug, getClient } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Starts the Sentry UI profiler.\n * This mode is exclusive with the transaction profiler and will only work if the profilesSampleRate is set to a falsy value.\n * In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.\n */\nfunction startProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n\n if (!integration) {\n DEBUG_BUILD && debug.warn('BrowserProfiling integration is not available');\n return;\n }\n\n client.emit('startUIProfiler');\n}\n\n/**\n * Stops the Sentry UI profiler.\n * Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.\n */\nfunction stopProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n client.emit('stopUIProfiler');\n}\n\n/**\n * Profiler namespace for controlling the JS profiler in 'manual' mode.\n *\n * Requires the `browserProfilingIntegration` from the `@sentry/browser` package.\n */\nexport const uiProfiler: Profiler = {\n startProfiler,\n stopProfiler,\n};\n"],"names":["getClient","DEBUG_BUILD","debug"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/profiling/index.ts"],"sourcesContent":["import type { Profiler } from '@sentry/core/browser';\nimport { debug, getClient } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Starts the Sentry UI profiler.\n * This mode is exclusive with the transaction profiler and will only work if the profilesSampleRate is set to a falsy value.\n * In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.\n */\nfunction startProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n\n if (!integration) {\n DEBUG_BUILD && debug.warn('BrowserProfiling integration is not available');\n return;\n }\n\n client.emit('startUIProfiler');\n}\n\n/**\n * Stops the Sentry UI profiler.\n * Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.\n */\nfunction stopProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n client.emit('stopUIProfiler');\n}\n\n/**\n * Profiler namespace for controlling the JS profiler in 'manual' mode.\n *\n * Requires the `browserProfilingIntegration` from the `@sentry/browser` package.\n */\nexport const uiProfiler: Profiler = {\n startProfiler,\n stopProfiler,\n};\n"],"names":["getClient","DEBUG_BUILD","debug"],"mappings":";;;;;AASA,SAAS,aAAA,GAAsB;AAC7B,EAAA,MAAM,SAASA,iBAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAAC,sBAAA,IAAeC,aAAA,CAAM,KAAK,sDAAsD,CAAA;AAChF,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,oBAAA,CAAqB,kBAAkB,CAAA;AAElE,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAAD,sBAAA,IAAeC,aAAA,CAAM,KAAK,+CAA+C,CAAA;AACzE,IAAA;AAAA,EACF;AAEA,EAAA,MAAA,CAAO,KAAK,iBAAiB,CAAA;AAC/B;AAMA,SAAS,YAAA,GAAqB;AAC5B,EAAA,MAAM,SAASF,iBAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAAC,sBAAA,IAAeC,aAAA,CAAM,KAAK,sDAAsD,CAAA;AAChF,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,oBAAA,CAAqB,kBAAkB,CAAA;AAClE,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAAD,sBAAA,IAAeC,aAAA,CAAM,KAAK,uCAAuC,CAAA;AACjE,IAAA;AAAA,EACF;AAEA,EAAA,MAAA,CAAO,KAAK,gBAAgB,CAAA;AAC9B;AAOO,MAAM,UAAA,GAAuB;AAAA,EAClC,aAAA;AAAA,EACA;AACF;;;;"}
|
|
@@ -7,63 +7,44 @@ const startProfileForSpan = require('./startProfileForSpan.js');
|
|
|
7
7
|
const UIProfiler = require('./UIProfiler.js');
|
|
8
8
|
const utils = require('./utils.js');
|
|
9
9
|
|
|
10
|
-
const INTEGRATION_NAME =
|
|
11
|
-
|
|
10
|
+
const INTEGRATION_NAME = "BrowserProfiling";
|
|
12
11
|
const _browserProfilingIntegration = (() => {
|
|
13
12
|
return {
|
|
14
13
|
name: INTEGRATION_NAME,
|
|
15
14
|
setup(client) {
|
|
16
|
-
const options = client.getOptions()
|
|
15
|
+
const options = client.getOptions();
|
|
17
16
|
const profiler = new UIProfiler.UIProfiler();
|
|
18
|
-
|
|
19
17
|
if (!utils.hasLegacyProfiling(options) && !options.profileLifecycle) {
|
|
20
|
-
|
|
21
|
-
options.profileLifecycle = 'manual';
|
|
18
|
+
options.profileLifecycle = "manual";
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
25
20
|
if (utils.hasLegacyProfiling(options) && !options.profilesSampleRate) {
|
|
26
|
-
debugBuild.DEBUG_BUILD && browser.debug.log(
|
|
21
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[Profiling] Profiling disabled, no profiling options found.");
|
|
27
22
|
return;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
const activeSpan = browser.getActiveSpan();
|
|
31
25
|
const rootSpan = activeSpan && browser.getRootSpan(activeSpan);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',
|
|
37
|
-
);
|
|
26
|
+
if (utils.hasLegacyProfiling(options) && options.profileSessionSampleRate !== void 0) {
|
|
27
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
28
|
+
"[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled."
|
|
29
|
+
);
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
// UI PROFILING (Profiling V2)
|
|
41
31
|
if (!utils.hasLegacyProfiling(options)) {
|
|
42
32
|
const lifecycleMode = options.profileLifecycle;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
client.on('stopUIProfiler', () => profiler.stop());
|
|
47
|
-
|
|
48
|
-
if (lifecycleMode === 'manual') {
|
|
33
|
+
client.on("startUIProfiler", () => profiler.start());
|
|
34
|
+
client.on("stopUIProfiler", () => profiler.stop());
|
|
35
|
+
if (lifecycleMode === "manual") {
|
|
49
36
|
profiler.initialize(client);
|
|
50
|
-
} else if (lifecycleMode ===
|
|
37
|
+
} else if (lifecycleMode === "trace") {
|
|
51
38
|
if (!browser.hasSpansEnabled(options)) {
|
|
52
|
-
debugBuild.DEBUG_BUILD &&
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
39
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn(
|
|
40
|
+
"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing."
|
|
41
|
+
);
|
|
56
42
|
return;
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
profiler.initialize(client);
|
|
60
|
-
|
|
61
|
-
// If there is an active, sampled root span already, notify the profiler
|
|
62
45
|
if (rootSpan) {
|
|
63
46
|
profiler.notifyRootSpanActive(rootSpan);
|
|
64
47
|
}
|
|
65
|
-
|
|
66
|
-
// In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.
|
|
67
48
|
helpers.WINDOW.setTimeout(() => {
|
|
68
49
|
const laterActiveSpan = browser.getActiveSpan();
|
|
69
50
|
const laterRootSpan = laterActiveSpan && browser.getRootSpan(laterActiveSpan);
|
|
@@ -73,81 +54,66 @@ const _browserProfilingIntegration = (() => {
|
|
|
73
54
|
}, 0);
|
|
74
55
|
}
|
|
75
56
|
} else {
|
|
76
|
-
// LEGACY PROFILING (v1)
|
|
77
57
|
if (rootSpan && utils.isAutomatedPageLoadSpan(rootSpan)) {
|
|
78
58
|
if (utils.shouldProfileSpanLegacy(rootSpan)) {
|
|
79
59
|
startProfileForSpan.startProfileForSpan(rootSpan);
|
|
80
60
|
}
|
|
81
61
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (span === rootSpan) {
|
|
62
|
+
client.on("spanStart", (span) => {
|
|
63
|
+
const rootSpan2 = browser.getRootSpan(span);
|
|
64
|
+
if (span === rootSpan2) {
|
|
86
65
|
if (utils.shouldProfileSpanLegacy(span)) {
|
|
87
66
|
startProfileForSpan.startProfileForSpan(span);
|
|
88
67
|
}
|
|
89
|
-
} else if (utils.PROFILED_ROOT_SPANS.has(
|
|
68
|
+
} else if (utils.PROFILED_ROOT_SPANS.has(rootSpan2)) {
|
|
90
69
|
utils.setThreadAttributes(span);
|
|
91
70
|
}
|
|
92
71
|
});
|
|
93
|
-
|
|
94
|
-
client.on('beforeEnvelope', (envelope) => {
|
|
95
|
-
// if not profiles are in queue, there is nothing to add to the envelope.
|
|
72
|
+
client.on("beforeEnvelope", (envelope) => {
|
|
96
73
|
if (!utils.getActiveProfilesCount()) {
|
|
97
74
|
return;
|
|
98
75
|
}
|
|
99
|
-
|
|
100
76
|
const profiledTransactionEvents = utils.findProfiledTransactionsFromEnvelope(envelope);
|
|
101
77
|
if (!profiledTransactionEvents.length) {
|
|
102
78
|
return;
|
|
103
79
|
}
|
|
104
|
-
|
|
105
80
|
const profilesToAddToEnvelope = [];
|
|
106
|
-
|
|
107
81
|
for (const profiledTransaction of profiledTransactionEvents) {
|
|
108
82
|
const context = profiledTransaction?.contexts;
|
|
109
|
-
const profile_id = context?.profile?.[
|
|
110
|
-
const start_timestamp = context?.profile?.[
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] cannot find profile for a span without a profile context');
|
|
83
|
+
const profile_id = context?.profile?.["profile_id"];
|
|
84
|
+
const start_timestamp = context?.profile?.["start_timestamp"];
|
|
85
|
+
if (typeof profile_id !== "string") {
|
|
86
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[Profiling] cannot find profile for a span without a profile context");
|
|
114
87
|
continue;
|
|
115
88
|
}
|
|
116
|
-
|
|
117
89
|
if (!profile_id) {
|
|
118
|
-
debugBuild.DEBUG_BUILD && browser.debug.log(
|
|
90
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[Profiling] cannot find profile for a span without a profile context");
|
|
119
91
|
continue;
|
|
120
92
|
}
|
|
121
|
-
|
|
122
|
-
// Remove the profile from the span context before sending, relay will take care of the rest.
|
|
123
93
|
if (context?.profile) {
|
|
124
94
|
delete context.profile;
|
|
125
95
|
}
|
|
126
|
-
|
|
127
96
|
const profile = utils.takeProfileFromGlobalCache(profile_id);
|
|
128
97
|
if (!profile) {
|
|
129
98
|
debugBuild.DEBUG_BUILD && browser.debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);
|
|
130
99
|
continue;
|
|
131
100
|
}
|
|
132
|
-
|
|
133
101
|
const profileEvent = utils.createProfilingEvent(
|
|
134
102
|
profile_id,
|
|
135
|
-
start_timestamp
|
|
103
|
+
start_timestamp,
|
|
136
104
|
profile,
|
|
137
|
-
profiledTransaction
|
|
105
|
+
profiledTransaction
|
|
138
106
|
);
|
|
139
107
|
if (profileEvent) {
|
|
140
108
|
profilesToAddToEnvelope.push(profileEvent);
|
|
141
109
|
}
|
|
142
110
|
}
|
|
143
|
-
|
|
144
|
-
utils.addProfilesToEnvelope(envelope , profilesToAddToEnvelope);
|
|
111
|
+
utils.addProfilesToEnvelope(envelope, profilesToAddToEnvelope);
|
|
145
112
|
});
|
|
146
113
|
}
|
|
147
|
-
}
|
|
114
|
+
}
|
|
148
115
|
};
|
|
149
|
-
})
|
|
150
|
-
|
|
116
|
+
});
|
|
151
117
|
const browserProfilingIntegration = browser.defineIntegration(_browserProfilingIntegration);
|
|
152
118
|
|
|
153
119
|
exports.browserProfilingIntegration = browserProfilingIntegration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core/browser';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan, hasSpansEnabled } from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport { UIProfiler } from './UIProfiler';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n hasLegacyProfiling,\n isAutomatedPageLoadSpan,\n PROFILED_ROOT_SPANS,\n setThreadAttributes,\n shouldProfileSpanLegacy,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions() as BrowserOptions;\n const profiler = new UIProfiler();\n\n if (!hasLegacyProfiling(options) && !options.profileLifecycle) {\n // Set default lifecycle mode\n options.profileLifecycle = 'manual';\n }\n\n // eslint-disable-next-line deprecation/deprecation\n if (hasLegacyProfiling(options) && !options.profilesSampleRate) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no profiling options found.');\n return;\n }\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',\n );\n }\n\n // UI PROFILING (Profiling V2)\n if (!hasLegacyProfiling(options)) {\n const lifecycleMode = options.profileLifecycle;\n\n // Registering hooks in all lifecycle modes to be able to notify users in case they want to start/stop the profiler manually in `trace` mode\n client.on('startUIProfiler', () => profiler.start());\n client.on('stopUIProfiler', () => profiler.stop());\n\n if (lifecycleMode === 'manual') {\n profiler.initialize(client);\n } else if (lifecycleMode === 'trace') {\n if (!hasSpansEnabled(options)) {\n DEBUG_BUILD &&\n debug.warn(\n \"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.\",\n );\n return;\n }\n\n profiler.initialize(client);\n\n // If there is an active, sampled root span already, notify the profiler\n if (rootSpan) {\n profiler.notifyRootSpanActive(rootSpan);\n }\n\n // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.\n WINDOW.setTimeout(() => {\n const laterActiveSpan = getActiveSpan();\n const laterRootSpan = laterActiveSpan && getRootSpan(laterActiveSpan);\n if (laterRootSpan) {\n profiler.notifyRootSpanActive(laterRootSpan);\n }\n }, 0);\n }\n } else {\n // LEGACY PROFILING (v1)\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpanLegacy(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n const rootSpan = getRootSpan(span);\n if (span === rootSpan) {\n if (shouldProfileSpanLegacy(span)) {\n startProfileForSpan(span);\n }\n } else if (PROFILED_ROOT_SPANS.has(rootSpan)) {\n setThreadAttributes(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction?.contexts;\n const profile_id = context?.profile?.['profile_id'];\n const start_timestamp = context?.profile?.['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context?.profile) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["UIProfiler","hasLegacyProfiling","DEBUG_BUILD","debug","getActiveSpan","getRootSpan","hasSpansEnabled","WINDOW","isAutomatedPageLoadSpan","shouldProfileSpanLegacy","startProfileForSpan","PROFILED_ROOT_SPANS","setThreadAttributes","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","defineIntegration"],"mappings":";;;;;;;;;AAqBA,MAAM,gBAAA,GAAmB,kBAAkB;;AAE3C,MAAM,4BAAA,IAAgC,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAC;AACxC,MAAM,MAAM,QAAA,GAAW,IAAIA,qBAAU,EAAE;;AAEvC,MAAM,IAAI,CAACC,wBAAkB,CAAC,OAA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A,QAAA,CAAA,CAAA;AACA,MAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,2BAAA,GAAAC,yBAAA,CAAA,4BAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"integration.js","sources":["../../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core/browser';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan, hasSpansEnabled } from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport { UIProfiler } from './UIProfiler';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n hasLegacyProfiling,\n isAutomatedPageLoadSpan,\n PROFILED_ROOT_SPANS,\n setThreadAttributes,\n shouldProfileSpanLegacy,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions() as BrowserOptions;\n const profiler = new UIProfiler();\n\n if (!hasLegacyProfiling(options) && !options.profileLifecycle) {\n // Set default lifecycle mode\n options.profileLifecycle = 'manual';\n }\n\n // eslint-disable-next-line deprecation/deprecation\n if (hasLegacyProfiling(options) && !options.profilesSampleRate) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no profiling options found.');\n return;\n }\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',\n );\n }\n\n // UI PROFILING (Profiling V2)\n if (!hasLegacyProfiling(options)) {\n const lifecycleMode = options.profileLifecycle;\n\n // Registering hooks in all lifecycle modes to be able to notify users in case they want to start/stop the profiler manually in `trace` mode\n client.on('startUIProfiler', () => profiler.start());\n client.on('stopUIProfiler', () => profiler.stop());\n\n if (lifecycleMode === 'manual') {\n profiler.initialize(client);\n } else if (lifecycleMode === 'trace') {\n if (!hasSpansEnabled(options)) {\n DEBUG_BUILD &&\n debug.warn(\n \"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.\",\n );\n return;\n }\n\n profiler.initialize(client);\n\n // If there is an active, sampled root span already, notify the profiler\n if (rootSpan) {\n profiler.notifyRootSpanActive(rootSpan);\n }\n\n // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.\n WINDOW.setTimeout(() => {\n const laterActiveSpan = getActiveSpan();\n const laterRootSpan = laterActiveSpan && getRootSpan(laterActiveSpan);\n if (laterRootSpan) {\n profiler.notifyRootSpanActive(laterRootSpan);\n }\n }, 0);\n }\n } else {\n // LEGACY PROFILING (v1)\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpanLegacy(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n const rootSpan = getRootSpan(span);\n if (span === rootSpan) {\n if (shouldProfileSpanLegacy(span)) {\n startProfileForSpan(span);\n }\n } else if (PROFILED_ROOT_SPANS.has(rootSpan)) {\n setThreadAttributes(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction?.contexts;\n const profile_id = context?.profile?.['profile_id'];\n const start_timestamp = context?.profile?.['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context?.profile) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["UIProfiler","hasLegacyProfiling","DEBUG_BUILD","debug","getActiveSpan","getRootSpan","hasSpansEnabled","WINDOW","isAutomatedPageLoadSpan","shouldProfileSpanLegacy","startProfileForSpan","rootSpan","PROFILED_ROOT_SPANS","setThreadAttributes","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","defineIntegration"],"mappings":";;;;;;;;;AAqBA,MAAM,gBAAA,GAAmB,kBAAA;AAEzB,MAAM,gCAAgC,MAAM;AAC1C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,MAAA,MAAM,QAAA,GAAW,IAAIA,qBAAA,EAAW;AAEhC,MAAA,IAAI,CAACC,wBAAA,CAAmB,OAAO,CAAA,IAAK,CAAC,QAAQ,gBAAA,EAAkB;AAE7D,QAAA,OAAA,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Aa,OAAA,EAAS,OAAA,GAAU,YAAY,CAAA;AAClD,YAAA,MAAM,eAAA,GAAkB,OAAA,EAAS,OAAA,GAAU,iBAAiB,CAAA;AAE5D,YAAA,IAAI,OAAO,eAAe,QAAA,EAAU;AAClC,cAAAb,sBAAA,IAAeC,aAAA,CAAM,IAAI,sEAAsE,CAAA;AAC/F,cAAA;AAAA,YACF;AAEA,YAAA,IAAI,CAAC,UAAA,EAAY;AACf,cAAAD,sBAAA,IAAeC,aAAA,CAAM,IAAI,sEAAsE,CAAA;AAC/F,cAAA;AAAA,YACF;AAGA,YAAA,IAAI,SAAS,OAAA,EAAS;AACpB,cAAA,OAAO,OAAA,CAAQ,OAAA;AAAA,YACjB;AAEA,YAAA,MAAM,OAAA,GAAUa,iCAA2B,UAAU,CAAA;AACrD,YAAA,IAAI,CAAC,OAAA,EAAS;AACZ,cAAAd,sBAAA,IAAeC,aAAA,CAAM,GAAA,CAAI,CAAA,iDAAA,EAAoD,UAAU,CAAA,CAAE,CAAA;AACzF,cAAA;AAAA,YACF;AAEA,YAAA,MAAM,YAAA,GAAec,0BAAA;AAAA,cACnB,UAAA;AAAA,cACA,eAAA;AAAA,cACA,OAAA;AAAA,cACA;AAAA,aACF;AACA,YAAA,IAAI,YAAA,EAAc;AAChB,cAAA,uBAAA,CAAwB,KAAK,YAAY,CAAA;AAAA,YAC3C;AAAA,UACF;AAEA,UAAAC,2BAAA,CAAsB,UAA2B,uBAAuB,CAAA;AAAA,QAC1E,CAAC,CAAA;AAAA,MACH;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAEO,MAAM,2BAAA,GAA8BC,0BAAkB,4BAA4B;;;;"}
|
|
@@ -5,141 +5,85 @@ const debugBuild = require('../debug-build.js');
|
|
|
5
5
|
const helpers = require('../helpers.js');
|
|
6
6
|
const utils = require('./utils.js');
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Wraps startTransaction and stopTransaction with profiling related logic.
|
|
10
|
-
* startProfileForTransaction is called after the call to startTransaction in order to avoid our own code from
|
|
11
|
-
* being profiled. Because of that same reason, stopProfiling is called before the call to stopTransaction.
|
|
12
|
-
*/
|
|
13
8
|
function startProfileForSpan(span) {
|
|
14
|
-
// Start the profiler and get the profiler instance.
|
|
15
9
|
let startTimestamp;
|
|
16
10
|
if (utils.isAutomatedPageLoadSpan(span)) {
|
|
17
|
-
startTimestamp = browser.timestampInSeconds() *
|
|
11
|
+
startTimestamp = browser.timestampInSeconds() * 1e3;
|
|
18
12
|
}
|
|
19
|
-
|
|
20
13
|
const profiler = utils.startJSSelfProfile();
|
|
21
|
-
|
|
22
|
-
// We failed to construct the profiler, so we skip.
|
|
23
|
-
// No need to log anything as this has already been logged in startProfile.
|
|
24
14
|
if (!profiler) {
|
|
25
15
|
return;
|
|
26
16
|
}
|
|
27
|
-
|
|
28
17
|
if (debugBuild.DEBUG_BUILD) {
|
|
29
18
|
browser.debug.log(`[Profiling] started profiling span: ${browser.spanToJSON(span).description}`);
|
|
30
19
|
}
|
|
31
|
-
|
|
32
|
-
// We create "unique" span names to avoid concurrent spans with same names
|
|
33
|
-
// from being ignored by the profiler. From here on, only this span name should be used when
|
|
34
|
-
// calling the profiler methods. Note: we log the original name to the user to avoid confusion.
|
|
35
20
|
const profileId = browser.uuid4();
|
|
36
|
-
|
|
37
|
-
// A couple of important things to note here:
|
|
38
|
-
// `CpuProfilerBindings.stopProfiling` will be scheduled to run in 30seconds in order to exceed max profile duration.
|
|
39
|
-
// Whichever of the two (span.finish/timeout) is first to run, the profiling will be stopped and the gathered profile
|
|
40
|
-
// will be processed when the original span is finished. Since onProfileHandler can be invoked multiple times in the
|
|
41
|
-
// event of an error or user mistake (calling span.finish multiple times), it is important that the behavior of onProfileHandler
|
|
42
|
-
// is idempotent as we do not want any timings or profiles to be overridden by the last call to onProfileHandler.
|
|
43
|
-
// After the original finish method is called, the event will be reported through the integration and delegated to transport.
|
|
44
21
|
let processedProfile = null;
|
|
45
|
-
|
|
46
|
-
browser.getCurrentScope().setContext('profile', {
|
|
22
|
+
browser.getCurrentScope().setContext("profile", {
|
|
47
23
|
profile_id: profileId,
|
|
48
|
-
start_timestamp: startTimestamp
|
|
24
|
+
start_timestamp: startTimestamp
|
|
49
25
|
});
|
|
50
|
-
|
|
51
26
|
utils.PROFILED_ROOT_SPANS.add(span);
|
|
52
27
|
utils.setThreadAttributes(span);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Idempotent handler for profile stop
|
|
56
|
-
*/
|
|
57
28
|
async function onProfileHandler() {
|
|
58
|
-
// Check if the profile exists and return it the behavior has to be idempotent as users may call span.finish multiple times.
|
|
59
29
|
if (!span) {
|
|
60
30
|
return;
|
|
61
31
|
}
|
|
62
|
-
// Satisfy the type checker, but profiler will always be defined here.
|
|
63
32
|
if (!profiler) {
|
|
64
33
|
return;
|
|
65
34
|
}
|
|
66
35
|
if (processedProfile) {
|
|
67
36
|
if (debugBuild.DEBUG_BUILD) {
|
|
68
|
-
browser.debug.log(
|
|
37
|
+
browser.debug.log("[Profiling] profile for:", browser.spanToJSON(span).description, "already exists, returning early");
|
|
69
38
|
}
|
|
70
39
|
return;
|
|
71
40
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (debugBuild.DEBUG_BUILD) {
|
|
82
|
-
browser.debug.log(`[Profiling] stopped profiling of span: ${browser.spanToJSON(span).description}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.
|
|
86
|
-
if (!profile) {
|
|
87
|
-
if (debugBuild.DEBUG_BUILD) {
|
|
88
|
-
browser.debug.log(
|
|
89
|
-
`[Profiling] profiler returned null profile for: ${browser.spanToJSON(span).description}`,
|
|
90
|
-
'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
processedProfile = profile;
|
|
97
|
-
utils.addProfileToGlobalCache(profileId, profile);
|
|
98
|
-
})
|
|
99
|
-
.catch(error => {
|
|
41
|
+
return profiler.stop().then((profile) => {
|
|
42
|
+
if (maxDurationTimeoutID) {
|
|
43
|
+
helpers.WINDOW.clearTimeout(maxDurationTimeoutID);
|
|
44
|
+
maxDurationTimeoutID = void 0;
|
|
45
|
+
}
|
|
46
|
+
if (debugBuild.DEBUG_BUILD) {
|
|
47
|
+
browser.debug.log(`[Profiling] stopped profiling of span: ${browser.spanToJSON(span).description}`);
|
|
48
|
+
}
|
|
49
|
+
if (!profile) {
|
|
100
50
|
if (debugBuild.DEBUG_BUILD) {
|
|
101
|
-
browser.debug.log(
|
|
51
|
+
browser.debug.log(
|
|
52
|
+
`[Profiling] profiler returned null profile for: ${browser.spanToJSON(span).description}`,
|
|
53
|
+
"this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started"
|
|
54
|
+
);
|
|
102
55
|
}
|
|
103
|
-
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
processedProfile = profile;
|
|
59
|
+
utils.addProfileToGlobalCache(profileId, profile);
|
|
60
|
+
}).catch((error) => {
|
|
61
|
+
if (debugBuild.DEBUG_BUILD) {
|
|
62
|
+
browser.debug.log("[Profiling] error while stopping profiler:", error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
104
65
|
}
|
|
105
|
-
|
|
106
|
-
// Enqueue a timeout to prevent profiles from running over max duration.
|
|
107
66
|
let maxDurationTimeoutID = helpers.WINDOW.setTimeout(() => {
|
|
108
67
|
if (debugBuild.DEBUG_BUILD) {
|
|
109
|
-
browser.debug.log(
|
|
68
|
+
browser.debug.log("[Profiling] max profile duration elapsed, stopping profiling for:", browser.spanToJSON(span).description);
|
|
110
69
|
}
|
|
111
|
-
// If the timeout exceeds, we want to stop profiling, but not finish the span
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
113
70
|
onProfileHandler();
|
|
114
71
|
}, utils.MAX_PROFILE_DURATION_MS);
|
|
115
|
-
|
|
116
|
-
// We need to reference the original end call to avoid creating an infinite loop
|
|
117
72
|
const originalEnd = span.end.bind(span);
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Wraps span `end()` with profiling related logic.
|
|
121
|
-
* startProfiling is called after the call to spanStart in order to avoid our own code from
|
|
122
|
-
* being profiled. Because of that same reason, stopProfiling is called before the call to spanEnd.
|
|
123
|
-
*/
|
|
124
73
|
function profilingWrappedSpanEnd() {
|
|
125
74
|
if (!span) {
|
|
126
75
|
return originalEnd();
|
|
127
76
|
}
|
|
128
|
-
// onProfileHandler should always return the same profile even if this is called multiple times.
|
|
129
|
-
// Always call onProfileHandler to ensure stopProfiling is called and the timeout is cleared.
|
|
130
77
|
void onProfileHandler().then(
|
|
131
78
|
() => {
|
|
132
79
|
originalEnd();
|
|
133
80
|
},
|
|
134
81
|
() => {
|
|
135
|
-
// If onProfileHandler fails, we still want to call the original finish method.
|
|
136
82
|
originalEnd();
|
|
137
|
-
}
|
|
83
|
+
}
|
|
138
84
|
);
|
|
139
|
-
|
|
140
85
|
return span;
|
|
141
86
|
}
|
|
142
|
-
|
|
143
87
|
span.end = profilingWrappedSpanEnd;
|
|
144
88
|
}
|
|
145
89
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startProfileForSpan.js","sources":["../../../../../src/profiling/startProfileForSpan.ts"],"sourcesContent":["import type { Span } from '@sentry/core/browser';\nimport { debug, getCurrentScope, spanToJSON, timestampInSeconds, uuid4 } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport type { JSSelfProfile } from './jsSelfProfiling';\nimport {\n addProfileToGlobalCache,\n isAutomatedPageLoadSpan,\n MAX_PROFILE_DURATION_MS,\n PROFILED_ROOT_SPANS,\n setThreadAttributes,\n startJSSelfProfile,\n} from './utils';\n\n/**\n * Wraps startTransaction and stopTransaction with profiling related logic.\n * startProfileForTransaction is called after the call to startTransaction in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to stopTransaction.\n */\nexport function startProfileForSpan(span: Span): void {\n // Start the profiler and get the profiler instance.\n let startTimestamp: number | undefined;\n if (isAutomatedPageLoadSpan(span)) {\n startTimestamp = timestampInSeconds() * 1000;\n }\n\n const profiler = startJSSelfProfile();\n\n // We failed to construct the profiler, so we skip.\n // No need to log anything as this has already been logged in startProfile.\n if (!profiler) {\n return;\n }\n\n if (DEBUG_BUILD) {\n debug.log(`[Profiling] started profiling span: ${spanToJSON(span).description}`);\n }\n\n // We create \"unique\" span names to avoid concurrent spans with same names\n // from being ignored by the profiler. From here on, only this span name should be used when\n // calling the profiler methods. Note: we log the original name to the user to avoid confusion.\n const profileId = uuid4();\n\n // A couple of important things to note here:\n // `CpuProfilerBindings.stopProfiling` will be scheduled to run in 30seconds in order to exceed max profile duration.\n // Whichever of the two (span.finish/timeout) is first to run, the profiling will be stopped and the gathered profile\n // will be processed when the original span is finished. Since onProfileHandler can be invoked multiple times in the\n // event of an error or user mistake (calling span.finish multiple times), it is important that the behavior of onProfileHandler\n // is idempotent as we do not want any timings or profiles to be overridden by the last call to onProfileHandler.\n // After the original finish method is called, the event will be reported through the integration and delegated to transport.\n let processedProfile: JSSelfProfile | null = null;\n\n getCurrentScope().setContext('profile', {\n profile_id: profileId,\n start_timestamp: startTimestamp,\n });\n\n PROFILED_ROOT_SPANS.add(span);\n setThreadAttributes(span);\n\n /**\n * Idempotent handler for profile stop\n */\n async function onProfileHandler(): Promise<void> {\n // Check if the profile exists and return it the behavior has to be idempotent as users may call span.finish multiple times.\n if (!span) {\n return;\n }\n // Satisfy the type checker, but profiler will always be defined here.\n if (!profiler) {\n return;\n }\n if (processedProfile) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] profile for:', spanToJSON(span).description, 'already exists, returning early');\n }\n return;\n }\n\n return profiler\n .stop()\n .then((profile: JSSelfProfile): void => {\n if (maxDurationTimeoutID) {\n WINDOW.clearTimeout(maxDurationTimeoutID);\n maxDurationTimeoutID = undefined;\n }\n\n if (DEBUG_BUILD) {\n debug.log(`[Profiling] stopped profiling of span: ${spanToJSON(span).description}`);\n }\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n if (DEBUG_BUILD) {\n debug.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n }\n return;\n }\n\n processedProfile = profile;\n addProfileToGlobalCache(profileId, profile);\n })\n .catch(error => {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] error while stopping profiler:', error);\n }\n });\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n let maxDurationTimeoutID: number | undefined = WINDOW.setTimeout(() => {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n }\n // If the timeout exceeds, we want to stop profiling, but not finish the span\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n onProfileHandler();\n }, MAX_PROFILE_DURATION_MS);\n\n // We need to reference the original end call to avoid creating an infinite loop\n const originalEnd = span.end.bind(span);\n\n /**\n * Wraps span `end()` with profiling related logic.\n * startProfiling is called after the call to spanStart in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to spanEnd.\n */\n function profilingWrappedSpanEnd(): Span {\n if (!span) {\n return originalEnd();\n }\n // onProfileHandler should always return the same profile even if this is called multiple times.\n // Always call onProfileHandler to ensure stopProfiling is called and the timeout is cleared.\n void onProfileHandler().then(\n () => {\n originalEnd();\n },\n () => {\n // If onProfileHandler fails, we still want to call the original finish method.\n originalEnd();\n },\n );\n\n return span;\n }\n\n span.end = profilingWrappedSpanEnd;\n}\n"],"names":["isAutomatedPageLoadSpan","timestampInSeconds","startJSSelfProfile","DEBUG_BUILD","debug","spanToJSON","uuid4","getCurrentScope","PROFILED_ROOT_SPANS","setThreadAttributes","WINDOW","addProfileToGlobalCache","MAX_PROFILE_DURATION_MS"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"startProfileForSpan.js","sources":["../../../../../src/profiling/startProfileForSpan.ts"],"sourcesContent":["import type { Span } from '@sentry/core/browser';\nimport { debug, getCurrentScope, spanToJSON, timestampInSeconds, uuid4 } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport type { JSSelfProfile } from './jsSelfProfiling';\nimport {\n addProfileToGlobalCache,\n isAutomatedPageLoadSpan,\n MAX_PROFILE_DURATION_MS,\n PROFILED_ROOT_SPANS,\n setThreadAttributes,\n startJSSelfProfile,\n} from './utils';\n\n/**\n * Wraps startTransaction and stopTransaction with profiling related logic.\n * startProfileForTransaction is called after the call to startTransaction in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to stopTransaction.\n */\nexport function startProfileForSpan(span: Span): void {\n // Start the profiler and get the profiler instance.\n let startTimestamp: number | undefined;\n if (isAutomatedPageLoadSpan(span)) {\n startTimestamp = timestampInSeconds() * 1000;\n }\n\n const profiler = startJSSelfProfile();\n\n // We failed to construct the profiler, so we skip.\n // No need to log anything as this has already been logged in startProfile.\n if (!profiler) {\n return;\n }\n\n if (DEBUG_BUILD) {\n debug.log(`[Profiling] started profiling span: ${spanToJSON(span).description}`);\n }\n\n // We create \"unique\" span names to avoid concurrent spans with same names\n // from being ignored by the profiler. From here on, only this span name should be used when\n // calling the profiler methods. Note: we log the original name to the user to avoid confusion.\n const profileId = uuid4();\n\n // A couple of important things to note here:\n // `CpuProfilerBindings.stopProfiling` will be scheduled to run in 30seconds in order to exceed max profile duration.\n // Whichever of the two (span.finish/timeout) is first to run, the profiling will be stopped and the gathered profile\n // will be processed when the original span is finished. Since onProfileHandler can be invoked multiple times in the\n // event of an error or user mistake (calling span.finish multiple times), it is important that the behavior of onProfileHandler\n // is idempotent as we do not want any timings or profiles to be overridden by the last call to onProfileHandler.\n // After the original finish method is called, the event will be reported through the integration and delegated to transport.\n let processedProfile: JSSelfProfile | null = null;\n\n getCurrentScope().setContext('profile', {\n profile_id: profileId,\n start_timestamp: startTimestamp,\n });\n\n PROFILED_ROOT_SPANS.add(span);\n setThreadAttributes(span);\n\n /**\n * Idempotent handler for profile stop\n */\n async function onProfileHandler(): Promise<void> {\n // Check if the profile exists and return it the behavior has to be idempotent as users may call span.finish multiple times.\n if (!span) {\n return;\n }\n // Satisfy the type checker, but profiler will always be defined here.\n if (!profiler) {\n return;\n }\n if (processedProfile) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] profile for:', spanToJSON(span).description, 'already exists, returning early');\n }\n return;\n }\n\n return profiler\n .stop()\n .then((profile: JSSelfProfile): void => {\n if (maxDurationTimeoutID) {\n WINDOW.clearTimeout(maxDurationTimeoutID);\n maxDurationTimeoutID = undefined;\n }\n\n if (DEBUG_BUILD) {\n debug.log(`[Profiling] stopped profiling of span: ${spanToJSON(span).description}`);\n }\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n if (DEBUG_BUILD) {\n debug.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n }\n return;\n }\n\n processedProfile = profile;\n addProfileToGlobalCache(profileId, profile);\n })\n .catch(error => {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] error while stopping profiler:', error);\n }\n });\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n let maxDurationTimeoutID: number | undefined = WINDOW.setTimeout(() => {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n }\n // If the timeout exceeds, we want to stop profiling, but not finish the span\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n onProfileHandler();\n }, MAX_PROFILE_DURATION_MS);\n\n // We need to reference the original end call to avoid creating an infinite loop\n const originalEnd = span.end.bind(span);\n\n /**\n * Wraps span `end()` with profiling related logic.\n * startProfiling is called after the call to spanStart in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to spanEnd.\n */\n function profilingWrappedSpanEnd(): Span {\n if (!span) {\n return originalEnd();\n }\n // onProfileHandler should always return the same profile even if this is called multiple times.\n // Always call onProfileHandler to ensure stopProfiling is called and the timeout is cleared.\n void onProfileHandler().then(\n () => {\n originalEnd();\n },\n () => {\n // If onProfileHandler fails, we still want to call the original finish method.\n originalEnd();\n },\n );\n\n return span;\n }\n\n span.end = profilingWrappedSpanEnd;\n}\n"],"names":["isAutomatedPageLoadSpan","timestampInSeconds","startJSSelfProfile","DEBUG_BUILD","debug","spanToJSON","uuid4","getCurrentScope","PROFILED_ROOT_SPANS","setThreadAttributes","WINDOW","addProfileToGlobalCache","MAX_PROFILE_DURATION_MS"],"mappings":";;;;;;;AAmBO,SAAS,oBAAoB,IAAA,EAAkB;AAEpD,EAAA,IAAI,cAAA;AACJ,EAAA,IAAIA,6BAAA,CAAwB,IAAI,CAAA,EAAG;AACjC,IAAA,cAAA,GAAiBC,4BAAmB,GAAI,GAAA;AAAA,EAC1C;AAEA,EAAA,MAAM,WAAWC,wBAAA,EAAmB;AAIpC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AAEA,EAAA,IAAIC,sBAAA,EAAa;AACf,IAAAC,aAAA,CAAM,IAAI,CAAA,oCAAA,EAAuCC,kBAAA,CAAW,IAAI,CAAA,CAAE,WAAW,CAAA,CAAE,CAAA;AAAA,EACjF;AAKA,EAAA,MAAM,YAAYC,aAAA,EAAM;AASxB,EAAA,IAAI,gBAAA,GAAyC,IAAA;AAE7C,EAAAC,uBAAA,EAAgB,CAAE,WAAW,SAAA,EAAW;AAAA,IACtC,UAAA,EAAY,SAAA;AAAA,IACZ,eAAA,EAAiB;AAAA,GAClB,CAAA;AAED,EAAAC,yBAAA,CAAoB,IAAI,IAAI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