Skip to content

Trace registration record changes back to their form submission - #2301

Draft
maebeale wants to merge 2 commits into
mainfrom
maebeale/trace-form-submission-changes
Draft

Trace registration record changes back to their form submission#2301
maebeale wants to merge 2 commits into
mainfrom
maebeale/trace-form-submission-changes

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 contained tracking change plus one swallowed-error bug fix, backend-only, well covered by specs

Why

Foundation for an upcoming admin "what this form submission changed" page: to show everything a public registration wrote, each record's change needs to be attributable to the submission that caused it.

What

  • Stamp form_submission_id on lifecycle Ahoy events. New Current.form_submission_id; LifecycleBuffer.flush stamps it onto each buffered event's properties. Stamped at flush because the submission is created partway through the service — after many events are already buffered. The registration controller sets it once the registration succeeds.
  • Fix silently-dropped sector tag events. SectorableItem#title called windows_type (a WorkshopLog-only association) for person/org sector tags; the raise was swallowed by the tracking rescue, so sector tag changes were never logged. Age groups were unaffected. #title had no other callers.

Tests

  • lifecycle_buffer_spec — stamps / doesn't clobber / no-ops when unset.
  • sectorable_item_spec#title no longer raises for a person; a sector tag now buffers a create.sectorable_item event.
  • public_registrations_spec — one comprehensive registration asserts every record it writes (person, address, contact_method, organization, affiliation, sectorable_item, categorizable_item, event_registration, form_submission) fires a lifecycle event carrying the submission id.

Stamp the form submission id onto the request's buffered Ahoy lifecycle
events at flush, so the records a public registration touches (person,
org, tags, affiliation) can each be attributed to the submission that
caused them — the basis for an upcoming per-submission "what changed" page.

The id isn't knowable when events are buffered mid-request (the submission
is created partway through the service), so it's stamped at flush, from a
Current attribute the controller sets once the registration succeeds.

Also fix SectorableItem#title: it called windows_type (a WorkshopLog-only
association) for person/org sector tags, and the raise was swallowed by the
lifecycle-tracking rescue — so sector tag changes were silently never logged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When an admin links (or creates-and-links) an org that wasn't a clean match,
attribute the resulting org profile fill to the submission that named it, so
that submission's "what changed" audit and count reflect the linking — the
same stamping the public registration flow already does.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant