# Production release checklist

DES-1581, T-07. These are the steps for switching from staging (staging.monetize.com) to production (monetize.com).

## How the switch works

`src/lib/seo.ts` reads `NEXT_PUBLIC_SITE_URL` when the site is built.

| Build | Command | Origin | Robots meta | `robots.txt` | Sitemap URLs |
| --- | --- | --- | --- | --- | --- |
| Production | `npm run build` | `https://monetize.com` (default) | `index, follow` (login stays `noindex`) | Allows all and disallows `/login`, with a link to the sitemap | `https://monetize.com/…` |
| Staging | `npm run build:staging` | `https://staging.monetize.com` | `noindex, follow` on every page | `Disallow: /` | `https://staging.monetize.com/…` |

Canonical and Open Graph URLs come from the same origin through `metadataBase`.

There's a second guard in `src/proxy.ts` that works at request time. Any host other than `monetize.com` or `www.monetize.com` gets `X-Robots-Tag: noindex` on every page and a `robots.txt` that disallows everything. This keeps staging out of search even if it's built with `npm run build`, although its pages' `<meta name="robots">` then still says `index, follow`.

## Before release

- [ ] DES-1581 sign-off is recorded, and the P1 designer tasks and Product inputs are closed.
- [ ] Product has approved the product-fact wording from the Oct 26 design, such as "Shared after we review your property" and "Final terms are in your agreement".
- [ ] Product has set the status of AdMobile, In-app offerings and CTV & streaming, which show "Availability to be confirmed" with a "Discuss availability" button (D-03, P-04). It has also confirmed the demo labels: "Illustrative concept" on the ad-format, Direqt and AI-app demos, and "Customer showcase" on CenturyLink (D-04).
- [ ] Legal has approved the Cookie Policy partner links from the Oct 26 design. LinkShare and LinkShare JP are now one entry, "LinkShare (now Rakuten Advertising), including Japan".
- [ ] Publisher Operations has confirmed that applications should go to `APPLY_TO` (info@monetize.com by default) (P-13).
- [ ] `npm run lint` passes.

## Build and deploy

- [ ] Leave `NEXT_PUBLIC_SITE_URL` unset in the production environment, or set it to exactly `https://monetize.com` with no trailing path. Any other value makes the site `noindex`.
- [ ] Set the email variables on the server, not in the repo: `ZEPTOMAIL_API_URL` (`https://api.zeptomail.in/v1.1/email`), `ZEPTOMAIL_API_KEY`, `APPLY_FROM` and `APPLY_TO`. See `.env.example`. `no-reply@monetize.com` must be a verified sender in ZeptoMail.
- [ ] Run `npm run admin:grant -- <email>` for each staff member once they have a Hub account. Accounts are no longer created on this site; they will come from the AdMedia application.
- [ ] Optional: set `ADVERTISER_TO` if advertiser leads should go to another inbox, for example sales@admedia.com as the old site did.
- [ ] Set `SLACK_WEBHOOK_URL` to the Incoming Webhook of the channel that should get application alerts.
- [ ] Set `DATABASE_URL` for the MySQL database, then run `npm ci` and `npm run db:migrate` to create or update the tables (applications, accounts, sites). See `docs/database.md`.
- [ ] Build with `npm run build`, not `build:staging`.
- [ ] Run the app with Node (`npm run start -- -p <port>`). It is no longer a static export: `/api/apply` sends the application emails, and `/customer-success` redirects to `/customer-feedback`.

## Check production right after deploy

- [ ] `https://monetize.com/robots.txt` allows crawling, disallows `/login` and links to `https://monetize.com/sitemap.xml`.
- [ ] `https://monetize.com/sitemap.xml` lists 23 pages and every URL starts with `https://monetize.com`.
- [ ] Pick 3 pages and view the source of each:
  - `<link rel="canonical">` points to `https://monetize.com/<path>`.
  - `<meta name="robots">` is `index, follow`.
  - `og:url` and `og:image` start with `https://monetize.com`.
- [ ] `/login` still has `noindex`.
- [ ] Send one test application from `/contact#apply`. The confirmation shows a reference such as `MZ-20261026-…`, and an email with that reference arrives at `APPLY_TO`, with the applicant as Reply-To.
- [ ] Sign in at `/hub-login`, add a site at `/hub/sites`, and check that `/hub/install` shows the code with that site's key. The dashboard shows zeros and the merchant list is empty until reporting and merchants are connected.
- [ ] Submit the sitemap in Google Search Console and Bing Webmaster Tools.

## Keep staging out of search

- [ ] Rebuild staging with `npm run build:staging` and run it with `npm run start`, never with the production build.
- [ ] `https://staging.monetize.com/robots.txt` returns `Disallow: /`, and its pages have `noindex`.

## Application alerts in Slack

`src/app/api/apply/slack.ts` posts every application to the channel in `SLACK_WEBHOOK_URL`. The alert shows the visitor's answers and products, the reference, the routed team, and whether the application was saved and each email was sent. Problems are marked ⚠️ at the top. An application that could not be saved or emailed is still posted, so the lead reaches the team. A Slack failure is only logged; it never affects the visitor.

## Application emails

`src/app/api/apply/route.ts` validates each application, then emails it through the ZeptoMail send-mail API. The browser shows "Application submitted" only when the API answers `ok: true`. Any failure (no API key, ZeptoMail error or timeout, invalid answers, too many attempts) keeps the visitor's answers and offers info@monetize.com.

The duplicate check (the same application is emailed once) and the rate limit (5 per address per 10 minutes) are kept in memory, so they reset when the app restarts. Behind the openresty proxy, the address comes from `X-Forwarded-For`, which the proxy must set.

## Known detail

The JSON-LD blocks on most pages are hard-coded to `https://monetize.com`, while `/about` builds its JSON-LD from `SITE_URL`. That is correct for production, and on staging it only means the structured data names the production address.
