Skip to content

Conversation

@fairlighteth
Copy link
Contributor

@fairlighteth fairlighteth commented Dec 18, 2025

Summary

  • Centralized the CoW Swap CTA into COW_SWAP_CTA (text/action/utm/href/deeplink) and wired all current usages to it.
  • Updated hero/footer CTAs on /cow-swap to use shared href/labels/analytics metadata.
  • Updated CoW Swap product card CTA on / and /products plus nav button (visible on all pages) to use the shared CTA config.

To Test

  1. Open /cow-swap

    • Hero CTA shows “Trade on CoW Swap”, links to https://swap.cow.fi/, and fires click-trade-on-cow-swap with utmContent cow-swap-trade-on-cow-swap-button.
    • Bottom CTA shows the same text/URL/analytics values.
  2. Open / (home)

    • CoW Swap product card CTA shows “Trade on CoW Swap”, links to https://swap.cow.fi/#/1/swap/USDC/COW, and uses the shared action/utm metadata.
  3. Open /products

    • CoW Swap product card CTA matches the home page behavior (text/deeplink/action/utm).
  4. Any page with the main menubar

    • Nav button shows “Trade on CoW Swap” and links to https://swap.cow.fi/#/1/swap/USDC/COW.

Background

CTA copy and tracking were duplicated across pages; the shared object keeps text/action/utm/urls consistent and easier to evolve.

Summary by CodeRabbit

  • Refactor
    • Centralized CoW Swap call-to-action configuration to ensure consistent links and messaging across the platform.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 18, 2025

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

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Dec 23, 2025 0:08am
explorer-dev Ready Ready Preview Dec 23, 2025 0:08am
swap-dev Ready Ready Preview Dec 23, 2025 0:08am
widget-configurator Ready Ready Preview Dec 23, 2025 0:08am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Dec 23, 2025 0:08am
sdk-tools Ignored Ignored Preview Dec 23, 2025 0:08am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

A new centralized CTA constant COW_SWAP_CTA is created containing button text, links, UTM parameters, and analytics action. Three files are updated to import and reference this constant instead of hardcoded values, establishing a single source of truth for CoW Swap CTA configuration.

Changes

Cohort / File(s) Change Summary
New CTA Constant Definition
apps/cow-fi/const/cta.ts
Introduces new exported constant COW_SWAP_CTA with frozen object containing text, action, utmContent, href, and deeplinkHref properties.
Component & Page CTA Updates
apps/cow-fi/app/(main)/cow-swap/page.tsx, apps/cow-fi/components/Layout/const.ts, apps/cow-fi/data/home/const.tsx
Import COW_SWAP_CTA and replace hardcoded CTA values (labels, links, analytics actions) with corresponding constant properties. Page component signature updated to include ReactNode return type annotation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Straightforward constant centralization with consistent import and usage pattern across three files
  • No complex logic changes or control flow modifications
  • Changes are homogeneous (same refactoring pattern repeated)
  • Type annotation addition is trivial

Suggested reviewers

  • elena-zh
  • alfetopito

Poem

🐰 From scattered strings to one true nest,
A CTA constant passes the test—
One source of truth, no more duplication,
Links align with navigation!
Constants reign, the code stands tall,
Now swap.cow.fi answers the call.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: centralize CoW Swap CTA cta constants' directly describes the main change—consolidating CTA configuration into a shared constant for consistency.
Description check ✅ Passed The description includes a clear summary of changes, comprehensive testing steps with checkboxes, and background context explaining the rationale for centralization.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/unify-cowfi-cta

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.

@fairlighteth fairlighteth self-assigned this Dec 18, 2025
@fairlighteth fairlighteth marked this pull request as ready for review December 18, 2025 16:57
@fairlighteth fairlighteth requested review from a team December 18, 2025 16:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/cow-fi/components/Layout/const.ts (1)

114-119: Consider using COW_SWAP_CTA.action for analytics consistency.

Line 117 uses 'Click Trade on CoW Swap' as the analytics action, while the centralized constant defines COW_SWAP_CTA.action as 'click-trade-on-cow-swap'. This creates an inconsistency in analytics tracking compared to other locations (e.g., apps/cow-fi/app/(main)/cow-swap/page.tsx lines 95, 429) that use COW_SWAP_CTA.action.

🔎 Apply this diff to align with the centralized action:
     onClick: () =>
       analytics.sendEvent({
         category: CowFiCategory.NAVIGATION,
-        action: 'Click Trade on CoW Swap',
+        action: COW_SWAP_CTA.action,
         label: 'menubar-nav-button',
       }),
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0bbe9e and c0bd95f.

📒 Files selected for processing (4)
  • apps/cow-fi/app/(main)/cow-swap/page.tsx (5 hunks)
  • apps/cow-fi/components/Layout/const.ts (2 hunks)
  • apps/cow-fi/const/cta.ts (1 hunks)
  • apps/cow-fi/data/home/const.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cow-fi/components/Layout/const.ts
  • apps/cow-fi/const/cta.ts
  • apps/cow-fi/data/home/const.tsx
  • apps/cow-fi/app/(main)/cow-swap/page.tsx
📚 Learning: 2025-05-28T16:50:12.273Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 5768
File: apps/cow-fi/components/LearnPageComponent.tsx:184-185
Timestamp: 2025-05-28T16:50:12.273Z
Learning: In apps/cow-fi/components/LearnPageComponent.tsx, the user prefers to keep the inconsistent link behavior where featured articles always open in new tabs (target="_blank") while media coverage links conditionally open in new tabs based on the linkExternal flag. This inconsistency should not be flagged as an issue in future reviews.

Applied to files:

  • apps/cow-fi/components/Layout/const.ts
  • apps/cow-fi/data/home/const.tsx
  • apps/cow-fi/app/(main)/cow-swap/page.tsx
📚 Learning: 2025-09-19T11:38:59.206Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6232
File: apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx:199-200
Timestamp: 2025-09-19T11:38:59.206Z
Learning: The makeBuildClickEvent function in apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx takes five parameters: defaultChainId, contextLabel, mode, isSwapMode, and chainsCount. The chainsCount parameter is used to determine the CrossChain flag in analytics events.

Applied to files:

  • apps/cow-fi/components/Layout/const.ts
  • apps/cow-fi/const/cta.ts
  • apps/cow-fi/app/(main)/cow-swap/page.tsx
📚 Learning: 2025-02-20T15:59:33.749Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.

Applied to files:

  • apps/cow-fi/components/Layout/const.ts
  • apps/cow-fi/const/cta.ts
  • apps/cow-fi/data/home/const.tsx
  • apps/cow-fi/app/(main)/cow-swap/page.tsx
📚 Learning: 2025-07-18T08:07:55.497Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5992
File: libs/tokens/src/const/tokensList.json:135-167
Timestamp: 2025-07-18T08:07:55.497Z
Learning: Token lists for CoW Swap are maintained in a separate repository at https://github.com/cowprotocol/token-lists, not in the main cowswap repository. Issues related to missing token lists should be tracked in the token-lists repository.

Applied to files:

  • apps/cow-fi/const/cta.ts
📚 Learning: 2025-09-11T08:25:51.460Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 6234
File: libs/tokens/src/index.ts:1-4
Timestamp: 2025-09-11T08:25:51.460Z
Learning: In the cowprotocol/cowswap project, there is currently no SSR (Server-Side Rendering) support, so localStorage access at module import time does not cause SSR-related issues.

Applied to files:

  • apps/cow-fi/data/home/const.tsx
  • apps/cow-fi/app/(main)/cow-swap/page.tsx
📚 Learning: 2025-06-05T08:31:01.284Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 5782
File: apps/cow-fi/app/(learn)/learn/topics/page.tsx:1-1
Timestamp: 2025-06-05T08:31:01.284Z
Learning: Next.js App Router official documentation states that Client Components marked with 'use client' should NOT be declared as async functions, as this can lead to infinite loops or application hangs. The recommended pattern for async operations in Client Components is to use useEffect hooks. Server Components (without 'use client') can be async, which might be a source of confusion.

Applied to files:

  • apps/cow-fi/app/(main)/cow-swap/page.tsx
🧬 Code graph analysis (3)
apps/cow-fi/components/Layout/const.ts (1)
apps/cow-fi/const/cta.ts (1)
  • COW_SWAP_CTA (1-7)
apps/cow-fi/data/home/const.tsx (1)
apps/cow-fi/const/cta.ts (1)
  • COW_SWAP_CTA (1-7)
apps/cow-fi/app/(main)/cow-swap/page.tsx (1)
apps/cow-fi/const/cta.ts (1)
  • COW_SWAP_CTA (1-7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup
🔇 Additional comments (6)
apps/cow-fi/const/cta.ts (1)

1-7: LGTM! Excellent centralization of CTA configuration.

The constant is well-structured with all necessary fields (text, action, utmContent, href, deeplinkHref) and properly typed with as const for immutability and type inference. This establishes a single source of truth for CoW Swap CTA configuration.

apps/cow-fi/data/home/const.tsx (1)

12-12: LGTM! Proper integration of centralized CTA.

The import organization is clean, and the CoW Swap product card correctly uses COW_SWAP_CTA.deeplinkHref, COW_SWAP_CTA.text, and COW_SWAP_CTA.action. The page-specific linkUtmContent on line 53 remains distinct for tracking purposes, which is appropriate.

Also applies to: 15-15, 49-51

apps/cow-fi/components/Layout/const.ts (1)

6-7: LGTM! Proper use of centralized CTA configuration.

The navigation button correctly uses COW_SWAP_CTA.text and COW_SWAP_CTA.deeplinkHref, maintaining consistency with the centralized configuration.

Also applies to: 111-112

apps/cow-fi/app/(main)/cow-swap/page.tsx (3)

3-3: LGTM! Good TypeScript practice.

Adding the ReactNode return type improves type safety and code clarity.

Also applies to: 46-46


20-20: LGTM! Excellent integration of centralized CTA in hero section.

The hero CTA correctly uses COW_SWAP_CTA.href, COW_SWAP_CTA.utmContent, COW_SWAP_CTA.action, and COW_SWAP_CTA.text, properly centralizing all CTA configuration. The use of href (base URL) instead of deeplinkHref is appropriate for the landing page context.

Also applies to: 88-99


422-434: LGTM! Consistent CTA implementation in footer section.

The footer CTA mirrors the hero section's proper use of COW_SWAP_CTA properties, maintaining consistency across the page.

Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants