GenerAI / worldmonitor /src /bootstrap /sentry-build-metadata.ts
amogaddy's picture
Integra World Monitor (AGPL-3.0, self-hosted) nello Space: pagina, menu, e arricchimento notizie per la AI (part 6)
fa9c65f verified
Raw
History Blame Contribute Delete
837 Bytes
const VERCEL_COMMIT_SHA = /^[0-9a-f]{40}$/i;
interface SentryBuildMetadata {
release: string;
dist?: string;
initialScope?: {
tags: {
build_sha: string;
};
};
}
/**
* Keep the semver release stable while making each Vercel deployment
* attributable. Sentry's `dist` is the build within a release; the explicit
* tag keeps the SHA available in issue/event searches and exports.
*/
export function getSentryBuildMetadata(
appVersion: string,
buildHash: string,
): SentryBuildMetadata {
const release = `worldmonitor@${appVersion}`;
const normalizedBuildHash = buildHash.trim();
if (!VERCEL_COMMIT_SHA.test(normalizedBuildHash)) return { release };
return {
release,
dist: normalizedBuildHash,
initialScope: {
tags: {
build_sha: normalizedBuildHash,
},
},
};
}