Repository navigation
feat(console): enrich Salesforce leads with Console account status - #54255
Slickstef11 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Mostly sound, with one blocking regression: the Enterprise form now fails completely whenever the Console account lookup fails.
How I checked: ran the three new test files (25 pass) and bun run typecheck in packages/console/app (passes). I also called handleEnterpriseRequest with a lookup that throws (as lookupConsoleAccount does on a non-2xx response or timeout). The route returned 500 and no Salesforce lead was submitted. I couldn't exercise a real Salesforce org or the companion Console route.
Public API: OpenCode's CLI, SDK, server and plugin APIs are unchanged. The website app gains an internal, token-authenticated POST /api/console-signup endpoint and two infra resources (CONSOLE_CRM_TOKEN secret, CONSOLE_CRM_LOOKUP_URL link). These are additive, but they must be configured before deploying.
Concerns:
- Blocking: the enterprise inquiry now hard-depends on the Console lookup (see inline). Because the lookup URL targets a route that only exists in the companion Console PR, deploying this first, or any Console outage, would drop every inquiry.
- Tests:
console-signup.test.tsspins up a real local HTTP server to fake Salesforce (see inline).
| return Response.json({ error: dict["enterprise.form.error.invalidInferenceSpend"] }, { status: 400 }) | ||
| } | ||
|
|
||
| const account = await (options.accountLookup ?? lookupConsoleAccount)(body.email) |
There was a problem hiding this comment.
If this lookup throws (Console 5xx/404, 8s timeout, missing token), the outer catch returns 500. The Salesforce lead, the sales email and the EmailOctopus subscription are then all skipped, so the inquiry is lost. On dev this form has no Console dependency. CONSOLE_CRM_LOOKUP_URL also points to a route that only exists in the companion Console PR, so deploying this first would break the form outright.
Enrichment should be best-effort. For example, .catch(() => undefined) here leaves the Console fields off the Lead (since consoleAccount === undefined skips them). Ideally run the lookup alongside the email/subscription calls instead of before them, so it doesn't add up to 8s of latency.
| ) { | ||
| const people: Record<string, unknown>[] = initial.map((person) => ({ ...person })) | ||
| const writes: { method: string; path: string; payload: Record<string, unknown> }[] = [] | ||
| const server = Bun.serve({ |
There was a problem hiding this comment.
syncConsoleAccount already takes an injectable SalesforceRequest, so these tests don't need a real Bun.serve instance, real fetches, or a hand-rolled SOQL/REST emulator with assertions inside the request handler. A plain in-memory request function that records calls would cover the same cases (create once, retry updates, converted Contact not duplicated, auth rejected), with far less code and no network or port state. Please cut this down to those core cases.
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Summary
enterprise website form) from Console signups (console signup) while preserving original sources on existing Leads and Contacts.Individualfor recognized personal-email providers.Companion Console change
anomalyco/opencode-console#3392 contains the form/FAQ changes, private account lookup, durable signup queue, verified-signup hooks, and worker scheduling.
Validation
bun test src/lib/salesforce.test.ts src/lib/console-signup.test.ts script/salesforce-cli-response.test.ts— 25 passed.bun typecheckinpackages/console/app— passed.console signupLead.Rollout
CONSOLE_CRM_TOKENon the SST website and Console API/jobs. SST linksCONSOLE_CRM_LOOKUP_URLto the stage's Console account-lookup route.Console_Account_Syncto the integration user. The metadata was already applied to the connected OpenCode Salesforce org during the approved local setup.