-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(cloudflare): Automatically set the release id when CF_VERSION_METADATA is enabled #18855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,4 +55,75 @@ describe('getFinalOptions', () => { | |
|
|
||
| expect(result).toEqual(userOptions); | ||
| }); | ||
|
|
||
| describe('CF_VERSION_METADATA', () => { | ||
| it('uses CF_VERSION_METADATA.id as release when no other release is set', () => { | ||
| const userOptions = { dsn: 'test-dsn' }; | ||
| const env = { CF_VERSION_METADATA: { id: 'version-123', tag: 'v1.0.0' } }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: 'version-123' }); | ||
| }); | ||
|
|
||
| it('prefers SENTRY_RELEASE over CF_VERSION_METADATA.id', () => { | ||
| const userOptions = { dsn: 'test-dsn' }; | ||
| const env = { | ||
| SENTRY_RELEASE: 'env-release', | ||
| CF_VERSION_METADATA: { id: 'version-123' }, | ||
| }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: 'env-release' }); | ||
| }); | ||
|
|
||
| it('prefers user release over CF_VERSION_METADATA.id', () => { | ||
| const userOptions = { dsn: 'test-dsn', release: 'user-release' }; | ||
| const env = { CF_VERSION_METADATA: { id: 'version-123' } }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: 'user-release' }); | ||
| }); | ||
|
|
||
| it('prefers user release over both SENTRY_RELEASE and CF_VERSION_METADATA.id', () => { | ||
| const userOptions = { dsn: 'test-dsn', release: 'user-release' }; | ||
| const env = { | ||
| SENTRY_RELEASE: 'env-release', | ||
| CF_VERSION_METADATA: { id: 'version-123' }, | ||
| }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: 'user-release' }); | ||
| }); | ||
|
|
||
| it('ignores CF_VERSION_METADATA when it is not an object', () => { | ||
| const userOptions = { dsn: 'test-dsn' }; | ||
| const env = { CF_VERSION_METADATA: 'not-an-object' }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: undefined }); | ||
| }); | ||
|
|
||
| it('ignores CF_VERSION_METADATA when id is not a string', () => { | ||
| const userOptions = { dsn: 'test-dsn' }; | ||
| const env = { CF_VERSION_METADATA: { id: 123 } }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: undefined }); | ||
| }); | ||
|
|
||
| it('ignores CF_VERSION_METADATA when id is missing', () => { | ||
| const userOptions = { dsn: 'test-dsn' }; | ||
| const env = { CF_VERSION_METADATA: { tag: 'v1.0.0' } }; | ||
|
|
||
| const result = getFinalOptions(userOptions, env); | ||
|
|
||
| expect(result).toEqual({ dsn: 'test-dsn', release: undefined }); | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing integration or E2E test for new featureLow Severity · Bugbot Rules This |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: can this happen/is it common to provide a non-string id? If so, we could stringify the release. Though only worth doing if this is actually a thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not defined what the
version IDcan be. Right now the id is always a UUID, so a string. But I'm not sure if this is always the case.