File: //home/cafsindia/snap.cafsinfotech.in/node_modules/@sentry/browser/esm/profiling/integration.js.map
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventProcessor, Hub, Integration, Transaction } from '@sentry/types';\nimport type { Profile } from '@sentry/types/src/profiling';\nimport { logger } from '@sentry/utils';\n\nimport { startProfileForTransaction } from './hubextensions';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n isAutomatedPageLoadTransaction,\n shouldProfileTransaction,\n takeProfileFromGlobalCache,\n} from './utils';\n\n/**\n * Browser profiling integration. Stores any event that has contexts[\"profile\"][\"profile_id\"]\n * This exists because we do not want to await async profiler.stop calls as transaction.finish is called\n * in a synchronous context. Instead, we handle sending the profile async from the promise callback and\n * rely on being able to pull the event from the cache when we need to construct the envelope. This makes the\n * integration less reliable as we might be dropping profiles when the cache is full.\n *\n * @experimental\n */\nexport class BrowserProfilingIntegration implements Integration {\n public static id: string = 'BrowserProfilingIntegration';\n\n public readonly name: string;\n\n public getCurrentHub?: () => Hub;\n\n public constructor() {\n this.name = BrowserProfilingIntegration.id;\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(_addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n this.getCurrentHub = getCurrentHub;\n\n const hub = this.getCurrentHub();\n const client = hub.getClient();\n const scope = hub.getScope();\n\n const transaction = scope.getTransaction();\n\n if (transaction && isAutomatedPageLoadTransaction(transaction)) {\n if (shouldProfileTransaction(transaction)) {\n startProfileForTransaction(transaction);\n }\n }\n\n if (client && typeof client.on === 'function') {\n client.on('startTransaction', (transaction: Transaction) => {\n if (shouldProfileTransaction(transaction)) {\n startProfileForTransaction(transaction);\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 && profiledTransaction.contexts;\n const profile_id = context && context['profile'] && context['profile']['profile_id'];\n const start_timestamp = context && context['profile'] && context['profile']['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n __DEBUG_BUILD__ &&\n logger.log('[Profiling] cannot find profile for a transaction without a profile context');\n continue;\n }\n\n if (!profile_id) {\n __DEBUG_BUILD__ &&\n logger.log('[Profiling] cannot find profile for a transaction without a profile context');\n continue;\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (context && context['profile']) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n __DEBUG_BUILD__ && logger.log(`[Profiling] Could not retrieve profile for transaction: ${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, profilesToAddToEnvelope);\n });\n } else {\n logger.warn('[Profiling] Client does not support hooks, profiling will be disabled');\n }\n }\n}\n"],"names":[],"mappings":";;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,2BAAA,EAAA;AACA,GAAA,OAAA,YAAA,GAAA,CAAA,IAAA,CAAA,EAAA,GAAA,8BAAA,CAAA;;AAMA,GAAA,WAAA,GAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,2BAAA,CAAA,EAAA,CAAA;AACA,GAAA;AACA;AACA;AACA;AACA;AACA,GAAA,SAAA,CAAA,wBAAA,EAAA,aAAA,EAAA;AACA,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA;AACA,IAAA,MAAA,GAAA,GAAA,IAAA,C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