You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(analytics): token and publish events survive a disconnect after commit #545
The lifecycle and onboarding events report with their commit: an interrupt that arrives during or right after COMMIT still reports a committed change (withLifecycleTransaction in Patches.ts, withReportedCommit in @patchy/sql, from #541 and #539). Three older emitters don't. They report in a separate step after their transaction, so a request interrupted between the commit and the report, such as a client disconnecting at that moment, loses the event:
token.minted, in DeviceLogins.poll (packages/auth/src/DeviceLogins.ts);
patch.created and patch.updated, in the publish handler (packages/patches/src/PatchesApi.ts). A retry with the same publish key replays the stored response and reports nothing, so that publish is never counted.
The window is small and costs one analytics event, never a wrong one.
Do
Give these emitters the same guarantee: the report runs with the commit, the work before it stays cancellable, and a refused or rolled-back change reports nothing. Reuse withReportedCommit or the existing mask pattern rather than adding a third mechanism. Publish records across more than one step, so put the report at the step that commits the version.
A test per emitter that interrupts during COMMIT and still sees exactly one event, modelled on packages/sql/src/sql.test.ts's slow-commit trigger.
Done when
Every business event's report survives an interrupt that arrives after its change committed.
Filed by Claude Opus 5.5 via Claude Code for Allison.
Activity