feat: Add changelog tracking to attribute definitions#270
feat: Add changelog tracking to attribute definitions#270ericapisani wants to merge 10 commits intomainfrom
Conversation
Add a changelog field to attribute JSON files that tracks how each attribute has changed across sentry-conventions release versions. This includes the schema extension, a generation script that derives changelog entries from git tags and commit history, updates to both TypeScript and Python code generators, docs UI rendering, and validation tests. Co-Authored-By: Claude <noreply@anthropic.com>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧Deps
Other
🤖 This preview updates automatically when you update the PR. |
Run biome formatter across all JSON model files to inline short arrays, and replace non-null assertions with optional chaining or type casts to satisfy biome's noNonNullAssertion rule. Co-Authored-By: Claude <noreply@anthropic.com>
Lms24
left a comment
There was a problem hiding this comment.
Nice! I really like the idea of the changelog. I missed this in the past when working on PRs like #208, so having this transparency feels like a win!
I had a question regarding manual changelog entries and how/when to run the changelog generation script.
| } | ||
|
|
||
| const attributeJson = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as AttributeJson; | ||
| attributeJson.changelog = changelog; |
There was a problem hiding this comment.
m: does this overwrite pre-existing changelog entries? I'm not sure if I'm missing something but it seems like in the future, we might want to run this script again for PRs that touch a lot of files (like #127) but there's also value in manually writing a changelog entry (for example, if we change semantics of an attribute like in #208 and add a description to the changelog). Would we overwrite the manually added entry when rerunning the script?
| @@ -29,6 +29,7 @@ | |||
| "create:attribute": "tsx scripts/create_attribute.ts", | |||
|
|
|||
| "generate": "tsx scripts/generate.ts && yarn format", | |||
| "generate:attribute-changelog": "tsx scripts/generate_attribute_changelog.ts", | |||
There was a problem hiding this comment.
m: I assume we want to run this on every new PR, correct? Can we adjust the generate script to also execute the changelog generation script? This way contributors only need to remember running the already existing yarn generate command.
l: I'm not sure how well this works in conjunction with manual entries but: Should we fail CI if running this script produces changes? I think we should get this for free when we add this script to the generate command as suggested above. WDYT?
|
Actually, one more Q: What about unreleased changes? If I make a change to an attribute today, it's unlikely I don't yet know which version will be the next one to release (I mean right now, it's most likely a minor 0.x.0 bump but this could change once/if we go to a stable 1.0.0 version). Should the version then be something like |
At the moment this script ignores them for the reason that you mentioned - we don't yet know what release the change could go out in. Once the release is made then, as it stands right now, another PR would need to be created with the regenerated docs. This issue will still be around if we were to set the version to
Yes, but I can look into modifying this so that it preserves pre-existing entries (including manually written ones that you mentioned in another comment), while still handling the edge case of a transition where what was listed under a
For sure we can make an adjustment to the generate script to also run this with every new PR. When you say "producing changes", are you referring to something like a diff existing between what's in the PR vs. what the script generated? Assuming that you are, then I think it's a great idea to fail the CI if that happens so as to ensure that the changelog is never out of date. I'll move this PR into draft while I work through the changes and ping you once they're in! 😄 |
Preserve manually added descriptions, hand-curated entries, and other manual edits when re-running the changelog generation script. Previously the script would completely replace existing changelog data on every run. Add mergeChangelogs() that indexes by version, unions PR numbers, preserves existing descriptions, keeps manual-only entries, and re-sorts newest-first. Add unit tests covering edge cases. Co-Authored-By: Claude <noreply@anthropic.com>
Support unreleased changes tracked as "next" entries in attribute changelogs. When a new release tag is created, "next" entries are automatically promoted to the new version while preserving manually-added descriptions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sounds great, thanks!
Yes basically. I checked our Build CI job and it seems like we already fail if |
Show the attribute changelog in the AttributeCard component, including entries with version 'next' (displayed without a 'v' prefix). Update compareVersions to handle 'next' correctly and export it for reuse in tests, removing the duplicate implementation. Co-Authored-By: Claude <noreply@anthropic.com>
Remove redundant 'next' guards in the sort comparator — compareVersions already handles 'next' correctly, making those checks dead code. Add a TODO comment noting the O(files × versions) git subprocess cost and suggesting a future batch approach using `git diff --name-only`. Co-Authored-By: Claude <noreply@anthropic.com>
…etsentry/sentry-conventions into ep/display-changelog-of-attributes-6su
Biome's noDelete lint rule flags the delete operator for performance. Since changelog is an optional field and JSON.stringify omits undefined values, the behavior is identical. Co-Authored-By: Claude <noreply@anthropic.com>
|
I've got the changes in! Quick summary of what's changed:
For the future:
|
Fixes #268 and CON-82
Add a
changelogfield to attribute definitions that tracks how each attribute has changed across sentry-conventions release versions.This makes it possible to show users when an attribute was introduced, deprecated, or changed — which is useful context when browsing the attribute docs or consuming the metadata in SDKs.
What's included
schemas/attribute.schema.json): New optionalchangelogarray withversion,prs, anddescriptionfieldsscripts/generate_attribute_changelog.ts): Derives changelog entries from git tags and commit history, extracting PR numbers from commit messagesscripts/generate_attributes.ts): Propagateschangeloginto the generated TypeScript (ChangelogEntryinterface onAttributeMetadata) and Python (ChangelogEntrydataclass) outputsdocs/src/components/AttributeCard.astro): Renders a collapsible "Changelog" section on each attribute card, linking to PRs on GitHubtest/attributes.test.ts): Validates changelog entry structure and ordering (newest first)Screenshots