Files
klz-cables.com/.pnpm-store/v10/files/a8/63449347dccda161939a448ad9c846acc864a5ca016883aa867417d544ed6ad7ff6f8496377d26351c11897b3615e1c499035f247a52ab05b53ffcb1fbc805
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
9.2 KiB
Plaintext

{"version":3,"file":"tracingUtils.js","sources":["../../../../src/common/utils/tracingUtils.ts"],"sourcesContent":["import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type { PropagationContext, Span, SpanAttributes } from '@sentry/core';\nimport {\n debug,\n getActiveSpan,\n getRootSpan,\n GLOBAL_OBJ,\n Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n startNewTrace,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { ATTR_NEXT_SEGMENT, ATTR_NEXT_SPAN_NAME, ATTR_NEXT_SPAN_TYPE } from '../nextSpanAttributes';\nimport { TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION } from '../span-attributes-with-logic-attached';\n\nconst commonPropagationContextMap = new WeakMap<object, PropagationContext>();\n\nconst PAGE_SEGMENT = '__PAGE__';\n\n/**\n * Takes a shared (garbage collectable) object between resources, e.g. a headers object shared between Next.js server components and returns a common propagation context.\n *\n * @param commonObject The shared object.\n * @param propagationContext The propagation context that should be shared between all the resources if no propagation context was registered yet.\n * @returns the shared propagation context.\n */\nexport function commonObjectToPropagationContext(\n commonObject: unknown,\n propagationContext: PropagationContext,\n): PropagationContext {\n if (typeof commonObject === 'object' && commonObject) {\n const memoPropagationContext = commonPropagationContextMap.get(commonObject);\n if (memoPropagationContext) {\n return memoPropagationContext;\n } else {\n commonPropagationContextMap.set(commonObject, propagationContext);\n return propagationContext;\n }\n } else {\n return propagationContext;\n }\n}\n\nconst commonIsolationScopeMap = new WeakMap<object, Scope>();\n\n/**\n * Takes a shared (garbage collectable) object between resources, e.g. a headers object shared between Next.js server components and returns a common propagation context.\n *\n * @param commonObject The shared object.\n * @param isolationScope The isolationScope that should be shared between all the resources if no isolation scope was created yet.\n * @returns the shared isolation scope.\n */\nexport function commonObjectToIsolationScope(commonObject: unknown): Scope {\n if (typeof commonObject === 'object' && commonObject) {\n const memoIsolationScope = commonIsolationScopeMap.get(commonObject);\n if (memoIsolationScope) {\n return memoIsolationScope;\n } else {\n const newIsolationScope = new Scope();\n commonIsolationScopeMap.set(commonObject, newIsolationScope);\n return newIsolationScope;\n }\n } else {\n return new Scope();\n }\n}\n\ninterface AsyncLocalStorage<T> {\n getStore(): T | undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;\n}\n\nlet nextjsEscapedAsyncStorage: AsyncLocalStorage<true>;\n\n/**\n * Will mark the execution context of the callback as \"escaped\" from Next.js internal tracing by unsetting the active\n * span and propagation context. When an execution passes through this function multiple times, it is a noop after the\n * first time.\n */\nexport function escapeNextjsTracing<T>(cb: () => T): T {\n const MaybeGlobalAsyncLocalStorage = (GLOBAL_OBJ as { AsyncLocalStorage?: new () => AsyncLocalStorage<true> })\n .AsyncLocalStorage;\n\n if (!MaybeGlobalAsyncLocalStorage) {\n DEBUG_BUILD &&\n debug.warn(\n \"Tried to register AsyncLocalStorage async context strategy in a runtime that doesn't support AsyncLocalStorage.\",\n );\n return cb();\n }\n\n if (!nextjsEscapedAsyncStorage) {\n nextjsEscapedAsyncStorage = new MaybeGlobalAsyncLocalStorage();\n }\n\n if (nextjsEscapedAsyncStorage.getStore()) {\n return cb();\n } else {\n return startNewTrace(() => {\n return nextjsEscapedAsyncStorage.run(true, () => {\n return cb();\n });\n });\n }\n}\n\n/**\n * Ideally this function never lands in the develop branch.\n *\n * Drops the entire span tree this function was called in, if it was a span tree created by Next.js.\n */\nexport function dropNextjsRootContext(): void {\n const nextJsOwnedSpan = getActiveSpan();\n if (nextJsOwnedSpan) {\n const rootSpan = getRootSpan(nextJsOwnedSpan);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n if (rootSpanAttributes?.['next.span_type']) {\n getRootSpan(nextJsOwnedSpan)?.setAttribute(TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION, true);\n }\n }\n}\n\n/**\n * Checks if the span is a resolve segment span.\n * @param spanAttributes The attributes of the span to check.\n * @returns True if the span is a resolve segment span, false otherwise.\n */\nexport function isResolveSegmentSpan(spanAttributes: SpanAttributes): boolean {\n return (\n spanAttributes[ATTR_NEXT_SPAN_TYPE] === 'NextNodeServer.getLayoutOrPageModule' &&\n spanAttributes[ATTR_NEXT_SPAN_NAME] === 'resolve segment modules' &&\n typeof spanAttributes[ATTR_NEXT_SEGMENT] === 'string'\n );\n}\n\n/**\n * Returns the enhanced name for a resolve segment span.\n * @param segment The segment of the resolve segment span.\n * @param route The route of the resolve segment span.\n * @returns The enhanced name for the resolve segment span.\n */\nexport function getEnhancedResolveSegmentSpanName({ segment, route }: { segment: string; route: string }): string {\n if (segment === PAGE_SEGMENT) {\n return `resolve page server component \"${route}\"`;\n }\n\n if (segment === '') {\n return 'resolve root layout server component';\n }\n\n return `resolve layout server component \"${segment}\"`;\n}\n\n/**\n * Maybe enhances the span name for a resolve segment span.\n * If the span is not a resolve segment span, this function does nothing.\n * @param activeSpan The active span.\n * @param spanAttributes The attributes of the span to check.\n * @param rootSpanAttributes The attributes of the according root span.\n */\nexport function maybeEnhanceServerComponentSpanName(\n activeSpan: Span,\n spanAttributes: SpanAttributes,\n rootSpanAttributes: SpanAttributes,\n): void {\n if (!isResolveSegmentSpan(spanAttributes)) {\n return;\n }\n\n const segment = spanAttributes[ATTR_NEXT_SEGMENT] as string;\n const route = rootSpanAttributes[ATTR_HTTP_ROUTE];\n const enhancedName = getEnhancedResolveSegmentSpanName({ segment, route: typeof route === 'string' ? route : '' });\n activeSpan.updateName(enhancedName);\n activeSpan.setAttributes({\n 'sentry.nextjs.ssr.function.type': segment === PAGE_SEGMENT ? 'Page' : 'Layout',\n 'sentry.nextjs.ssr.function.route': route,\n });\n activeSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'function.nextjs');\n}\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,YAAA,GAAe,UAAU;;AA0B/B,MAAM,uBAAA,GAA0B,IAAI,OAAO,EAAiB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,YAAY,EAAkB;AAC3E,EAAE,IAAI,OAAO,YAAA,KAAiB,QAAA,IAAY,YAAY,EAAE;AACxD,IAAI,MAAM,qBAAqB,uBAAuB,CAAC,GAAG,CAAC,YAAY,CAAC;AACxE,IAAI,IAAI,kBAAkB,EAAE;AAC5B,MAAM,OAAO,kBAAkB;AAC/B,IAAI,OAAO;AACX,MAAM,MAAM,iBAAA,GAAoB,IAAI,KAAK,EAAE;AAC3C,MAAM,uBAAuB,CAAC,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC;AAClE,MAAM,OAAO,iBAAiB;AAC9B,IAAI;AACJ,EAAE,OAAO;AACT,IAAI,OAAO,IAAI,KAAK,EAAE;AACtB,EAAE;AACF;;AAQA,IAAI,yBAAyB;;AAE7B;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAI,EAAE,EAAc;AACvD,EAAE,MAAM,4BAAA,GAA+B,CAAC,UAAA;AACxC,KAAK,iBAAiB;;AAEtB,EAAE,IAAI,CAAC,4BAA4B,EAAE;AACrC,IAAI,WAAA;AACJ,MAAM,KAAK,CAAC,IAAI;AAChB,QAAQ,iHAAiH;AACzH,OAAO;AACP,IA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