Files
triggerdotdev--trigger.dev/apps/webapp/app/utils/plain.server.ts
Chris Arderne c7861be520 chore: activate no-unused-vars and import linters (#4096)
Once this is merged, oxlint is at a pretty sensible baseline.

**Enable `no-unused-vars`, `typescript/consistent-type-imports`, and
`import/no-duplicates` lint rules**

Turns on three previously-disabled oxlint rules across the monorepo and
fixes all violations:

- **`no-unused-vars`** – enabled as an error with standard ignore
patterns: unused function arguments are ignored by default (`args:
"none"`), variables/caught errors/destructured array elements prefixed
with `_` are allowed, and rest siblings are permitted.
- **`typescript/consistent-type-imports`** – enforced as an error; all
type-only imports now use the `import type` syntax.
- **`import/no-duplicates`** – enforced as an error; duplicate import
statements from the same module have been merged.

The remaining commits clean up the violations found across the codebase:
removing unused variables/imports/type aliases, adding `_` prefixes to
intentionally unused bindings, fixing duplicate imports, and converting
value imports to `import type` where appropriate.
2026-07-02 11:37:05 +01:00

63 lines
1.4 KiB
TypeScript

import type { uiComponent } from "@team-plain/typescript-sdk";
import { PlainClient } from "@team-plain/typescript-sdk";
import { env } from "~/env.server";
type Input = {
userId: string;
email: string;
name: string;
title: string;
components: ReturnType<typeof uiComponent.text>[];
labelTypeIds?: string[];
};
export async function sendToPlain({ userId, email, name, title, components, labelTypeIds }: Input) {
if (!env.PLAIN_API_KEY) {
return;
}
const client = new PlainClient({
apiKey: env.PLAIN_API_KEY,
});
const upsertCustomerRes = await client.upsertCustomer({
identifier: {
emailAddress: email,
},
onCreate: {
externalId: userId,
fullName: name,
email: {
email: email,
isVerified: true,
},
},
onUpdate: {
externalId: { value: userId },
fullName: { value: name },
email: {
email: email,
isVerified: true,
},
},
});
if (upsertCustomerRes.error) {
console.error("Failed to upsert customer in Plain", upsertCustomerRes.error);
return;
}
const createThreadRes = await client.createThread({
customerIdentifier: {
customerId: upsertCustomerRes.data.customer.id,
},
title: title,
components: components,
labelTypeIds,
});
if (createThreadRes.error) {
console.error("Failed to create thread in Plain", createThreadRes.error);
}
}