summaryrefslogtreecommitdiffhomepage
path: root/packages/console/app/src
diff options
context:
space:
mode:
authorRyan Vogel <[email protected]>2026-04-18 18:30:28 -0400
committerGitHub <[email protected]>2026-04-18 18:30:28 -0400
commit1d54b0e54065e3ad09093cff658447d0e2ffde3b (patch)
tree0e8793ec6b12691e46e2c26682df5e57d35e2dd9 /packages/console/app/src
parent7e971d8302c3d2c0020bd81e94d3ca039b4fd9a9 (diff)
downloadopencode-1d54b0e54065e3ad09093cff658447d0e2ffde3b.tar.gz
opencode-1d54b0e54065e3ad09093cff658447d0e2ffde3b.zip
Stefan/enterprise forms waitlist (#23158)
Co-authored-by: Ryan Vogel <[email protected]>
Diffstat (limited to 'packages/console/app/src')
-rw-r--r--packages/console/app/src/routes/api/enterprise.ts71
1 files changed, 69 insertions, 2 deletions
diff --git a/packages/console/app/src/routes/api/enterprise.ts b/packages/console/app/src/routes/api/enterprise.ts
index 1bc4d0eb2..6560a9361 100644
--- a/packages/console/app/src/routes/api/enterprise.ts
+++ b/packages/console/app/src/routes/api/enterprise.ts
@@ -1,5 +1,6 @@
import type { APIEvent } from "@solidjs/start/server"
import { AWS } from "@opencode-ai/console-core/aws.js"
+import { Resource } from "@opencode-ai/console-resource"
import { i18n } from "~/i18n"
import { localeFromRequest } from "~/lib/language"
import { createLead } from "~/lib/salesforce"
@@ -14,6 +15,64 @@ interface EnterpriseFormData {
message: string
}
+const EMAIL_OCTOPUS_LIST_ID = "1b381e5e-39bd-11f1-ba4a-cdd4791f0c43"
+
+function splitFullName(fullName: string) {
+ const parts = fullName
+ .trim()
+ .split(/\s+/)
+ .filter((p) => p.length > 0)
+ if (parts.length === 0) return { firstName: "", lastName: "" }
+ if (parts.length === 1) return { firstName: parts[0], lastName: "" }
+ return { firstName: parts[0], lastName: parts.slice(1).join(" ") }
+}
+
+function getEmailOctopusApiKey() {
+ if (process.env.EMAILOCTOPUS_API_KEY) return process.env.EMAILOCTOPUS_API_KEY
+ try {
+ return Resource.EMAILOCTOPUS_API_KEY.value
+ } catch {
+ return
+ }
+}
+
+function subscribe(email: string, fullName: string) {
+ const apiKey = getEmailOctopusApiKey()
+ if (!apiKey) {
+ console.warn("Skipping EmailOctopus subscribe: missing API key")
+ return Promise.resolve(false)
+ }
+
+ const name = splitFullName(fullName)
+ const fields: Record<string, string> = {}
+ if (name.firstName) fields.FirstName = name.firstName
+ if (name.lastName) fields.LastName = name.lastName
+
+ const payload: { email_address: string; fields?: Record<string, string> } = { email_address: email }
+ if (Object.keys(fields).length) payload.fields = fields
+
+ return fetch(`https://api.emailoctopus.com/lists/${EMAIL_OCTOPUS_LIST_ID}/contacts`, {
+ method: "PUT",
+ headers: {
+ Authorization: `Bearer ${apiKey}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(payload),
+ }).then(
+ (res) => {
+ if (!res.ok) {
+ console.error("EmailOctopus subscribe failed:", res.status, res.statusText)
+ return false
+ }
+ return true
+ },
+ (err) => {
+ console.error("Failed to subscribe enterprise email:", err)
+ return false
+ },
+ )
+}
+
export async function POST(event: APIEvent) {
const dict = i18n(localeFromRequest(event.request))
try {
@@ -41,7 +100,7 @@ ${body.role}<br>
${body.company ? `${body.company}<br>` : ""}${body.email}<br>
${body.phone ? `${body.phone}<br>` : ""}`.trim()
- const [lead, mail] = await Promise.all([
+ const [lead, mail, octopus] = await Promise.all([
createLead({
name: body.name,
role: body.role,
@@ -49,6 +108,9 @@ ${body.phone ? `${body.phone}<br>` : ""}`.trim()
email: body.email,
phone: body.phone,
message: body.message,
+ }).catch((err) => {
+ console.error("Failed to create Salesforce lead:", err)
+ return false
}),
AWS.sendEmail({
@@ -62,9 +124,14 @@ ${body.phone ? `${body.phone}<br>` : ""}`.trim()
return false
},
),
+ subscribe(body.email, body.name),
])
- if (!lead && !mail) {
+ if (!lead && !mail && !octopus) {
+ if (import.meta.env.DEV) {
+ console.warn("Enterprise inquiry accepted in dev mode without integrations", { email: body.email })
+ return Response.json({ success: true, message: dict["enterprise.form.success.submitted"] }, { status: 200 })
+ }
console.error("Enterprise inquiry delivery failed", { email: body.email })
return Response.json({ error: dict["enterprise.form.error.internalServer"] }, { status: 500 })
}