MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / action

Function action

apps/webapp/app/routes/resources.feedback.ts:38–153  ·  view source on GitHub ↗
({ request }: ActionFunctionArgs)

Source from the content-addressed store, hash-verified

36});
37
38export async function action({ request }: ActionFunctionArgs) {
39 const user = await requireUser(request);
40
41 const formData = await request.formData();
42 const submission = parse(formData, { schema });
43
44 if (!submission.value || submission.intent !== "submit") {
45 return json(submission);
46 }
47
48 try {
49 if (!env.PLAIN_API_KEY) {
50 console.error("PLAIN_API_KEY is not set");
51 submission.error.message = "PLAIN_API_KEY is not set";
52 return json(submission);
53 }
54
55 client = new PlainClient({
56 apiKey: env.PLAIN_API_KEY,
57 });
58
59 const upsertCustomerRes = await client.upsertCustomer({
60 identifier: {
61 emailAddress: user.email,
62 },
63 onCreate: {
64 externalId: user.id,
65 fullName: user.name ?? "",
66 // TODO - Optional: set 'first name' on user
67 // shortName: ''
68 email: {
69 email: user.email,
70 isVerified: true,
71 },
72 },
73 onUpdate: {
74 externalId: { value: user.id },
75 fullName: { value: user.name ?? "" },
76 // TODO - see above
77 // shortName: { value: "" },
78 email: {
79 email: user.email,
80 isVerified: true,
81 },
82 },
83 });
84
85 if (upsertCustomerRes.error) {
86 console.error(
87 inspect(upsertCustomerRes.error, {
88 showHidden: false,
89 depth: null,
90 colors: true,
91 })
92 );
93 submission.error.message = upsertCustomerRes.error.message;
94 return json(submission);
95 }

Callers

nothing calls this directly

Calls 6

requireUserFunction · 0.90
jsonFunction · 0.85
upsertCustomerMethod · 0.80
errorMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…