Skip to content

feat: add tagged to Journaled::Change - #82

Merged
smudge merged 3 commits into
Betterment:masterfrom
stevenjackson:sj/add-tagged-to-change
Aug 19, 2026
Merged

feat: add tagged to Journaled::Change#82
smudge merged 3 commits into
Betterment:masterfrom
stevenjackson:sj/add-tagged-to-change

Conversation

@stevenjackson

Copy link
Copy Markdown
Contributor

Add support for the gem's existing "tagged" mechanism to Journaled::Change, so apps that use Journaled.tag!/Journaled.tagged to attach per-request context (e.g. actor metadata, request ID, span, job ID, etc) can now see that context on change events.

@stevenjackson
stevenjackson requested a review from a team as a code owner August 14, 2026 20:05
Comment thread lib/journaled/version.rb Outdated

module Journaled
VERSION = "6.2.9"
VERSION = "6.3.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change for anyone already consuming the event, so we'll want to go to 7.0.0 here.

@smudge smudge Aug 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(specifically, the change to journaled_schemas/journaled/change.json means that consumers will need to handle tags even if it's empty / not present by default)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to 7!

it 'includes :tags only in the tagged instance\'s payload' do
tagged_change

expect(untagged_change.journaled_attributes.keys).not_to include(:tags)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this is the desired behavior that gives consumers a migration path.

@smudge smudge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to debate whether or not this is truly merits a major version bump, but looking at this from the perspective of consumers, the gem now allows for a local implementation change that will pass CI checks but then potentially break consumers in production, so I was thinking that we could use the major release to flag that.

Alternatively, we would need some way of detecting and failing if someone adds tagged: true to an existing directive (forcing them to acknowledge that consumers are prepared for this new field), but I wasn't seeing a clear path to incorporating such a check into the consuming app's own runtime behavior (such that the consuming app would have a chance to have its own tests fail).

@stevenjackson
stevenjackson requested a review from smudge August 17, 2026 20:26
Comment thread README.md Outdated
Comment on lines +369 to +371
This is useful for capturing metadata (like an impersonating actor) that isn't
itself a column on the model. It defaults to `false` to preserve the existing
event shape for models that don't opt in.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is useful for capturing metadata (like an impersonating actor) that isn't
itself a column on the model. It defaults to `false` to preserve the existing
event shape for models that don't opt in.
This is useful for capturing metadata (like a session or visitor ID) that isn't
itself a column on the model. It defaults to `false` to preserve the existing
event shape for models that don't opt in.

Nitpick here, but I think transient IDs are a more common use case for README purposes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change in the PR description but forgot it here, good catch!

smudge
smudge previously approved these changes Aug 19, 2026

@smudge smudge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for the slow review -- and my slowness resulting in this needing a rebase 😞

I added one nitpick (take it or leave it, but I figure since you're rebasing anyways)

The rest looks great -- thank you for this contribution! 🙌

Add support for the gem's existing "tagged" mechanism to `Journaled::Change`, so apps that use `Journaled.tag!`/`Journaled.tagged` to attach per-request context (e.g.  actor metadata, request ID, span, job ID, etc) can now see that context on change events.
@smudge
smudge merged commit f823cdd into Betterment:master Aug 19, 2026
9 checks passed
@stevenjackson
stevenjackson deleted the sj/add-tagged-to-change branch August 19, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants