The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Upgrade Plain to auto-generate support title
Steven Teya25da69e652f
diff --git a/apps/web/app/api/support/route.ts b/apps/web/app/api/support/route.tsindex 236dbf3219..f17e734b35 100644--- a/apps/web/app/api/support/route.ts+++ b/apps/web/app/api/support/route.ts@@ -11,14 +11,13 @@ export const GET = withSession(async ({ session }) => {});const supportRequestQuerySchema = z.object({- title: z.string().min(1),message: z.string().min(1),attachmentIds: z.array(z.string()),});// POST /api/support – file a support requestexport const POST = withSession(async ({ req, session }) => {- const { title, message, attachmentIds } = supportRequestQuerySchema.parse(+ const { message, attachmentIds } = supportRequestQuerySchema.parse(await req.json(),);@@ -26,7 +25,6 @@ export const POST = withSession(async ({ req, session }) => {customerIdentifier: {externalId: session.user.id,},- title,components: [{componentText: {diff --git a/apps/web/lib/ai/generate-support-title.ts b/apps/web/lib/ai/generate-support-title.tsdeleted file mode 100644index 6e91fb53e4..0000000000--- a/apps/web/lib/ai/generate-support-title.ts+++ /dev/null@@ -1,26 +0,0 @@-"use server";--import { anthropic } from "@ai-sdk/anthropic";-import { streamText } from "ai";-import { createStreamableValue } from "ai/rsc";--export async function generateSupportTitle(prompt: string) {- const stream = createStreamableValue();-- (async () => {- const { textStream } = await streamText({- model: anthropic("claude-3-sonnet-20240229"),- prompt: `Create a short but concise title that summarizes the following support request. Only return the generated title, and nothing else. Don't use quotation marks.-- ${prompt}`,- });-- for await (const delta of textStream) {- stream.update(delta);- }-- stream.done();- })();-- return { output: stream.value };-}diff --git a/apps/web/package.json b/apps/web/package.jsonindex 41a089001f..a59b9bcebd 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -30,7 +30,7 @@"@splinetool/react-spline": "^2.2.6","@splinetool/runtime": "^1.2.8","@stripe/stripe-js": "^1.44.1",- "@team-plain/typescript-sdk": "^3.9.0",+ "@team-plain/typescript-sdk": "^4.5.0","@upstash/qstash": "^2.3.0","@upstash/ratelimit": "^1.1.3","@upstash/redis": "^1.25.1",diff --git a/apps/web/ui/layout/help/contact-form.tsx b/apps/web/ui/layout/help/contact-form.tsxindex 86878b5d80..2b9061ce97 100644--- a/apps/web/ui/layout/help/contact-form.tsx+++ b/apps/web/ui/layout/help/contact-form.tsx@@ -1,7 +1,5 @@-import { generateSupportTitle } from "@/lib/ai/generate-support-title";import { CheckCircleFill } from "@/ui/shared/icons";import { Button, FileUpload, LoadingSpinner, useEnterSubmit } from "@dub/ui";-import { readStreamableValue } from "ai/rsc";import { AnimatePresence, motion } from "framer-motion";import { ChevronLeft, Paperclip, Trash2 } from "lucide-react";import { Dispatch, SetStateAction, useRef, useState } from "react";@@ -14,11 +12,9 @@ export function ContactForm({setScreen: Dispatch<SetStateAction<"main" | "contact">>;}) {const [data, setData] = useState<{- title: string | null;message: string;attachmentIds: string[];}>({- title: null,message: "",attachmentIds: [],});@@ -120,32 +116,13 @@ export function ContactForm({toast.error(res.error);setFormStatus("idle");} else {- setData({ title: null, message: "", attachmentIds: [] });+ setData({ message: "", attachmentIds: [] });setFormStatus("success");}}}initial={{ opacity: 1, y: 0 }}exit={{ opacity: 0, y: -10 }}>- {typeof data.title === "string" && (- <label>- <span className="text-sm font-medium text-gray-700">- Issue title- </span>- <input- name="title"- required- placeholder="E.g. Custom domain not working"- autoComplete="off"- value={data.title}- onChange={(e) =>- setData((prev) => ({ ...prev, title: e.target.value }))- }- className="mt-1 block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- />- </label>- )}-<label><span className="text-sm font-medium text-gray-700">Describe the issue@@ -158,19 +135,6 @@ export function ContactForm({autoFocusautoComplete="off"value={data.message}- onBlur={async () => {- if (!data.title && data.message) {- const { output } = await generateSupportTitle(data.message);-- for await (const delta of readStreamableValue(output)) {- setData((prev) => ({- ...prev,- // if prev.title is not null, append the delta to it- title: prev.title ? prev.title + delta : delta,- }));- }- }- }}onChange={(e) =>setData((prev) => ({ ...prev, message: e.target.value }))}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 73b27f6848..dfa1d60e65 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -89,8 +89,8 @@ importers:specifier: ^1.44.1version: 1.44.1'@team-plain/typescript-sdk':- specifier: ^3.9.0- version: 3.9.0+ specifier: ^4.5.0+ version: 4.5.0'@upstash/qstash':specifier: ^2.3.0version: 2.3.0@@ -7837,8 +7837,8 @@ packages:tailwindcss: 3.3.3dev: false- /@team-plain/[email protected]:- resolution: {integrity: sha512-fS22kpwPuKzXpIHs+tK+974Wx/+CPs3+vmxW1kldmuXGWZ1p8V4PdYC0R8AC0uiG9f48VX4gq6x1Uw2isPpM+w==}+ /@team-plain/[email protected]:+ resolution: {integrity: sha512-+m9sfToLtlkV6wOnpYBxGnRwEpvn4zcaXHhA+C4lst52U6cvTzTCw2t7z2EYgXqe/IG/5voR5DiiyKK1vIM32g==}dependencies:'@graphql-typed-document-node/core': 3.2.0([email protected])ajv: 8.12.0