MyAppAffiliate

Go-Live & Deploy

From zero to tracking a real app.

1. Deploy the API (public HTTPS)

The API ships with a Dockerfile + fly.toml + render.yaml. Fly (no GitHub needed):

Shell
cd .
brew install flyctl && fly auth login
fly launch --no-deploy
fly secrets set DATABASE_URL="<pooled Neon URL>" API_CORS_ORIGINS="*"
fly deploy && fly open /health

Use the pooled Neon URL (host has -pooler) for runtime; migrations run automatically as the release step. Render/Railway alternatives are in the repo's docs/18-deployment.md.

The prototype API is already live at https://maa-api-cccf50.fly.dev.

2. Onboard your app

Shell
APP_NAME="YourApp" BUNDLE_ID="com.you.app" CODE="YOURCODE" \
API_BASE_URL="https://<your-api>" pnpm --filter @maa/api onboard

Prints (once): appId, SDK key, a webhook URL + secret for every supported billing provider, and your referral code. You only configure the providers you use.

3. Integrate the SDK

See SDKs (e.g. iOS) — two calls: start(apiKey) then identify(userId). No API URL goes into your code. Web SaaS product? Follow the Web SaaS guide instead.

4. Connect your billing provider

See Billing & Webhooks. Register the endpoint for whichever provider bills your customers — RevenueCat, Adapty, Superwall, Stripe or Paddle — paste its secret, and make sure the user id it reports is the same string you pass to identify.

To make …/<appId>/<code> links attribute automatically:

  1. Deploy the link Worker (apps/links, wrangler deploy); set LINKS_API_BASE_URL and APPLE_APP_ID (TEAMID.bundleid).
  2. Host the AASA (the Worker serves /.well-known/apple-app-site-association).
  3. Add the Associated Domains capability in Xcode: applinks:<your-link-domain>.
  4. Handle the URL with MyAppAffiliate.attribute(url:) — or, in SwiftUI, the .myAppAffiliate(apiKey:) modifier, which wires it for you.

The referral-code path needs none of this and works immediately.

6. Verify

Make a sandbox purchase → your provider's webhook fires → run setup_verify, which tells you the event arrived and how many of your paid events were tests. Or rehearse without a device: pnpm --filter @maa/api smoke.

A sandbox purchase will not produce a commission, and that is correct. We read the environment your provider stamps on every event — Superwall, RevenueCat and Adapty send an environment field, Stripe sends livemode — and test purchases are recorded but never earn a commission and never count as revenue. Without that, verifying your setup would create real payable money against a sale that never happened.

So what you are checking here is that the event arrives — not that money moved. setup_verify says so explicitly when every paid event it can see was a test, instead of reporting a missing commission as a fault. On the dashboard, test events are kept out of paid conversions and attributed revenue, and those cards note how many were excluded, so a low number never looks like a lost webhook.

Paddle is the exception: its webhooks carry no environment field at all, because Paddle sandbox is a separate account with its own endpoints and secrets. If you point a Paddle sandbox destination at us, mark it with set_webhook_environment so those events are treated as tests — otherwise they count as real revenue.

When you are ready for the real thing, one live purchase produces the commission.