← Metriku

Documentation

Everything you need to ship Metriku: SDK, Firebase push, live config, funnels, and RevenueCat.

1. Create a project

  1. Register at metriku.dev → New project with your iOS Bundle ID.
  2. Open Settings → copy the App Key (created with the project, always visible).
  3. That App Key is the only credential your iOS app needs.

2. Install the iOS SDK

SPM: https://github.com/haxhiuurim/DoraSDK.git or binary DoraVersion (1.2.0+). Pass only the App Key and optional launchOptions — the SDK talks to https://metriku.dev automatically (never pass an API base URL).

import Metriku

#if DEBUG
Metriku.setSandbox(true)
#endif

Metriku.initialize("YOUR_APP_KEY", launchOptions: launchOptions)

3. Firebase Cloud Messaging (server)

GoogleService-Info.plist ≠ what Metriku needs. That plist is for the iOS app client (Firebase SDK / OneSignal client setup). Metriku sends push from our backend, so you upload a Firebase service account JSON instead — same idea as OneSignal's “Firebase Server Key / service account” step.
  1. Firebase Console → create/select project → add iOS app with your Bundle ID (optional for FCM server send, required if you use Firebase in-app).
  2. APNs: Project settings → Cloud Messaging → upload your Apple APNs Auth Key (.p8) or certificates. Without this, FCM cannot deliver to iOS.
  3. Service account: Project settings → Service accounts → Generate new private key → download the .json file.
  4. Metriku → Settings → upload that JSON (file picker or paste).
  5. TestFlight not required for day-to-day testing: run from Xcode on a physical device (sandbox APNs), enable Push capability, register for remote notifications. In-app messages never need APNs.
  6. TestFlight / App Store builds use production APNs. Debug push working does not prove TestFlight delivery — upload a build when you need to validate the production path (same APNs Auth Key in Firebase covers both environments).

4. Push

Metriku.Notifications.requestPermission { granted in }
// In AppDelegate:
Metriku.Notifications.setPushToken(deviceToken)
print(Metriku.User.deviceId()) // paste into Settings → Test messaging

Use Settings → Test messaging with a device ID for the fastest verification. No TestFlight required for Xcode → device sandbox testing. Full guide: PUSH-SETUP.md.

4b. Test push in Metriku Demo (step by step)

  1. Upload APNs .p8 in Firebase Cloud Messaging + service account JSON in Metriku Settings.
  2. Run MetrikuDemo on a physical iPhone from Xcode (not Simulator).
  3. Paste your App Key only → Connect (SDK uses metriku.dev automatically).
  4. Allow notifications; copy deviceId from the demo.
  5. Dashboard → Settings → Test messaging → paste deviceId → Send test push.
  6. If nothing arrives: check Users page shows push on; re-check APNs + JSON for this project.

5. Live config

Keys you publish in the dashboard are what the demo shows under Live config / config keys. Create show_paywall (BOOLEAN) and feature_flags (ARRAY) then tap Force refresh in the demo (SDK also polls every ~60s). Empty keys means the SDK has not received any configs yet (wrong App Key or not connected yet).

let on = Metriku.Config.getBool("show_paywall", default: false)
let flags = Metriku.Config.getStringArray("feature_flags")
let any = Metriku.Config.getValue("custom_key")
Metriku.Config.refresh(force: true) // ignore ETag after publishing new keys

Demo UI labels (“config keys”, “show paywall”, “feature flags”) read the same live config store — they are not a separate feature. Defaults show until those keys exist and refresh succeeds.

6. Subscription funnel

Prefer the typed helpers (SDK 1.2.0+). RevenueCat webhooks can also fill conversion events when app_user_id matches Metriku.login.

Metriku.Analytics.trackPaywallView()
Metriku.Analytics.trackTrialStarted()
Metriku.Analytics.trackTrialConverted()
Metriku.Analytics.trackRenewed()
Metriku.Analytics.trackCanceled()
Metriku.Analytics.trackBillingGraceFailed()

7. RevenueCat

  1. Settings shows a pre-filled webhook URL unique to this project (/api/v1/webhooks/revenuecat/{projectId}). Create one RevenueCat webhook per Metriku project — events are stored and filtered by project, same as users, push, and config.
  2. Authorization Bearer / HMAC is optional but recommended and also per-project. If you set one in Metriku, set the same value in that RC webhook.
  3. Use the same user id in RevenueCat and Metriku.login.

8. Audiences

Segment by tags (Metriku.User.addTag), subscription status, and activity. Recompute runs in the background when Redis is available.

9. In-app messages

Publish from the In-app messaging page. The SDK fetches eligible campaigns and shows them on the configured trigger (session start, immediate, or a custom event name). No TestFlight or push token required — IAM is HTTP-fetched by the SDK (works on simulator for UI, device recommended for realism).

// Triggers that match campaign "EVENT" trigger:
Metriku.Analytics.track("your_event_name")

10. Sandbox data

Dashboard toggle hides sandbox devices and RevenueCat SANDBOX events. Mark DEBUG installs with Metriku.setSandbox(true).

11. Settings checklist

  • App Key → SDK
  • Firebase service account JSON → push
  • RevenueCat webhook URL → paste into RC
  • Test by device ID → verify delivery

12. Roadmap gaps

High-level gaps: FEATURE-GAPS.md. Implementation plan (rollouts, quiet hours, journeys, A/B, delivery funnel): FEATURE-PLAN.md.

13. AI copy-paste prompts

Give these to Cursor / ChatGPT one at a time against your iOS app. Full set lives in PUSH-SETUP.md.

Add Metriku via SPM (DoraSDK or DoraVersion 1.2.0+, product Metriku).
Call Metriku.initialize("YOUR_APP_KEY", launchOptions: launchOptions) only —
do NOT pass an API base URL (defaults to https://metriku.dev).
DEBUG: Metriku.setSandbox(true). Use Analytics.trackPaywallView() etc for funnel.
Request Metriku.Notifications.requestPermission; in didRegisterForRemoteNotifications
call setPushToken(deviceToken); log Metriku.User.deviceId() for dashboard test push.
Enable Push capability.