Skip to content

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

Open
isshaddad wants to merge 4 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 4 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: 4135bbb

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: 6a0a965f-63b6-4ba1-bfd5-f20e8cf4eabb

📥 Commits

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

📒 Files selected for processing (1)
  • .server-changes/plain-graphql-migration.md
📜 Recent review details
⏰ Context from checks skipped due to timeout. (36)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
  • GitHub Check: sdk-compat / Node.js 22.23 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Node.js 20.20 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Node.js 24.18 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Node.js 26.4 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • 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)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-14T14:54:39.095Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3545
File: .server-changes/agent-view-sessions.md:10-10
Timestamp: 2026-05-14T14:54:39.095Z
Learning: In the `trigger.dev` repository, do not flag inconsistent dot vs slash notation in route/path strings inside `.server-changes/*.md` files. These markdown files are consumed verbatim into the changelog, so the mixed notation (e.g., `resources.orgs.../runs.$runParam/...`) is intentional and should be preserved as-is.

Applied to files:

  • .server-changes/plain-graphql-migration.md
🔇 Additional comments (1)
.server-changes/plain-graphql-migration.md (1)

1-6: LGTM!


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 | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the Plain GraphQL migration and org-tenant attribution.
Description check ✅ Passed It covers the migration, org attribution, deploy prerequisite, and testing, but not the exact template headings.
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 devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment thread apps/webapp/package.json
Comment thread apps/webapp/app/utils/plain.server.ts

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread apps/webapp/app/utils/plain.server.ts
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