Skip to content

Commit

Permalink
Adds a secondary check and a fall back.
Browse files Browse the repository at this point in the history
Names are required for Plain and we don't always have a username, nor do
we always have a name this takes care of both
  • Loading branch information
perkinsjr committed Sep 20, 2024
1 parent cc0eedd commit cf784e3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions apps/dashboard/lib/trpc/routers/plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
issueType,
severity,
message: z.string(),
}),
})
)
.mutation(async ({ input, ctx }) => {
const apiKey = env().PLAIN_API_KEY;
Expand All @@ -38,7 +38,6 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
}

const email = user.emailAddresses.at(0)!.emailAddress;

const plainUser = await client.upsertCustomer({
identifier: {
emailAddress: email,
Expand All @@ -47,16 +46,18 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
externalId: user.id,
email: {
email: email,
isVerified: user.emailAddresses.at(0)?.verification?.status === "verified",
isVerified:
user.emailAddresses.at(0)?.verification?.status === "verified",
},
fullName: user.username ?? "",
fullName: user.username ?? user.firstName ?? "none avail",
},
onUpdate: {
email: {
email: email,
isVerified: user.emailAddresses.at(0)?.verification?.status === "verified",
isVerified:
user.emailAddresses.at(0)?.verification?.status === "verified",
},
fullName: { value: user.username ?? "" },
fullName: { value: user.username ?? user.firstName ?? "none avail" },
},
});
if (plainUser.error) {
Expand All @@ -77,9 +78,14 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
uiComponent.plainText({ text: input.message }),
uiComponent.spacer({ spacingSize: "M" }),
uiComponent.row({
mainContent: [uiComponent.plainText({ text: ctx.tenant.id, color: "MUTED" })],
mainContent: [
uiComponent.plainText({ text: ctx.tenant.id, color: "MUTED" }),
],
asideContent: [
uiComponent.copyButton({ value: ctx.tenant.id, tooltip: "Copy Tenant Id" }),
uiComponent.copyButton({
value: ctx.tenant.id,
tooltip: "Copy Tenant Id",
}),
],
}),
],
Expand Down

0 comments on commit cf784e3

Please sign in to comment.