@sentry/browser 11.0.0-alpha.0 → 11.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/npm/cjs/dev/client.js.map +1 -1
- package/build/npm/cjs/dev/helpers.js +2 -1
- package/build/npm/cjs/dev/helpers.js.map +1 -1
- package/build/npm/cjs/dev/index.js +7 -4
- package/build/npm/cjs/dev/index.js.map +1 -1
- package/build/npm/cjs/dev/integrations/bfcache.js +113 -0
- package/build/npm/cjs/dev/integrations/bfcache.js.map +1 -0
- package/build/npm/cjs/dev/integrations/breadcrumbs.js +1 -1
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js +11 -11
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js +2 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/dev/integrations/graphqlClient.js +3 -3
- package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js +4 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spotlight.js +2 -1
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js +2 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/dev/profiling/index.js.map +1 -1
- package/build/npm/cjs/dev/profiling/integration.js +21 -91
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
- package/build/npm/cjs/dev/profiling/utils.js +0 -283
- package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +0 -4
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js +5 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +30 -86
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js +3 -3
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/dev/tracing/request.js +7 -9
- package/build/npm/cjs/dev/tracing/request.js.map +1 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js +2 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/cjs/prod/client.js.map +1 -1
- package/build/npm/cjs/prod/helpers.js +2 -1
- package/build/npm/cjs/prod/helpers.js.map +1 -1
- package/build/npm/cjs/prod/index.js +7 -4
- package/build/npm/cjs/prod/index.js.map +1 -1
- package/build/npm/cjs/prod/integrations/bfcache.js +113 -0
- package/build/npm/cjs/prod/integrations/bfcache.js.map +1 -0
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +1 -1
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js +11 -11
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/cjs/prod/integrations/globalhandlers.js +2 -1
- package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/prod/integrations/graphqlClient.js +3 -3
- package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js +4 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spotlight.js +2 -1
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js +2 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/prod/profiling/index.js.map +1 -1
- package/build/npm/cjs/prod/profiling/integration.js +21 -91
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
- package/build/npm/cjs/prod/profiling/utils.js +0 -283
- package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +0 -4
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js +5 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +30 -86
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js +3 -3
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/tracing/request.js +7 -9
- package/build/npm/cjs/prod/tracing/request.js.map +1 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js +2 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/dev/client.js.map +1 -1
- package/build/npm/esm/dev/helpers.js +2 -1
- package/build/npm/esm/dev/helpers.js.map +1 -1
- package/build/npm/esm/dev/index.js +4 -4
- package/build/npm/esm/dev/integrations/bfcache.js +109 -0
- package/build/npm/esm/dev/integrations/bfcache.js.map +1 -0
- package/build/npm/esm/dev/integrations/breadcrumbs.js +2 -2
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js +3 -3
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js +2 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/dev/integrations/graphqlClient.js +5 -5
- package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js +4 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/dev/integrations/spotlight.js +2 -1
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js +2 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/dev/package.json +1 -1
- package/build/npm/esm/dev/profiling/index.js.map +1 -1
- package/build/npm/esm/dev/profiling/integration.js +22 -92
- package/build/npm/esm/dev/profiling/integration.js.map +1 -1
- package/build/npm/esm/dev/profiling/utils.js +2 -272
- package/build/npm/esm/dev/profiling/utils.js.map +1 -1
- package/build/npm/esm/dev/sdk.js +0 -4
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js +5 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +32 -87
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js +3 -3
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/tracing/request.js +9 -11
- package/build/npm/esm/dev/tracing/request.js.map +1 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js +2 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/prod/client.js.map +1 -1
- package/build/npm/esm/prod/helpers.js +2 -1
- package/build/npm/esm/prod/helpers.js.map +1 -1
- package/build/npm/esm/prod/index.js +4 -4
- package/build/npm/esm/prod/integrations/bfcache.js +109 -0
- package/build/npm/esm/prod/integrations/bfcache.js.map +1 -0
- package/build/npm/esm/prod/integrations/breadcrumbs.js +2 -2
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js +3 -3
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js +2 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/prod/integrations/graphqlClient.js +5 -5
- package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js +4 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/prod/integrations/spotlight.js +2 -1
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js +2 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/prod/package.json +1 -1
- package/build/npm/esm/prod/profiling/index.js.map +1 -1
- package/build/npm/esm/prod/profiling/integration.js +22 -92
- package/build/npm/esm/prod/profiling/integration.js.map +1 -1
- package/build/npm/esm/prod/profiling/utils.js +2 -272
- package/build/npm/esm/prod/profiling/utils.js.map +1 -1
- package/build/npm/esm/prod/sdk.js +0 -4
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js +5 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +32 -87
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js +3 -3
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/tracing/request.js +9 -11
- package/build/npm/esm/prod/tracing/request.js.map +1 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js +2 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/types/client.d.ts +22 -1
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/exports.d.ts +2 -2
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.bundle.d.ts +2 -2
- package/build/npm/types/index.bundle.d.ts.map +1 -1
- package/build/npm/types/index.bundle.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +6 -5
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/bfcache.d.ts +42 -0
- package/build/npm/types/integrations/bfcache.d.ts.map +1 -0
- package/build/npm/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/build/npm/types/integrations/graphqlClient.d.ts.map +1 -1
- package/build/npm/types/integrations/httpclient.d.ts.map +1 -1
- package/build/npm/types/integrations/interactions.d.ts +2 -0
- package/build/npm/types/integrations/interactions.d.ts.map +1 -0
- package/build/npm/types/integrations/reportingobserver.d.ts.map +1 -1
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -1
- package/build/npm/types/profiling/index.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts +1 -74
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/tracing/backgroundtab.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +0 -19
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts +1 -13
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types/utils/detectBrowserExtension.d.ts.map +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
- package/package.json +10 -9
- package/build/npm/cjs/dev/integrations/spanstreaming.js +0 -34
- package/build/npm/cjs/dev/integrations/spanstreaming.js.map +0 -1
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js +0 -91
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/cjs/prod/integrations/spanstreaming.js +0 -34
- package/build/npm/cjs/prod/integrations/spanstreaming.js.map +0 -1
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js +0 -91
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js +0 -31
- package/build/npm/esm/dev/integrations/spanstreaming.js.map +0 -1
- package/build/npm/esm/dev/profiling/startProfileForSpan.js +0 -89
- package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js +0 -31
- package/build/npm/esm/prod/integrations/spanstreaming.js.map +0 -1
- package/build/npm/esm/prod/profiling/startProfileForSpan.js +0 -89
- package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/types/integrations/spanstreaming.d.ts +0 -5
- package/build/npm/types/integrations/spanstreaming.d.ts.map +0 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts +0 -8
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../src/profiling/utils.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n Envelope,\n Event,\n EventEnvelope,\n Profile,\n ProfileChunk,\n Span,\n ThreadCpuProfile,\n} from '@sentry/core/browser';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n DEFAULT_ENVIRONMENT,\n forEachEnvelopeItem,\n getClient,\n getDebugImagesForResources,\n GLOBAL_OBJ,\n spanToJSON,\n timestampInSeconds,\n uuid4,\n} from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport type { JSSelfProfile, JSSelfProfiler, JSSelfProfilerConstructor, JSSelfProfileStack } from './jsSelfProfiling';\n\nconst MS_TO_NS = 1e6;\n\n// Checking if we are in Main or Worker thread: `self` (not `window`) is the `globalThis` in Web Workers and `importScripts` are only available in Web Workers\nconst isMainThread = 'window' in GLOBAL_OBJ && GLOBAL_OBJ.window === GLOBAL_OBJ && typeof importScripts === 'undefined';\n\n// Setting ID to 0 as we cannot get an ID from Web Workers\nexport const PROFILER_THREAD_ID_STRING = String(0);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\n\n// We force make this optional to be on the safe side...\nconst navigator = WINDOW.navigator as typeof WINDOW.navigator | undefined;\n\n// Machine properties (eval only once)\nlet OS_PLATFORM = '';\nlet OS_PLATFORM_VERSION = '';\nlet OS_ARCH = '';\nlet OS_BROWSER = navigator?.userAgent || '';\nlet OS_MODEL = '';\nconst OS_LOCALE = navigator?.language || navigator?.languages?.[0] || '';\n\ntype UAData = {\n platform?: string;\n architecture?: string;\n model?: string;\n platformVersion?: string;\n fullVersionList?: {\n brand: string;\n version: string;\n }[];\n};\n\ninterface UserAgentData {\n getHighEntropyValues: (keys: string[]) => Promise<UAData>;\n}\n\nfunction isUserAgentData(data: unknown): data is UserAgentData {\n return typeof data === 'object' && data !== null && 'getHighEntropyValues' in data;\n}\n\n// @ts-expect-error userAgentData is not part of the navigator interface yet\nconst userAgentData = navigator?.userAgentData;\n\nif (isUserAgentData(userAgentData)) {\n userAgentData\n .getHighEntropyValues(['architecture', 'model', 'platform', 'platformVersion', 'fullVersionList'])\n .then((ua: UAData) => {\n OS_PLATFORM = ua.platform || '';\n OS_ARCH = ua.architecture || '';\n OS_MODEL = ua.model || '';\n OS_PLATFORM_VERSION = ua.platformVersion || '';\n\n if (ua.fullVersionList?.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const firstUa = ua.fullVersionList[ua.fullVersionList.length - 1]!;\n OS_BROWSER = `${firstUa.brand} ${firstUa.version}`;\n }\n })\n .catch(e => void e);\n}\n\nfunction isProcessedJSSelfProfile(profile: ThreadCpuProfile | JSSelfProfile): profile is JSSelfProfile {\n return !('thread_metadata' in profile);\n}\n\n// Enriches the profile with threadId of the current thread.\n// This is done in node as we seem to not be able to get the info from C native code.\n/**\n *\n */\nexport function enrichWithThreadInformation(profile: ThreadCpuProfile | JSSelfProfile): ThreadCpuProfile {\n if (!isProcessedJSSelfProfile(profile)) {\n return profile;\n }\n\n return convertJSSelfProfileToSampledFormat(profile);\n}\n\n// Profile is marked as optional because it is deleted from the metadata\n// by the integration before the event is processed by other integrations.\nexport interface ProfiledEvent extends Event {\n sdkProcessingMetadata: {\n profile?: JSSelfProfile;\n };\n}\n\nfunction getTraceId(event: Event): string {\n const traceId: unknown = event.contexts?.trace?.trace_id;\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (typeof traceId === 'string' && traceId.length !== 32) {\n if (DEBUG_BUILD) {\n debug.log(`[Profiling] Invalid traceId: ${traceId} on profiled event`);\n }\n }\n if (typeof traceId !== 'string') {\n return '';\n }\n\n return traceId;\n}\n/**\n * Creates a profiling event envelope from a Sentry event. If profile does not pass\n * validation, returns null.\n * @param event\n * @param dsn\n * @param metadata\n * @param tunnel\n * @returns {EventEnvelope | null}\n */\n\n/**\n * Creates a profiling event envelope from a Sentry event.\n */\nexport function createProfilePayload(\n profile_id: string,\n start_timestamp: number | undefined,\n processed_profile: JSSelfProfile,\n event: ProfiledEvent,\n): Profile {\n if (event.type !== 'transaction') {\n // createProfilingEventEnvelope should only be called for transactions,\n // we type guard this behavior with isProfiledTransactionEvent.\n throw new TypeError('Profiling events may only be attached to transactions, this should never occur.');\n }\n\n if (processed_profile === undefined || processed_profile === null) {\n throw new TypeError(\n `Cannot construct profiling event envelope without a valid profile. Got ${processed_profile} instead.`,\n );\n }\n\n const traceId = getTraceId(event);\n const enrichedThreadProfile = enrichWithThreadInformation(processed_profile);\n const transactionStartMs = start_timestamp\n ? start_timestamp\n : typeof event.start_timestamp === 'number'\n ? event.start_timestamp * 1000\n : timestampInSeconds() * 1000;\n const transactionEndMs = typeof event.timestamp === 'number' ? event.timestamp * 1000 : timestampInSeconds() * 1000;\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(transactionStartMs).toISOString(),\n platform: 'javascript',\n version: '1',\n release: event.release || '',\n environment: event.environment || DEFAULT_ENVIRONMENT,\n runtime: {\n name: 'javascript',\n version: WINDOW.navigator.userAgent,\n },\n os: {\n name: OS_PLATFORM,\n version: OS_PLATFORM_VERSION,\n build_number: OS_BROWSER,\n },\n device: {\n locale: OS_LOCALE,\n model: OS_MODEL,\n manufacturer: OS_BROWSER,\n architecture: OS_ARCH,\n is_emulator: false,\n },\n debug_meta: {\n images: applyDebugMetadata(processed_profile.resources),\n },\n profile: enrichedThreadProfile,\n transactions: [\n {\n name: event.transaction || '',\n id: event.event_id || uuid4(),\n trace_id: traceId,\n active_thread_id: PROFILER_THREAD_ID_STRING,\n relative_start_ns: '0',\n relative_end_ns: ((transactionEndMs - transactionStartMs) * 1e6).toFixed(0),\n },\n ],\n };\n\n return profile;\n}\n\n/**\n * Create a profile chunk envelope item\n */\nexport function createProfileChunkPayload(\n jsSelfProfile: JSSelfProfile,\n client: Client,\n profilerId?: string,\n): ProfileChunk {\n // only == to catch null and undefined\n if (jsSelfProfile == null) {\n throw new TypeError(\n `Cannot construct profiling event envelope without a valid profile. Got ${jsSelfProfile} instead.`,\n );\n }\n\n const continuousProfile = convertToContinuousProfile(jsSelfProfile);\n\n const options = client.getOptions();\n const sdk = client.getSdkMetadata?.()?.sdk;\n\n return {\n chunk_id: uuid4(),\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.browser',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profilerId || uuid4(),\n platform: 'javascript',\n version: '2',\n release: options.release ?? '',\n environment: options.environment ?? 'production',\n debug_meta: {\n // function name obfuscation\n images: applyDebugMetadata(jsSelfProfile.resources),\n },\n profile: continuousProfile,\n };\n}\n\n/**\n * Validate a profile chunk against the Sample Format V2 requirements.\n * https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/\n * - Presence of samples, stacks, frames\n * - Required metadata fields\n */\nexport function validateProfileChunk(chunk: ProfileChunk): { valid: true } | { reason: string } {\n try {\n // Required metadata\n if (!chunk || typeof chunk !== 'object') {\n return { reason: 'chunk is not an object' };\n }\n\n // profiler_id and chunk_id must be 32 lowercase hex chars\n const isHex32 = (val: unknown): boolean => typeof val === 'string' && /^[a-f0-9]{32}$/.test(val);\n if (!isHex32(chunk.profiler_id)) {\n return { reason: 'missing or invalid profiler_id' };\n }\n if (!isHex32(chunk.chunk_id)) {\n return { reason: 'missing or invalid chunk_id' };\n }\n\n if (!chunk.client_sdk) {\n return { reason: 'missing client_sdk metadata' };\n }\n\n // Profile data must have frames, stacks, samples\n const profile = chunk.profile as { frames?: unknown[]; stacks?: unknown[]; samples?: unknown[] } | undefined;\n if (!profile) {\n return { reason: 'missing profile data' };\n }\n\n if (!Array.isArray(profile.frames) || !profile.frames.length) {\n return { reason: 'profile has no frames' };\n }\n if (!Array.isArray(profile.stacks) || !profile.stacks.length) {\n return { reason: 'profile has no stacks' };\n }\n if (!Array.isArray(profile.samples) || !profile.samples.length) {\n return { reason: 'profile has no samples' };\n }\n\n return { valid: true };\n } catch (e) {\n return { reason: `unknown validation error: ${e}` };\n }\n}\n\n/**\n * Convert from JSSelfProfile format to ContinuousThreadCpuProfile format.\n */\nfunction convertToContinuousProfile(input: {\n frames: { name: string; resourceId?: number; line?: number; column?: number }[];\n stacks: { frameId: number; parentId?: number }[];\n samples: { timestamp: number; stackId?: number }[];\n resources: string[];\n}): ContinuousThreadCpuProfile {\n // Frames map 1:1 by index; fill only when present to avoid sparse writes\n const frames: ContinuousThreadCpuProfile['frames'] = [];\n for (let i = 0; i < input.frames.length; i++) {\n const frame = input.frames[i];\n if (!frame) {\n continue;\n }\n frames[i] = {\n function: frame.name,\n abs_path: typeof frame.resourceId === 'number' ? input.resources[frame.resourceId] : undefined,\n lineno: frame.line,\n colno: frame.column,\n };\n }\n\n // Build stacks by following parent links, top->down order (root last)\n const stacks: ContinuousThreadCpuProfile['stacks'] = [];\n for (let i = 0; i < input.stacks.length; i++) {\n const stackHead = input.stacks[i];\n if (!stackHead) {\n continue;\n }\n const list: number[] = [];\n let current: { frameId: number; parentId?: number } | undefined = stackHead;\n while (current) {\n list.push(current.frameId);\n current = current.parentId === undefined ? undefined : input.stacks[current.parentId];\n }\n stacks[i] = list;\n }\n\n // Align timestamps to SDK time origin to match span/event timelines\n const perfOrigin = browserPerformanceTimeOrigin();\n const origin = typeof performance.timeOrigin === 'number' ? performance.timeOrigin : perfOrigin || 0;\n const adjustForOriginChange = origin - (perfOrigin || origin);\n\n const samples: ContinuousThreadCpuProfile['samples'] = [];\n for (let i = 0; i < input.samples.length; i++) {\n const sample = input.samples[i];\n if (!sample) {\n continue;\n }\n // Convert ms to seconds epoch-based timestamp\n const timestampSeconds = (origin + (sample.timestamp - adjustForOriginChange)) / 1000;\n samples[i] = {\n stack_id: sample.stackId ?? 0,\n thread_id: PROFILER_THREAD_ID_STRING,\n timestamp: timestampSeconds,\n };\n }\n\n return {\n frames,\n stacks,\n samples,\n thread_metadata: { [PROFILER_THREAD_ID_STRING]: { name: PROFILER_THREAD_NAME } },\n };\n}\n\n/**\n *\n */\nexport function isProfiledTransactionEvent(event: Event): event is ProfiledEvent {\n return !!event.sdkProcessingMetadata?.profile;\n}\n\n/*\n See packages/browser-utils/src/browser/router.ts\n*/\n/**\n *\n */\nexport function isAutomatedPageLoadSpan(span: Span): boolean {\n return spanToJSON(span).op === 'pageload';\n}\n\n/**\n * Converts a JSSelfProfile to a our sampled format.\n * Does not currently perform stack indexing.\n */\nexport function convertJSSelfProfileToSampledFormat(input: JSSelfProfile): Profile['profile'] {\n let EMPTY_STACK_ID: undefined | number = undefined;\n let STACK_ID = 0;\n\n // Initialize the profile that we will fill with data\n const profile: Profile['profile'] = {\n samples: [],\n stacks: [],\n frames: [],\n thread_metadata: {\n [PROFILER_THREAD_ID_STRING]: { name: PROFILER_THREAD_NAME },\n },\n };\n\n const firstSample = input.samples[0];\n if (!firstSample) {\n return profile;\n }\n\n // We assert samples.length > 0 above and timestamp should always be present\n const start = firstSample.timestamp;\n // The JS SDK might change it's time origin based on some heuristic (see See packages/utils/src/time.ts)\n // when that happens, we need to ensure we are correcting the profile timings so the two timelines stay in sync.\n // Since JS self profiling time origin is always initialized to performance.timeOrigin, we need to adjust for\n // the drift between the SDK selected value and our profile time origin.\n const perfOrigin = browserPerformanceTimeOrigin();\n const origin = typeof performance.timeOrigin === 'number' ? performance.timeOrigin : perfOrigin || 0;\n const adjustForOriginChange = origin - (perfOrigin || origin);\n\n input.samples.forEach((jsSample, i) => {\n // If sample has no stack, add an empty sample\n if (jsSample.stackId === undefined) {\n if (EMPTY_STACK_ID === undefined) {\n EMPTY_STACK_ID = STACK_ID;\n profile.stacks[EMPTY_STACK_ID] = [];\n STACK_ID++;\n }\n\n profile['samples'][i] = {\n // convert ms timestamp to ns\n elapsed_since_start_ns: ((jsSample.timestamp + adjustForOriginChange - start) * MS_TO_NS).toFixed(0),\n stack_id: EMPTY_STACK_ID,\n thread_id: PROFILER_THREAD_ID_STRING,\n };\n return;\n }\n\n let stackTop: JSSelfProfileStack | undefined = input.stacks[jsSample.stackId];\n\n // Functions in top->down order (root is last)\n // We follow the stackTop.parentId trail and collect each visited frameId\n const stack: number[] = [];\n\n while (stackTop) {\n stack.push(stackTop.frameId);\n\n const frame = input.frames[stackTop.frameId];\n\n // If our frame has not been indexed yet, index it\n if (frame && profile.frames[stackTop.frameId] === undefined) {\n profile.frames[stackTop.frameId] = {\n function: frame.name,\n abs_path: typeof frame.resourceId === 'number' ? input.resources[frame.resourceId] : undefined,\n lineno: frame.line,\n colno: frame.column,\n };\n }\n\n stackTop = stackTop.parentId === undefined ? undefined : input.stacks[stackTop.parentId];\n }\n\n const sample: Profile['profile']['samples'][0] = {\n // convert ms timestamp to ns\n elapsed_since_start_ns: ((jsSample.timestamp + adjustForOriginChange - start) * MS_TO_NS).toFixed(0),\n stack_id: STACK_ID,\n thread_id: PROFILER_THREAD_ID_STRING,\n };\n\n profile['stacks'][STACK_ID] = stack;\n profile['samples'][i] = sample;\n STACK_ID++;\n });\n\n return profile;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param envelope\n */\nexport function addProfilesToEnvelope(envelope: EventEnvelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param envelope\n * @returns\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: Event[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n for (let j = 1; j < item.length; j++) {\n const event = item[j] as Event;\n\n if (event?.contexts?.profile?.profile_id) {\n events.push(item[j] as Event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Applies debug meta data to an event from a list of paths to resources (sourcemaps)\n */\nexport function applyDebugMetadata(resource_paths: ReadonlyArray<string>): DebugImage[] {\n const client = getClient();\n const options = client?.getOptions();\n const stackParser = options?.stackParser;\n\n if (!stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(stackParser, resource_paths);\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n debug.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && debug.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\nfunction isValidProfile(profile: JSSelfProfile): profile is JSSelfProfile & { profile_id: string } {\n if (profile.samples.length < 2) {\n if (DEBUG_BUILD) {\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n debug.log('[Profiling] Discarding profile because it contains less than 2 samples');\n }\n return false;\n }\n\n if (!profile.frames.length) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] Discarding profile because it contains no frames');\n }\n return false;\n }\n\n return true;\n}\n\n// Keep a flag value to avoid re-initializing the profiler constructor. If it fails\n// once, it will always fail and this allows us to early return.\nlet PROFILING_CONSTRUCTOR_FAILED: boolean = false;\nexport const MAX_PROFILE_DURATION_MS = 30_000;\n\n/**\n * Check if profiler constructor is available.\n * @param maybeProfiler\n */\nfunction isJSProfilerSupported(maybeProfiler: unknown): maybeProfiler is typeof JSSelfProfilerConstructor {\n return typeof maybeProfiler === 'function';\n}\n\n/**\n * Starts the profiler and returns the profiler instance.\n */\nexport function startJSSelfProfile(): JSSelfProfiler | undefined {\n // Feature support check first\n const JSProfilerConstructor = WINDOW.Profiler;\n\n if (!isJSProfilerSupported(JSProfilerConstructor)) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.');\n }\n return;\n }\n\n // From initial testing, it seems that the minimum value for sampleInterval is 10ms.\n const samplingIntervalMS = 10;\n // Start the profiler\n const maxSamples = Math.floor(MAX_PROFILE_DURATION_MS / samplingIntervalMS);\n\n // Attempt to initialize the profiler constructor, if it fails, we disable profiling for the current user session.\n // This is likely due to a missing 'Document-Policy': 'js-profiling' header. We do not want to throw an error if this happens\n // as we risk breaking the user's application, so just disable profiling and log an error.\n try {\n return new JSProfilerConstructor({ sampleInterval: samplingIntervalMS, maxBufferSize: maxSamples });\n } catch {\n if (DEBUG_BUILD) {\n debug.log(\n \"[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.\",\n );\n debug.log('[Profiling] Disabling profiling for current user session.');\n }\n PROFILING_CONSTRUCTOR_FAILED = true;\n }\n\n return;\n}\n\n/**\n * Determine if a profile should be profiled.\n */\nexport function shouldProfileSpanLegacy(span: Span): boolean {\n // If constructor failed once, it will always fail, so we can early return.\n if (PROFILING_CONSTRUCTOR_FAILED) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] Profiling has been disabled for the duration of the current user session.');\n }\n return false;\n }\n\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return false;\n }\n\n const client = getClient();\n const options = client?.getOptions();\n if (!options) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no options found.');\n return false;\n }\n\n // eslint-disable-next-line typescript/no-deprecated\n const profilesSampleRate = (options as BrowserOptions).profilesSampleRate as\n | BrowserOptions['profilesSampleRate']\n | boolean;\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(profilesSampleRate)) {\n DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid sample rate.');\n return false;\n }\n\n // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped\n if (!profilesSampleRate) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0',\n );\n return false;\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;\n // Check if we should sample this profile\n if (!sampled) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(\n profilesSampleRate,\n )})`,\n );\n return false;\n }\n\n return true;\n}\n\n/**\n * Determine if a profile should be created for the current session.\n */\nexport function shouldProfileSession(options: BrowserOptions): boolean {\n // If constructor failed once, it will always fail, so we can early return.\n if (PROFILING_CONSTRUCTOR_FAILED) {\n if (DEBUG_BUILD) {\n debug.log(\n '[Profiling] Profiling has been disabled for the duration of the current user session as the JS Profiler could not be started.',\n );\n }\n return false;\n }\n\n if (options.profileLifecycle !== 'trace' && options.profileLifecycle !== 'manual') {\n DEBUG_BUILD && debug.warn('[Profiling] Session not sampled. Invalid `profileLifecycle` option.');\n return false;\n }\n\n // Session sampling: profileSessionSampleRate gates whether profiling is enabled for this session\n const profileSessionSampleRate = options.profileSessionSampleRate;\n\n if (!isValidSampleRate(profileSessionSampleRate)) {\n DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid profileSessionSampleRate.');\n return false;\n }\n\n if (!profileSessionSampleRate) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0');\n return false;\n }\n\n return Math.random() <= profileSessionSampleRate;\n}\n\n/**\n * Checks if legacy profiling is configured.\n */\nexport function hasLegacyProfiling(options: BrowserOptions): boolean {\n // eslint-disable-next-line typescript/no-deprecated\n return typeof options.profilesSampleRate !== 'undefined';\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param event\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(\n profile_id: string,\n start_timestamp: number | undefined,\n profile: JSSelfProfile,\n event: ProfiledEvent,\n): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(profile_id, start_timestamp, profile, event);\n}\n\n// TODO (v8): We need to obtain profile ids in @sentry-internal/tracing,\n// but we don't have access to this map because importing this map would\n// cause a circular dependency. We need to resolve this in v8.\nconst PROFILE_MAP: Map<string, JSSelfProfile> = new Map();\n/**\n *\n */\nexport function getActiveProfilesCount(): number {\n return PROFILE_MAP.size;\n}\n\n/**\n * Retrieves profile from global cache and removes it.\n */\nexport function takeProfileFromGlobalCache(profile_id: string): JSSelfProfile | undefined {\n const profile = PROFILE_MAP.get(profile_id);\n if (profile) {\n PROFILE_MAP.delete(profile_id);\n }\n return profile;\n}\n/**\n * Adds profile to global cache and evicts the oldest profile if the cache is full.\n */\nexport function addProfileToGlobalCache(profile_id: string, profile: JSSelfProfile): void {\n PROFILE_MAP.set(profile_id, profile);\n\n if (PROFILE_MAP.size > 30) {\n const last = PROFILE_MAP.keys().next().value;\n if (last !== undefined) {\n PROFILE_MAP.delete(last);\n }\n }\n}\n\nexport const PROFILED_ROOT_SPANS = new WeakSet<Span>();\n\nexport function setThreadAttributes(span: Span): void {\n span.setAttribute('thread.id', PROFILER_THREAD_ID_STRING);\n span.setAttribute('thread.name', PROFILER_THREAD_NAME);\n}\n"],"names":["GLOBAL_OBJ","WINDOW","DEBUG_BUILD","debug","timestampInSeconds","DEFAULT_ENVIRONMENT","uuid4","browserPerformanceTimeOrigin","spanToJSON","forEachEnvelopeItem","getClient","getDebugImagesForResources"],"mappings":";;;;;;AA8BA,MAAM,QAAA,GAAW,GAAA;AAGjB,MAAM,eAAe,QAAA,IAAYA,kBAAA,IAAcA,mBAAW,MAAA,KAAWA,kBAAA,IAAc,OAAO,aAAA,KAAkB,WAAA;AAGrG,MAAM,yBAAA,GAA4B,OAAO,CAAC;AAC1C,MAAM,oBAAA,GAAuB,eAAe,MAAA,GAAS;AAG5D,MAAM,YAAYC,cAAA,CAAO,SAAA;AAGzB,IAAI,WAAA,GAAc,EAAA;AAClB,IAAI,mBAAA,GAAsB,EAAA;AAC1B,IAAI,OAAA,GAAU,EAAA;AACd,IAAI,UAAA,GAAa,WAAW,SAAA,IAAa,EAAA;AACzC,IAAI,QAAA,GAAW,EA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;AAEA,EAAA,OAAO,oBAAA,CAAqB,UAAA,EAAY,eAAA,EAAiB,OAAA,EAAS,KAAK,CAAA;AACzE;AAKA,MAAM,WAAA,uBAA8C,GAAA,EAAI;AAIjD,SAAS,sBAAA,GAAiC;AAC/C,EAAA,OAAO,WAAA,CAAY,IAAA;AACrB;AAKO,SAAS,2BAA2B,UAAA,EAA+C;AACxF,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,GAAA,CAAI,UAAU,CAAA;AAC1C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,WAAA,CAAY,OAAO,UAAU,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,OAAA;AACT;AAIO,SAAS,uBAAA,CAAwB,YAAoB,OAAA,EAA8B;AACxF,EAAA,WAAA,CAAY,GAAA,CAAI,YAAY,OAAO,CAAA;AAEnC,EAAA,IAAI,WAAA,CAAY,OAAO,EAAA,EAAI;AACzB,IAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAK,CAAE,MAAK,CAAE,KAAA;AACvC,IAAA,IAAI,SAAS,MAAA,EAAW;AACtB,MAAA,WAAA,CAAY,OAAO,IAAI,CAAA;AAAA,IACzB;AAAA,EACF;AACF;AAEO,MAAM,mBAAA,uBAA0B,OAAA;AAEhC,SAAS,oBAAoB,IAAA,EAAkB;AACpD,EAAA,IAAA,CAAK,YAAA,CAAa,aAAa,yBAAyB,CAAA;AACxD,EAAA,IAAA,CAAK,YAAA,CAAa,eAAe,oBAAoB,CAAA;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../src/profiling/utils.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, ContinuousThreadCpuProfile, DebugImage, ProfileChunk, Span } from '@sentry/core/browser';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getClient,\n getDebugImagesForResources,\n GLOBAL_OBJ,\n uuid4,\n} from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport type { JSSelfProfile, JSSelfProfiler, JSSelfProfilerConstructor } from './jsSelfProfiling';\n\n// Checking if we are in Main or Worker thread: `self` (not `window`) is the `globalThis` in Web Workers and `importScripts` are only available in Web Workers\nconst isMainThread = 'window' in GLOBAL_OBJ && GLOBAL_OBJ.window === GLOBAL_OBJ && typeof importScripts === 'undefined';\n\n// Setting ID to 0 as we cannot get an ID from Web Workers\nexport const PROFILER_THREAD_ID_STRING = String(0);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\n\n/**\n * Create a profile chunk envelope item\n */\nexport function createProfileChunkPayload(\n jsSelfProfile: JSSelfProfile,\n client: Client,\n profilerId?: string,\n): ProfileChunk {\n // only == to catch null and undefined\n if (jsSelfProfile == null) {\n throw new TypeError(\n `Cannot construct profiling event envelope without a valid profile. Got ${jsSelfProfile} instead.`,\n );\n }\n\n const continuousProfile = convertToContinuousProfile(jsSelfProfile);\n\n const options = client.getOptions();\n const sdk = client.getSdkMetadata?.()?.sdk;\n\n return {\n chunk_id: uuid4(),\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.browser',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profilerId || uuid4(),\n platform: 'javascript',\n version: '2',\n release: options.release ?? '',\n environment: options.environment ?? 'production',\n debug_meta: {\n // function name obfuscation\n images: applyDebugMetadata(jsSelfProfile.resources),\n },\n profile: continuousProfile,\n };\n}\n\n/**\n * Validate a profile chunk against the Sample Format V2 requirements.\n * https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/\n * - Presence of samples, stacks, frames\n * - Required metadata fields\n */\nexport function validateProfileChunk(chunk: ProfileChunk): { valid: true } | { reason: string } {\n try {\n // Required metadata\n if (!chunk || typeof chunk !== 'object') {\n return { reason: 'chunk is not an object' };\n }\n\n // profiler_id and chunk_id must be 32 lowercase hex chars\n const isHex32 = (val: unknown): boolean => typeof val === 'string' && /^[a-f0-9]{32}$/.test(val);\n if (!isHex32(chunk.profiler_id)) {\n return { reason: 'missing or invalid profiler_id' };\n }\n if (!isHex32(chunk.chunk_id)) {\n return { reason: 'missing or invalid chunk_id' };\n }\n\n if (!chunk.client_sdk) {\n return { reason: 'missing client_sdk metadata' };\n }\n\n // Profile data must have frames, stacks, samples\n const profile = chunk.profile as { frames?: unknown[]; stacks?: unknown[]; samples?: unknown[] } | undefined;\n if (!profile) {\n return { reason: 'missing profile data' };\n }\n\n if (!Array.isArray(profile.frames) || !profile.frames.length) {\n return { reason: 'profile has no frames' };\n }\n if (!Array.isArray(profile.stacks) || !profile.stacks.length) {\n return { reason: 'profile has no stacks' };\n }\n if (!Array.isArray(profile.samples) || !profile.samples.length) {\n return { reason: 'profile has no samples' };\n }\n\n return { valid: true };\n } catch (e) {\n return { reason: `unknown validation error: ${e}` };\n }\n}\n\n/**\n * Convert from JSSelfProfile format to ContinuousThreadCpuProfile format.\n */\nfunction convertToContinuousProfile(input: {\n frames: { name: string; resourceId?: number; line?: number; column?: number }[];\n stacks: { frameId: number; parentId?: number }[];\n samples: { timestamp: number; stackId?: number }[];\n resources: string[];\n}): ContinuousThreadCpuProfile {\n // Frames map 1:1 by index; fill only when present to avoid sparse writes\n const frames: ContinuousThreadCpuProfile['frames'] = [];\n for (let i = 0; i < input.frames.length; i++) {\n const frame = input.frames[i];\n if (!frame) {\n continue;\n }\n frames[i] = {\n function: frame.name,\n abs_path: typeof frame.resourceId === 'number' ? input.resources[frame.resourceId] : undefined,\n lineno: frame.line,\n colno: frame.column,\n };\n }\n\n // Build stacks by following parent links, top->down order (root last)\n const stacks: ContinuousThreadCpuProfile['stacks'] = [];\n for (let i = 0; i < input.stacks.length; i++) {\n const stackHead = input.stacks[i];\n if (!stackHead) {\n continue;\n }\n const list: number[] = [];\n let current: { frameId: number; parentId?: number } | undefined = stackHead;\n while (current) {\n list.push(current.frameId);\n current = current.parentId === undefined ? undefined : input.stacks[current.parentId];\n }\n stacks[i] = list;\n }\n\n // Align timestamps to SDK time origin to match span/event timelines\n const perfOrigin = browserPerformanceTimeOrigin();\n const origin = typeof performance.timeOrigin === 'number' ? performance.timeOrigin : perfOrigin || 0;\n const adjustForOriginChange = origin - (perfOrigin || origin);\n\n const samples: ContinuousThreadCpuProfile['samples'] = [];\n for (let i = 0; i < input.samples.length; i++) {\n const sample = input.samples[i];\n if (!sample) {\n continue;\n }\n // Convert ms to seconds epoch-based timestamp\n const timestampSeconds = (origin + (sample.timestamp - adjustForOriginChange)) / 1000;\n samples[i] = {\n stack_id: sample.stackId ?? 0,\n thread_id: PROFILER_THREAD_ID_STRING,\n timestamp: timestampSeconds,\n };\n }\n\n return {\n frames,\n stacks,\n samples,\n thread_metadata: { [PROFILER_THREAD_ID_STRING]: { name: PROFILER_THREAD_NAME } },\n };\n}\n\n/**\n * Applies debug meta data to an event from a list of paths to resources (sourcemaps)\n */\nexport function applyDebugMetadata(resource_paths: ReadonlyArray<string>): DebugImage[] {\n const client = getClient();\n const options = client?.getOptions();\n const stackParser = options?.stackParser;\n\n if (!stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(stackParser, resource_paths);\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n debug.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && debug.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\n// Keep a flag value to avoid re-initializing the profiler constructor. If it fails\n// once, it will always fail and this allows us to early return.\nlet PROFILING_CONSTRUCTOR_FAILED: boolean = false;\nexport const MAX_PROFILE_DURATION_MS = 30_000;\n\n/**\n * Check if profiler constructor is available.\n * @param maybeProfiler\n */\nfunction isJSProfilerSupported(maybeProfiler: unknown): maybeProfiler is typeof JSSelfProfilerConstructor {\n return typeof maybeProfiler === 'function';\n}\n\n/**\n * Starts the profiler and returns the profiler instance.\n */\nexport function startJSSelfProfile(): JSSelfProfiler | undefined {\n // Feature support check first\n const JSProfilerConstructor = WINDOW.Profiler;\n\n if (!isJSProfilerSupported(JSProfilerConstructor)) {\n if (DEBUG_BUILD) {\n debug.log('[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.');\n }\n return;\n }\n\n // From initial testing, it seems that the minimum value for sampleInterval is 10ms.\n const samplingIntervalMS = 10;\n // Start the profiler\n const maxSamples = Math.floor(MAX_PROFILE_DURATION_MS / samplingIntervalMS);\n\n // Attempt to initialize the profiler constructor, if it fails, we disable profiling for the current user session.\n // This is likely due to a missing 'Document-Policy': 'js-profiling' header. We do not want to throw an error if this happens\n // as we risk breaking the user's application, so just disable profiling and log an error.\n try {\n return new JSProfilerConstructor({ sampleInterval: samplingIntervalMS, maxBufferSize: maxSamples });\n } catch {\n if (DEBUG_BUILD) {\n debug.log(\n \"[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.\",\n );\n debug.log('[Profiling] Disabling profiling for current user session.');\n }\n PROFILING_CONSTRUCTOR_FAILED = true;\n }\n\n return;\n}\n\n/**\n * Determine if a profile should be created for the current session.\n */\nexport function shouldProfileSession(options: BrowserOptions): boolean {\n // If constructor failed once, it will always fail, so we can early return.\n if (PROFILING_CONSTRUCTOR_FAILED) {\n if (DEBUG_BUILD) {\n debug.log(\n '[Profiling] Profiling has been disabled for the duration of the current user session as the JS Profiler could not be started.',\n );\n }\n return false;\n }\n\n if (options.profileLifecycle !== 'trace' && options.profileLifecycle !== 'manual') {\n DEBUG_BUILD && debug.warn('[Profiling] Session not sampled. Invalid `profileLifecycle` option.');\n return false;\n }\n\n // Session sampling: profileSessionSampleRate gates whether profiling is enabled for this session\n const profileSessionSampleRate = options.profileSessionSampleRate;\n\n if (!isValidSampleRate(profileSessionSampleRate)) {\n DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid profileSessionSampleRate.');\n return false;\n }\n\n if (!profileSessionSampleRate) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0');\n return false;\n }\n\n return Math.random() <= profileSessionSampleRate;\n}\n\nexport function setThreadAttributes(span: Span): void {\n span.setAttribute('thread.id', PROFILER_THREAD_ID_STRING);\n span.setAttribute('thread.name', PROFILER_THREAD_NAME);\n}\n"],"names":["GLOBAL_OBJ","uuid4","browserPerformanceTimeOrigin","getClient","getDebugImagesForResources","DEBUG_BUILD","debug","WINDOW"],"mappings":";;;;;;AAgBA,MAAM,eAAe,QAAA,IAAYA,kBAAA,IAAcA,mBAAW,MAAA,KAAWA,kBAAA,IAAc,OAAO,aAAA,KAAkB,WAAA;AAGrG,MAAM,yBAAA,GAA4B,OAAO,CAAC;AAC1C,MAAM,oBAAA,GAAuB,eAAe,MAAA,GAAS;AAKrD,SAAS,yBAAA,CACd,aAAA,EACA,MAAA,EACA,UAAA,EACc;AAEd,EAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,0EAA0E,aAAa,CAAA,SAAA;AAAA,KACzF;AAAA,EACF;AAEA,EAAA,MAAM,iBAAA,GAAoB,2BAA2B,aAAa,CAAA;AAElE,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,cAAA,IAAiB,EAAG,GAAA;AAEvC,EAAA,OAAO;AAAA,IACL,U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A,CAAQ,qBAAqB,QAAA,EAAU;AACjF,IAAAD,sBAAA,IAAeC,aAAA,CAAM,KAAK,qEAAqE,CAAA;AAC/F,IAAA,OAAO,KAAA;AAAA,EACT;AAGA,EAAA,MAAM,2BAA2B,OAAA,CAAQ,wBAAA;AAEzC,EAAA,IAAI,CAAC,iBAAA,CAAkB,wBAAwB,CAAA,EAAG;AAChD,IAAAD,sBAAA,IAAeC,aAAA,CAAM,KAAK,6EAA6E,CAAA;AACvG,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAAD,sBAAA,IACEC,aAAA,CAAM,IAAI,4FAA4F,CAAA;AACxG,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA,CAAK,QAAO,IAAK,wBAAA;AAC1B;AAEO,SAAS,oBAAoB,IAAA,EAAkB;AACpD,EAAA,IAAA,CAAK,YAAA,CAAa,aAAa,yBAAyB,CAAA;AACxD,EAAA,IAAA,CAAK,YAAA,CAAa,eAAe,oBAAoB,CAAA;AACvD;;;;;;;;;;;;;"}
|
|
@@ -9,7 +9,6 @@ const culturecontext = require('./integrations/culturecontext.js');
|
|
|
9
9
|
const globalhandlers = require('./integrations/globalhandlers.js');
|
|
10
10
|
const httpcontext = require('./integrations/httpcontext.js');
|
|
11
11
|
const linkederrors = require('./integrations/linkederrors.js');
|
|
12
|
-
const spanstreaming = require('./integrations/spanstreaming.js');
|
|
13
12
|
const stackParsers = require('./stack-parsers.js');
|
|
14
13
|
const fetch = require('./transports/fetch.js');
|
|
15
14
|
const normalizeStringifyValue = require('./normalizeStringifyValue.js');
|
|
@@ -37,9 +36,6 @@ function init(options = {}) {
|
|
|
37
36
|
integrations: options.integrations,
|
|
38
37
|
defaultIntegrations
|
|
39
38
|
});
|
|
40
|
-
if ((typeof __SENTRY_TRACING__ === "undefined" || __SENTRY_TRACING__) && options.traceLifecycle !== "static" && !integrations.some((integration) => integration.name === spanstreaming.INTEGRATION_NAME)) {
|
|
41
|
-
integrations.push(spanstreaming.spanStreamingIntegration());
|
|
42
|
-
}
|
|
43
39
|
const clientOptions = {
|
|
44
40
|
...options,
|
|
45
41
|
enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core/browser';\nimport {\n conversationIdIntegration,\n dedupeIntegration,\n eventFiltersIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n initAndBind,\n setNormalizeStringifier,\n stackParserFromStackParserOptions,\n} from '@sentry/core/browser';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { cultureContextIntegration } from './integrations/culturecontext';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { spotlightBrowserIntegration } from './integrations/spotlight';\nimport {
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core/browser';\nimport {\n conversationIdIntegration,\n dedupeIntegration,\n eventFiltersIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n initAndBind,\n setNormalizeStringifier,\n stackParserFromStackParserOptions,\n} from '@sentry/core/browser';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { cultureContextIntegration } from './integrations/culturecontext';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { spotlightBrowserIntegration } from './integrations/spotlight';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\nimport { normalizeStringifyValue } from './normalizeStringifyValue';\nimport { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension';\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n eventFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n cultureContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): Client | undefined {\n const shouldDisableBecauseIsBrowserExtenstion =\n !options.skipBrowserExtensionCheck && checkAndWarnIfIsEmbeddedBrowserExtension();\n\n let defaultIntegrations =\n options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations;\n\n /*! rollup-include-development-only */\n if (options.spotlight) {\n if (!defaultIntegrations) {\n defaultIntegrations = [];\n }\n const args = typeof options.spotlight === 'string' ? { sidecarUrl: options.spotlight } : undefined;\n defaultIntegrations.push(spotlightBrowserIntegration(args));\n }\n /*! rollup-include-development-only-end */\n\n const integrations = getIntegrationsToSetup({\n integrations: options.integrations,\n defaultIntegrations,\n });\n\n const clientOptions: BrowserClientOptions = {\n ...options,\n enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations,\n transport: options.transport || makeFetchTransport,\n };\n\n setNormalizeStringifier(normalizeStringifyValue);\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n"],"names":["eventFiltersIntegration","functionToStringIntegration","conversationIdIntegration","browserApiErrorsIntegration","breadcrumbsIntegration","globalHandlersIntegration","linkedErrorsIntegration","dedupeIntegration","httpContextIntegration","cultureContextIntegration","browserSessionIntegration","checkAndWarnIfIsEmbeddedBrowserExtension","getIntegrationsToSetup","stackParserFromStackParserOptions","defaultStackParser","makeFetchTransport","setNormalizeStringifier","normalizeStringifyValue","initAndBind","BrowserClient"],"mappings":";;;;;;;;;;;;;;;;AA2BO,SAAS,uBAAuB,QAAA,EAAkC;AAKvE,EAAA,OAAO;AAAA,IACLA,+BAAA,EAAwB;AAAA,IACxBC,mCAAA,EAA4B;AAAA,IAC5BC,iCAAA,EAA0B;AAAA,IAC1BC,4CAAA,EAA4B;AAAA,IAC5BC,kCAAA,EAAuB;AAAA,IACvBC,wCAAA,EAA0B;AAAA,IAC1BC,oCAAA,EAAwB;AAAA,IACxBC,yBAAA,EAAkB;AAAA,IAClBC,kCAAA,EAAuB;AAAA,IACvBC,wCAAA,EAA0B;AAAA,IAC1BC,wCAAA;AAA0B,GAC5B;AACF;AAgDO,SAAS,IAAA,CAAK,OAAA,GAA0B,EAAC,EAAuB;AACrE,EAAA,MAAM,uCAAA,GACJ,CAAC,OAAA,CAAQ,yBAAA,IAA6BC,+DAAA,EAAyC;AAEjF,EAAA,IAAI,sBACF,OAAA,CAAQ,mBAAA,IAAuB,OAAO,sBAAA,CAA8B,IAAI,OAAA,CAAQ,mBAAA;AAElF,EAAA,MAAM,eAAeC,8BAAA,CAAuB;AAAA,IAC1C,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB;AAAA,GACD,CAAA;AAED,EAAA,MAAM,aAAA,GAAsC;AAAA,IAC1C,GAAG,OAAA;AAAA,IACH,OAAA,EAAS,uCAAA,GAA0C,KAAA,GAAQ,OAAA,CAAQ,OAAA;AAAA,IACnE,WAAA,EAAaC,yCAAA,CAAkC,OAAA,CAAQ,WAAA,IAAeC,+BAAkB,CAAA;AAAA,IACxF,YAAA;AAAA,IACA,SAAA,EAAW,QAAQ,SAAA,IAAaC;AAAA,GAClC;AAEA,EAAAC,+BAAA,CAAwBC,+CAAuB,CAAA;AAE/C,EAAA,OAAOC,mBAAA,CAAYC,sBAAe,aAAa,CAAA;AACjD;AAMO,SAAS,SAAA,GAAkB;AAElC;AAMO,SAAS,OAAO,QAAA,EAA4B;AACjD,EAAA,QAAA,EAAS;AACX;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const browser = require('@sentry/core/browser');
|
|
4
4
|
const debugBuild = require('../debug-build.js');
|
|
5
5
|
const helpers = require('../helpers.js');
|
|
6
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
6
7
|
|
|
7
8
|
function registerBackgroundTabDetection() {
|
|
8
9
|
if (helpers.WINDOW.document) {
|
|
@@ -14,7 +15,10 @@ function registerBackgroundTabDetection() {
|
|
|
14
15
|
const rootSpan = browser.getRootSpan(activeSpan);
|
|
15
16
|
if (helpers.WINDOW.document.hidden && rootSpan) {
|
|
16
17
|
const cancelledStatus = "cancelled";
|
|
17
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
attributes: { [attributes.SENTRY_OP]: op },
|
|
20
|
+
status
|
|
21
|
+
} = browser.spanToJSON(rootSpan);
|
|
18
22
|
if (debugBuild.DEBUG_BUILD) {
|
|
19
23
|
browser.debug.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);
|
|
20
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backgroundtab.js","sources":["../../../../../src/tracing/backgroundtab.ts"],"sourcesContent":["import { debug, getActiveSpan, getRootSpan, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\n/**\n * Add a listener that cancels and finishes a transaction when the global\n * document is hidden.\n */\nexport function registerBackgroundTabDetection(): void {\n if (WINDOW.document) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n\n const rootSpan = getRootSpan(activeSpan);\n\n if (WINDOW.document.hidden && rootSpan) {\n const cancelledStatus = 'cancelled';\n\n const { op
|
|
1
|
+
{"version":3,"file":"backgroundtab.js","sources":["../../../../../src/tracing/backgroundtab.ts"],"sourcesContent":["import { debug, getActiveSpan, getRootSpan, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { SENTRY_OP } from '@sentry/conventions/attributes';\n\n/**\n * Add a listener that cancels and finishes a transaction when the global\n * document is hidden.\n */\nexport function registerBackgroundTabDetection(): void {\n if (WINDOW.document) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n\n const rootSpan = getRootSpan(activeSpan);\n\n if (WINDOW.document.hidden && rootSpan) {\n const cancelledStatus = 'cancelled';\n\n const {\n attributes: { [SENTRY_OP]: op },\n status,\n } = spanToJSON(rootSpan);\n\n if (DEBUG_BUILD) {\n debug.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);\n }\n\n // We should not set status if it is already set, this prevent important statuses like\n // error or data loss from being overwritten on transaction.\n if (status === 'ok') {\n rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: cancelledStatus });\n }\n\n rootSpan.setAttribute('sentry.cancellation_reason', 'document.hidden');\n rootSpan.end();\n }\n });\n } else {\n DEBUG_BUILD && debug.warn('[Tracing] Could not set up background tab detection due to lack of global document');\n }\n}\n"],"names":["WINDOW","getActiveSpan","getRootSpan","SENTRY_OP","spanToJSON","DEBUG_BUILD","debug","SPAN_STATUS_ERROR"],"mappings":";;;;;;;AASO,SAAS,8BAAA,GAAuC;AACrD,EAAA,IAAIA,eAAO,QAAA,EAAU;AACnB,IAAAA,cAAA,CAAO,QAAA,CAAS,gBAAA,CAAiB,kBAAA,EAAoB,MAAM;AACzD,MAAA,MAAM,aAAaC,qBAAA,EAAc;AACjC,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,QAAA,GAAWC,oBAAY,UAAU,CAAA;AAEvC,MAAA,IAAIF,cAAA,CAAO,QAAA,CAAS,MAAA,IAAU,QAAA,EAAU;AACtC,QAAA,MAAM,eAAA,GAAkB,WAAA;AAExB,QAAA,MAAM;AAAA,UACJ,UAAA,EAAY,EAAE,CAACG,oBAAS,GAAG,EAAA,EAAG;AAAA,UAC9B;AAAA,SACF,GAAIC,mBAAW,QAAQ,CAAA;AAEvB,QAAA,IAAIC,sBAAA,EAAa;AACf,UAAAC,aAAA,CAAM,GAAA,CAAI,CAAA,uBAAA,EAA0B,eAAe,CAAA,2CAAA,EAA8C,EAAE,CAAA,CAAE,CAAA;AAAA,QACvG;AAIA,QAAA,IAAI,WAAW,IAAA,EAAM;AACnB,UAAA,QAAA,CAAS,UAAU,EAAE,IAAA,EAAMC,yBAAA,EAAmB,OAAA,EAAS,iBAAiB,CAAA;AAAA,QAC1E;AAEA,QAAA,QAAA,CAAS,YAAA,CAAa,8BAA8B,iBAAiB,CAAA;AACrE,QAAA,QAAA,CAAS,GAAA,EAAI;AAAA,MACf;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAA,MAAO;AACL,IAAAF,sBAAA,IAAeC,aAAA,CAAM,KAAK,oFAAoF,CAAA;AAAA,EAChH;AACF;;;;"}
|
|
@@ -5,7 +5,6 @@ const browserUtils = require('@sentry/browser-utils');
|
|
|
5
5
|
const debugBuild = require('../debug-build.js');
|
|
6
6
|
const core = require('@sentry/core');
|
|
7
7
|
const helpers = require('../helpers.js');
|
|
8
|
-
const fetchStreamPerformance = require('../integrations/fetchStreamPerformance.js');
|
|
9
8
|
const webVitals = require('../integrations/webVitals.js');
|
|
10
9
|
const backgroundtab = require('./backgroundtab.js');
|
|
11
10
|
const linkedTraces = require('./linkedTraces.js');
|
|
@@ -13,14 +12,6 @@ const request = require('./request.js');
|
|
|
13
12
|
const attributes = require('@sentry/conventions/attributes');
|
|
14
13
|
|
|
15
14
|
const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
|
|
16
|
-
const BOT_USER_AGENT_RE = /Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Facebot|facebookexternalhit|LinkedInBot|Twitterbot|Applebot/i;
|
|
17
|
-
function isBotUserAgent() {
|
|
18
|
-
const nav = helpers.WINDOW.navigator;
|
|
19
|
-
if (!nav?.userAgent) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return BOT_USER_AGENT_RE.test(nav.userAgent);
|
|
23
|
-
}
|
|
24
15
|
const DEFAULT_BROWSER_TRACING_OPTIONS = {
|
|
25
16
|
...browser.TRACING_DEFAULTS,
|
|
26
17
|
instrumentNavigation: true,
|
|
@@ -34,7 +25,6 @@ const DEFAULT_BROWSER_TRACING_OPTIONS = {
|
|
|
34
25
|
linkPreviousTrace: "in-memory",
|
|
35
26
|
consistentTraceSampling: false,
|
|
36
27
|
enableReportPageLoaded: false,
|
|
37
|
-
_experiments: {},
|
|
38
28
|
...request.defaultRequestInstrumentationOptions
|
|
39
29
|
};
|
|
40
30
|
const browserTracingIntegration = ((options = {}) => {
|
|
@@ -45,16 +35,11 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
45
35
|
);
|
|
46
36
|
});
|
|
47
37
|
}
|
|
48
|
-
const latestRoute = {
|
|
49
|
-
name: void 0,
|
|
50
|
-
source: void 0
|
|
51
|
-
};
|
|
52
38
|
const optionalWindowDocument = helpers.WINDOW.document;
|
|
53
39
|
const {
|
|
54
40
|
enableInp,
|
|
55
41
|
enableLongTask,
|
|
56
42
|
enableLongAnimationFrame,
|
|
57
|
-
_experiments: { enableInteractions },
|
|
58
43
|
beforeStartSpan,
|
|
59
44
|
idleTimeout,
|
|
60
45
|
finalTimeout,
|
|
@@ -62,8 +47,6 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
62
47
|
markBackgroundSpan,
|
|
63
48
|
traceFetch,
|
|
64
49
|
traceXHR,
|
|
65
|
-
// eslint-disable-next-line typescript/no-deprecated
|
|
66
|
-
trackFetchStreamPerformance,
|
|
67
50
|
shouldCreateSpanForRequest,
|
|
68
51
|
enableHTTPTimings,
|
|
69
52
|
ignoreResourceSpans,
|
|
@@ -79,21 +62,21 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
79
62
|
...DEFAULT_BROWSER_TRACING_OPTIONS,
|
|
80
63
|
...options
|
|
81
64
|
};
|
|
82
|
-
const _isBot = isBotUserAgent();
|
|
65
|
+
const _isBot = browserUtils.isBotUserAgent();
|
|
83
66
|
let lastInteractionTimestamp;
|
|
84
67
|
let _pageloadSpan;
|
|
85
68
|
function _createRouteSpan(client, startSpanOptions, makeActive = true, url) {
|
|
86
69
|
const isPageloadSpan = startSpanOptions.op === "pageload";
|
|
87
70
|
const initialSpanName = startSpanOptions.name;
|
|
88
71
|
const finalStartSpanOptions = beforeStartSpan ? beforeStartSpan(startSpanOptions) : startSpanOptions;
|
|
89
|
-
const urlObject = browser.parseStringToURLObject(url ||
|
|
72
|
+
const urlObject = browser.parseStringToURLObject(url || browserUtils.getLocationHref());
|
|
90
73
|
const attributes$1 = {
|
|
91
74
|
...urlObject?.pathname && { [attributes.URL_PATH]: urlObject.pathname },
|
|
92
75
|
...urlObject && !browser.isURLObjectRelative(urlObject) && { [attributes.URL_FULL]: core.filterCollectedUrl(urlObject.href) },
|
|
93
76
|
...finalStartSpanOptions.attributes
|
|
94
77
|
};
|
|
95
78
|
if (initialSpanName !== finalStartSpanOptions.name) {
|
|
96
|
-
attributes$1[
|
|
79
|
+
attributes$1[attributes.SENTRY_SEGMENT_NAME_SOURCE] = "custom";
|
|
97
80
|
}
|
|
98
81
|
finalStartSpanOptions.attributes = attributes$1;
|
|
99
82
|
if (!makeActive) {
|
|
@@ -104,8 +87,6 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
104
87
|
}).end(now);
|
|
105
88
|
return;
|
|
106
89
|
}
|
|
107
|
-
latestRoute.name = finalStartSpanOptions.name;
|
|
108
|
-
latestRoute.source = attributes$1[browser.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
|
|
109
90
|
const idleSpan = browser.startIdleSpan(finalStartSpanOptions, {
|
|
110
91
|
idleTimeout,
|
|
111
92
|
finalTimeout,
|
|
@@ -142,9 +123,6 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
142
123
|
} else if (enableLongTask) {
|
|
143
124
|
browserUtils.startTrackingLongTasks();
|
|
144
125
|
}
|
|
145
|
-
if (enableInteractions) {
|
|
146
|
-
browserUtils.startTrackingInteractions();
|
|
147
|
-
}
|
|
148
126
|
if (detectRedirects && optionalWindowDocument) {
|
|
149
127
|
const interactionHandler = () => {
|
|
150
128
|
lastInteractionTimestamp = browser.timestampInSeconds();
|
|
@@ -154,8 +132,10 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
154
132
|
}
|
|
155
133
|
function maybeEndActiveSpan() {
|
|
156
134
|
const activeSpan = getActiveIdleSpan(client);
|
|
157
|
-
if (activeSpan && !browser.spanToJSON(activeSpan).
|
|
158
|
-
debugBuild.DEBUG_BUILD && browser.debug.log(
|
|
135
|
+
if (activeSpan && !browser.spanToJSON(activeSpan).end_timestamp) {
|
|
136
|
+
debugBuild.DEBUG_BUILD && browser.debug.log(
|
|
137
|
+
`[Tracing] Finishing current active span with op: ${browser.spanToJSON(activeSpan).attributes[attributes.SENTRY_OP]}`
|
|
138
|
+
);
|
|
159
139
|
activeSpan.setAttribute(browser.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, "cancelled");
|
|
160
140
|
activeSpan.end();
|
|
161
141
|
}
|
|
@@ -254,6 +234,7 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
254
234
|
if (_isBot) {
|
|
255
235
|
return;
|
|
256
236
|
}
|
|
237
|
+
browser._INTERNAL_ensureBrowserSpanStreaming(client);
|
|
257
238
|
if (client.addIntegration && !client.getIntegrationByName?.(webVitals.WEB_VITALS_INTEGRATION_NAME)) {
|
|
258
239
|
client.addIntegration(
|
|
259
240
|
webVitals.webVitalsIntegration({
|
|
@@ -261,19 +242,18 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
261
242
|
})
|
|
262
243
|
);
|
|
263
244
|
}
|
|
264
|
-
let startingUrl =
|
|
245
|
+
let startingUrl = browserUtils.getLocationHref();
|
|
265
246
|
if (linkPreviousTrace !== "off") {
|
|
266
247
|
linkedTraces.linkTraces(client, { linkPreviousTrace, consistentTraceSampling });
|
|
267
248
|
}
|
|
268
249
|
if (helpers.WINDOW.location) {
|
|
269
250
|
if (instrumentPageLoad) {
|
|
270
|
-
const origin = browser.browserPerformanceTimeOrigin();
|
|
271
251
|
startBrowserTracingPageLoadSpan(client, {
|
|
272
|
-
|
|
273
|
-
//
|
|
274
|
-
|
|
252
|
+
// With span streaming, span names have to be low cardinality, and there is no route
|
|
253
|
+
// information available here.
|
|
254
|
+
name: browser.hasSpanStreamingEnabled(client) ? browser.PAGELOAD_SPAN_NAME_FALLBACK : helpers.WINDOW.location.pathname,
|
|
275
255
|
attributes: {
|
|
276
|
-
[
|
|
256
|
+
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: "url",
|
|
277
257
|
[browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.pageload.browser"
|
|
278
258
|
}
|
|
279
259
|
});
|
|
@@ -291,9 +271,11 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
291
271
|
startBrowserTracingNavigationSpan(
|
|
292
272
|
client,
|
|
293
273
|
{
|
|
294
|
-
|
|
274
|
+
// With span streaming, span names have to be low cardinality, and there is no route
|
|
275
|
+
// information available here.
|
|
276
|
+
name: browser.hasSpanStreamingEnabled(client) ? browser.NAVIGATION_SPAN_NAME_FALLBACK : parsed?.pathname || helpers.WINDOW.location.pathname,
|
|
295
277
|
attributes: {
|
|
296
|
-
[
|
|
278
|
+
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: "url",
|
|
297
279
|
[browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.navigation.browser"
|
|
298
280
|
}
|
|
299
281
|
},
|
|
@@ -305,9 +287,6 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
305
287
|
if (markBackgroundSpan) {
|
|
306
288
|
backgroundtab.registerBackgroundTabDetection();
|
|
307
289
|
}
|
|
308
|
-
if (enableInteractions) {
|
|
309
|
-
registerInteractionListener(client, idleTimeout, finalTimeout, childSpanTimeout, latestRoute);
|
|
310
|
-
}
|
|
311
290
|
request.instrumentOutgoingRequests(client, {
|
|
312
291
|
traceFetch,
|
|
313
292
|
traceXHR,
|
|
@@ -317,15 +296,19 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
317
296
|
onRequestSpanStart,
|
|
318
297
|
onRequestSpanEnd
|
|
319
298
|
});
|
|
320
|
-
if (trackFetchStreamPerformance) {
|
|
321
|
-
client.addIntegration(fetchStreamPerformance.fetchStreamPerformanceIntegration());
|
|
322
|
-
}
|
|
323
299
|
}
|
|
324
300
|
};
|
|
325
301
|
});
|
|
326
302
|
function startBrowserTracingPageLoadSpan(client, spanOptions, traceOptions) {
|
|
327
|
-
|
|
328
|
-
browser.getCurrentScope().setTransactionName(spanOptions.name);
|
|
303
|
+
const isFallbackSpanName = spanOptions.name === browser.PAGELOAD_SPAN_NAME_FALLBACK;
|
|
304
|
+
browser.getCurrentScope().setTransactionName(isFallbackSpanName ? helpers.WINDOW.location?.pathname : spanOptions.name);
|
|
305
|
+
const timeOrigin = browser.browserPerformanceTimeOrigin();
|
|
306
|
+
const pageloadSpanOptions = {
|
|
307
|
+
...spanOptions,
|
|
308
|
+
// startTime needs to be in seconds, not ms
|
|
309
|
+
startTime: spanOptions.startTime ?? (timeOrigin ? timeOrigin / 1e3 : void 0)
|
|
310
|
+
};
|
|
311
|
+
client.emit("startPageLoadSpan", pageloadSpanOptions, traceOptions);
|
|
329
312
|
const pageloadSpan = getActiveIdleSpan(client);
|
|
330
313
|
if (pageloadSpan) {
|
|
331
314
|
client.emit("afterStartPageLoadSpan", pageloadSpan);
|
|
@@ -337,7 +320,10 @@ function startBrowserTracingNavigationSpan(client, spanOptions, options) {
|
|
|
337
320
|
client.emit("beforeStartNavigationSpan", spanOptions, { isRedirect: isRedirect2, url });
|
|
338
321
|
client.emit("startNavigationSpan", spanOptions, { isRedirect: isRedirect2, url });
|
|
339
322
|
const scope = browser.getCurrentScope();
|
|
340
|
-
|
|
323
|
+
const isFallbackSpanName = spanOptions.name === browser.NAVIGATION_SPAN_NAME_FALLBACK;
|
|
324
|
+
scope.setTransactionName(
|
|
325
|
+
isFallbackSpanName ? url && browser.parseStringToURLObject(url)?.pathname || helpers.WINDOW.location?.pathname : spanOptions.name
|
|
326
|
+
);
|
|
341
327
|
if (url && !isRedirect2) {
|
|
342
328
|
scope.setSDKProcessingMetadata({
|
|
343
329
|
normalizedRequest: {
|
|
@@ -358,47 +344,6 @@ function getServerTiming(name) {
|
|
|
358
344
|
const entry = navigation?.serverTiming?.find((entry2) => entry2.name === name);
|
|
359
345
|
return entry?.description;
|
|
360
346
|
}
|
|
361
|
-
function registerInteractionListener(client, idleTimeout, finalTimeout, childSpanTimeout, latestRoute) {
|
|
362
|
-
const optionalWindowDocument = helpers.WINDOW.document;
|
|
363
|
-
let inflightInteractionSpan;
|
|
364
|
-
const registerInteractionTransaction = () => {
|
|
365
|
-
const op = "ui.action.click";
|
|
366
|
-
const activeIdleSpan = getActiveIdleSpan(client);
|
|
367
|
-
if (activeIdleSpan) {
|
|
368
|
-
const currentRootSpanOp = browser.spanToJSON(activeIdleSpan).op;
|
|
369
|
-
if (["navigation", "pageload"].includes(currentRootSpanOp)) {
|
|
370
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(`[Tracing] Did not create ${op} span because a pageload or navigation span is in progress.`);
|
|
371
|
-
return void 0;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (inflightInteractionSpan) {
|
|
375
|
-
inflightInteractionSpan.setAttribute(browser.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, "interactionInterrupted");
|
|
376
|
-
inflightInteractionSpan.end();
|
|
377
|
-
inflightInteractionSpan = void 0;
|
|
378
|
-
}
|
|
379
|
-
if (!latestRoute.name) {
|
|
380
|
-
debugBuild.DEBUG_BUILD && browser.debug.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);
|
|
381
|
-
return void 0;
|
|
382
|
-
}
|
|
383
|
-
inflightInteractionSpan = browser.startIdleSpan(
|
|
384
|
-
{
|
|
385
|
-
name: latestRoute.name,
|
|
386
|
-
op,
|
|
387
|
-
attributes: {
|
|
388
|
-
[browser.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || "url"
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
idleTimeout,
|
|
393
|
-
finalTimeout,
|
|
394
|
-
childSpanTimeout
|
|
395
|
-
}
|
|
396
|
-
);
|
|
397
|
-
};
|
|
398
|
-
if (optionalWindowDocument) {
|
|
399
|
-
addEventListener("click", registerInteractionTransaction, { capture: true });
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
347
|
const ACTIVE_IDLE_SPAN_PROPERTY = "_sentry_idleSpan";
|
|
403
348
|
function getActiveIdleSpan(client) {
|
|
404
349
|
return client[ACTIVE_IDLE_SPAN_PROPERTY];
|
|
@@ -424,7 +369,6 @@ exports.BROWSER_TRACING_INTEGRATION_ID = BROWSER_TRACING_INTEGRATION_ID;
|
|
|
424
369
|
exports.browserTracingIntegration = browserTracingIntegration;
|
|
425
370
|
exports.getMetaContent = getMetaContent;
|
|
426
371
|
exports.getServerTiming = getServerTiming;
|
|
427
|
-
exports.isBotUserAgent = isBotUserAgent;
|
|
428
372
|
exports.startBrowserTracingNavigationSpan = startBrowserTracingNavigationSpan;
|
|
429
373
|
exports.startBrowserTracingPageLoadSpan = startBrowserTracingPageLoadSpan;
|
|
430
374
|
//# sourceMappingURL=browserTracingIntegration.js.map
|