Skip to content

Add HubSpot sync for coupon and newsletter opt-ins#37

Merged
michaelzick merged 1 commit into
mainfrom
codex/coupon-hubspot-subscriber-sync
May 27, 2026
Merged

Add HubSpot sync for coupon and newsletter opt-ins#37
michaelzick merged 1 commit into
mainfrom
codex/coupon-hubspot-subscriber-sync

Conversation

@michaelzick

Copy link
Copy Markdown
Owner

Summary

Adds HubSpot subscriber sync to the existing michaelzick.com newsletter and NGU coupon flows. NGU coupon signups still send the coupon email first, and contact-form workbook/newsletter opt-ins still send the contact notification first; HubSpot sync runs afterward as a best-effort integration so CRM issues do not block successful form submissions.

  • HubSpot male subscriber sync: upserts contacts by normalized email with gender = Male, lifecyclestage = subscriber, and the configured HubSpot owner.
  • Email-only coupon behavior: NGU coupon signups add/update HubSpot contacts without placeholder names or clearing existing first/last names.
  • Contact opt-in behavior: contact-form submissions add first/last names to HubSpot only when the workbook/newsletter checkbox is selected.
  • michaelzick.com entry notes: creates First entry: michaelzick.com for new contacts and Existing entry: michaelzick.com for existing contacts, skipping duplicate entry notes.
  • Non-blocking CRM failures: missing HubSpot env vars or HubSpot API failures are logged with sanitized errors and do not prevent coupon/contact success responses.

Changes

  • hubspot-subscriber.ts (new) — server-only HubSpot config, contact upsert, note association, duplicate-note detection, sanitized error handling
  • ngu-coupon/route.ts — syncs coupon subscribers to HubSpot after visitor/admin emails send
  • contact/route.ts — syncs HubSpot only for workbook/newsletter opt-ins, preserving normal contact form behavior
  • server.test.ts — adds coverage for env fallback, normalization, contact create/update, conflict retry, duplicate-note skipping, sanitized failures, and name/no-name request bodies
  • AGENTS.md, CLAUDE.md, GEMINI.md — documents HubSpot env vars and subscriber-sync behavior

Test plan

  • npm test
  • npm run agent-briefs:check
  • npm run lint
  • npm run typecheck
  • npm run check

Created by Codex

@michaelzick michaelzick marked this pull request as ready for review May 27, 2026 12:27
@michaelzick michaelzick merged commit 65902ed into main May 27, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant