Skip to content

feat(webapp): migrate Plain to @team-plain/graphql + attribute support threads to org tenant - #4368

Open
isshaddad wants to merge 5 commits into
mainfrom
chore/migrate-plain-sdk-tri-12460
Open

feat(webapp): migrate Plain to @team-plain/graphql + attribute support threads to org tenant#4368
isshaddad wants to merge 5 commits into
mainfrom
chore/migrate-plain-sdk-tri-12460

Conversation

@isshaddad

Copy link
Copy Markdown
Collaborator

What

Two changes, shipped together:

  1. SDK migration (TRI-12460). @team-plain/typescript-sdk is deprecated. Move the webapp to its successors — @team-plain/graphql (client) and @team-plain/ui-components (uiComponent builder). Behaviour-preserving: the PlainClient customer upsert + thread creation move to the new client.mutation.*({ input }) shape; the client now throws on failure, so sendToPlain wraps its calls and logs, staying best-effort.

  2. Org tenant attribution (TRI-12461). When org context is available, sendToPlain now upserts a Plain tenant keyed by externalId = 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's tenantIdentifier is gated on their success, so a tenant failure never blocks thread creation.

Not affected

  • customer.externalId stays User.id — the customer cards + impersonation link are unchanged.
  • No ticket content leaves Plain.
  • Callers without a single org (e.g. the feedback widget) are unchanged — the org params are optional.

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:create
  • tenant:edit
  • customerTenantMembership:create

Until granted, nothing breaks — sendToPlain logs the forbidden error and creates the thread without attribution.

Testing

  • pnpm typecheck --filter webapp passes; oxfmt + oxlint clean.
  • Ran the real sendToPlain end-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.

@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 92f8b3c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42b9bcbd-81f3-451f-8b76-44d7b2fe7025

📥 Commits

Reviewing files that changed from the base of the PR and between 4135bbb and 92f8b3c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • apps/webapp/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/webapp/package.json
📜 Recent review details
⏰ Context from checks skipped due to timeout. (21)
  • GitHub Check: sdk-compat / Node.js 20.20 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Node.js 22.23 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: sdk-compat / Node.js 26.4 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: sdk-compat / Node.js 24.18 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: Build and publish previews
  • GitHub Check: code-quality / code-quality
  • GitHub Check: audit
  • GitHub Check: audit
  • GitHub Check: 🛡️ E2E Auth Tests (full)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)

Walkthrough

The 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 | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change and testing, but it misses required template sections like Closes #issue, checklist, changelog, and screenshots. Add the Closes #issue line, the checklist section, a short changelog, and screenshots placeholders to match the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: Plain SDK migration and org tenant attribution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/migrate-plain-sdk-tri-12460

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

@isshaddad
isshaddad marked this pull request as ready for review July 24, 2026 18:45
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@92f8b3c

trigger.dev

npm i https://pkg.pr.new/trigger.dev@92f8b3c

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@92f8b3c

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@92f8b3c

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@92f8b3c

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@92f8b3c

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@92f8b3c

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@92f8b3c

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@92f8b3c

commit: 92f8b3c

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