@embrace-io/web-sdk
Version:
1 lines • 1.95 kB
Source Map (JSON)
{"version":3,"file":"spanPredicates.cjs","names":["ATTR_HTTP_REQUEST_METHOD","ATTR_HTTP_RESPONSE_STATUS_CODE","ATTR_URL_FULL","KEY_EMB_TYPE","KEY_EMB_SOFT_NAVIGATION_SOURCE"],"sources":["../../src/utils/spanPredicates.ts"],"sourcesContent":["import type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport type { ReadableSpan, Span } from '@opentelemetry/sdk-trace';\nimport {\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_URL_FULL,\n} from '@opentelemetry/semantic-conventions';\nimport { EMB_TYPES, KEY_EMB_TYPE } from '../constants/index.ts';\nimport type { SessionPartSpan } from '../instrumentations/index.ts';\nimport { KEY_EMB_SOFT_NAVIGATION_SOURCE } from '../instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/constants.ts';\n\nexport interface NetworkSpan extends ReadableSpan {\n attributes: Attributes & { [ATTR_HTTP_REQUEST_METHOD]: AttributeValue };\n}\n\nexport const isNetworkSpan = (\n span: ReadableSpan | NetworkSpan,\n): span is NetworkSpan => {\n if (\n span.attributes[ATTR_HTTP_REQUEST_METHOD] &&\n typeof span.attributes[ATTR_HTTP_RESPONSE_STATUS_CODE] === 'number'\n ) {\n const url = span.attributes[ATTR_URL_FULL];\n\n return typeof url === 'string' && url.includes('://');\n }\n\n return false;\n};\n\nexport const isSessionPartSpan = (\n span: ReadableSpan | SessionPartSpan,\n): span is SessionPartSpan =>\n span.attributes[KEY_EMB_TYPE] === EMB_TYPES.SessionPart;\n\nexport const isSoftNavigationSpan = (span: ReadableSpan | Span): boolean =>\n span.attributes[KEY_EMB_SOFT_NAVIGATION_SOURCE] !== undefined;\n"],"mappings":";;;;;AAeA,MAAa,iBACX,SACwB;CACxB,IACE,KAAK,WAAWA,oCAAAA,6BAChB,OAAO,KAAK,WAAWC,oCAAAA,oCAAoC,UAC3D;EACA,MAAM,MAAM,KAAK,WAAWC,oCAAAA;EAE5B,OAAO,OAAO,QAAQ,YAAY,IAAI,SAAS,KAAK;CACtD;CAEA,OAAO;AACT;AAEA,MAAa,qBACX,SAEA,KAAK,WAAWC,6BAAAA,kBAAAA;AAElB,MAAa,wBAAwB,SACnC,KAAK,WAAWC,wGAAAA,oCAAoC,KAAA"}