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 → a commission appears on the dashboard. Or rehearse without a device: pnpm --filter @maa/api smoke.