{"version":3,"file":"profiling.js","sources":["../../src/profiling.ts"],"sourcesContent":["import type { Profiler, ProfilingIntegration } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\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 && logger.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 && logger.warn('ProfilingIntegration is not available');\n return;\n }\n\n if (!isProfilingIntegrationWithProfiler(integration)) {\n DEBUG_BUILD && logger.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 && logger.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 && logger.warn('ProfilingIntegration is not available');\n return;\n }\n\n if (!isProfilingIntegrationWithProfiler(integration)) {\n DEBUG_BUILD && logger.warn('Profiler is not available on profiling integration.');\n return;\n }\n\n integration._profiler.stop();\n}\n\nexport const profiler: Profiler = {\n startProfiler,\n stopProfiler,\n};\n"],"names":[],"mappings":";;;;AAMA,SAAS,kCAAkC;AAC3C,EAAE,WAAW;AACb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