feat: persist deeplink attribution with MMKV#29542
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #29542 +/- ##
==========================================
- Coverage 82.16% 82.15% -0.02%
==========================================
Files 5176 5184 +8
Lines 137275 137548 +273
Branches 31024 31115 +91
==========================================
+ Hits 112795 112999 +204
- Misses 16840 16888 +48
- Partials 7640 7661 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There is a PR #29641 to skip the known failing test. Once it’s merged, I’ll update my PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4e3ac25. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Key impacts:
SmokeWalletPlatform is selected because:
No other tags are warranted: the changes are purely attribution/analytics infrastructure with no impact on confirmations, swaps, accounts, network management, snaps, browser, or other feature areas. Performance Test Selection: |
|
| try { | ||
| if (uri && typeof uri === 'string') { | ||
| AppStateEventProcessor.setCurrentDeeplink(uri, source); | ||
| if ( |
There was a problem hiding this comment.
do we have a prettier issue here?




Description
Mobile only kept deep-link UTM / attribution_id in memory (via AppStateEventListener / processAttribution). After the first foreground pass the deeplink is often cleared, and onboarding → Wallet Setup Completed usually happens in a later session, so acquisition data was lost and could not be attached to conversion analytics.
This PR adds a dedicated Redux slice for attribution with redux-persist + MMKV (separate from root filesystem persist). It exposes saveAttribution, clearAttribution, and expireAttributionIfStale (default 7-day TTL). Data is written when:
Privacy: No persistence when marketing consent is off; persisted data is cleared when the user opts out of marketing data collection and when onboarding is cleared (CLEAR_ONBOARDING). Root persist blacklists attribution so it is not double-stored with the nested MMKV persist.
Includes unit tests for the slice (save / clear / expire), marketing sagas, deeplink handler, app state listener, and persistConfig blacklist expectations
Jira: https://consensyssoftware.atlassian.net/browse/TO-717
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Introduces new persisted attribution state and wires it into deeplink/app-state flows plus migrations; mistakes could incorrectly retain or clear marketing acquisition data and impact analytics/privacy expectations.
Overview
Adds a new persisted
attributionRedux slice to store acquisition fields (utm_*,attribution_id) with a 7-day TTL, deduping, and explicitsaveAttribution/clearAttribution/expireAttributionIfStaleactions.Attribution is now saved from both the legacy deeplink entrypoint (when
security.dataCollectionForMarketingistrue) and fromAppStateEventListenerafterprocessAttribution, and the listener now clearscurrentDeeplinkafter processing to avoid re-saving on subsequent resumes.On app start, persisted attribution is cleared if marketing consent isn’t explicitly granted, otherwise stale records are expired; new sagas also clear attribution on marketing opt-out and
CLEAR_ONBOARDING. A migration (136) imports any legacy MMKV-stored attribution into the root persisted state and removes the old key, and selectors/tests are added to validate the new behavior.Reviewed by Cursor Bugbot for commit 4e3ac25. Bugbot is set up for automated code reviews on this repo. Configure here.