Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Send feedback via email instead of Discord webhook
Richie McIlroybff97822f36b
diff --git a/apps/web/app/api/desktop/[...route]/root.ts b/apps/web/app/api/desktop/[...route]/root.tsindex 30f167904..bc191642d 100644--- a/apps/web/app/api/desktop/[...route]/root.ts+++ b/apps/web/app/api/desktop/[...route]/root.ts@@ -1,5 +1,7 @@import * as crypto from "node:crypto";import { db } from "@cap/database";+import { sendEmail } from "@cap/database/emails/config";+import { Feedback } from "@cap/database/emails/feedback";import {organizationMembers,organizations,@@ -255,31 +257,23 @@ app.post(),async (c) => {const { feedback, os, version } = c.req.valid("form");+ const userEmail = c.get("user").email;try {- const discordWebhookUrl = serverEnv().DISCORD_FEEDBACK_WEBHOOK_URL;- if (!discordWebhookUrl)- throw new Error("Discord webhook URL is not configured");-- const response = await fetch(discordWebhookUrl, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- content: [- `New feedback from ${c.get("user").email}:`,- feedback,- os && version && `${os} v${version}`,- ]- .filter(Boolean)- .join("\n"),+ await sendEmail({+ email: "[email protected]",+ subject: `New Feedback from ${userEmail}`,+ react: Feedback({+ userEmail,+ feedback,+ os,+ version,}),+ cc: userEmail,+ replyTo: userEmail,+ fromOverride: "Richie from Cap <[email protected]>",});- if (!response.ok)- throw new Error(- `Failed to send feedback to Discord: ${response.statusText}`,- );-return c.json({success: true,message: "Feedback submitted successfully",diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.tsindex 7a171c180..ad20552b6 100644--- a/packages/database/emails/config.ts+++ b/packages/database/emails/config.ts@@ -12,6 +12,9 @@ export const sendEmail = async ({marketing,test,scheduledAt,+ cc,+ replyTo,+ fromOverride,}: {email: string;subject: string;@@ -19,6 +22,9 @@ export const sendEmail = async ({marketing?: boolean;test?: boolean;scheduledAt?: string;+ cc?: string | string[];+ replyTo?: string;+ fromOverride?: string;}) => {const r = resend();if (!r) {@@ -28,7 +34,8 @@ export const sendEmail = async ({if (marketing && !buildEnv.NEXT_PUBLIC_IS_CAP) return;let from;- if (marketing) from = "Richie from Cap <[email protected]>";+ if (fromOverride) from = fromOverride;+ else if (marketing) from = "Richie from Cap <[email protected]>";else if (buildEnv.NEXT_PUBLIC_IS_CAP)from = "Cap Auth <[email protected]>";else from = `auth@${serverEnv().RESEND_FROM_DOMAIN}`;@@ -39,5 +46,7 @@ export const sendEmail = async ({subject,react,scheduledAt,+ cc: test ? undefined : cc,+ reply_to: replyTo,}) as any;};diff --git a/packages/database/emails/feedback.tsx b/packages/database/emails/feedback.tsxnew file mode 100644index 000000000..964c35a34--- /dev/null+++ b/packages/database/emails/feedback.tsx@@ -0,0 +1,67 @@+import { CAP_LOGO_URL } from "@cap/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";++export function Feedback({+ userEmail = "",+ feedback = "",+ os,+ version,+}: {+ userEmail: string;+ feedback: string;+ os?: string;+ version?: string;+}) {+ return (+ <Html>+ <Head />+ <Preview>New feedback from {userEmail}</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-gray-1 font-sans">+ <Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">+ <Section className="mt-8">+ <Img+ src={CAP_LOGO_URL}+ width="40"+ height="40"+ alt="Cap"+ className="mx-auto my-0"+ />+ </Section>+ <Heading className="mx-0 my-7 p-0 text-center text-xl font-semibold text-black">+ New User Feedback+ </Heading>+ <Text className="text-sm leading-6 text-black">+ <strong>From:</strong> {userEmail}+ </Text>+ {(os || version) && (+ <Text className="text-sm leading-6 text-black">+ <strong>Platform:</strong> {os || "Unknown"}{" "}+ {version ? `v${version}` : ""}+ </Text>+ )}+ <Section className="my-4 p-4 bg-gray-50 rounded-lg">+ <Text className="text-sm leading-6 text-gray-700 whitespace-pre-wrap">+ {feedback}+ </Text>+ </Section>+ <Text className="text-sm leading-6 text-gray-500">+ Reply to this email to respond directly to the user.+ </Text>+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}