Repository navigation
refactor(analytics): send every event through FlipcashAnalytics.track - #1554
Merged
Merged
Conversation
Every transfer call site now tracks a TransferEvents builder. The amount conversion follows the type each caller already had (LocalFiat, or the scanned Fiat on a failed grab), so the property block is unchanged. Grab Time now goes out as a number instead of a string. The session delegate tests assert the event each grab, give, claim and cash-link share sends. TippingCoordinator lost its transfer call in #1463; only its unused Analytics import goes here.
Every add-money call site now tracks an AddMoneyEvents builder instead of the legacy Analytics.AddMoney enums and FlipcashAnalyticsService methods. Fiat/LocalFiat amounts and thrown errors go through their .analytics converters, so each property block is unchanged except numbers going out as numbers instead of strings. Analytics.AddMoneySource, AddMoneyMethod, the AddMoneyEvent sealed interface, and the Mixpanel delegate overrides are dead now that every caller uses the shared builder, so they are removed.
The five contact-verification screens now track OnrampEvents.step(...) from the same LaunchedEffect. The events carry no properties, and a new test pins each step to the name the screens sent before. openOnramp, onrampPurchase, OnrampSource, OnrampPurchaseStep and their eight events had no callers and are deleted.
Wallet connect/request-amount/failed/cancel in SwapViewModel now go through WalletEvents instead of the bespoke FlipcashAnalyticsService methods, so amounts and providers convert through .analytics like the other builder call sites. transactionSubmittedToWallet had no caller and is deleted along with its event and property mapping.
TokenInfoEntry.Discovery, Chat and ChatGate used to report as "Token Info: Opened From Wallet". They now send Opened From Discovery, Chat and Chat Gate, so the Wallet count drops by what those three entries carried. Deeplink and Wallet are unchanged. The mapping has no else branch, so a new TokenInfoEntry fails to compile until it is mapped. TokenInfoSource.Give and its event have had no caller since 6419a95 and are deleted.
SwapViewModel.trackTransaction now calls the generated SwapEvents.purchase and SwapEvents.sell builders instead of the ad-hoc Analytics.buy/sell path, dropping the local Analytics.SwapMethod/PurchaseMethod enums and the TokenTransactionEvent sealed hierarchy they drove. Fee is sent as a decimal (events.toml already defines it as `type = "decimal"`) instead of a string.
Gallery scan (Scanner.kt), tip card scan (CodeScanDelegate) and tip card present (TipCardDelegate) now call analytics.track(ScanEvents.*) instead of the FlipcashAnalyticsService methods, which are deleted along with their Events.kt classes and MixpanelAnalyticsDelegate wiring. Tier, Zoom and Time go out as numbers and Exhausted as a flag, matching the shared builder; Scanner.kt has no test harness so its three call sites are reviewed by diff only. CodeScanDelegateTest and TipCardDelegateTest now assert against RecordingAnalytics with ScanEvents builders instead of verifying the legacy methods.
App.kt, Scanner.kt and CashLinkDelegate.kt track the DeeplinkEvents builders instead of the legacy service methods. Two values change: - Type comes from DeeplinkType.analytics, an explicit string per subclass, instead of javaClass.simpleName. The strings match the source class names, but no keep rule covers DeeplinkType, so a minified release build may have sent R8-renamed names until now. - The parse-failure Error carries the URL without its query or fragment, which can hold secrets. CashLinkDelegateTest asserts the routed event, with the type as a string literal, on each early return and on success.
Replaces FlipcashAnalyticsService.displayNameSubmitted(source, hadPreviousName) with DisplayNameEvents.set/updated from the generated builder, called directly from NameEntryViewModel. Deletes the old DisplayNameEvent.Set/Updated sealed classes from Events.kt, the interface/stub method from Analytics.kt, and the Mixpanel override, since nothing else referenced them. NameEntryViewModel now takes a DispatcherProvider (wired to BaseViewModel's defaultDispatcher) so its CheckName pipeline runs deterministically under a test dispatcher, matching WalletViewModel's existing pattern; needed to cover the branch through NameEntryViewModelTest with RecordingAnalytics.
NavMessagingEntryDecorator.kt tracks ErrorModalEvents.displayed instead of the legacy displayedErrorModal method. Name, keys (Title, Message, Screen, Call Site) and value types are unchanged; Screen and Call Site still drop from the map when null, matching :libs:analytics-events' ErrorModalEventsTest, which already pins that exact name and property map. The decorator has no test harness, so the call site was reviewed by diff against that existing builder test rather than given a new one. Deletes displayedErrorModal from FlipcashAnalyticsService, StubFlipcashAnalytics and MixpanelAnalyticsDelegate, and ErrorModalDisplayed from Events.kt. No dead declarations in this domain.
…uilders Button taps track ButtonEvents.tapped with the shared Button enum, and the account actions and paidForAccount track AccountEvents. Every event name is unchanged; Create Account Payment's Fiat goes out as a number. Actions.kt is gone, along with Button.AllowCamera and Button.Sell, which had no callers. Compose callers read the service through rememberAnalytics(), since LocalAnalytics is typed as the base service without track(). The login tests assert the tracked button events with RecordingAnalytics instead of verifying action() on a mock.
Every caller now goes through FlipcashAnalytics.track/increment, so FlipcashAnalyticsService, StubFlipcashAnalytics, Events.kt and :libs:analytics have no users left. LocalAnalytics moves into the Flipcash analytics module, typed as FlipcashAnalytics, with previews providing FlipcashAnalytics.None. The delegate's app-start trace went with the lifecycle hooks it lived in; nothing called those hooks.
code/cash left successful at its default on this path, so a failed Sent Cash / Sent Tip reported State: Success; this branch sends Failure and the test keeps it that way.
It sat in the main source set, so it shipped in the app and production code could inject it. It now lives in the analytics module's testFixtures, which the nine modules whose tests use it pull in with testImplementation(testFixtures(...)), the same way :libs:coroutines and :ui:resources share their fakes. The fixture compilation needs the Compose BOM and ui on its classpath because the module applies the Compose compiler.
…oordinator TippingCoordinator took a FlipcashAnalytics it never called, both before and after the track() migration. Remove the constructor parameter and the module's dependency on :apps:flipcash:shared:analytics.
ChatViewModel dispatched events on the real Dispatchers.Default, so ChatSendFailureAnalyticsTest polled for up to 5s and could leave the send handler running after the test returned. CI then failed ReportViewModelTest, the next messenger test, with UncaughtExceptionsBeforeTest, which is how kotlinx-coroutines-test reports an exception thrown by an earlier test's leftover coroutine. It did not reproduce locally. Inject DispatcherProvider into ChatViewModel, as NameEntryViewModel does, and pass the test's dispatcher so no work outlives the test. Production still gets Dispatchers.Default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces
FlipcashAnalyticsService(about 40 methods),StubFlipcashAnalytics,Events.kt,Actions.kt, theAnalyticsenums and:libs:analyticswith one interface:Every event name and property key now comes from the shared builders in
:libs:analytics-events(#1538). Android domain types convert through the.analyticsextensions inConversions.kt. Tests assert tracked events withRecordingAnalyticsrather than verifying mockk calls. There's one commit per domain, so each can be reviewed against the property block it replaces.What changes in Mixpanel
Everything else keeps its event name, keys and values.
Grab Time, scan zoom and time, and the Create Account Payment fiat used to be sent as strings, and now go out as numbers. Gallery Scan: Failed'sExhaustedused to be the string"true"/"false"and is now a boolean, as the contract defines it. A saved Mixpanel filter on the old string value stops matching. Event names and keys are unchanged.State: Failure. Oncode/cash,ChatViewModel's failure path leftsuccessfulat its default oftrue, so these failures went out asState: Successalong with anError. Every other transfer failure already sentFailure. Dashboards that filter onState = Successwill stop counting failed chat sends.ChatSendFailureAnalyticsTestpins the new value.Typeis an explicit string perDeeplinkType, notjavaClass.simpleName. Nothing keeps theDeeplinkTypeclass names through R8, so release builds may have been sending obfuscated values. A Mixpanel lookup of releaseTypevalues for Deeplink: Parse and Deeplink: Routed would tell us whether release values change or stay the same. That lookup hasn't been done yet./c/#/e=…, seeLinkify.cashLink).TokenInfoEntry.Discovery,ChatandChatGateused to report as Token Info: Opened From Wallet. They now send Opened From Discovery, Opened From Chat and Opened From Chat Gate, so the Wallet count drops by what those entries carried.Deleted as dead
These had no callers (see
docs/superpowers/specs/2026-09-23-analytics-inventory.mdin the orchestrator repo), so they're deleted rather than ported:openOnramp,onrampPurchase,OnrampSource,OnrampPurchaseStepand their eight eventstransactionSubmittedToWalletTokenInfoSource.Give(no caller since 6419a95)Button.AllowCamera,Button.Sell