Skip to content

Add Matcha referral tracking with dynamic community config#1683

Draft
willyogo wants to merge 2 commits intocanaryfrom
matcha-ref
Draft

Add Matcha referral tracking with dynamic community config#1683
willyogo wants to merge 2 commits intocanaryfrom
matcha-ref

Conversation

@willyogo
Copy link
Member

@willyogo willyogo commented Jan 20, 2026

Summary

  • Adds ref query parameter to Matcha trade URLs for referral tracking
  • Creates SystemConfigProvider to expose community config to client components
  • Swap fidget dynamically uses brand.displayName from the community config as the ref value
  • Updates getMatchaUrl helper to accept optional ref parameter (defaults to "nounspace")

Changes

  • New: src/common/providers/SystemConfigProvider.tsx - React context provider with useSystemConfig hook
  • Updated: src/common/providers/index.tsx - Wraps app with SystemConfigProvider
  • Updated: src/app/layout.tsx - Passes systemConfig to Providers
  • Updated: src/fidgets/swap/Swap.tsx - Uses useSystemConfig() to get brand.displayName for ref
  • Updated: src/common/lib/utils/links.ts - getMatchaUrl accepts optional ref parameter

Why 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

  • Verify Swap fidget iframe URL includes ref=[communityDisplayName] parameter
  • Test on different community domains to confirm ref changes per community
  • Verify getMatchaUrl helper works with and without ref parameter

🤖 Generated with Claude Code

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]>
@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
space-system Ready Ready Preview, Comment Jan 20, 2026 10:45pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Adds a SystemConfig context/provider and passes systemConfig into Providers; Swap now reads that config to append a ref query parameter (default "nounspace") to Matcha URLs via the updated links util.

Changes

Cohort / File(s) Summary
Matcha URL util
src/common/lib/utils/links.ts
getMatchaUrl signature now accepts optional ref?: string (default "nounspace") and appends &ref=<ref> to generated Matcha URLs.
Swap UI
src/fidgets/swap/Swap.tsx
Uses useSystemConfig to obtain displayName (as matchaRef), buildMatchaUrl updated to include ref param and wrapped in React.useCallback; effects updated to depend on it.
SystemConfig provider
src/common/providers/SystemConfigProvider.tsx, src/common/providers/index.tsx
New SystemConfigProvider and useSystemConfig hook; Providers component now accepts a systemConfig prop and nests the new provider around existing providers.
Root layout
src/app/layout.tsx
Providers invocation updated to pass systemConfig={systemConfig} into the provider tree.

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>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble context into the ground,
A tiny ref hops all around,
Providers stack, the tree takes root,
Matcha links now bear my boot,
Nounspace whispers: tracking bound. 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Matcha referral tracking with dynamic community config' accurately describes the main changes: adding referral tracking to Matcha URLs and introducing dynamic system configuration context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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]>
@willyogo willyogo changed the title Add Matcha referral tracking parameter to swap URLs Add Matcha referral tracking with dynamic community config Jan 20, 2026
@willyogo willyogo added the LGFTP Looks Good From Testing Perspective label Jan 20, 2026
@j-paterson j-paterson marked this pull request as draft January 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGFTP Looks Good From Testing Perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant