diff --git a/src/app/api/volunteer/details/route.ts b/src/app/api/volunteer/details/route.ts index 0041664..8f883d6 100644 --- a/src/app/api/volunteer/details/route.ts +++ b/src/app/api/volunteer/details/route.ts @@ -7,13 +7,13 @@ import { SHEET_COLUMNS, SHEET_TAB, } from "@/app/toronto/volunteer/build-the-vote"; +import { identifyToCustomerio } from "@/lib/customerio"; import { upsertSheetRow } from "@/lib/google-sheet"; // Build the Vote step 2: optional details, added to the volunteer's row in the // Sheet shared with CJPAC. The row is found by the email step 1's response put -// in an httpOnly cookie, so the email is never in a URL or the page. These -// answers (including a mayoral preference) go to the Sheet only, not to -// Customer.io. +// in an httpOnly cookie, so the email is never in a URL or the page. The +// answers also go to Customer.io, best-effort as in step 1. export async function POST(req: NextRequest) { try { @@ -41,6 +41,16 @@ export async function POST(req: NextRequest) { }, }); + try { + await identifyToCustomerio(email, { + toronto_2026_build_the_vote_availability: availability.join(", "), + toronto_2026_build_the_vote_mayoral_candidate: mayoral, + toronto_2026_build_the_vote_issues: issues, + }); + } catch (err) { + console.error(err); + } + return NextResponse.json({ success: true }); } catch (err) { console.error(err); diff --git a/src/app/api/volunteer/route.ts b/src/app/api/volunteer/route.ts index 760243f..8e173a7 100644 --- a/src/app/api/volunteer/route.ts +++ b/src/app/api/volunteer/route.ts @@ -16,8 +16,7 @@ import { sheetTimestamp, upsertSheetRow } from "@/lib/google-sheet"; // aren't newsletter subscribers created by our newsletter form. // // The Sheet write must succeed, or the volunteer is told to try again: a -// sign-up CJPAC never sees is lost. Customer.io is best-effort. The phone -// number goes to the Sheet only; CJPAC calls, we don't. +// sign-up CJPAC never sees is lost. Customer.io is best-effort. const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; @@ -71,9 +70,14 @@ export async function POST(req: NextRequest) { first_name: firstName, last_name: lastName, name: `${firstName} ${lastName}`, + phone, city, postal_code: postalCode, toronto_2026_build_the_vote_volunteer: true, + toronto_2026_build_the_vote_consent_to_share_with_cjpac: true, + toronto_2026_build_the_vote_utm_source: str(body.utm_source, 100), + toronto_2026_build_the_vote_utm_medium: str(body.utm_medium, 100), + toronto_2026_build_the_vote_utm_campaign: str(body.utm_campaign, 100), // A Unix timestamp, so date-based segments can use it. toronto_2026_build_the_vote_signed_up_at: Math.floor(Date.now() / 1000), });