UNPKG

@sentry/core

Version:
44 lines (43 loc) • 1.42 kB
import { getTraceData } from "./traceData.js"; // src/utils/meta.ts /** * Returns a string of meta tags that represent the current trace data. * * You can use this to propagate a trace from your server-side rendered Html to the browser. * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the * current trace data state. * * @example * Usage example: * * ```js * function renderHtml() { * return ` * <head> * ${getTraceMetaTags()} * </head> * `; * } * ``` * */ function getTraceMetaTags(traceData) { return Object.entries(traceData || getTraceData()).map(([key, value]) => `<meta name="${key}" content="${value}"/>`).join(""); } /** * The name of the meta tag that gives the release to the browser SDK. Framework SDKs write it into each page * instead of injecting the release into the client chunks, where it would change their content hashes on every * release. */ const RELEASE_META_TAG_NAME = "sentry-release"; /** * Returns the meta tag that gives `release` to the browser SDK. */ function getReleaseMetaTag(release) { return `<meta name="${RELEASE_META_TAG_NAME}" content="${escapeHtmlAttribute(release)}"/>`; } function escapeHtmlAttribute(value) { return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); } export { RELEASE_META_TAG_NAME, getReleaseMetaTag, getTraceMetaTags }; //# sourceMappingURL=meta.js.map