File size: 837 Bytes
fa9c65f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 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,
},
},
};
}
|