Skip to content

Cross-platform analytics

Summary

  • The taxonomy is spec data. spec/analytics/events.json lists every event, its properties, their types and allowed values, and who emits it. Every platform is tested against it, as with rule sets.
  • A thin wrapper per platform, no-op first. Analytics is an interface passed in the constructor, like any other side effect, with NoopSink, RecordingSink (tests and CLIs) and, later, a vendor sink. All of it can be built and tested before any vendor is chosen.
  • Stack: PostHog EU Cloud for product analytics and crash reports on iPhone, Android, the web game and the Rust server. No analytics on homefelt.io at launch. Store funnels come from App Store Connect and the Play Console.
  • Anonymous. A random install ID never linked to an account, personless events, IP capture off, no autocapture, no session replay. Cards, hands and seeds are never sent.
  • Ask first, everywhere. One question after the first finished game, two equal choices, and a switch in Settings. Nothing is sent before a yes.
  • The server owns online game facts. Clients emit game events only for games they run, so nothing is counted twice.
  • Separate from ads. Analytics has its own consent and never touches an advertising ID.

1. Questions analytics must answer

Question Answered by
Activation: first game finished game_over_seen within 7 days of the first app_opened
Retention D1, D7, D30 app_opened per install ID, cohorted by first open
Games per week game_finished (client for local games, server for online)
Solo, one screen or online mode on game events
Invites sent and accepted invite_shared (client), invite_redeemed (server)
Family or Official rule_set
Bot difficulty and win rates bot_levels, result on game_finished
Large text, deck text_size, deck on every client event; setting_changed
Drop-off, abandoned hands game_abandoned with hand_number; last hand_finished per game_id
Crashes and errors crash events; refusal_shown for rule refusals
Platform mix platform on every event
Site to play entry on the web game’s app_opened
Store conversion the stores’ own reports (section 6)

2. The event taxonomy as spec data

Files. spec/analytics/events.json (below); spec/analytics/sessions/*.json, scripted games (rule set, seed, controllers, moves) with the exact events each must produce, volatile values (game_id, durations) matched by type; spec/invalid/analytics/, one broken file per rule (unknown property, missing required one, value outside its enum, forbidden key), with texts in invalid/expected.json; and an “Analytics” section in spec/README.md.

{
"version": 1,
"common": {
"platform": { "type": "string", "enum": ["ios", "android", "web", "server"] },
"app_version": { "type": "string" },
"game": { "type": "string", "enum": ["canasta"] },
"schema_version": { "type": "integer" },
"text_size": { "type": "string", "enum": ["standard", "large"], "clientOnly": true },
"deck": { "type": "string", "enum": ["fourColour", "classic"], "clientOnly": true }
},
"events": {
"game_finished": {
"description": "A game reached its target and the final score sheet was produced.",
"emitter": { "client": ["solo", "oneScreen"], "server": ["online"] },
"properties": {
"game_id": { "type": "string", "format": "uuid" },
"mode": { "type": "string", "enum": ["solo", "oneScreen", "online"] },
"rule_set": { "type": "string", "enumFrom": "rulesets.id" },
"players": { "type": "integer", "enumFrom": "rulesets.tables.players" },
"bot_levels": { "type": "array", "items": { "enum": ["easy", "normal"] } },
"hands_played": { "type": "integer", "minimum": 1 },
"duration_bucket": { "type": "string", "enum": ["lt10m", "10to30m", "30to60m", "1to2h", "gt2h"] },
"result": { "type": "string", "enum": ["humansWon", "computersWon", "mixed", "tie"] }
},
"required": ["game_id", "mode", "rule_set", "players", "hands_played", "result"]
}
},
"forbidden": ["seed", "stream", "cards", "hand", "pile", "melds", "log", "email", "name",
"display_name", "user_id", "table_id", "invite_code", "token", "url", "ip"]
}

enumFrom reads values from other spec files, so a new rule set is a valid rule_set with no change here. refusal_shown.code lists the rule errors in spec/README.md “Errors”, and each core checks its RuleError cases against it.

First events. app_opened (entry: direct, site, invite, store), game_started, game_resumed, hand_finished (hand_number, who went out or stockEmpty), game_finished, game_over_seen (client, every mode, for activation), game_abandoned (an unfinished game replaced or discarded), refusal_shown, setting_changed, signed_in (provider), invite_shared (kind: link or code), and from the server invite_redeemed (outcome), join_request_answered, online_table_paused, seat_handed_over.

Conventions.

  • Event names are snake_case object_past_verb (game_finished), and so are property names. Enum values reuse the spec’s ids (fourColour, official), so they never need translating.
  • No PII: no names, emails, account or table IDs, invite codes, tokens, URLs (/join/* paths carry invite tokens) or free text.
  • No cards, hands, piles, melds, logs, seeds or streams. The seed alone would replay the shuffle.
  • Durations and scores are bucketed.
  • A new event or property is a spec change first, then every platform, like a rule-set setting.

Tests, Reflex-style.

  • Spec tests (Swift, Kotlin, Rust, web) load events.json and reject every invalid file. Debug and test builds validate each emitted event and fail on a mismatch; release builds drop it and log the problem.
  • Mapper tests. Game events come from a pure function of the state before and after an action, in the layer the app and the CLI share (NodeState and its Swift and Rust counterparts, and the web’s state over canasta-wasm). Each suite replays the session files.
  • Behaviour suite. A new CLI request, events, prints the session’s RecordingSink (added to spec/protocol/cli.md). tests/analytics.test.ts expects the same events from the Swift, Kotlin and Rust CLIs and from Wasm, still inside the network guard.
  • Server. canasta-server plays an online table on the in-memory store with a RecordingSink and checks it against the same session files.
  • Emitter rule. A test fails if a client emits a game event for mode: online, or the server emits one for a local mode.

3. Tool choice

Scores run from 1 (poor) to 5 (best) for Homefelt. “Tracking”, in Apple’s sense, means linking data with other companies’ data for advertising, or sharing it with data brokers [14]. None of the first-party set-ups below does that, so none needs the ATT prompt.

PostHog EU TelemetryDeck Firebase / GA4 Plausible (site) Vercel Web Analytics (site) Sentry (crashes)
Privacy, GDPR 4: Frankfurt, IP capture off by default for EU projects, DPA [1] 5: EU only, no IPs stored, DPA [6] 2: Google, consent mode for ad signals [8] 5: EU, no cookies [9] 4: no cookies, visitor hash dropped after 24 h [10] 4: Frankfurt region, chosen when the org is created [12]
App Store label Not linked, if personless Not linked Device ID; IDFA if AdSupport is linked [8] n/a n/a Crash Data
ATT Not needed Not needed Avoidable, with the core SDK [8] n/a n/a Not needed
Play Data safety Collected; not shared (service provider) [13] Same Same, plus the advertising ID unless removed n/a n/a Crash logs
Cost, small scale Free: 1M events, 100k exceptions, 1M flag requests a month [3] Free: 50k events a month for new accounts; paid tiers not checked [7] Free, 500 distinct events [8] From $9 a month, 10k pageviews [9] Hobby: 50k events, no custom events [11] Free: 5k errors, 1 user; Team $26 a month billed yearly [12]
React, Swift, Kotlin, Rust 5: all four; official Rust crate [4] 3: Swift, Kotlin, JS; HTTP API for Rust [6] 3: no server SDK listed [8] site only site only 5
Crash reports 4: iOS Mach exceptions and signals, Android uncaught exceptions [5] none Crashlytics, separate none none 5
Lock-in Medium (behind the wrapper) Low High Low Low Low

Recommended stack.

  1. PostHog EU Cloud for the apps, the web game and the server: product analytics, plus error tracking with autocapture and dSYM and R8 mapping uploads [5], and the Rust crate on the server [4]. Eduardo already runs it for Alisi. Personless events are the cheaper kind, and the first million a month are free [2]. One vendor means one DPA, one consent and one privacy line.
  2. No analytics on homefelt.io, as docs/marketing-site.md decided. If it is ever needed, use Vercel Web Analytics or Plausible, and rewrite the privacy page’s “This website” paragraph.
  3. Fallbacks. Sentry for crashes if PostHog falls short (Play Console Android vitals covers ANRs in the meantime). TelemetryDeck if PostHog’s terms change: stronger privacy, but no Rust SDK and no crash reports.
  4. Not Firebase or GA4. They bring Google’s advertising identifiers with them, which is what analytics must stay clear of.

4. Privacy design

  • Install ID. A random UUID created on the first yes and kept in app storage (on the web, homefelt.analytics.installId in local storage, not a cookie). It is never sent to the game server. Switching analytics off deletes it, and a later yes makes a new one. It rotates every 13 months, the CNIL’s tracker lifetime [15].

  • Personless. personProfiles: never on iOS and Android, $process_person_profile: false on the server [2], and no identify().

  • Account linking: not by default. Online players have an install ID too, so retention works without accounts. Link only for signed-in online play, only when a real question needs it (cross-device retention, say), through a salted hash, and after the privacy page changes.

  • Consent.

    Region Legal floor Homefelt default
    EEA, UK, Switzerland Consent before storing an ID on the device; France’s exemption has strict conditions [15] Off until yes
    Rest of the world Usually notice and opt-out Off until yes

    Recommendation: ask everywhere. One code path, no region detection, and trust is the brand. A two-option opt-in that is not linked to identity and changes no feature may also qualify for Apple’s “Product Improvement Programs” optional disclosure [14]. Declare it anyway. Ask once, after the first finished game, never mid-hand. Settings gets a switch, “Share anonymous usage and crash reports”. If fewer than about 30% say yes, reconsider on-by-default outside Europe.

  • IP. IP capture stays off [1]. The web sends through a play.homefelt.io/ingest proxy, and the server forwards no client IPs. Still to check: whether country GeoIP survives with IP off.

  • Off. Autocapture, pageviews (URLs hold invite tokens), session replay (it would film hands), surveys, heatmaps. On the web, before_send strips $current_url and $referrer.

  • Retention. 13 months of raw events where the plan allows it, then aggregates; crash reports 90 days.

  • Privacy page. A new section, “Anonymous usage statistics (only if you say yes)”: what is sent, the install ID, PostHog in Frankfurt, no IP, retention, and how to switch it off. Also a line on online game statistics (section 5). “This website” stays as it is.

  • Store labels. App Store: Product Interaction, Crash Data, Performance Data and Device ID, all not linked to you and not used for tracking; purpose Analytics [14]. Play: App activity, App info and performance, Device or other IDs; collected, optional, not shared [13].

  • Future ads (TODO(ads)). Ad SDKs usually bring IDFA or AAID, ATT and a TCF consent string. Analytics stays separate: its own switch, no ad IDs, no ID exchange with the ad SDK, and no ad SDK started for subscribers. Ads are measured in the network’s reports plus one ad_shown (placement only). The “no tracking” ban in “Do not claim” stays.

  • Marketing site. Still no scripts and no cookies. The site’s Play links carry ?ref=site-home, the web game copies it into app_opened.entry (after a yes) and drops it with history.replaceState.

5. Server-side events

  • Source of truth. For online tables the server emits game_started, hand_finished, game_finished, invite_redeemed, join_request_answered, online_table_paused and seat_handed_over. Results go out when hand_results and game_results are written, once per hand (docs/server.md “Persistence”), so reconnects and restarts cannot repeat them.
  • No double counting. At online tables, clients emit only interface events (game_over_seen, invite_shared, refusal_shown). The spec’s emitter rule enforces it.
  • Identity. The distinct ID is HMAC-SHA256(table id, HOMEFELT_ANALYTICS_SALT). The table ID never leaves the server, the schema does not change, and no person is involved, so these events rest on legitimate interest rather than per-player consent.
  • Config. HOMEFELT_ANALYTICS_KEY and HOMEFELT_ANALYTICS_HOST; unset means NoopSink. Sending happens off the table task, so analytics never slows a move.

6. Dashboards and the first 10 metrics

# Metric First target
1 Weekly active installs, by platform trend
2 Activation within 7 days over 50%
3 D1, D7, D30 retention D7 over 25%
4 Games finished per active install per week trend
5 Mode mix: solo, one screen, online online rising
6 Invites shared to seated over 40%
7 Family or Official share, by mode guides the default
8 Human win rate by bot level Easy about 70%, Normal about 45%
9 Games abandoned, and at which hand under 30%
10 Crash-free installs, by platform and version over 99.5%

The targets are guesses to revise once data arrives. The board also shows the Large text and classic deck share, the top refusal_shown codes (a recurring refusal marks a confusing screen) and web entry. Store conversion comes from App Store Connect campaign links (ct=site-home, aggregated, minimum 5 [16]) and the Play Console’s acquisition report.

Who and when. Eduardo reads the weekly board on Mondays (15 minutes) and the release-health view (metric 10, new error groups) 48 hours after each release. A monthly review of cohorts, mode mix and bot balance can produce issues, such as a spec/bots.md change.

7. Phased plan

Each step is one checkpoint: one issue, one PR, the spec first, then every platform.

Step What Done when Size
1 Taxonomy: events.json, session files, invalid files, README section Swift, Kotlin, Rust and web load it and reject every invalid file M
2 Wrappers and sinks: Analytics, NoopSink, RecordingSink, validation, mappers, the CLI events request, the behaviour test, server recording The behaviour suite passes on all four targets with no network L
3 Consent and install ID: the one question, the Settings switch, deletion on off UI tests on all three apps; nothing recorded before a yes M
4 PostHog sink behind a flag (key set and analytics.vendor on), web proxy, server sink Events reach a staging project; production flag off M
5 Crash reports: autocapture, dSYM and R8 uploads in release builds, web error boundary, server panics A test crash arrives symbolicated from each platform M
6 Dashboards: the 10 metrics, the board, an alert on crash-free installs The board renders from staging data S
7 Privacy page, store labels, “Do not claim”; then the production flag The page is live before the flag; labels go with the release S

Steps 1 to 3 need no vendor account and no decision on ads.

Sources

  1. PostHog GDPR guide: https://posthog.com/docs/privacy/gdpr-compliance
  2. PostHog anonymous and identified events: https://posthog.com/docs/data/anonymous-vs-identified-events
  3. PostHog pricing: https://posthog.com/pricing.md
  4. PostHog Rust SDK: https://posthog.com/docs/libraries/rust
  5. PostHog error tracking: https://posthog.com/docs/error-tracking/installation/ios, https://posthog.com/docs/error-tracking/installation/android
  6. TelemetryDeck FAQ: https://telemetrydeck.com/faq/
  7. TelemetryDeck pricing update, July 2026: https://telemetrydeck.com/blog/pricing-update-2026/
  8. Firebase Analytics: https://firebase.google.com/docs/analytics, https://firebase.google.com/docs/analytics/configure-data-collection
  9. Plausible: https://plausible.io/#pricing
  10. Vercel Web Analytics privacy: https://vercel.com/docs/analytics/privacy-policy
  11. Vercel Web Analytics pricing: https://vercel.com/docs/analytics/limits-and-pricing
  12. Sentry: https://sentry.io/pricing/, https://docs.sentry.io/organization/data-storage-location/
  13. Google Play Data safety: https://support.google.com/googleplay/android-developer/answer/10787469
  14. Apple: https://developer.apple.com/app-store/app-privacy-details/, https://developer.apple.com/app-store/user-privacy-and-data-use/
  15. CNIL analytics exemption: https://www.cnil.fr/en/sheet-ndeg16-use-analytics-your-websites-and-applications
  16. App Store campaign links: https://developer.apple.com/help/app-store-connect/view-app-analytics/manage-campaigns/

Open questions for Eduardo

  • Opt-in everywhere (recommended), or on by default outside Europe?
  • One switch for usage and crash reports, or two?
  • PostHog under the Alisi organisation or a separate Homefelt one (its own DPA and billing)?
  • Rotating the install ID every 13 months breaks cohorts older than a year. Is that acceptable?
  • Will analytics ever be linked to accounts for online play? (Recommended: not until a question needs it.)
  • Keep country-level location, or drop GeoIP?
  • Should homefelt.io stay without analytics after launch?
  • Should anyone besides Eduardo see the dashboards?