feat(webapp): migrate Plain to @team-plain/graphql + attribute support threads to org tenant#4368
feat(webapp): migrate Plain to @team-plain/graphql + attribute support threads to org tenant#4368isshaddad wants to merge 4 commits into
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (36)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-05-14T14:54:39.095ZApplied to files:
🔇 Additional comments (1)
WalkthroughThe webapp migrated Plain imports from the legacy SDK to GraphQL and UI component packages. The Plain integration now uses guarded GraphQL mutations, supports optional organization fields, links customers to tenants when organization data is available, and conditionally assigns threads to tenants. Cancellation feedback and quota-increase requests now include organization identifiers and names. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Two changes, shipped together:
SDK migration (TRI-12460).
@team-plain/typescript-sdkis deprecated. Move the webapp to its successors —@team-plain/graphql(client) and@team-plain/ui-components(uiComponentbuilder). Behaviour-preserving: thePlainClientcustomer upsert + thread creation move to the newclient.mutation.*({ input })shape; the client now throws on failure, sosendToPlainwraps its calls and logs, staying best-effort.Org tenant attribution (TRI-12461). When org context is available,
sendToPlainnow upserts a Plain tenant keyed byexternalId = org_id, links the customer to it, and stamps the created thread with that tenant — so support threads become attributable to a Trigger.dev org. Wired into the four add-on quota requests and the plan-cancellation feedback (which already have org context). The tenant steps are isolated in their own try/catch and the thread'stenantIdentifieris gated on their success, so a tenant failure never blocks thread creation.Not affected
customer.externalIdstaysUser.id— the customer cards + impersonation link are unchanged.Deploy prerequisite
The webapp's Plain API key needs three new scopes for attribution to work (it already has
customer:create,customer:edit,thread:create):tenant:createtenant:editcustomerTenantMembership:createUntil granted, nothing breaks —
sendToPlainlogs the forbidden error and creates the thread without attribution.Testing
pnpm typecheck --filter webapppasses; oxfmt + oxlint clean.sendToPlainend-to-end via a throwaway vitest harness against live Plain — confirmed the code path executes; the live write is gated only by the key scopes above.