feat: start trials from platform admin invites - #5920
Conversation
|
|
Running ultrareview automatically — This PR reworks invitation acceptance to arm enterprise trials atomically with row locks, serialized concurrency, and external WorkOS reconciliation—any subtle bug could corrupt trial lifecycle, membership, or audit data, so a deep multi-pass review is warranted.. I'll post findings when complete. |
|
|
||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Ultrareview completed in 9m 13s
All reported issues were addressed across 12 files
Linked issue analysis
Linked issue: GRW-62: feat: start enterprise trial when first platform-admin invite is accepted
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | A first user accepting an organization invitation sent by a current platform admin starts an active 14-day Enterprise trial. | The acceptance transaction detects a platform-admin inviter and first-user condition, arms the Enterprise trial, and the integration test verifies tier and 14-day duration. |
| ✅ | The new membership, role assignments, entitlements, trial lifecycle, audit record, and invitation acceptance are atomic and concurrent first acceptances produce one trial. | Acceptance locks the organization, performs local provisioning and trial arming in one transaction, and tests verify rollback on bundle failure plus serialized concurrent acceptance. |
| ✅ | The invited first user retains the invitation's organization-admin role and role synchronization is preserved. | The invitation role is persisted and synchronized transactionally, then reconciled with WorkOS after commit; tests verify the authoritative role and existing-membership reconciliation. |
| ✅ | The organization's configured whitelist value and existing trial lifecycle remain unchanged where applicable. | Trial arming updates account type without changing whitelist state, and the tests verify whitelist preservation and no changes to an existing lifecycle. |
| ✅ | The successful first-user flow triggers the existing trial lifecycle messaging and PostHog onboarding event with created_via set to platform_admin_invite. | Post-commit TrialStarted and PostHog capture/identify calls are implemented, with failures logged without rolling back acceptance; the test verifies the event shape and notification behavior. |
| ✅ | Later invitations, ordinary organization invitations, existing trial records, and deleted/non-platform-admin inviters do not incorrectly start a new trial. | Eligibility requires no other active users, a non-deleted platform-admin inviter, and no existing lifecycle; dedicated tests cover ordinary invites, existing lifecycles, and deleted inviters. |
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
706f8ef to
9f0317d
Compare
Refresh cached trial entitlements after commit and use the accepted invitation role for local and WorkOS membership reconciliation.
9f0317d to
76c1e02
Compare
Linear: GRW-62
Summary
Motivation
Organizations created and configured by platform admins previously missed the self-serve Enterprise trial lifecycle when their first customer joined. This reuses the established trial provisioning and lifecycle behavior while preserving whitelist settings, existing trial history, self-signup, and ordinary invitation behavior.
Summary by cubic
Starts the existing 14-day Enterprise trial when an organization's first user accepts an invite sent by a current platform admin. Organizations created by platform admins previously skipped the trial lifecycle; now the first customer to accept an invite gets the same self-serve Enterprise trial as signup.
Written for commit 76c1e02. Summary will update on new commits.