Add Matcha referral tracking with dynamic community config#1683
Add Matcha referral tracking with dynamic community config#1683
Conversation
Appends ref query parameter to Matcha trade URLs in both the Swap fidget and the getMatchaUrl helper. Uses NEXT_PUBLIC_MATCHA_REF env var with "nounspace" as the default value. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds a SystemConfig context/provider and passes Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant RootLayout
participant Providers
participant SystemConfigProvider
participant Swap
participant LinksUtil
RootLayout->>Providers: render with systemConfig
Providers->>SystemConfigProvider: wrap children (provide systemConfig)
SystemConfigProvider->>Swap: Swap mounts (consumes context via useSystemConfig)
Swap->>LinksUtil: buildMatchaUrl(address, network, ref=matchaRef)
LinksUtil-->>Swap: return Matcha URL with &ref=<matchaRef>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replaces environment variable approach with dynamic community config. Creates SystemConfigProvider to expose systemConfig to client components, allowing the Swap fidget to use brand.displayName as the Matcha referral parameter. Changes: - Add SystemConfigProvider with useSystemConfig hook - Update Providers to accept and wrap with SystemConfigProvider - Update Swap fidget to use useSystemConfig for ref parameter - Update getMatchaUrl helper to accept optional ref parameter Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary
refquery parameter to Matcha trade URLs for referral trackingSystemConfigProviderto expose community config to client componentsbrand.displayNamefrom the community config as the ref valuegetMatchaUrlhelper to accept optional ref parameter (defaults to "nounspace")Changes
src/common/providers/SystemConfigProvider.tsx- React context provider withuseSystemConfighooksrc/common/providers/index.tsx- Wraps app with SystemConfigProvidersrc/app/layout.tsx- Passes systemConfig to Providerssrc/fidgets/swap/Swap.tsx- UsesuseSystemConfig()to get brand.displayName for refsrc/common/lib/utils/links.ts-getMatchaUrlaccepts optional ref parameterWhy this approach?
The system supports multiple communities per deployment via domain-based resolution. A static environment variable would not work since different domains serve different community configs. The SystemConfigProvider makes server-loaded config available to client components in an idiomatic React/Next.js way.
Test plan
ref=[communityDisplayName]parametergetMatchaUrlhelper works with and without ref parameter🤖 Generated with Claude Code