# RevenueCat

With RevenueCat connected, every sale, trial, renewal and refund shows up as it happens, and each purchase is joined to what that person did in the app.

## 1. Connect it

On the **Connect** page, add RevenueCat:

1. Make a secret key: **Project settings › API keys**, version 2. [Open RevenueCat](https://app.revenuecat.com/)
2. Give it read access: Write on **Project configuration** adds sales the minute they happen.

Then open your app's row and pick its RevenueCat project. Apparent reads your history once.

## 2. Add the webhook

For sales within seconds, the app's row shows a **Webhook URL** and an **Authorization header**. In RevenueCat, **Integrations › Webhooks › Add**, paste both. Each purchase is then its own alert.

## 3. Join purchases to people

One line after `Purchases.configure`, so a purchase knows which install made it:

| SDK | Call |
|---|---|
| React Native and Expo | `await Apparent.linkRevenueCat(Purchases)` |
| Swift | `Apparent.linkRevenueCat { Purchases.shared.attribution.setAttributes($0) }` |
| Kotlin | `Apparent.linkRevenueCat { Purchases.sharedInstance.setAttributes(it) }` |
| Flutter | `await Apparent.linkRevenueCat((attrs) => Purchases.setAttributes(attrs))` |

It puts the install's id on the RevenueCat customer as `apparent_id`. Call it again after a sign-out.

Even simpler: start the SDK with RevenueCat's app user id as the install id (`getAnonymousId` in Expo, `anonymousId` in Kotlin and Flutter), so both sides use one id from the first launch.

## Without RevenueCat

- Swift: StoreKit 2, `Apparent.observeStoreKitTransactions()` and `Apparent.trackPurchase(…)`.
- Kotlin: `Apparent.trackPurchase("pro_yearly", 29.99, "EUR")` from Play Billing.
- Anywhere: `track("purchase", { product, price, currency })`.

Store sales still arrive from App Store Connect and Google Play, a day or two late.
