chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:32:57 +08:00
commit cd420f9332
4811 changed files with 884702 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
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);
}
}