Skip to content

fix(tokens): track currency-info opens and shares from the card overlay - #1560

Merged
bmc08gt merged 20 commits into
code/cashfrom
fix/token-info-overlay-analytics
Sep 25, 2026
Merged

bmc08gt merged 20 commits into
code/cashfrom
fix/token-info-overlay-analytics

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1554. Retarget to code/cash once that merges.

Tapping a wallet card opens CurrencyInfoExpansion, an app-level overlay, not the pushed TokenInfoScreen. The overlay sent no analytics, so wallet opens never sent Token Info: Opened From Wallet and its share button never sent Button: Share Token Info. A /token deeplink opens the same overlay through CardExpansionController.beginExpanded, so Token Info: Opened From Deeplink was missing as well. This dates from the card-expand change (#1252), not from #1554.

iOS sends all three from its overlay: WalletScreen.openCard, openCardImmediately, and the share link's tap gesture. This PR matches those names and the Mint property.

  • Open: tracked once per open, keyed on the mint. The source is WALLET when the card flew out of the deck and DEEPLINK when there was no source card. The choice lives in cardExpansionOpened(), which CurrencyInfoExpansionAnalyticsTest covers.
  • Once per open: the "already tracked" flag is rememberSaveable. Pushing Give, Convert or Withdraw takes the wallet entry, and the overlay with it, out of composition, and a plain LaunchedEffect(mint) would fire again on return. The entry stays on the back stack, so RetainedEntryState keeps its saved state. Closing the overlay removes it from composition, which resets the flag for the next open.
  • Share: tracks ButtonEvents.tapped(Button.SHARE_TOKEN_INFO) before dispatching.

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.
Tapping a wallet card opens CurrencyInfoExpansion, an overlay rather than
the pushed TokenInfoScreen, and the overlay tracked nothing. Wallet opens
never sent `Token Info: Opened From Wallet`, and its share button never
sent `Button: Share Token Info`. Deeplinks open the same overlay through
beginExpanded, so `Opened From Deeplink` was missing too. iOS sends all
three from WalletScreen.openCard, openCardImmediately and the share link.

The open event fires once per open, keyed on the mint, with WALLET when
the card flew out of the deck and DEEPLINK when there was no source card.
The "already tracked" flag is rememberSaveable because a pushed Give,
Convert or Withdraw takes the wallet entry, and the overlay with it, out
of composition. The entry's saved state outlives that, so coming back
does not count a second open.
@bmc08gt bmc08gt self-assigned this Sep 25, 2026
@bmc08gt
bmc08gt changed the base branch from refactor/analytics-track to code/cash September 25, 2026 02:33
@bmc08gt
bmc08gt merged commit 12cad7b into code/cash Sep 25, 2026
@github-actions github-actions Bot added type: fix Bug fix area: payments Payments, transfers, intents, billing area: onramp Deposit, purchase, Coinbase, fiat on-ramp area: scanner QR/Kikcode scanning, camera area: build-system Gradle, convention plugins, build-logic area: tokens Token accounts, balances, token info area: session labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build-system Gradle, convention plugins, build-logic area: onboarding area: onramp Deposit, purchase, Coinbase, fiat on-ramp area: payments Payments, transfers, intents, billing area: scanner QR/Kikcode scanning, camera area: session area: tokens Token accounts, balances, token info type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant