UNPKG

@sentry/core

Version:
61 lines (57 loc) • 1.83 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const attributes = require('@sentry/conventions/attributes'); function scopeContextsToSpanAttributes(contexts) { const attrs = {}; const { response, profile, cloud_resource, culture, state } = contexts; if (response) { if (response.status_code != null) { attrs[attributes.HTTP_RESPONSE_STATUS_CODE] = response.status_code; } if (response.body_size != null) { attrs[attributes.HTTP_RESPONSE_BODY_SIZE] = response.body_size; } } if (profile) { if (profile.profile_id) { attrs[attributes.SENTRY_PROFILE_ID] = profile.profile_id; } if (profile.profiler_id) { attrs[attributes.SENTRY_PROFILER_ID] = profile.profiler_id; } } if (cloud_resource) { for (const [key, value] of Object.entries(cloud_resource)) { if (value != null) { attrs[key] = value; } } } if (culture) { if (culture.locale) { attrs[attributes.CULTURE_LOCALE] = culture.locale; } if (culture.timezone) { attrs[attributes.CULTURE_TIMEZONE] = culture.timezone; } } if (state?.state && typeof state.state.type === "string") { attrs[attributes.STATE_TYPE] = state.state.type; } const angular = contexts["angular"]; if (angular) { const version = angular["version"]; if (typeof version === "string" || typeof version === "number") { attrs[attributes.ANGULAR_VERSION] = version; } } const react = contexts["react"]; if (react) { const version = react["version"]; if (typeof version === "string" || typeof version === "number") { attrs[attributes.REACT_VERSION] = version; } } return attrs; } exports.scopeContextsToSpanAttributes = scopeContextsToSpanAttributes; //# sourceMappingURL=scopeContextAttributes.js.map