Files
Jules cc621dcfb1 feat(web): forward submitted form data on newsletter signup
* chore(web): add a debug level to the logger

Logs in every build but tests, for output a deployed preview needs.

* feat(web): forward submitted form data on newsletter signup

Every field a form collects is sent to the subscribe endpoint, select
values as their labels rather than CiviCRM option ids. Logs the payload.

* docs(funnel): document the forwarded subscribe payload

* fix(web): build the funnel newsletter payload from answers only

Keeps the intake captcha token and field defs out of the newsletter
service whatever a caller puts in extraPayload.
2026-08-05 19:42:15 +09:00

35 lines
1.2 KiB
TypeScript

/**
* Thin logging seam for the apps/web runtime.
*
* Today this just forwards to `console`, but every server-side caller routes
* through here so swapping in Sentry / OTLP later means editing one module.
* Don't import `console` directly in lib/* — call `logger.error(...)` instead.
*/
type LoggerContext = Record<string, unknown>
function format(message: string, context?: LoggerContext): unknown[] {
return context ? [message, context] : [message]
}
export const logger = {
error(message: string, context?: LoggerContext): void {
// Server console; in production this is captured by the host's stdout.
console.error(...format(message, context))
},
warn(message: string, context?: LoggerContext): void {
console.warn(...format(message, context))
},
info(message: string, context?: LoggerContext): void {
if (process.env.NODE_ENV !== 'production') {
console.info(...format(message, context))
}
},
/** Logs in every build but tests -- use when a deployed preview needs it. */
debug(message: string, context?: LoggerContext): void {
if (process.env.NODE_ENV !== 'test') {
console.debug(...format(message, context))
}
},
}