Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(landing): add Contact Sales page and inquiry endpoint (MUL-2493) (#2988)
Bohan Jiang7984606eedfd
diff --git a/apps/web/app/(landing)/contact-sales/page.tsx b/apps/web/app/(landing)/contact-sales/page.tsxnew file mode 100644index 0000000000..93397e2746--- /dev/null+++ b/apps/web/app/(landing)/contact-sales/page.tsx@@ -0,0 +1,21 @@+import type { Metadata } from "next";+import { ContactSalesPageClient } from "@/features/landing/components/contact-sales-page-client";++export const metadata: Metadata = {+ title: "Contact Sales",+ description:+ "Talk to the Multica team about rolling out human + agent workflows at your company.",+ openGraph: {+ title: "Contact Sales — Multica",+ description:+ "Tell us about your team. We’ll respond within three business days.",+ url: "/contact-sales",+ },+ alternates: {+ canonical: "/contact-sales",+ },+};++export default function ContactSalesPage() {+ return <ContactSalesPageClient />;+}diff --git a/apps/web/app/sitemap.ts b/apps/web/app/sitemap.tsindex 3a2e6ae0d9..2442c7c835 100644--- a/apps/web/app/sitemap.ts+++ b/apps/web/app/sitemap.ts@@ -22,5 +22,11 @@ export default function sitemap(): MetadataRoute.Sitemap {changeFrequency: "weekly",priority: 0.6,},+ {+ url: `${baseUrl}/contact-sales`,+ lastModified: new Date("2026-05-21"),+ changeFrequency: "monthly",+ priority: 0.7,+ },];}diff --git a/apps/web/features/landing/components/contact-sales-page-client.tsx b/apps/web/features/landing/components/contact-sales-page-client.tsxnew file mode 100644index 0000000000..0f00403458--- /dev/null+++ b/apps/web/features/landing/components/contact-sales-page-client.tsx@@ -0,0 +1,594 @@+"use client";++import Link from "next/link";+import { useId, useMemo, useState } from "react";+import { LandingHeader } from "./landing-header";+import { LandingFooter } from "./landing-footer";+import { useLocale } from "../i18n";++type SubmitState =+ | { status: "idle" }+ | { status: "submitting" }+ | { status: "success" }+ | { status: "error"; message: string };++type FormState = {+ firstName: string;+ lastName: string;+ businessEmail: string;+ companyName: string;+ companySize: string;+ countryRegion: string;+ useCase: string;+ goals: string;+ consentOutreach: boolean;+ consentUpdates: boolean;+};++const EMPTY_FORM: FormState = {+ firstName: "",+ lastName: "",+ businessEmail: "",+ companyName: "",+ companySize: "",+ countryRegion: "",+ useCase: "",+ goals: "",+ consentOutreach: false,+ consentUpdates: false,+};++// Free providers we reject client-side, so users get instant feedback. The+// server enforces a longer list independently — this is purely a UX guard+// and is not a security boundary.+const CLIENT_FREE_EMAIL_DOMAINS = new Set([+ "gmail.com",+ "googlemail.com",+ "outlook.com",+ "hotmail.com",+ "live.com",+ "msn.com",+ "yahoo.com",+ "icloud.com",+ "me.com",+ "aol.com",+ "qq.com",+ "163.com",+ "126.com",+ "foxmail.com",+]);++export function ContactSalesPageClient() {+ const { t } = useLocale();+ const c = t.contactSales;++ const [form, setForm] = useState<FormState>(EMPTY_FORM);+ const [state, setState] = useState<SubmitState>({ status: "idle" });++ const isBusy = state.status === "submitting";++ const emailDomain = useMemo(() => {+ const at = form.businessEmail.lastIndexOf("@");+ if (at < 0) return "";+ return form.businessEmail.slice(at + 1).trim().toLowerCase();+ }, [form.businessEmail]);++ const emailLooksFree = emailDomain !== "" && CLIENT_FREE_EMAIL_DOMAINS.has(emailDomain);++ function update<K extends keyof FormState>(key: K, value: FormState[K]) {+ setForm((prev) => ({ ...prev, [key]: value }));+ }++ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {+ e.preventDefault();+ if (isBusy) return;+ if (emailLooksFree) {+ setState({ status: "error", message: c.errors.freeEmail });+ return;+ }+ setState({ status: "submitting" });++ try {+ const res = await fetch("/api/contact-sales", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ first_name: form.firstName,+ last_name: form.lastName,+ business_email: form.businessEmail,+ company_name: form.companyName,+ company_size: form.companySize,+ country_region: form.countryRegion,+ use_case: form.useCase,+ goals: form.goals,+ consent_outreach: form.consentOutreach,+ consent_updates: form.consentUpdates,+ }),+ });++ if (res.ok) {+ setState({ status: "success" });+ setForm(EMPTY_FORM);+ return;+ }++ // 429 from per-IP middleware or per-email DB cap.+ if (res.status === 429) {+ setState({ status: "error", message: c.errors.rateLimit });+ return;+ }++ // Try to extract a server error message; fall back to generic copy.+ let serverMsg = "";+ try {+ const body = (await res.json()) as { error?: unknown };+ if (typeof body?.error === "string") serverMsg = body.error;+ } catch {+ // ignore — body wasn't JSON.+ }+ if (/business email/i.test(serverMsg)) {+ setState({ status: "error", message: c.errors.freeEmail });+ } else if (/email/i.test(serverMsg)) {+ setState({ status: "error", message: c.errors.invalidEmail });+ } else {+ setState({ status: "error", message: c.errors.generic });+ }+ } catch {+ setState({ status: "error", message: c.errors.generic });+ }+ }++ return (+ <>+ <LandingHeader variant="light" />+ <main className="bg-[#f7f8fa] text-[#0a0d12]">+ <div className="mx-auto max-w-[760px] px-4 py-12 sm:px-6 sm:py-16 lg:py-20">+ <div className="mb-8 text-center">+ <p className="text-[12px] font-semibold uppercase tracking-[0.12em] text-[#0a0d12]/45">+ {c.eyebrow}+ </p>+ <h1 className="mt-2 font-[family-name:var(--font-serif)] text-[2.4rem] leading-[1.1] tracking-[-0.02em] sm:text-[2.8rem]">+ {c.title}+ </h1>+ <p className="mt-3 text-[14px] text-[#0a0d12]/60 sm:text-[15px]">+ {c.subtitle}+ </p>+ </div>++ {state.status === "success" ? (+ <SuccessCard+ title={c.success.title}+ message={c.success.message}+ cta={c.success.cta}+ />+ ) : (+ <FormCard+ form={form}+ update={update}+ emailLooksFree={emailLooksFree}+ busy={isBusy}+ error={state.status === "error" ? state.message : null}+ onSubmit={handleSubmit}+ dict={c}+ />+ )}+ </div>+ </main>+ <LandingFooter />+ </>+ );+}++function SuccessCard({+ title,+ message,+ cta,+}: {+ title: string;+ message: string;+ cta: string;+}) {+ return (+ <div className="rounded-[16px] border border-[#0a0d12]/8 bg-white p-8 shadow-[0_1px_2px_rgba(10,13,18,0.04)] sm:p-10">+ <h2 className="font-[family-name:var(--font-serif)] text-[1.8rem] leading-[1.15] tracking-[-0.02em]">+ {title}+ </h2>+ <p className="mt-3 text-[15px] leading-[1.7] text-[#0a0d12]/70">+ {message}+ </p>+ <div className="mt-6">+ <Link+ href="/"+ className="inline-flex items-center gap-2 rounded-[11px] bg-[#0a0d12] px-5 py-2.5 text-[13px] font-semibold text-white transition-colors hover:bg-[#0a0d12]/88"+ >+ {cta}+ </Link>+ </div>+ </div>+ );+}++type FormDict = ReturnType<typeof useLocale>["t"]["contactSales"];++function FormCard({+ form,+ update,+ emailLooksFree,+ busy,+ error,+ onSubmit,+ dict,+}: {+ form: FormState;+ update: <K extends keyof FormState>(key: K, value: FormState[K]) => void;+ emailLooksFree: boolean;+ busy: boolean;+ error: string | null;+ onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;+ dict: FormDict;+}) {+ const firstNameId = useId();+ const lastNameId = useId();+ const emailId = useId();+ const emailHintId = useId();+ const companyId = useId();+ const sizeId = useId();+ const countryId = useId();+ const useCaseId = useId();+ const goalsId = useId();+ const goalsHintId = useId();+ const consentOutreachId = useId();+ const consentUpdatesId = useId();++ return (+ <form+ onSubmit={onSubmit}+ className="space-y-8 rounded-[16px] border border-[#0a0d12]/8 bg-white p-6 shadow-[0_1px_2px_rgba(10,13,18,0.04)] sm:p-10"+ >+ <div className="rounded-[12px] border border-[#0a0d12]/8 bg-[#f7f8fa] p-4 text-[13px] leading-[1.6] text-[#0a0d12]/72">+ <p className="font-semibold text-[#0a0d12]">+ <span aria-hidden className="mr-1.5">📌</span>+ {dict.notice.badge}+ </p>+ <p className="mt-1">{dict.notice.body}</p>+ </div>++ <div className="grid gap-5 sm:grid-cols-2">+ <Field label={dict.fields.firstName} htmlFor={firstNameId} required>+ <TextInput+ id={firstNameId}+ value={form.firstName}+ onChange={(v) => update("firstName", v)}+ autoComplete="given-name"+ maxLength={80}+ required+ disabled={busy}+ />+ </Field>+ <Field label={dict.fields.lastName} htmlFor={lastNameId} required>+ <TextInput+ id={lastNameId}+ value={form.lastName}+ onChange={(v) => update("lastName", v)}+ autoComplete="family-name"+ maxLength={80}+ required+ disabled={busy}+ />+ </Field>+ </div>++ <div className="grid gap-5 sm:grid-cols-2">+ <Field+ label={dict.fields.businessEmail}+ htmlFor={emailId}+ required+ hint={dict.fields.businessEmailHint}+ hintId={emailHintId}+ tone={emailLooksFree ? "warning" : undefined}+ >+ <TextInput+ id={emailId}+ type="email"+ value={form.businessEmail}+ onChange={(v) => update("businessEmail", v)}+ autoComplete="email"+ maxLength={254}+ required+ disabled={busy}+ ariaDescribedBy={emailHintId}+ ariaInvalid={emailLooksFree || undefined}+ />+ </Field>+ <Field label={dict.fields.companyName} htmlFor={companyId} required>+ <TextInput+ id={companyId}+ value={form.companyName}+ onChange={(v) => update("companyName", v)}+ autoComplete="organization"+ maxLength={200}+ required+ disabled={busy}+ />+ </Field>+ </div>++ <Field label={dict.fields.companySize} htmlFor={sizeId} required>+ <SelectInput+ id={sizeId}+ value={form.companySize}+ onChange={(v) => update("companySize", v)}+ placeholder={dict.fields.selectPlaceholder}+ required+ disabled={busy}+ options={dict.companySizes}+ />+ </Field>++ <Field label={dict.fields.countryRegion} htmlFor={countryId} required>+ <SelectInput+ id={countryId}+ value={form.countryRegion}+ onChange={(v) => update("countryRegion", v)}+ placeholder={dict.fields.selectPlaceholder}+ required+ disabled={busy}+ options={dict.countries.map((c) => ({ value: c, label: c }))}+ />+ </Field>++ <Field label={dict.fields.useCase} htmlFor={useCaseId} required>+ <SelectInput+ id={useCaseId}+ value={form.useCase}+ onChange={(v) => update("useCase", v)}+ placeholder={dict.fields.selectPlaceholder}+ required+ disabled={busy}+ options={dict.useCases}+ />+ </Field>++ <Field+ label={dict.fields.goals}+ htmlFor={goalsId}+ hint={dict.fields.goalsHint}+ hintId={goalsHintId}+ >+ <textarea+ id={goalsId}+ value={form.goals}+ onChange={(e) => update("goals", e.target.value)}+ rows={4}+ maxLength={2000}+ disabled={busy}+ aria-describedby={goalsHintId}+ className="block w-full rounded-[10px] border border-[#0a0d12]/14 bg-white px-3.5 py-2.5 text-[14px] text-[#0a0d12] placeholder:text-[#0a0d12]/35 transition-colors focus:border-[#0a0d12]/40 focus:outline-none focus:ring-2 focus:ring-[#0a0d12]/10 disabled:opacity-60"+ />+ </Field>++ <ConsentBlock+ outreachId={consentOutreachId}+ updatesId={consentUpdatesId}+ form={form}+ update={update}+ dict={dict}+ busy={busy}+ />++ {error ? (+ <p+ role="alert"+ className="rounded-[10px] border border-[#c83a3a]/24 bg-[#fdecec] px-4 py-3 text-[13px] leading-[1.6] text-[#7a1d1d]"+ >+ {error}+ </p>+ ) : null}++ <button+ type="submit"+ disabled={busy}+ className="inline-flex w-full items-center justify-center rounded-[12px] bg-[#f04a2f] px-5 py-3 text-[14px] font-semibold text-white transition-colors hover:bg-[#d63d24] disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto"+ >+ {busy ? dict.fields.submitting : dict.fields.submit}+ </button>+ </form>+ );+}++function Field({+ label,+ htmlFor,+ required,+ hint,+ hintId,+ tone,+ children,+}: {+ label: string;+ htmlFor: string;+ required?: boolean;+ hint?: string;+ hintId?: string;+ tone?: "warning";+ children: React.ReactNode;+}) {+ return (+ <div className="space-y-1.5">+ <label+ htmlFor={htmlFor}+ className="block text-[13px] font-medium text-[#0a0d12]/82"+ >+ {label}+ {required ? <span className="ml-0.5 text-[#f04a2f]">*</span> : null}+ </label>+ {children}+ {hint ? (+ <p+ id={hintId}+ className={+ tone === "warning"+ ? "text-[12px] leading-[1.55] text-[#7a1d1d]"+ : "text-[12px] leading-[1.55] text-[#0a0d12]/55"+ }+ >+ {hint}+ </p>+ ) : null}+ </div>+ );+}++function TextInput({+ id,+ value,+ onChange,+ type = "text",+ autoComplete,+ maxLength,+ required,+ disabled,+ ariaDescribedBy,+ ariaInvalid,+}: {+ id: string;+ value: string;+ onChange: (v: string) => void;+ type?: string;+ autoComplete?: string;+ maxLength?: number;+ required?: boolean;+ disabled?: boolean;+ ariaDescribedBy?: string;+ ariaInvalid?: boolean;+}) {+ return (+ <input+ id={id}+ type={type}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ autoComplete={autoComplete}+ maxLength={maxLength}+ required={required}+ disabled={disabled}+ aria-describedby={ariaDescribedBy}+ aria-invalid={ariaInvalid}+ className="block w-full rounded-[10px] border border-[#0a0d12]/14 bg-white px-3.5 py-2.5 text-[14px] text-[#0a0d12] placeholder:text-[#0a0d12]/35 transition-colors focus:border-[#0a0d12]/40 focus:outline-none focus:ring-2 focus:ring-[#0a0d12]/10 disabled:opacity-60 aria-[invalid=true]:border-[#c83a3a]/60 aria-[invalid=true]:focus:ring-[#c83a3a]/15"+ />+ );+}++function SelectInput({+ id,+ value,+ onChange,+ options,+ placeholder,+ required,+ disabled,+}: {+ id: string;+ value: string;+ onChange: (v: string) => void;+ options: { value: string; label: string }[];+ placeholder: string;+ required?: boolean;+ disabled?: boolean;+}) {+ return (+ <select+ id={id}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ required={required}+ disabled={disabled}+ className="block w-full appearance-none rounded-[10px] border border-[#0a0d12]/14 bg-white bg-[url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%228%22%20viewBox%3D%220%200%2012%208%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M1%201.5L6%206.5L11%201.5%22%20stroke%3D%22%230a0d12%22%20stroke-opacity%3D%220.5%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E')] bg-[length:12px_8px] bg-[right_14px_center] bg-no-repeat px-3.5 py-2.5 pr-10 text-[14px] text-[#0a0d12] transition-colors focus:border-[#0a0d12]/40 focus:outline-none focus:ring-2 focus:ring-[#0a0d12]/10 disabled:opacity-60"+ >+ <option value="" disabled>+ {placeholder}+ </option>+ {options.map((opt) => (+ <option key={opt.value} value={opt.value}>+ {opt.label}+ </option>+ ))}+ </select>+ );+}++function ConsentBlock({+ outreachId,+ updatesId,+ form,+ update,+ dict,+ busy,+}: {+ outreachId: string;+ updatesId: string;+ form: FormState;+ update: <K extends keyof FormState>(key: K, value: FormState[K]) => void;+ dict: FormDict;+ busy: boolean;+}) {+ return (+ <div className="space-y-3 text-[13px] leading-[1.65] text-[#0a0d12]/70">+ <p className="font-semibold text-[#0a0d12]">+ {dict.consent.intro}+ </p>+ <ConsentCheckbox+ id={outreachId}+ checked={form.consentOutreach}+ onChange={(v) => update("consentOutreach", v)}+ disabled={busy}+ label={dict.consent.outreach}+ />+ <ConsentCheckbox+ id={updatesId}+ checked={form.consentUpdates}+ onChange={(v) => update("consentUpdates", v)}+ disabled={busy}+ label={dict.consent.updates}+ />+ <p>+ {dict.consent.unsubscribe}{" "}+ <Link+ href={dict.consent.privacyLinkHref}+ className="text-[#0a0d12] underline decoration-[#0a0d12]/30 underline-offset-2 hover:decoration-[#0a0d12]/60"+ >+ {dict.consent.privacyLinkLabel}+ </Link>+ </p>+ <p>{dict.consent.submitConsent}</p>+ </div>+ );+}++function ConsentCheckbox({+ id,+ checked,+ onChange,+ disabled,+ label,+}: {+ id: string;+ checked: boolean;+ onChange: (v: boolean) => void;+ disabled?: boolean;+ label: string;+}) {+ return (+ <label htmlFor={id} className="flex items-start gap-2.5">+ <input+ id={id}+ type="checkbox"+ checked={checked}+ onChange={(e) => onChange(e.target.checked)}+ disabled={disabled}+ className="mt-0.5 size-4 shrink-0 rounded-[4px] border-[#0a0d12]/30 text-[#0a0d12] focus:ring-[#0a0d12]/20 disabled:opacity-60"+ />+ <span>{label}</span>+ </label>+ );+}diff --git a/apps/web/features/landing/components/landing-header.tsx b/apps/web/features/landing/components/landing-header.tsxindex df1d233fcc..bb39a9c188 100644--- a/apps/web/features/landing/components/landing-header.tsx+++ b/apps/web/features/landing/components/landing-header.tsx@@ -53,6 +53,15 @@ export function LandingHeader({>{t.header.changelog}</Link>+ <Link+ href="/contact-sales"+ className={cn(+ headerButtonClassName("ghost", variant),+ "hidden md:inline-flex",+ )}+ >+ {t.header.contactSales}+ </Link><Linkhref={githubUrl}target="_blank"diff --git a/apps/web/features/landing/i18n/en.ts b/apps/web/features/landing/i18n/en.tsindex 3d5cdf3859..23241512af 100644--- a/apps/web/features/landing/i18n/en.ts+++ b/apps/web/features/landing/i18n/en.ts@@ -8,6 +8,7 @@ export function createEnDict(allowSignup: boolean): LandingDict {login: "Log in",dashboard: "Dashboard",changelog: "Changelog",+ contactSales: "Contact Sales",},hero: {@@ -244,6 +245,7 @@ export function createEnDict(allowSignup: boolean): LandingDict {links: [{ label: "About", href: "/about" },{ label: "Open Source", href: "#open-source" },+ { label: "Contact Sales", href: "/contact-sales" },{ label: "GitHub", href: githubUrl },],},@@ -1364,5 +1366,121 @@ export function createEnDict(allowSignup: boolean): LandingDict {versionUnavailable: "Version unavailable — check GitHub",},},+ contactSales: {+ pageTitle: "Contact Sales",+ pageDescription:+ "Talk to the Multica team about rolling out human + agent workflows at your company.",+ eyebrow: "Contact Sales",+ title: "Let’s understand your needs",+ subtitle:+ "Help us tailor the best solution for you before we connect.",+ notice: {+ badge: "Our system only recognizes business email domains.",+ body: "Requests from personal emails (e.g., @gmail.com, @outlook.com) will not be detected or processed.",+ },+ fields: {+ firstName: "First name",+ lastName: "Last name",+ businessEmail: "Business email",+ businessEmailHint:+ "Company email required. Please use a valid company domain so we can follow up with you.",+ companyName: "Company name",+ companySize: "Company size",+ countryRegion: "Country / Region",+ useCase: "How do you plan to use or collaborate with Multica?",+ goals: "Your goals or challenges",+ goalsHint:+ "Tell us what you’d like to achieve with Multica or the challenges you’re facing. The more details you provide, the better we can support you.",+ selectPlaceholder: "Please select",+ submit: "Submit",+ submitting: "Submitting…",+ },+ companySizes: [+ { value: "1-10", label: "1 – 10 employees" },+ { value: "11-50", label: "11 – 50 employees" },+ { value: "51-200", label: "51 – 200 employees" },+ { value: "201-500", label: "201 – 500 employees" },+ { value: "501-1000", label: "501 – 1,000 employees" },+ { value: "1000+", label: "1,000+ employees" },+ ],+ useCases: [+ { value: "evaluate", label: "Evaluating Multica for my team" },+ { value: "adopt_team", label: "Rolling out Multica to a team or company" },+ { value: "self_host", label: "Self-hosting on our own infrastructure" },+ { value: "integrate", label: "Integrating Multica with existing tools" },+ { value: "partner", label: "Partnership or reseller inquiry" },+ { value: "other", label: "Something else" },+ ],+ countries: [+ "United States",+ "Canada",+ "United Kingdom",+ "Germany",+ "France",+ "Netherlands",+ "Sweden",+ "Switzerland",+ "Spain",+ "Italy",+ "Ireland",+ "Norway",+ "Denmark",+ "Finland",+ "Belgium",+ "Portugal",+ "Australia",+ "New Zealand",+ "Japan",+ "South Korea",+ "Singapore",+ "Hong Kong SAR",+ "Taiwan",+ "China (Mainland)",+ "India",+ "Indonesia",+ "Thailand",+ "Vietnam",+ "Philippines",+ "Malaysia",+ "United Arab Emirates",+ "Saudi Arabia",+ "Israel",+ "Turkey",+ "South Africa",+ "Brazil",+ "Mexico",+ "Argentina",+ "Chile",+ "Other",+ ],+ consent: {+ intro:+ "Multica, Inc. respects your privacy. We’ll use your personal information only to manage your account and deliver the products or services you’ve requested. Occasionally, we’d love to share product updates, best practices, and insights that may be relevant to you. Please let us know below if you’d like to hear from us.",+ outreach:+ "I’d like to receive one-to-one communication from Multica, Inc., including service updates, support inquiries, and business-related follow-ups.",+ updates:+ "I’d like to receive product updates, insights, and event invitations from Multica.",+ unsubscribe:+ "You can unsubscribe from our communications at any time. For more details on how we handle your data and privacy rights, please review our",+ submitConsent:+ "By clicking “Submit,” you consent to allow Multica, Inc. to store and process your information for the purpose of delivering the requested content.",+ privacyLinkLabel: "Privacy Policy.",+ privacyLinkHref: "/about",+ },+ success: {+ title: "Thanks — we got it.",+ message:+ "A member of the Multica team will respond within three business days. In the meantime, feel free to explore the docs or star us on GitHub.",+ cta: "Back to multica.ai",+ },+ errors: {+ generic: "Something went wrong — please try again in a moment.",+ rateLimit:+ "We’ve received a few inquiries from this address recently. Please try again in a little while.",+ freeEmail:+ "Please use a business email address — free providers (gmail, outlook, etc.) are not accepted.",+ invalidEmail: "That doesn’t look like a valid email address.",+ },+ },};}diff --git a/apps/web/features/landing/i18n/types.ts b/apps/web/features/landing/i18n/types.tsindex 11a9b43e5d..3c85a77ed5 100644--- a/apps/web/features/landing/i18n/types.ts+++ b/apps/web/features/landing/i18n/types.ts@@ -19,8 +19,16 @@ type FooterGroup = {links: { label: string; href: string }[];};+export type ContactSalesOption = { value: string; label: string };+export type LandingDict = {- header: { github: string; login: string; dashboard: string; changelog: string };+ header: {+ github: string;+ login: string;+ dashboard: string;+ changelog: string;+ contactSales: string;+ };hero: {headlineLine1: string;headlineLine2: string;@@ -162,4 +170,46 @@ export type LandingDict = {versionUnavailable: string;};};+ contactSales: {+ pageTitle: string;+ pageDescription: string;+ eyebrow: string;+ title: string;+ subtitle: string;+ notice: { badge: string; body: string };+ fields: {+ firstName: string;+ lastName: string;+ businessEmail: string;+ businessEmailHint: string;+ companyName: string;+ companySize: string;+ countryRegion: string;+ useCase: string;+ goals: string;+ goalsHint: string;+ selectPlaceholder: string;+ submit: string;+ submitting: string;+ };+ companySizes: ContactSalesOption[];+ useCases: ContactSalesOption[];+ countries: string[];+ consent: {+ intro: string;+ outreach: string;+ updates: string;+ unsubscribe: string;+ submitConsent: string;+ privacyLinkLabel: string;+ privacyLinkHref: string;+ };+ success: { title: string; message: string; cta: string };+ errors: {+ generic: string;+ rateLimit: string;+ freeEmail: string;+ invalidEmail: string;+ };+ };};diff --git a/apps/web/features/landing/i18n/zh.ts b/apps/web/features/landing/i18n/zh.tsindex 2b4f71a0e3..e9d6cebf34 100644--- a/apps/web/features/landing/i18n/zh.ts+++ b/apps/web/features/landing/i18n/zh.ts@@ -8,6 +8,7 @@ export function createZhDict(allowSignup: boolean): LandingDict {login: "\u767b\u5f55",dashboard: "\u8fdb\u5165\u5de5\u4f5c\u53f0",changelog: "\u66f4\u65b0\u65e5\u5fd7",+ contactSales: "\u8054\u7cfb\u5546\u52a1",},hero: {@@ -244,6 +245,7 @@ export function createZhDict(allowSignup: boolean): LandingDict {links: [{ label: "\u5173\u4e8e\u6211\u4eec", href: "/about" },{ label: "\u5f00\u6e90", href: "#open-source" },+ { label: "\u8054\u7cfb\u5546\u52a1", href: "/contact-sales" },{ label: "GitHub", href: githubUrl },],},@@ -1361,5 +1363,120 @@ export function createZhDict(allowSignup: boolean): LandingDict {versionUnavailable: "版本获取失败——请前往 GitHub 查看",},},+ contactSales: {+ pageTitle: "联系商务",+ pageDescription:+ "了解如何在你的团队中落地 Multica 的人类 + 智能体协作工作流。",+ eyebrow: "联系商务",+ title: "先了解你的需求",+ subtitle: "在正式沟通之前,让我们为你定制最合适的方案。",+ notice: {+ badge: "系统仅识别企业邮箱域名。",+ body: "来自个人邮箱(例如 @gmail.com、@outlook.com)的请求不会被处理。",+ },+ fields: {+ firstName: "名",+ lastName: "姓",+ businessEmail: "企业邮箱",+ businessEmailHint:+ "请使用真实的企业邮箱域名,方便我们后续与你联系。",+ companyName: "公司名称",+ companySize: "公司规模",+ countryRegion: "国家 / 地区",+ useCase: "你打算如何使用 Multica 或与我们合作?",+ goals: "你的目标或挑战",+ goalsHint:+ "告诉我们你希望借助 Multica 达成什么目标,或正在面临的挑战。信息越详细,我们越能给到合适的支持。",+ selectPlaceholder: "请选择",+ submit: "提交",+ submitting: "正在提交…",+ },+ companySizes: [+ { value: "1-10", label: "1 – 10 人" },+ { value: "11-50", label: "11 – 50 人" },+ { value: "51-200", label: "51 – 200 人" },+ { value: "201-500", label: "201 – 500 人" },+ { value: "501-1000", label: "501 – 1,000 人" },+ { value: "1000+", label: "1,000 人以上" },+ ],+ useCases: [+ { value: "evaluate", label: "正在为团队评估 Multica" },+ { value: "adopt_team", label: "希望在团队 / 公司内推广使用" },+ { value: "self_host", label: "需要在自有基础设施上自托管" },+ { value: "integrate", label: "希望与现有工具集成" },+ { value: "partner", label: "合作 / 渠道合作咨询" },+ { value: "other", label: "其他" },+ ],+ countries: [+ "中国大陆",+ "中国香港",+ "中国澳门",+ "中国台湾",+ "新加坡",+ "马来西亚",+ "印度尼西亚",+ "泰国",+ "越南",+ "菲律宾",+ "日本",+ "韩国",+ "印度",+ "阿联酋",+ "沙特阿拉伯",+ "以色列",+ "土耳其",+ "美国",+ "加拿大",+ "英国",+ "德国",+ "法国",+ "荷兰",+ "瑞典",+ "瑞士",+ "西班牙",+ "意大利",+ "爱尔兰",+ "挪威",+ "丹麦",+ "芬兰",+ "比利时",+ "葡萄牙",+ "澳大利亚",+ "新西兰",+ "南非",+ "巴西",+ "墨西哥",+ "阿根廷",+ "智利",+ "其他",+ ],+ consent: {+ intro:+ "Multica, Inc. 尊重你的隐私。我们仅会将你的个人信息用于管理账户,以及提供你所请求的产品或服务。我们偶尔也希望与你分享产品更新、最佳实践或行业洞察,如果你愿意接收,请在下方勾选。",+ outreach:+ "我希望接收来自 Multica, Inc. 的一对一沟通,包括服务更新、支持咨询以及业务相关的跟进。",+ updates:+ "我希望接收 Multica 的产品更新、洞察以及活动邀请。",+ unsubscribe:+ "你可以随时取消订阅我们的邮件。关于我们如何处理你的数据以及隐私权利,请参阅",+ submitConsent:+ "点击「提交」即表示你同意 Multica, Inc. 存储并处理你提交的信息,以便交付你请求的内容。",+ privacyLinkLabel: "隐私政策。",+ privacyLinkHref: "/about",+ },+ success: {+ title: "已收到,谢谢!",+ message:+ "Multica 团队会在三个工作日内回复你。在此期间,欢迎查看我们的文档,或在 GitHub 上为我们点个 Star。",+ cta: "返回 multica.ai",+ },+ errors: {+ generic: "提交失败,请稍后再试。",+ rateLimit: "该邮箱近期已提交多次,请稍后再试。",+ freeEmail:+ "请使用企业邮箱——免费邮箱(gmail、outlook 等)暂不接受。",+ invalidEmail: "邮箱地址格式不正确。",+ },+ },};}diff --git a/docs/analytics.md b/docs/analytics.mdindex 15748877fd..3cabcf91c3 100644--- a/docs/analytics.md+++ b/docs/analytics.md@@ -91,7 +91,7 @@ Every event is assigned to one dashboard category:|---|---|| `core_loop` | `workspace_created`, `runtime_registered`, `runtime_ready`, `runtime_failed`, `runtime_offline`, `agent_created`, `issue_created`, `chat_message_sent`, `agent_task_queued`, `agent_task_dispatched`, `agent_task_started`, `agent_task_completed`, `agent_task_failed`, `agent_task_cancelled`, `autopilot_run_started`, `autopilot_run_completed`, `autopilot_run_failed` || `onboarding_support` | `onboarding_started`, `onboarding_questionnaire_submitted`, `onboarding_completed`, `onboarding_runtime_path_selected`, `onboarding_runtime_detected` |-| `acquisition` | `signup`, `download_intent_expressed`, `download_page_viewed`, `download_initiated`, `cloud_waitlist_joined` |+| `acquisition` | `signup`, `download_intent_expressed`, `download_page_viewed`, `download_initiated`, `cloud_waitlist_joined`, `contact_sales_submitted` || `ops_feedback` | `feedback_opened`, `feedback_submitted` || `system/noise` | `$pageview`, `$set`, `$identify`, `$autocapture`, `$rageclick` |@@ -452,6 +452,21 @@ funnel and used to size hosted-runtime interest.`distinct_id` is the user's id.+### `contact_sales_submitted`++Fires from `CreateContactSales` after the `contact_sales_inquiry` row is+inserted. The endpoint is public and unauthenticated, so the+`distinct_id` is the inquiry id (no user identity to attach to). The+free-text `goals` field stays in the DB and is never broadcast.++| Property | Type | Description |+|---|---|---|+| `inquiry_id` | string | Stable inquiry id; same as `distinct_id`. Useful for joining to operational data. |+| `company_size` | string | Closed enum from the form dropdown (`1-10`, `11-50`, `51-200`, `201-500`, `501-1000`, `1000+`). |+| `country_region` | string | Country / region label submitted from the dropdown. |+| `use_case` | string | Closed enum (`evaluate` / `adopt_team` / `self_host` / `integrate` / `partner` / `other`). |+| `has_goals` | bool | Presence flag for the free-text goals field. |+### `feedback_submitted`Fires from `CreateFeedback` after the `feedback` row is inserted and thediff --git a/packages/core/paths/reserved-slugs.ts b/packages/core/paths/reserved-slugs.tsindex e72bb2cc71..064620b937 100644--- a/packages/core/paths/reserved-slugs.ts+++ b/packages/core/paths/reserved-slugs.ts@@ -57,6 +57,7 @@ export const RESERVED_SLUGS: ReadonlySet<string> = new Set(["terms","security","contact",+ "contact-sales","blog","careers","press",diff --git a/server/cmd/server/router.go b/server/cmd/server/router.goindex 9048da2810..0f996878f6 100644--- a/server/cmd/server/router.go+++ b/server/cmd/server/router.go@@ -246,6 +246,7 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.BustrustedProxies := middleware.ParseTrustedProxies(os.Getenv("RATE_LIMIT_TRUSTED_PROXIES"))authRL := middleware.RateLimit(rdb, envPositiveInt("RATE_LIMIT_AUTH", 5), time.Minute, trustedProxies)authVerifyRL := middleware.RateLimit(rdb, envPositiveInt("RATE_LIMIT_AUTH_VERIFY", 20), time.Minute, trustedProxies)+ contactSalesRL := middleware.RateLimit(rdb, envPositiveInt("RATE_LIMIT_CONTACT_SALES", 5), time.Hour, trustedProxies)r.With(authRL).Post("/auth/send-code", h.SendCode)r.With(authVerifyRL).Post("/auth/verify-code", h.VerifyCode)r.With(authRL).Post("/auth/google", h.GoogleLogin)@@ -253,6 +254,7 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus// Public APIr.Get("/api/config", h.GetConfig)+ r.With(contactSalesRL).Post("/api/contact-sales", h.CreateContactSales)// Webhook ingress for autopilots. Outside the authenticated group on// purpose: the bearer token in the URL path IS the credential. Workspacediff --git a/server/internal/analytics/events.go b/server/internal/analytics/events.goindex ff750fdd3d..cfdaf8fccf 100644--- a/server/internal/analytics/events.go+++ b/server/internal/analytics/events.go@@ -30,6 +30,7 @@ const (EventOnboardingCompleted = "onboarding_completed"EventCloudWaitlistJoined = "cloud_waitlist_joined"EventFeedbackSubmitted = "feedback_submitted"+ EventContactSalesSubmitted = "contact_sales_submitted")const EventSchemaVersion = 2@@ -542,6 +543,28 @@ func FeedbackSubmitted(userID, workspaceID string, messageLen int, hasImages boo}}+// ContactSalesSubmitted fires after a contact-sales inquiry is recorded.+// The form is public and unauthenticated, so DistinctID is empty (PostHog+// will treat it as an anonymous event). We carry the coarse company size,+// country, and intended use case so sales / marketing can split inbound+// volume without having to query the operational DB.+func ContactSalesSubmitted(inquiryID, companySize, countryRegion, useCase string, hasGoals bool) Event {+ props := map[string]any{+ "inquiry_id": inquiryID,+ "company_size": companySize,+ "country_region": countryRegion,+ "use_case": useCase,+ "has_goals": hasGoals,+ }+ return Event{+ Name: EventContactSalesSubmitted,+ DistinctID: inquiryID,+ Properties: withCoreProperties(props, CoreProperties{+ Source: "marketing_contact_sales",+ }),+ }+}+func agentTaskEvent(name string, ctx TaskContext, extra map[string]any) Event {props := withCoreProperties(extra, CoreProperties(ctx))return Event{diff --git a/server/internal/handler/contact_sales.go b/server/internal/handler/contact_sales.gonew file mode 100644index 0000000000..d1ba76b982--- /dev/null+++ b/server/internal/handler/contact_sales.go@@ -0,0 +1,309 @@+package handler++import (+ "encoding/json"+ "log/slog"+ "net"+ "net/http"+ "net/mail"+ "net/netip"+ "slices"+ "strings"++ "github.com/multica-ai/multica/server/internal/analytics"+ "github.com/multica-ai/multica/server/internal/logger"+ db "github.com/multica-ai/multica/server/pkg/db/generated"+)++// Public, unauthenticated endpoint for the landing-page "Contact Sales"+// form. Spam is mitigated by:+// - business-email validation (free providers blocked at the handler).+// - a per-email hourly cap so a successful submission can't be replayed+// into a flood from the same address.+// - per-IP rate limiting applied at the router (RATE_LIMIT_CONTACT_SALES).+//+// Free-text fields are length-capped before they reach the DB, and the+// request body itself is bounded so an attacker can't POST megabytes of+// junk into the JSONB-free TEXT columns.+const (+ contactSalesMaxFirstName = 80+ contactSalesMaxLastName = 80+ contactSalesMaxEmail = 254+ contactSalesMaxCompanyName = 200+ contactSalesMaxGoals = 2000+ contactSalesHourlyEmailCap = 3+ contactSalesBodyLimit = 16 * 1024+)++// contactSalesAllowedCompanySize is the closed enum the frontend dropdown+// emits. Keep this in sync with `apps/web/features/landing/i18n/types.ts`.+var contactSalesAllowedCompanySize = []string{+ "1-10",+ "11-50",+ "51-200",+ "201-500",+ "501-1000",+ "1000+",+}++// contactSalesAllowedUseCase mirrors the "How do you plan to use or+// collaborate with Multica?" dropdown.+var contactSalesAllowedUseCase = []string{+ "evaluate",+ "adopt_team",+ "self_host",+ "integrate",+ "partner",+ "other",+}++// freeEmailDomains are the personal-mail domains we reject up front. The+// frontend shows the same warning copy, but server-side enforcement is the+// authority — a hand-rolled curl request mustn't be able to bypass it.+var freeEmailDomains = map[string]struct{}{+ "gmail.com": {},+ "googlemail.com": {},+ "outlook.com": {},+ "hotmail.com": {},+ "live.com": {},+ "msn.com": {},+ "yahoo.com": {},+ "yahoo.co.uk": {},+ "yahoo.co.jp": {},+ "ymail.com": {},+ "icloud.com": {},+ "me.com": {},+ "mac.com": {},+ "aol.com": {},+ "protonmail.com": {},+ "proton.me": {},+ "pm.me": {},+ "gmx.com": {},+ "gmx.de": {},+ "mail.com": {},+ "zoho.com": {},+ "yandex.com": {},+ "yandex.ru": {},+ "qq.com": {},+ "163.com": {},+ "126.com": {},+ "sina.com": {},+ "foxmail.com": {},+}++type CreateContactSalesRequest struct {+ FirstName string `json:"first_name"`+ LastName string `json:"last_name"`+ BusinessEmail string `json:"business_email"`+ CompanyName string `json:"company_name"`+ CompanySize string `json:"company_size"`+ CountryRegion string `json:"country_region"`+ UseCase string `json:"use_case"`+ Goals string `json:"goals"`+ ConsentOutreach bool `json:"consent_outreach"`+ ConsentUpdates bool `json:"consent_updates"`+}++type ContactSalesResponse struct {+ ID string `json:"id"`+ CreatedAt string `json:"created_at"`+}++// CreateContactSales is the public POST /api/contact-sales endpoint.+func (h *Handler) CreateContactSales(w http.ResponseWriter, r *http.Request) {+ r.Body = http.MaxBytesReader(w, r.Body, contactSalesBodyLimit)+ var req CreateContactSalesRequest+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {+ writeError(w, http.StatusBadRequest, "invalid request body")+ return+ }++ firstName, ok := requireTrimmedField(w, req.FirstName, "first_name", contactSalesMaxFirstName)+ if !ok {+ return+ }+ lastName, ok := requireTrimmedField(w, req.LastName, "last_name", contactSalesMaxLastName)+ if !ok {+ return+ }+ companyName, ok := requireTrimmedField(w, req.CompanyName, "company_name", contactSalesMaxCompanyName)+ if !ok {+ return+ }++ email, ok := canonicalBusinessEmail(req.BusinessEmail)+ if !ok {+ writeError(w, http.StatusBadRequest, "business_email is invalid")+ return+ }+ if len(email) > contactSalesMaxEmail {+ writeError(w, http.StatusBadRequest, "business_email is too long")+ return+ }+ if !isBusinessEmailDomain(email) {+ writeError(w, http.StatusBadRequest, "please use a business email address")+ return+ }++ companySize := strings.TrimSpace(req.CompanySize)+ if !slices.Contains(contactSalesAllowedCompanySize, companySize) {+ writeError(w, http.StatusBadRequest, "company_size is invalid")+ return+ }++ countryRegion := strings.TrimSpace(req.CountryRegion)+ if countryRegion == "" {+ writeError(w, http.StatusBadRequest, "country_region is required")+ return+ }+ // Bound the dropdown value at a generous length — we accept any string+ // the frontend submits (country list is large) but cap it so an+ // attacker can't stuff the column.+ if len(countryRegion) > 80 {+ writeError(w, http.StatusBadRequest, "country_region is too long")+ return+ }++ useCase := strings.TrimSpace(req.UseCase)+ if !slices.Contains(contactSalesAllowedUseCase, useCase) {+ writeError(w, http.StatusBadRequest, "use_case is invalid")+ return+ }++ goals := strings.TrimSpace(req.Goals)+ if len(goals) > contactSalesMaxGoals {+ writeError(w, http.StatusBadRequest, "goals is too long")+ return+ }++ // Per-email hourly cap: keeps a single business address from being+ // used as a re-submit channel after one valid pass. DB-backed so it+ // works across replicas and survives a restart.+ count, err := h.Queries.CountRecentContactSalesByEmail(r.Context(), email)+ if err != nil {+ slog.Warn("count recent contact sales failed", append(logger.RequestAttrs(r), "error", err)...)+ writeError(w, http.StatusInternalServerError, "failed to submit inquiry")+ return+ }+ if count >= contactSalesHourlyEmailCap {+ writeError(w, http.StatusTooManyRequests, "too many recent inquiries from this email")+ return+ }++ inquiry, err := h.Queries.CreateContactSalesInquiry(r.Context(), db.CreateContactSalesInquiryParams{+ FirstName: firstName,+ LastName: lastName,+ BusinessEmail: email,+ CompanyName: companyName,+ CompanySize: companySize,+ CountryRegion: countryRegion,+ UseCase: useCase,+ Goals: goals,+ ConsentOutreach: req.ConsentOutreach,+ ConsentUpdates: req.ConsentUpdates,+ UserAgent: truncateString(r.UserAgent(), 512),+ SubmitterIp: submitterIP(r),+ })+ if err != nil {+ slog.Warn("create contact sales failed", append(logger.RequestAttrs(r), "error", err)...)+ writeError(w, http.StatusInternalServerError, "failed to submit inquiry")+ return+ }++ inquiryID := uuidToString(inquiry.ID)+ slog.Info("contact sales submitted",+ append(logger.RequestAttrs(r),+ "inquiry_id", inquiryID,+ "company_size", companySize,+ "country_region", countryRegion,+ "use_case", useCase,+ )...)++ h.Analytics.Capture(analytics.ContactSalesSubmitted(+ inquiryID,+ companySize,+ countryRegion,+ useCase,+ goals != "",+ ))++ writeJSON(w, http.StatusCreated, ContactSalesResponse{+ ID: inquiryID,+ CreatedAt: timestampToString(inquiry.CreatedAt),+ })+}++func requireTrimmedField(w http.ResponseWriter, raw, field string, max int) (string, bool) {+ v := strings.TrimSpace(raw)+ if v == "" {+ writeError(w, http.StatusBadRequest, field+" is required")+ return "", false+ }+ if len(v) > max {+ writeError(w, http.StatusBadRequest, field+" is too long")+ return "", false+ }+ return v, true+}++func truncateString(s string, max int) string {+ if len(s) <= max {+ return s+ }+ return s[:max]+}++// canonicalBusinessEmail parses raw user input with net/mail and returns the+// canonical "local@domain" form (lower-cased, no display name, no surrounding+// whitespace). It is the only safe input to isBusinessEmailDomain — checking+// the raw string allows `Ada <[email protected]>` to slip past the free-email+// block list because the parsed RFC 5322 address would have domain `gmail.com`+// while the raw "@" suffix would be `gmail.com>`.+func canonicalBusinessEmail(raw string) (string, bool) {+ trimmed := strings.TrimSpace(raw)+ if trimmed == "" {+ return "", false+ }+ addr, err := mail.ParseAddress(trimmed)+ if err != nil {+ return "", false+ }+ email := strings.ToLower(strings.TrimSpace(addr.Address))+ // mail.ParseAddress also accepts forms like `<[email protected]>` and+ // addresses with comments; addr.Address strips both. Require the+ // canonical local@domain shape with non-empty pieces on either side.+ at := strings.LastIndex(email, "@")+ if at <= 0 || at == len(email)-1 {+ return "", false+ }+ return email, true+}++func isBusinessEmailDomain(email string) bool {+ at := strings.LastIndex(email, "@")+ if at < 0 || at == len(email)-1 {+ return false+ }+ domain := strings.ToLower(email[at+1:])+ if _, blocked := freeEmailDomains[domain]; blocked {+ return false+ }+ return true+}++// submitterIP captures the raw connection IP so we can correlate abuse+// after the fact. We deliberately ignore X-Forwarded-For here — the+// router's rate-limit middleware already vets trusted-proxy headers; for+// the audit record we want the actual TCP peer, which is the conservative+// signal under deployments that don't enforce XFF stripping.+func submitterIP(r *http.Request) *netip.Addr {+ host, _, err := net.SplitHostPort(r.RemoteAddr)+ if err != nil {+ host = r.RemoteAddr+ }+ addr, err := netip.ParseAddr(host)+ if err != nil {+ return nil+ }+ return &addr+}diff --git a/server/internal/handler/contact_sales_test.go b/server/internal/handler/contact_sales_test.gonew file mode 100644index 0000000000..25e22d1c79--- /dev/null+++ b/server/internal/handler/contact_sales_test.go@@ -0,0 +1,236 @@+package handler++import (+ "bytes"+ "context"+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "testing"+)++func newContactSalesRequest(body CreateContactSalesRequest) *http.Request {+ var buf bytes.Buffer+ json.NewEncoder(&buf).Encode(body)+ req := httptest.NewRequest("POST", "/api/contact-sales", &buf)+ req.Header.Set("Content-Type", "application/json")+ return req+}++func validContactSalesRequest() CreateContactSalesRequest {+ return CreateContactSalesRequest{+ FirstName: "Ada",+ LastName: "Lovelace",+ BusinessEmail: "[email protected]",+ CompanyName: "Analytical Engine Co.",+ CompanySize: "11-50",+ CountryRegion: "United Kingdom",+ UseCase: "evaluate",+ Goals: "We want to compound agent productivity across the team.",+ ConsentOutreach: true,+ ConsentUpdates: false,+ }+}++func clearContactSalesForEmail(t *testing.T, email string) {+ t.Helper()+ if _, err := testPool.Exec(context.Background(),+ `DELETE FROM contact_sales_inquiry WHERE business_email = $1`, email); err != nil {+ t.Fatalf("clear contact_sales_inquiry: %v", err)+ }+ t.Cleanup(func() {+ testPool.Exec(context.Background(),+ `DELETE FROM contact_sales_inquiry WHERE business_email = $1`, email)+ })+}++func TestCreateContactSalesHappyPath(t *testing.T) {+ body := validContactSalesRequest()+ clearContactSalesForEmail(t, body.BusinessEmail)++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusCreated {+ t.Fatalf("expected 201, got %d: %s", w.Code, w.Body.String())+ }+ var resp ContactSalesResponse+ if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {+ t.Fatalf("decode response: %v", err)+ }+ if resp.ID == "" {+ t.Fatal("expected inquiry id in response")+ }+}++func TestCreateContactSalesRejectsFreeEmail(t *testing.T) {+ body := validContactSalesRequest()+ body.BusinessEmail = "[email protected]"++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesRejectsInvalidEmail(t *testing.T) {+ body := validContactSalesRequest()+ body.BusinessEmail = "not-an-email"++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesRejectsUnknownCompanySize(t *testing.T) {+ body := validContactSalesRequest()+ body.CompanySize = "ten-ish"++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesRejectsUnknownUseCase(t *testing.T) {+ body := validContactSalesRequest()+ body.UseCase = "world-domination"++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesMissingFirstName(t *testing.T) {+ body := validContactSalesRequest()+ body.FirstName = " "++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesPerEmailRateLimit(t *testing.T) {+ body := validContactSalesRequest()+ body.BusinessEmail = "[email protected]"+ clearContactSalesForEmail(t, body.BusinessEmail)++ for i := 0; i < contactSalesHourlyEmailCap; i++ {+ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))+ if w.Code != http.StatusCreated {+ t.Fatalf("iteration %d: expected 201, got %d: %s", i, w.Code, w.Body.String())+ }+ }++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))+ if w.Code != http.StatusTooManyRequests {+ t.Fatalf("expected 429, got %d: %s", w.Code, w.Body.String())+ }+}++func TestIsBusinessEmailDomain(t *testing.T) {+ cases := []struct {+ email string+ want bool+ }{+ {"[email protected]", true},+ {"[email protected]", true},+ {"[email protected]", false},+ {"[email protected]", false},+ {"[email protected]", false},+ {"[email protected]", false},+ {"weird-no-at", false},+ {"ada@", false},+ }+ for _, c := range cases {+ got := isBusinessEmailDomain(c.email)+ if got != c.want {+ t.Errorf("isBusinessEmailDomain(%q) = %v, want %v", c.email, got, c.want)+ }+ }+}++func TestCanonicalBusinessEmail(t *testing.T) {+ cases := []struct {+ name string+ input string+ want string+ wantOk bool+ }{+ {"plain", "[email protected]", "[email protected]", true},+ {"uppercase normalized", "[email protected]", "[email protected]", true},+ {"trim whitespace", " [email protected] ", "[email protected]", true},+ {"display name stripped", "Ada Lovelace <[email protected]>", "[email protected]", true},+ {"angle-bracketed", "<[email protected]>", "[email protected]", true},+ {"empty", "", "", false},+ {"only whitespace", " ", "", false},+ {"missing at", "no-at-sign", "", false},+ {"missing local", "@multica.ai", "", false},+ {"missing domain", "ada@", "", false},+ }+ for _, c := range cases {+ t.Run(c.name, func(t *testing.T) {+ got, ok := canonicalBusinessEmail(c.input)+ if ok != c.wantOk || got != c.want {+ t.Errorf("canonicalBusinessEmail(%q) = (%q, %v), want (%q, %v)",+ c.input, got, ok, c.want, c.wantOk)+ }+ })+ }+}++// Regression: net/mail.ParseAddress accepts display-name forms like+// `Ada <[email protected]>`. Earlier versions of the handler ran the+// free-email check against the raw user input, so the domain it saw was+// `gmail.com>` (with the trailing angle bracket) — which is not in the+// block list, allowing a personal address to bypass the gate. The handler+// must canonicalize through the parsed addr.Address before the check.+func TestCreateContactSalesRejectsFreeEmailWithDisplayName(t *testing.T) {+ body := validContactSalesRequest()+ body.BusinessEmail = "Ada Lovelace <[email protected]>"++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())+ }+}++func TestCreateContactSalesNormalizesDisplayNameEmail(t *testing.T) {+ body := validContactSalesRequest()+ body.BusinessEmail = "Ada Lovelace <[email protected]>"+ clearContactSalesForEmail(t, "[email protected]")++ w := httptest.NewRecorder()+ testHandler.CreateContactSales(w, newContactSalesRequest(body))++ if w.Code != http.StatusCreated {+ t.Fatalf("expected 201, got %d: %s", w.Code, w.Body.String())+ }++ var stored string+ if err := testPool.QueryRow(context.Background(),+ `SELECT business_email FROM contact_sales_inquiry WHERE business_email = $1`,+ "[email protected]").Scan(&stored); err != nil {+ t.Fatalf("expected row with canonical email persisted: %v", err)+ }+ if stored != "[email protected]" {+ t.Fatalf("expected canonical email persisted, got %q", stored)+ }+}diff --git a/server/internal/handler/reserved_slugs.json b/server/internal/handler/reserved_slugs.jsonindex 5419526b87..e2a0c5edf4 100644--- a/server/internal/handler/reserved_slugs.json+++ b/server/internal/handler/reserved_slugs.json@@ -45,6 +45,7 @@"terms","security","contact",+ "contact-sales","blog","careers","press",diff --git a/server/migrations/098_contact_sales_inquiries.down.sql b/server/migrations/098_contact_sales_inquiries.down.sqlnew file mode 100644index 0000000000..7047668933--- /dev/null+++ b/server/migrations/098_contact_sales_inquiries.down.sql@@ -0,0 +1 @@+DROP TABLE IF EXISTS contact_sales_inquiry;diff --git a/server/migrations/098_contact_sales_inquiries.up.sql b/server/migrations/098_contact_sales_inquiries.up.sqlnew file mode 100644index 0000000000..fb4611ed4b--- /dev/null+++ b/server/migrations/098_contact_sales_inquiries.up.sql@@ -0,0 +1,26 @@+-- Contact-sales inquiries submitted from the public marketing site.+--+-- The endpoint is unauthenticated so the row has no user_id / workspace_id.+-- Spam mitigation is handled by per-IP rate limiting + business-email+-- validation at the handler layer. We store the IP only so the abuse signal+-- survives a process restart; we never expose it back through the API.++CREATE TABLE contact_sales_inquiry (+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),+ first_name TEXT NOT NULL,+ last_name TEXT NOT NULL,+ business_email TEXT NOT NULL,+ company_name TEXT NOT NULL,+ company_size TEXT NOT NULL,+ country_region TEXT NOT NULL,+ use_case TEXT NOT NULL,+ goals TEXT NOT NULL DEFAULT '',+ consent_outreach BOOLEAN NOT NULL DEFAULT false,+ consent_updates BOOLEAN NOT NULL DEFAULT false,+ submitter_ip INET,+ user_agent TEXT NOT NULL DEFAULT '',+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()+);++CREATE INDEX idx_contact_sales_inquiry_created ON contact_sales_inquiry(created_at DESC);+CREATE INDEX idx_contact_sales_inquiry_email_created ON contact_sales_inquiry(business_email, created_at DESC);diff --git a/server/pkg/db/generated/contact_sales.sql.go b/server/pkg/db/generated/contact_sales.sql.gonew file mode 100644index 0000000000..e73a1ef98b--- /dev/null+++ b/server/pkg/db/generated/contact_sales.sql.go@@ -0,0 +1,96 @@+// Code generated by sqlc. DO NOT EDIT.+// versions:+// sqlc v1.30.0+// source: contact_sales.sql++package db++import (+ "context"+ "net/netip"+)++const countRecentContactSalesByEmail = `-- name: CountRecentContactSalesByEmail :one+SELECT count(*) FROM contact_sales_inquiry+WHERE business_email = $1 AND created_at > now() - interval '1 hour'+`++func (q *Queries) CountRecentContactSalesByEmail(ctx context.Context, businessEmail string) (int64, error) {+ row := q.db.QueryRow(ctx, countRecentContactSalesByEmail, businessEmail)+ var count int64+ err := row.Scan(&count)+ return count, err+}++const createContactSalesInquiry = `-- name: CreateContactSalesInquiry :one+INSERT INTO contact_sales_inquiry (+ first_name,+ last_name,+ business_email,+ company_name,+ company_size,+ country_region,+ use_case,+ goals,+ consent_outreach,+ consent_updates,+ submitter_ip,+ user_agent+)+VALUES (+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,+ $12::inet,+ $11+)+RETURNING id, first_name, last_name, business_email, company_name, company_size, country_region, use_case, goals, consent_outreach, consent_updates, submitter_ip, user_agent, created_at+`++type CreateContactSalesInquiryParams struct {+ FirstName string `json:"first_name"`+ LastName string `json:"last_name"`+ BusinessEmail string `json:"business_email"`+ CompanyName string `json:"company_name"`+ CompanySize string `json:"company_size"`+ CountryRegion string `json:"country_region"`+ UseCase string `json:"use_case"`+ Goals string `json:"goals"`+ ConsentOutreach bool `json:"consent_outreach"`+ ConsentUpdates bool `json:"consent_updates"`+ UserAgent string `json:"user_agent"`+ SubmitterIp *netip.Addr `json:"submitter_ip"`+}++func (q *Queries) CreateContactSalesInquiry(ctx context.Context, arg CreateContactSalesInquiryParams) (ContactSalesInquiry, error) {+ row := q.db.QueryRow(ctx, createContactSalesInquiry,+ arg.FirstName,+ arg.LastName,+ arg.BusinessEmail,+ arg.CompanyName,+ arg.CompanySize,+ arg.CountryRegion,+ arg.UseCase,+ arg.Goals,+ arg.ConsentOutreach,+ arg.ConsentUpdates,+ arg.UserAgent,+ arg.SubmitterIp,+ )+ var i ContactSalesInquiry+ err := row.Scan(+ &i.ID,+ &i.FirstName,+ &i.LastName,+ &i.BusinessEmail,+ &i.CompanyName,+ &i.CompanySize,+ &i.CountryRegion,+ &i.UseCase,+ &i.Goals,+ &i.ConsentOutreach,+ &i.ConsentUpdates,+ &i.SubmitterIp,+ &i.UserAgent,+ &i.CreatedAt,+ )+ return i, err+}diff --git a/server/pkg/db/generated/models.go b/server/pkg/db/generated/models.goindex 5344b78e09..c78177312f 100644--- a/server/pkg/db/generated/models.go+++ b/server/pkg/db/generated/models.go@@ -5,6 +5,8 @@package dbimport (+ "net/netip"+"github.com/jackc/pgx/v5/pgtype")@@ -216,6 +218,23 @@ type CommentReaction struct {CreatedAt pgtype.Timestamptz `json:"created_at"`}+type ContactSalesInquiry struct {+ ID pgtype.UUID `json:"id"`+ FirstName string `json:"first_name"`+ LastName string `json:"last_name"`+ BusinessEmail string `json:"business_email"`+ CompanyName string `json:"company_name"`+ CompanySize string `json:"company_size"`+ CountryRegion string `json:"country_region"`+ UseCase string `json:"use_case"`+ Goals string `json:"goals"`+ ConsentOutreach bool `json:"consent_outreach"`+ ConsentUpdates bool `json:"consent_updates"`+ SubmitterIp *netip.Addr `json:"submitter_ip"`+ UserAgent string `json:"user_agent"`+ CreatedAt pgtype.Timestamptz `json:"created_at"`+}+type DaemonConnection struct {ID pgtype.UUID `json:"id"`AgentID pgtype.UUID `json:"agent_id"`diff --git a/server/pkg/db/queries/contact_sales.sql b/server/pkg/db/queries/contact_sales.sqlnew file mode 100644index 0000000000..7fe983c363--- /dev/null+++ b/server/pkg/db/queries/contact_sales.sql@@ -0,0 +1,25 @@+-- name: CreateContactSalesInquiry :one+INSERT INTO contact_sales_inquiry (+ first_name,+ last_name,+ business_email,+ company_name,+ company_size,+ country_region,+ use_case,+ goals,+ consent_outreach,+ consent_updates,+ submitter_ip,+ user_agent+)+VALUES (+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,+ sqlc.narg(submitter_ip)::inet,+ $11+)+RETURNING *;++-- name: CountRecentContactSalesByEmail :one+SELECT count(*) FROM contact_sales_inquiry+WHERE business_email = $1 AND created_at > now() - interval '1 hour';