All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.npm.cjs.profiling.integration.js.map Maven / Gradle / Ivy

There is a newer version: 8.40.0
Show newest version
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import { defineIntegration, getActiveSpan, getRootSpan } from '@sentry/core';\nimport type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { DEBUG_BUILD } from '../debug-build';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport type { ProfiledEvent } from './utils';\nimport { isAutomatedPageLoadSpan, shouldProfileSpan } from './utils';\nimport {\n  addProfilesToEnvelope,\n  createProfilingEvent,\n  findProfiledTransactionsFromEnvelope,\n  getActiveProfilesCount,\n  takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n  return {\n    name: INTEGRATION_NAME,\n    setup(client) {\n      const activeSpan = getActiveSpan();\n      const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n      if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n        if (shouldProfileSpan(rootSpan)) {\n          startProfileForSpan(rootSpan);\n        }\n      }\n\n      client.on('spanStart', (span: Span) => {\n        if (span === getRootSpan(span) && shouldProfileSpan(span)) {\n          startProfileForSpan(span);\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 && logger.log('[Profiling] cannot find profile for a span without a profile context');\n            continue;\n          }\n\n          if (!profile_id) {\n            DEBUG_BUILD && logger.log('[Profiling] cannot find profile for a span without a profile context');\n            continue;\n          }\n\n          // Remove the profile from the span 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 span: ${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 as EventEnvelope, profilesToAddToEnvelope);\n      });\n    },\n  };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["getActiveSpan","getRootSpan","isAutomatedPageLoadSpan","shouldProfileSpan","startProfileForSpan","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","DEBUG_BUILD","logger","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","defineIntegration"],"mappings":";;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,kBAAkB,CAAA;AAC3C;AACA,MAAM,4BAA6B,IAAG,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,UAAA,GAAaA,kBAAa,EAAE,CAAA;AACxC,MAAM,MAAM,WAAW,UAAA,IAAcC,gBAAW,CAAC,UAAU,CAAC,CAAA;AAC5D;AACA,MAAM,IAAI,QAAS,IAAGC,6BAAuB,CAAC,QAAQ,CAAC,EAAE;AACzD,QAAQ,IAAIC,uBAAiB,CAAC,QAAQ,CAAC,EAAE;AACzC,UAAUC,uCAAmB,CAAC,QAAQ,CAAC,CA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