{"version":3,"file":"profiling.js","sources":["../../src/profiling.ts"],"sourcesContent":["import { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { Profiler, ProfilingIntegration } from './types/profiling';\nimport { debug } from './utils/debug-logger';\n\nfunction isProfilingIntegrationWithProfiler(\n integration: ProfilingIntegration | undefined,\n): integration is ProfilingIntegration {\n return (\n !!integration &&\n typeof integration['_profiler'] !== 'undefined' &&\n typeof integration['_profiler']['start'] === 'function' &&\n typeof integration['_profiler']['stop'] === 'function'\n );\n}\n/**\n * Starts the Sentry continuous 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 continuous 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('ProfilingIntegration');\n\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n if (!isProfilingIntegrationWithProfiler(integration)) {\n DEBUG_BUILD && debug.warn('Profiler is not available on profiling integration.');\n return;\n }\n\n integration._profiler.start();\n}\n\n/**\n * Stops the Sentry continuous 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('ProfilingIntegration');\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n if (!isProfilingIntegrationWithProfiler(integration)) {\n DEBUG_BUILD && debug.warn('Profiler is not available on profiling integration.');\n return;\n }\n\n integration._profiler.stop();\n}\n\n/**\n * Profiler namespace for controlling the profiler in 'manual' mode.\n *\n * Requires the `nodeProfilingIntegration` from the `@sentry/profiling-node` package.\n */\nexport const profiler: Profiler = {\n startProf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