Next · Unreleased

Working-tree content. Subject to change and not yet released. Commit: e3d4530507.

Analytics events

Analytics is schema-driven. Event param shapes live in Valibot schemas; typed track() contracts are derived from them. You never hand-write event constants or call the Firebase SDK directly from a feature.

Schema shape

Each event is a Valibot v.object({ … }) keyed by canonical snake_case name:

// packages/analytics/src/event-schemas.ts
export const eventSchemas = {
  song_click: v.object({
    song_session_id: v.optional(v.string()),
    song_id: v.optional(v.string()),
    // …
  }),
  videoads_trigger: v.object({
    screen: v.optional(v.picklist(["song_unlock", "revive"])),
    location: v.optional(v.picklist(["home", "result", "shop", "others", "revive"])),
    reward: v.optional(v.picklist(["song_unlock", "revive", "song_learn"])),
    song_id: v.optional(v.string()),
    song_name: v.optional(v.string()),
  }),
} as const;

Types derive automatically:

// event-types.ts
export type AnalyticsEventMap = {
  [K in keyof typeof eventSchemas]: v.InferOutput<(typeof eventSchemas)[K]>;
};

App/ad code imports taxonomy types from @piano/analytics (schema-types.ts) — AnalyticsParam, RewardedAdContext, VideoadsStamp, reviveRewardedContext(), etc. — all derived from AnalyticsEventMap, not hand-written unions.

Layers

LayerFileRole
Valibot schemasevent-schemas.tsSingle source of truth — event names, params, enums.
Derived typesevent-types.tsAnalyticsEventMap, AnalyticsEventName via v.InferOutput.
Runtime validationdispatcher.tstrack() validates against schemas — strips unknown keys, rejects bad enums in dev/test.
Schema typesschema-types.tsApp-facing aliases (RewardedAdContext, reviveRewardedContext(), …).
Routingevent-routing.tsProvider fan-out, AppsFlyer name overrides, AUTO_SDK_EVENTS.
Contractevent-contract.tsstatus + trigger file paths for CI wiring tests.

Adding / changing an event

  1. Edit packages/analytics/src/event-schemas.ts. Keep the name snake_case and globally unique.

  2. Update routing in event-routing.ts (which providers receive the event).

  3. Update contract in event-contract.ts (status, trigger path once implemented).

  4. Implement the call site in a feature using the typed API:

    import { trackEvent, newSongSessionId } from '@core/sdk/analytics';
    trackEvent('song_click', { song_session_id: newSongSessionId(), song_id: id });

    Or in a component via the hook: const a = useAnalytics(); a.track(...). FTUE funnel events use trackFtueSessionEvent / trackFtueEvent from src/core/sdk/ftue-analytics.ts — they stamp the persisted session counter (incremented once per cold start via bindFtueSession() in the root layout). Cold-start boot events (fn_loading_start, fn_loading_end, fn_after_splash_screen) go through useTutorialStore((st) => st.trackBootEvent) so the store gates once-per-install firing and skips after onboarding + tutorial complete. Those events and fn_intro_1 also carry elapsed_ms (ms since JS entry, stamped by js-entry-mark); fn_loading_end adds status = ok | degraded (a boot service threw or timed out) | ceiling (the 8 s services ceiling released the app first). It now fires whenever the guarded service chain settles — not only when the hub bootstrap succeeded — so a drop between fn_loading_start and fn_loading_end means the app was killed/crashed, not that a service failed. fn_loading_start fires when loading starts — after the 1.65 s splash intro (every launch; boot runs only once the intro has played), so its elapsed_ms includes the intro. boot_timing (once per cold start, not install-gated) reports per-service latency (rc_ms, iap_ms, af_ms), js_entry_ms (React Native startup → JS entry = bundle-load time), status, failed_step and ceiling_hit; it goes out at the ceiling if that comes first, so a hung service is named. Boot events are emitted from src/bootstrap/start-app-bootstrap.ts; the UI hook only forwards the lifecycle start action. Deferred first-FTUE gameplay warmups are outside boot_timing and do not hold fn_loading_end. splash_timing (once per cold start, not install-gated) fires when the splash has gone (the splash store) and says how long it ran: splash_ms (bundle load + JS entry → gone; the native launch before JS is not counted), intro_ms (the JS splash intro, 0 when it never took over), loading_ms (loading start → the services releasing the splash; absent when they never did), wait_ms (that release → gone: the last gates and the splash minimum, which is the intro's own length) and ceiling_hit (the 12 s hard ceiling released it). fn_after_splash_screen carries the same splash_ms for the FTUE funnel. The app version is on every event via the app_version / app_build user properties. Firebase Performance traces (boot_total, boot_<step>) mirror the same timings — see Boot performance. onboarding_perf fires when the onboarding screen goes (useOnboardingPerf): the UI thread's frame rate while it was in view — counted from the splash going, since the screen mounts under it (avg_fps, low_fps = worst second, jank_pct = frames over twice the budget, max_fps = 60 or 120 Hz, duration_ms; a Reanimated frame callback, frame-stats), the JS thread's (js_avg_fps), film_ms (screen open → the film's first frame), thumbs_ms / thumbs_ok (the boot prefetch of the tutorial songs' covers, absent while it is still running) and config_wait_ms (from the screen being seen to the install's A/B-tested values being locked, at most 3 s; 0 when an earlier launch had them; absent when the screen went first). gpu_prewarm_done / gpu_prewarm_ms were dropped on 19/11 with the onboarding prewarm. boot_timing.rc_ms / failed_step still say how often the fetch is slow or gives up. ab_config_applied (onboarding_script, mon_pkg_variant, ab_lock_version) fires when an install locks its A/B-tested Remote Config on the console's answer (experiment-decision.ts) — once per round of tests, never for an install that fell back to the in-app baseline — and is the activation event of every Firebase experiment on those keys. The user property ab_source (remote | fallback) says which an install is, on every event after the lock; filter A/B analyses on ab_source = remote. onboarding_script and mon_pkg_variant report the locked values. The arm is also on every event as a param: setting the user property mon_pkg_variant or mon_pkg_rev sets the same key as a Firebase default event parameter (user-properties-on-every-event.ts, dispatcher setUserProperty). BigQuery stamps a row only with the user properties set when its event was logged, so a filter on the user property drops rows logged before the arm was known (the tutorial's, when Remote Config was slow); the param is on every row logged after, and Firebase keeps default params across launches. Rows from before the first lock still have no arm: take each user's arm by user_pseudo_id for them instead of dropping them. fn_next_song_after_tutorial goes through useTutorialStore.getState().trackNextSongAfterTutorial from PlayScreen — once per install when the first post-tutorial session starts (tutorial_next from Get or home from the song list). Song engagement events use helpers in src/core/sdk/song-analytics.ts — trackSongImpression (2s visibility) is meant to begin the song_session_id funnel, but nothing calls it yet (see Known tracking issues); trackSongClick starts the session, or reuses the song's active one. song_id is one id per song across builds: trackEvent passes every event's params through withCanonicalSongId (song-id-canonical.ts). A catalog id that is only the song's name squashed (rushe, furelise, nobatidão, dance_monkey — early builds and a few Sheet edits) is sent as the name's kebab slug (rush-e, fur-elise, no-batidao, dance-monkey); any other id is sent as it is. Old rows map with the same rule in SQL: lowercase, strip accents, keep [a-z0-9], compare with the song_name's. song_order must be the 1-based position in the visible on-screen list via songListOrderFromIndex / songListOrderFromId — never catalog sortOrder from the remote sheet. It goes out only on home and recommended_result plays (songOrderForPlayType drops it for every other play type), and only when such a list opened the play: Home's filteredTracks (Game Mode and the Learn CTA) and Game Mode's Result recommendations. Learn's result Next song is recommended_result with no song_order: it is one suggestion, not a list row. Set status: "implemented" and a trigger file path in event-contract.ts once it's merged.

  5. Test: cd packages/analytics && bun test — contract tests verify trigger files exist and actually call track() for implemented events.

Param / trigger descriptions in schema

PM-facing semantics live on the Valibot schema via v.pipe(..., v.description("…")) — not sent to Firebase. Reuse shared fragments in event-schema-fragments.ts (e.g. videoadsScreen, videoadsLocation) so revive copy is defined once.

export const videoadsScreen = v.pipe(
  v.optional(v.picklist(["song_unlock", "revive"])),
  v.description("revive = learn mode out-of-hearts Continue → earn 1 heart …"),
);

videoads_trigger: videoadsEvent(
  "User tapped Watch ads — unlock or learn revive.",
  { ...videoadsContextEntries, song_id: videoadsSongIdOptional },
),

Read descriptions at runtime or for docs export:

import { getEventTriggerDescription, getEventParamDescriptions, buildEventDocRegistry } from '@piano/analytics';

getEventTriggerDescription('videoads_trigger');
getEventParamDescriptions('videoads_show').location;
buildEventDocRegistry(); // flat list for PM / visualizer

Event-level v.description() = when the event fires. Field-level = when to stamp each param. File wiring stays in event-contract.ts (trigger path).

Videoads context

All videoads_* events share the same param fields (screen, location, reward, song_id, song_name). Stash context before showRewarded():

  • Song unlock: songUnlockRewardedContext(songId, songName, mode) → screen: "song_unlock"; mode: "learn" (the unlock opens the song in Learn) adds reward: "song_learn"
  • Learn revive: reviveRewardedContext(songId, songName) → screen: "revive", location/reward: "revive"

The Song List's Learn CTA on a rewarded row shares the Play CTA's unlock, so it shares its context too — the same songUnlockRewardedContext — bound for Learn, so its reward is song_learn — and the same unlock_song placement. Its order is song_click (song_mode: "learn", on the press) → the sheet → videoads_* (on "Learn this song for free", after the sheet dismisses) → Learn Mode's own session events. No second song_click: the session guard in trackSongClick has already fired one for that session, and the Learn CTA reuses it. See features/songs.md.

See src/core/sdk/ad-analytics-track.ts.

App Open (openads_*) — the AdMob App Open format (cold launch and return from the background, ad-trigger-logic.md §6) reports the eight events of the PO's sheet (10/11). All are Firebase-only:

EventFires when
openads_requesta load goes out
openads_request_successthe load succeeds
openads_request_failedthe load fails; carries fail_reason
openads_show_readyan ad is in hand at show time
openads_show_notreadythe show has nothing to show; carries fail_reason, no unit
openads_showthe ad is displayed; carries session
openads_show_failedthe ad was in hand but never displayed; carries fail_reason
openads_clickthe player taps the ad

Params:

  • Every event carries connection (online / offline, left out until the app has read the network state once; connection.ts).
  • Every event carries accumulated_count, plus ad_unit_tier and ad_unit_id except on a notready. The count is the user's lifetime total for that event, kept in useEventCountStore; it is read from memory at once but saved to MMKV in batches (eventCountStorage: one write per ~1.5 s window on the idle queue, and at once when the app leaves the foreground), so a process that dies inside the window can lose the last few counts.
  • The five show-side events (show_ready, show_notready, show, show_failed, click) carry trigger: how the app came up for the show — cold_start (opened from scratch) or warm_resume (back from the background).
  • openads_show carries session: this launch's number for the player (1 = the first launch), the count the arm's "App Open from session N" rule reads.
  • The request events carry no trigger.

Changed on 10/11 (dashboards must switch):

  • location became trigger on the show-side events: app_open → cold_start, foreground_return → warm_resume.
  • The request events no longer carry location or att_status.
  • openads_finish (the close) is no longer sent.

openads_show_notready has three sources:

  • launch_wait_5s: the launch waited 5 s and nothing loaded.
  • show_no_ready: a return found nothing loaded.
  • show_no_ready: the ads engine found no ad at show time.

A gate that stops the App Open sends nothing (premium, FTUE, fewer than 4 finished songs, the 120 s / 60 s gaps, a menu that is covered), as in Guitar. There is no openads_trigger.

The paid event sends ad_impression / ad_impression_ama with ad_format: "app_open" and ad_unit_name: "Open_All" (Guitar's name), plus AppsFlyer af_ad_revenue. There is no AppsFlyer custom event. See app-open.ts and ad-analytics-track.ts.

Full Screen Native (nativeads_*) — the native ad shown full screen right after an interstitial or a rewarded video, by the install's mon_pkg arm (ad-trigger-logic.md §7). The PO's funnel (sheet of 2026-11-09), Firebase-only:

EventFires when
nativeads_requesta load is asked: the first one, the reload after a show, and each retry on the backoff
nativeads_request_successthe load lands
nativeads_request_failedthe load fails (fail_reason = the SDK's <code>: <message>)
nativeads_show_readythe FSN is due (after an FS or an RV) and its slot holds an ad
nativeads_show_notreadythe FSN is due but its slot holds no ad (fail_reason = show_no_ready); it is skipped and a load starts
nativeads_showthe ad on screen records its impression
nativeads_show_failedthe module could not put a loaded ad up (fail_reason = not_ready / no_presenter / present_failed, or show_exception: …)
nativeads_clickthe player taps the ad

Params on every event: connection (online / offline, left out until the app has read the network state once; connection.ts), accumulated_count, ad_unit_tier (always all: one unit per slot) and ad_unit_id, which tells the two slots apart as magicPad does. nativeads_show / nativeads_click also carry trigger (after_fs = after an interstitial, after_rv = after a rewarded video); until 2026-11-09 that value was sent as location. Nothing is sent for a slot that is shut (the arm has no FSN, the player is before fsn_from, has No Ads / VIP, or there is no unit) or for a load parked mid-song.

The paid event sends ad_impression / ad_impression_ama with ad_format: "native" (the tracking sheet's value; it was magicPad's fullscreen_native until the QC tracking pass, 2026-11-19) and ad_unit_name FSN_Inter / FSN_RW, plus AppsFlyer af_ad_revenue; ad_source is the network that filled, which the module reads from the ad's response. See fsn-controller.ts and composition-root.ts.

Ad funnel params (fullads_*, videoads_*, bannerads_*)

A funnel event that stands for one AdMob unit names it — ad_unit_tier (high / all) and ad_unit_id (the full ca-app-pub-…/… id); *_trigger and videoads_backfill carry none, and so does *_show_notready now — it only fires when neither tier is loaded, so there is never a unit behind it. An empty show is only that: *_show_failed keeps its own meaning — an ad was in hand and never reached the player — and always names the unit it had. The engine keeps two tiers warm per format like magicPad's tier cache policy, but since the ads moved onto the SDK's preload pools (admob-integration.md §3) it never requests an ad itself: there is no retry ladder, load timeout or eviction, and a High unit cannot be spammed by anything the app does (AdMob had flagged High's failed requests). *_request marks a pool being created, or refilling after a take; *_request_success a pool reporting an ad; *_request_failed a pool that could not be created or whose preload failed. The SDK does the network requests on its own, so the volume no longer lines up with magicPad's. A failed pool is rebuilt at most once a minute, and that rebuild is a new *_request. In Game Mode, the requests a song needs go out on its loading screen, which holds the countdown up to 5 s for the interstitial; from the countdown until the player leaves the song nothing new is requested, so a *_request never lands mid-song. The banner reports the same three-event shape, still on the 5 s → 60 s retry ladder: bannerads_request / _request_success / _request_failed, alongside the existing bannerads_show / _empty / _click. Since 2026-10-05 the app keeps one banner loaded ahead, so a banner request can precede any banner screen: it then carries no location, and bannerads_show fires when the banner appears in a screen's slot, not when it loads. No banner request goes out from a Game Mode song's countdown until its last note has ended.

fullads_request, fullads_request_success and fullads_request_failed also carry att_status (since 2026-10-07): the iOS App Tracking Transparency status the request went out under — granted (the IDFA is readable), denied (iOS "restricted" included) or undetermined (both: no IDFA). Android has no prompt and sends none. It is there to split interstitial no-fill by whether the networks could see the IDFA; videoads_* and bannerads_* do not carry it. Until 2026-10-19 a status other than granted also meant non-personalised ads only; since then the request is the same for every status.

fail_reason is the SDK's <code>: <message> or an app-side reason, at most 100 characters. New app-side values: both_tiers_empty / show_no_ready (an empty interstitial / rewarded show — magicPad's own wording, never with a unit named, and on *_show_notready only), reward_not_earned (a rewarded the player closed before earning it). Retired: sdk_not_loaded no longer reaches any event — the tier is simply not picked, and the reason stays in the ads log only. retry_count is still not a param (it never was); what changed is that a retry now shows up as its own *_request event instead of nothing. Details: admob-integration.md §8.

fullads_trigger and fullads_show carry location (since 2026-11-09) only for an interstitial at the end of a Learn stage: learn_mode_stage_<n>, the stage just completed (screen stays others). It is there for the arms that run Learn by stage (learn_fs.mode = stages). No other interstitial sends location, and the schema accepts no other value (learn-stage-location.ts).

Song sessions across Game Mode and Learn Mode

  • song_mode (game | learn) is stamped on every song_* event except song_impression, song_preview, song_pause and song_pause_action. The shared builders in src/core/sdk/song-analytics.ts and song-engagement-run.ts default to game, and Learn names its own. The Game Mode result's recommendation column names it too now that it has a Learn/Play toggle: a card tapped on the Learn half opens Learn Mode, so trackResultRecommendationSongClick stamps song_mode: "learn" on it rather than letting it default to game.

  • song_version rides on every event that carries song_mode: default for the song's own MIDI, otherwise the name of the version Remote Config song_versions assigned (short; see features/catalog.md). Game Mode session events report the chart that loaded (useMagicGameplay's playedVersionRef), so a version that could not be had and fell back reports default. The Song List, Replay and result recommendation clicks report the version the play will load. Learn Mode, the tutorial's own song (it plays its tutorial_song MIDI) and song_impression report default.

  • Learn Mode opens after four finished songs (features/songs.md), and the lock adds no events. The locked Learn pill on the Song List sends nothing: no song was chosen, so no song_click. The first entry is the "Learn Mode unlocked!" popup's Claim, which sends the song_click the Learn pill sends (useLearnEntryClick: song_mode: "learn", song_play_type: "home", no song_order — no list row opened it) for twinkle-twinkle-little-star, then Learn Mode's own session events as usual.

  • Learn Mode sends through one tracker, src/features/learn/learn-analytics.ts, made once per visit by useLearnSessionAnalytics. The screen only says when:

    • the action phase;
    • a key press, saying whether it belongs to the final stage's judged run;
    • a stage completed;
    • the final (test) stage's run ended;
    • out of hearts, a revive offered, a revive;
    • a revive about to restart the stage's attempt, with that attempt's counts (carryAttemptCounts), and the time the revive's ad took (excludeAdTime);
    • a stage left (stageLeft, from goToStage);
    • Retry / Restart / Next song;
    • leaving.

    The tracker owns the per-session guards. A Retry, Restart or Next song opens a new song_session_id. The Learn CTA reuses the song's session unless it already has a click or reached song_ap (trackSongClickForNewPlay).

  • Learn me_start has two milestones, and sends once per session on whichever the session reaches first:

    • stage 1 completed; or
    • the 5th press of the final stage's challenge run — the milestone for a session that can never complete stage 1: a Retry, a Replay, or a player returning to a song whose stages they have all passed and resuming on the show.

    The count is the final (test) stage's Challenge only. Its Practice counts nothing, the listen step and the "I'm ready!" card take no play input at all, and neither does any earlier stage. Every press the run takes counts, right or wrong: the milestone is that the player is playing the show, not that they are playing it well. Like every other run-state flag the count is per song session — leaving and coming back, or a Retry / Restart / Next song, starts it again from zero, and me_start still goes out at most once per session. The threshold is LEARN_CHALLENGE_ME_START_PRESSES in src/features/learn/learn-analytics.ts, the one place the rule lives.

  • Learn song_progress adds up every attempt of the stage that a revive (the out-of-hearts card's Keep going) restarted, until the stage completes or the player moves to another stage: error_cnt sums their wrong presses. hint_cnt is 0 or 1: a revive keeps the attempt's Hint reveal, so the attempt that completes the stage counts that Hint once, however many revives it carried through.

  • Learn song_playtime (on song_end and song_result) runs from song_ap and leaves out the time spent in a revive's ad.

  • Learn song_end / song_result go out the moment the final stage's Challenge run ends: when its last note is ruled on — claimed, or its window (±150 ms on the phone's speaker, ±250 ms on headphones) shut with nothing claiming it — not when the backing reaches its cue marker, which on some songs is seconds later. So song_playtime stops at the last note, and a press after it is not judged: it adds nothing to error_cnt (on song_result, and the stage's song_progress) or wrong_rate, and does not count towards me_start's five presses. A run nothing ever rules on is ended by a backstop, 2.5 s after its last window shuts. A run the player backs out of (back after "I'm ready!", then Keep going!) never ends: it sends neither event, and the run that starts over from "I'm ready!" sends them once, with its own stats only, though its song_playtime still runs from song_ap and so includes the abandoned attempt and the time on the Leave card and the question.

  • Learn song_result rates need not sum to 1: perfect_rate + miss_rate is 1, early_rate and late_rate count timed claims again, and wrong_rate counts presses.

  • song_revive_impression goes to subscribers too: the out-of-hearts card offers them Keep going although no ad plays for them. Their heart takes one of the song's 3 refills in any 24 hours, but no ad was watched, so no song_revive follows.

  • The tutorial song (FTUE, on Game Mode's gameplay) sends song_ap once its song is ready to play and is watched for song_quit from there, with Game Mode's chart-group progress (useTutorialSongSession). It has no way out of the song, so only a force quit reports one; its song_end closes the watch.

  • song_quit (src/core/sdk/song-quit.ts) goes out for a session watched from song_ap that is left before song_end / song_result.

    • A quit also ends that song session, so the next play of the song opens a new one.
    • The watch lives in a persisted store (open-song-session-store.ts). A session still open at the next launch was left by a force quit, and flushSongQuitFromLastLaunch in useBootstrapEntrySDK reports it. The flush runs in the bootstrap's mount effect, and the root layout renders no screen until the bootstrap is ready, so it goes out even when the new launch opens onboarding or the tutorial again.
    • progress is "done/total": chart groups in Game Mode and the tutorial song, passed stages in Learn (a five-stage song gives n/5). In Game Mode the total is the last one the chart reported (play-screen-quit.ts): the gameplay controller is cleared before the screen's unmount records the progress, so a quit reported from that record no longer reads "0/0".
    • A Learn visit that ended at its result, or was left before song_ap, releases its session when the screen goes.

Known tracking issues (not fixed yet)

  • song_impression helper exists but no call site wires 2s list visibility yet.
  • Some planned events in event-contract.ts have no trigger — expected until implemented.

Shop and No Ads popup (PM sheet "Event Shop", 2026-11-10)

Source of truth: the "Event Shop" sheet of the Piano Simulation Roadmap; decisions in features/shop.md. No Ads events carry pack_type (noads_1day / noads_7days / noads_lifetime, the same in both price tiers) instead of the store package; the Song list's IAP songs (screen = home) keep package.

Eventscreen / paramsWhenWhere
shop_viewsource: side_tab / noads_popup / othersEvery time the Shop tab gains focus (a paywall or the Switch popup over it does not take its focus). Never in a variant without the Shop.features/shop/store.ts viewShop, from ShopScreen
sub_offer_showshopThe Premium Access card on screen, with each shop_view (not for VIP: the card is hidden).Shop store
sub_offer_show / _click / _close / _cancel, user_subscriptionshop_all_plansThe paywall "See All Plans" opens (openPlans in infra/container/shop-module.ts).PaywallHost
sub_see_all_plansshop"See All Plans" pressed. Only the Shop has that button.Shop store
sub_offer_clickshop, plan_selected = weekly"Try Free Now" / "Subscribe Now" pressed: it buys the weekly VIP subscription directly.Shop store
user_subscription / sub_offer_cancelshopThat purchase went through / did not (cancel, store error, not found).Shop store
iap_offer_showshop / popup_fs / popup_app_open / popup_default, pack_type, show_index (popup only, lifetime count over every placement)Shop: one per pack on sale with each shop_view (Active, Included, the owned Lifetime card and VIP's packs log nothing). Popup: each time it shows.Shop store, noads-popup-store.ts
iap_offer_clickshop / popup_fs / popup_app_open / popup_default, pack_typeA pack's price pressed, or "Remove ads forever". A longer pass over a running one logs the click at the price press, before the Switch popup; "Keep" logs nothing more.same
iap_offer_success+ transaction_id, price, price_value, currency, is_switchThe store confirmed and ads are off. is_switch = yes after the Switch popup's "Switch".same
iap_offer_fail+ fail_reason (user_cancel / store_error / product_not_found), error_code, error_messageThe purchase did not go through.same
iap_offer_showsonglist_banner, pack_type (the pack shop.noads_banner.product sells)The Song list's No Ads banner is at least half on screen: once per visit (each focus of the Song list, logged at the focus when the banner is still in view); scrolling back and forth logs no more. The banner is not in the list (so nothing logs) while the player has any No Ads pack or VIP, or in a variant without the Shop.song-list-flow-store.ts rowsHalfViewable, from SongList
iap_offer_clicksonglist_banner, pack_typeAny press on the banner: the card and its price button both buy.song-list-flow-store.ts buyRemoveAds
iap_offer_success / iap_offer_failsonglist_banner, pack_type, + the params above (is_switch not sent)As the Shop's: the store's transaction and price, or why it did not go through. Once the store has charged it is a success, even if syncing it into the app then fails (that is warned).logic/buy-banner-no-ads.ts
iap_offer_closepopup_fs / popup_app_open / popup_defaultThe popup's X only. The backdrop no longer closes it; "See passes" is a shop_view, not a close; a purchase closes it with no close event.noads-popup-store.ts
noads_expirepack_type (noads_1day / noads_7days), sessions_activeThe first time the app sees a pass over and ads back (boot, expiry timer, foreground). A 1-day pass replaced by a switch never fires; the 7 days do when they end. sessions_active = cold starts while the pass ran, the buying one included.features/monetization/noads-tracking.ts, from syncEntitlements
user property noads_statusnone / 1day / 7days / lifetimeSet on each launch's first sync and whenever it changes (buy, switch, expiry, restore). VIP without a pack is none.same

Only the popup the monetization slice opens logs; Labs logs nothing, and a locked Lifetime bonus song never opens it (Free / Rewarded / VIP sheet rules). Its screen says where it came: popup_fs after the Nth interstitial (the QC tracking sheet's name; noads_popup from 2026-11-10 to 2026-11-19), popup_app_open at an app open, popup_default at the Nth song start in place of the default paywall (Aggressive A/B, noads_popup.app_open_from_session / noads_popup.song_start). The slice's own noads_popup_trigger (with placement fs / app_open / song_start) stays in the slice: the app sends only its iap_offer_show (SLICE_EVENTS in monetization-app-container.ts), so Firebase never gets it. shop_view.source from its "See passes" is still noads_popup.

The price, currency and transaction come from the store: IapProduct.currencyCode, IapPurchaseResult.transactionId and the RevenueCat error's code / message (purchaseErrorDetails in core/iap/rc-mappers.pure.ts).

Paywall locations (screen) per trigger

Every paywall trigger sends its own screen on sub_offer_show / sub_offer_click / sub_offer_cancel / sub_offer_close (clicked after a purchase press) / user_subscription; none falls back to unknown.

user_subscription.is_trial is what the store reported right after the purchase: yes when the entitlement the product unlocked is in its free-trial period (RevenueCat periodType TRIAL, IapEntitlements.trialProductIds), so an Apple ID that already used the trial logs no. Only when the store does not report trial periods does it fall back to whether the product sells a free trial (paywall/user-subscription.pure.ts; the Shop's card trial in the Shop).

user_subscription also sends the price as the store bills it: price (the localized string, kept for older reports), price_value (the number behind it, e.g. 4.99 or 249000) and currency (ISO 4217), plus the store's transaction_id, on every paywall and the Shop. Revenue sums use price_value per currency, never price. The 50%-off modal sends paywall_variant: "discount", the rest default.

screenTrigger
introPaywall after onboarding / the tutorial's video paywall
resultFirst-song paywall on the result after the tutorial
sessionOpen-app paywall, and the one-off 50%-off offer of session 3
vip_offer50%-off offer after the Nth VIP song press of a session (new)
default_paywallDefault paywall at the Nth song_start (new)
replayPer-song replay paywall (new; was result)
home_returnPaywall on returning Home after N songs (new; was song_list)
songVIP song press (plain paywall), "Unlock all songs"
iconPremium button
settingSettings
profileProfile (new; was unknown)
shopShop's Premium Access card (sub_offer_show with each shop_view, and its "Try Free Now" / "Subscribe Now")
shop_all_plansThe paywall the Shop's "See All Plans" opens

Remote Config suggestion per variant (mon_pkg.paywall, all optional; arm defaults apply when a key is absent):

{"variant":"friendly","paywall":{"trial_intro":true,"trial_user_opened":true,"launch_paywall":true,"launch_from_session":2,"discount_50":true,"discount_50_from_session":3,"discount_50_after_dismissals":15,"vip_offer":true,"vip_offer_after_taps":2,"vip_offer_per_session":1,"default_paywall":true,"default_paywall_song_start":6,"home_return":true,"home_return_songs":3,"replay":true}}
{"variant":"balance","paywall":{}}
{"variant":"aggressive","paywall":{}}
{"variant":"very_aggressive","paywall":{}}

song_start counts after the first note of every gameplay, so a Retry of a normal play counts again.

Meta app events (Facebook SDK)

Meta's campaign types that optimise on in-app events need the events from Meta's own SDK (AppsFlyer → Meta postbacks only cover installs well). The build carries the Facebook SDK for iOS (react-native-fbsdk-next 13.4.3, Core pod only — patches/react-native-fbsdk-next@13.4.3.patch); the Meta app's ID / client token / name come from .env (FACEBOOK_APP_ID, FACEBOOK_CLIENT_TOKEN, APP_NAME) into Info.plist (config/facebook-sdk.ts).

What Meta getsFromNotes
Install, app activation, sessionsthe SDK itself (FacebookAutoLogAppEventsEnabled)from launch (FacebookAutoInitEnabled)
In-app purchasesAppsFlyer, not the SDK (campaign team's choice, 2026-11-30): AppsFlyer posts af_purchase back to Meta (Integrated Partners → Meta ads → In-app events)the SDK's own purchase logging is off on the Meta App Dashboard (Settings → Basic → iOS card → "Log in-app events automatically": No). There is no app-side switch for purchases alone — FacebookAutoLogAppEventsEnabled: false would also stop install / activation. One purchase source only, or Meta counts each purchase twice
AdImpressionevery AdMob paid event (meta-ad-tracking.ts)valueToSum revenue, fb_currency, ad_type — see admob-integration.md § 8
Advertiser tracking (IDFA)the ATT answer (meta-att-sync.ts)granted → on; the SDK reads ATT itself from iOS 17, iOS 16 needs it told

Everything goes through @core/meta-events (getMetaAppEvents()); sim builds send nothing. The SDK's Expo AppDelegate subscriber hands launches and opened URLs (the fb<appId> scheme) to the SDK for Aggregated Event Measurement. App Store privacy answers ("Data Used to Track You") must cover the Meta SDK in the release that ships it.

Cross Promotion

Spec: tab "Event: Cross Promotion" (2026-11-20). This app is the destination: a player taps a promo in another Amanotes app (the source app) and arrives through an AppsFlyer OneLink. Flow, routing and files: features/cross-promo.md. Both events are Firebase only, never AppsFlyer (event-routing.ts).

Event / propertyWhenTrigger
map_user_idEvery session start once the AppsFlyer id exists; again within the session when the ids changemap-user-id-runtime.ts
crosspromo_deeplink_openA cross-promo link's open is routed (after the first run, on the tab shell)cross-promo-route-runtime.ts
user property xp_uidEach open the intake takes, before the open waits for routing; always the first xp_uidcross-promo-deep-link-runtime.ts

map_user_id joins the AppsFlyer id to this install's Firebase ids, so a player from the source app can be matched in BigQuery.

  • Params:
    • appsflyer_id: required; the event is never sent without it.
    • idfa: only when tracking is allowed.
    • idfv.
    • pseudo_id: the Firebase app instance id (user_pseudo_id in BigQuery).
    • ama_device_id: ios_ + the IDFV, dashes removed, lower case.
    • installation_id: the Firebase Installation id.
    • att_status: authorized / denied / restricted / not_determined, the raw iOS status, read fresh each time. Unlike the ads' att_status (granted / denied / undetermined), restricted is kept apart from denied.
  • An id that is empty or can't be read is left out (null in BigQuery), never sent as "".
  • Session start = the cold start (right after AppsFlyer's init) or a return to the foreground after 30 min or more in the background (Firebase's session timeout). It is sent at every session start, even when nothing changed.
  • Within a session it is sent again only when the row changed. It checks on every return to the foreground and right after the ATT answer: allowing adds idfa and authorized, denying changes the status. A return or an answer that changes nothing sends nothing.
  • No AppsFlyer id (AppsFlyer off, as in EXPO_PUBLIC_APP_VARIANT=sim, or its init failed): nothing is sent. The next check that finds one sends.
  • A new player has no ATT answer at the cold start (not_determined, no idfa), so the answer at the end of the tutorial song sends a second row. A returning player asked at boot answers before AppsFlyer's init, so the first row already has the answer.

crosspromo_deeplink_open: one per click on the source app's promo.

  • Params:
    • xp_uid (deep_link_sub1): required. The source app's click id.
    • placement (deep_link_sub2), song_genre (deep_link_sub3, as the link sent it), experiment_group (deep_link_sub4): left out when the link does not carry them.
    • match_type: deterministic / probabilistic (AppsFlyer's match of the deep link), or not_found (AppsFlyer's deep link did not resolve; the link was recovered from the install's conversion data, on the first launch only; AppsFlyer's own match of the same click, arriving later, replaces it before the event is sent).
    • open_type: deferred (the first open after an install from the link) / direct (the app was already installed).
    • route_result: matched_song (the song is shown on the Song List), matched_genre (the list is filtered to the genre), fallback_default (the Song List as it is: no match, no song_genre, or a dance genre, which this app has none of), fallback_error (routing failed; the Song List as it is).
  • Sent only when the link carries a real xp_uid (OneLink template placeholders don't count). An organic install, or a link that is not cross promotion, sends nothing.
  • Sent when the open is routed, not when the link arrives: after the onboarding and the tutorial, once the app is on its tab shell and the catalog has songs. A deferred open from a fresh install is sent after the first run, even across a relaunch.
  • One click = one event. The same click delivered twice sends once. Another click while an open still waits for routing is dropped.

User property xp_uid: the first xp_uid this install received, kept for good (MMKV). It is set on every open the intake takes, before the open waits for routing (so before its event), and always to that first value. A later link sends its own xp_uid on the event but leaves the property alone. It is not copied onto every event as a param (unlike mon_pkg_variant). Firebase keeps it across launches; a reinstall starts over.

ama_device_id on ad impressions. ad_impression and ad_impression_ama now carry ama_device_id beside appsflyerid, with the same value as map_user_id's. Boot reads the IDFV once, so it is there from the first paid ad; it is absent only when that read failed.

Not in the app: user_subscription token_1 / token_2. App Store Server Notification ids reach the server, never the client. user_subscription.price stays text, with price_value and currency beside it.

QC with Firebase DebugView on a connected device (the build must already be installed):

xcrun devicectl device process launch --terminate-existing --device <udid> co.leap.apps.sim.pinao -- -FIRDebugEnabled

xcrun devicectl list devices gives the <udid>. Debug mode stays on until a launch with -FIRDebugDisabled.