@sentry/browser
Version:
Official Sentry SDK for browsers
50 lines (49 loc) • 1.73 kB
JavaScript
const require_debug_build = require("../debug-build.js");
let _sentry_core = require("@sentry/core");
// src/profiling/index.ts
/**
* Starts a manually controlled Sentry UI profiling session.
*
* Profiling starts only when the integration sampled the current session and `profileLifecycle` is `manual`.
* While running, the profiler periodically sends profile chunks to Sentry until `stopProfiler()` is called.
*/
function startProfiler() {
const client = (0, _sentry_core.getClient)();
if (!client) {
require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn("No Sentry client available, profiling is not started");
return;
}
if (!client.getIntegrationByName("BrowserProfiling")) {
require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn("BrowserProfiling integration is not available");
return;
}
client.emit("startUIProfiler");
}
/**
* Stops a manually controlled Sentry UI profiling session.
*
* Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.
*/
function stopProfiler() {
const client = (0, _sentry_core.getClient)();
if (!client) {
require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn("No Sentry client available, profiling is not started");
return;
}
if (!client.getIntegrationByName("BrowserProfiling")) {
require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn("ProfilingIntegration is not available");
return;
}
client.emit("stopUIProfiler");
}
/**
* Profiler namespace for controlling the JS profiler in 'manual' mode.
*
* Requires the `browserProfilingIntegration` from the `@sentry/browser` package.
*/
const uiProfiler = {
startProfiler,
stopProfiler
};
exports.uiProfiler = uiProfiler;
//# sourceMappingURL=index.js.map