UNPKG

@sentry/browser

Version:
39 lines (38 loc) • 1.83 kB
const require_debug_build = require("../debug-build.js"); const require_helpers = require("../helpers.js"); const require_UIProfiler = require("./UIProfiler.js"); let _sentry_core = require("@sentry/core"); // src/profiling/integration.ts const INTEGRATION_NAME = "BrowserProfiling"; const _browserProfilingIntegration = (() => { return { name: INTEGRATION_NAME, setup(client) { const options = client.getOptions(); const profiler = new require_UIProfiler.UIProfiler(); if (!options.profileLifecycle) options.profileLifecycle = "manual"; const activeSpan = (0, _sentry_core.getActiveSpan)(); const rootSpan = activeSpan && (0, _sentry_core.getRootSpan)(activeSpan); const lifecycleMode = options.profileLifecycle; client.on("startUIProfiler", () => profiler.start()); client.on("stopUIProfiler", () => profiler.stop()); if (lifecycleMode === "manual") profiler.initialize(client); else if (lifecycleMode === "trace") { if (!(0, _sentry_core.hasSpansEnabled)(options)) { require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn("[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing."); return; } profiler.initialize(client); if (rootSpan) profiler.notifyRootSpanActive(rootSpan); require_helpers.WINDOW.setTimeout(() => { const laterActiveSpan = (0, _sentry_core.getActiveSpan)(); const laterRootSpan = laterActiveSpan && (0, _sentry_core.getRootSpan)(laterActiveSpan); if (laterRootSpan) profiler.notifyRootSpanActive(laterRootSpan); }, 0); } } }; }); const browserProfilingIntegration = (0, _sentry_core.defineIntegration)(_browserProfilingIntegration); exports.browserProfilingIntegration = browserProfilingIntegration; //# sourceMappingURL=integration.js.map