Skip to content

Commit 0f60aad

Browse files
committed
fix(node-core,vercel-edge): Use HEROKU_BUILD_COMMIT env var for default release
Add HEROKU_BUILD_COMMIT as the primary env var for detecting the release on Heroku, keeping HEROKU_SLUG_COMMIT as a fallback since it is deprecated by Heroku. Closes: #19615 Agent transcript: https://claudescope.sentry.dev/share/w_FBx963Azo2_3JULQsv03PCYKpkBHg3NHWZaL6HiYU
1 parent d975bcd commit 0f60aad

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

packages/node-core/src/sdk/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export function getSentryRelease(fallback?: string): string | undefined {
6666
process.env['FC_GIT_COMMIT_SHA'] ||
6767
// Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
6868
process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||
69-
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
69+
// Heroku #2 https://devcenter.heroku.com/articles/dyno-metadata#dyno-metadata
70+
process.env['HEROKU_BUILD_COMMIT'] ||
71+
// Heroku #3 (deprecated by Heroku, kept for backward compatibility)
7072
process.env['HEROKU_SLUG_COMMIT'] ||
7173
// Railway - https://docs.railway.app/reference/variables#git-variables
7274
process.env['RAILWAY_GIT_COMMIT_SHA'] ||
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { afterEach, describe, expect, it, vi } from 'vitest';
2+
import { getSentryRelease } from '../../src/sdk/api';
3+
4+
afterEach(() => {
5+
vi.unstubAllEnvs();
6+
});
7+
8+
describe('getSentryRelease', () => {
9+
it('uses HEROKU_BUILD_COMMIT env var', () => {
10+
vi.stubEnv('HEROKU_BUILD_COMMIT', 'heroku-build-commit-sha');
11+
12+
expect(getSentryRelease()).toBe('heroku-build-commit-sha');
13+
});
14+
15+
it('falls back to HEROKU_SLUG_COMMIT if HEROKU_BUILD_COMMIT is not set', () => {
16+
vi.stubEnv('HEROKU_SLUG_COMMIT', 'heroku-slug-commit-sha');
17+
18+
expect(getSentryRelease()).toBe('heroku-slug-commit-sha');
19+
});
20+
21+
it('prefers HEROKU_BUILD_COMMIT over HEROKU_SLUG_COMMIT', () => {
22+
vi.stubEnv('HEROKU_BUILD_COMMIT', 'heroku-build-commit-sha');
23+
vi.stubEnv('HEROKU_SLUG_COMMIT', 'heroku-slug-commit-sha');
24+
25+
expect(getSentryRelease()).toBe('heroku-build-commit-sha');
26+
});
27+
});

packages/vercel-edge/src/sdk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ export function getSentryRelease(fallback?: string): string | undefined {
265265
process.env['FC_GIT_COMMIT_SHA'] ||
266266
// Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
267267
process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||
268-
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
268+
// Heroku #2 https://devcenter.heroku.com/articles/dyno-metadata#dyno-metadata
269+
process.env['HEROKU_BUILD_COMMIT'] ||
270+
// Heroku #3 (deprecated by Heroku, kept for backward compatibility)
269271
process.env['HEROKU_SLUG_COMMIT'] ||
270272
// Railway - https://docs.railway.app/reference/variables#git-variables
271273
process.env['RAILWAY_GIT_COMMIT_SHA'] ||

0 commit comments

Comments
 (0)