rubyforgood / rubyforgood/awbw
Stamp a correlation id on Ahoy events so one save reads as one action
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 15
- Forks
- 26
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 242
Description
🤖 From Claude:
One admin save that touches several records produces several unrelated events. ahoy_events has visit_id, but that's a session, not an action — there is no way to say "these five changes were one save."
A timeline that wants to render "Mae updated this registration" instead of five separate rows needs that grouping, and so does any "undo this action" or "what did that save actually do" view.
Why now rather than later
The column is cheap. The data is not backfillable — every event written before the id exists is permanently ungroupable. This is the same argument that made the capture fixes in #2245 urgent: nothing is lost by shipping the reader later, everything is lost by shipping the writer later.
Sketch
- A per-request uuid (
ApplicationControllersets it alongsideCurrent.user), stamped intopropertiesbyAnalytics::EventBuilder.lifecycleand promoted to a column by the samebefore_validationhook inconfig/initializers/ahoy.rbthat already promotesresource_type/resource_id. - Index it, so grouping is a lookup rather than a scan.
- Jobs and rake tasks get their own id per run, which also gives "what did that job change" for free.
Acceptance
- Two records changed in one request share an id; the same records changed in two requests don't.
- The id is queryable as a column, not only inside the JSON payload.
Related: #2351 (many writes produce no event at all — worth fixing first, since an id on nothing is still nothing).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ApplicationController, Analytics::EventBuilder.lifecycle, and the existing promotion hook in config/initializers/ahoy.rb to trace how events are written and promoted. Check the related #2351 issue before starting. Done means events from one request share a queryable id, while events from separate requests do not, with jobs and rake tasks receiving their own ids.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100