Skip to content

fix: add mixpanel tracking for yield.xyz provider (#12013)#12086

Merged
gomesalexandre merged 5 commits intodevelopfrom
fix/issue-12013
Mar 4, 2026
Merged

fix: add mixpanel tracking for yield.xyz provider (#12013)#12086
gomesalexandre merged 5 commits intodevelopfrom
fix/issue-12013

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Mar 3, 2026

Description

This PR adds Mixpanel tracking events for the yield.xyz provider to ensure proper analytics coverage for yield deposits, withdrawals, and claims.

Changes

  1. Added new MixPanelEvents in src/lib/mixpanel/types.ts:

    • YieldEnterConfirm - Tracked when a yield deposit is confirmed
    • YieldEnterSuccess - Tracked when a yield deposit completes successfully
    • YieldExitConfirm - Tracked when a yield withdrawal is confirmed
    • YieldExitSuccess - Tracked when a yield withdrawal completes successfully
    • YieldClaimConfirm - Tracked when a yield claim is confirmed
    • YieldClaimSuccess - Tracked when a yield claim completes successfully
  2. Added trackYieldEvent helper in src/lib/mixpanel/helpers.ts:

    • Tracks yield events with provider ID, yield type, yield ID, asset symbol, network, amount, and action type
  3. Integrated tracking in useYieldTransactionFlow in src/pages/Yields/hooks/useYieldTransactionFlow.ts:

    • Tracks confirm events when the first non-approval transaction is submitted
    • Tracks success events when the yield flow completes successfully

Event Data

Each yield event includes:

  • provider: The yield provider ID (e.g., 'yield-xyz', 'lido', etc.)
  • yieldType: The yield mechanics type (e.g., 'staking', 'lending', 'vault')
  • yieldId: The unique yield ID
  • asset: The asset symbol
  • network: The yield network
  • amountCryptoPrecision: The amount in crypto precision
  • action: The action type ('enter', 'exit', or 'manage')

Closes #12013

Summary by CodeRabbit

  • Chores
    • Added analytics tracking for yield flows: new confirm and success events for yield enter, exit, and claim actions.
    • Tracking now includes asset and transaction details to better capture flow confirmations, completions, and edge-case outcomes.

QA Report ✅

Tested: 2026-03-03
Status: PASSED (Code Review + CI)

QABot Report: https://qabot-kappa.vercel.app/runs/56dc244a-4989-42b5-ba9d-a15e09bf5bb0

@NeOMakinG NeOMakinG requested a review from a team as a code owner March 3, 2026 14:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

Adds Mixpanel yield tracking: six new MixPanelEvent members, a TrackYieldEventProps type and trackYieldEvent helper, and integrates tracking calls into useYieldTransactionFlow with a new assetSymbol parameter to emit confirm and success events at key flow points.

Changes

Cohort / File(s) Summary
Mixpanel types
src/lib/mixpanel/types.ts
Added six new enum members for yield events: YieldEnterConfirm, YieldEnterSuccess, YieldExitConfirm, YieldExitSuccess, YieldClaimConfirm, YieldClaimSuccess.
Mixpanel helpers
src/lib/mixpanel/helpers.ts
Added TrackYieldEventProps type and trackYieldEvent(event: MixPanelEvent, properties: TrackYieldEventProps) helper that builds event payloads and calls mixpanel.track if available.
Yield transaction hook
src/pages/Yields/hooks/useYieldTransactionFlow.ts
Integrated tracking: added assetSymbol to UseYieldTransactionFlowProps, emit confirm events on first non-approval tx and success events on transaction completion and several completed-flow edge cases. Imported and used new Mixpanel types/helpers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped into code with a twitch and a wink,
I noted each confirm, each success in a blink,
Asset symbol and flow, all logged with delight,
Mixpanel listens as data takes flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Mixpanel tracking for the yield.xyz provider, which is the core objective of this pull request.
Linked Issues check ✅ Passed The implementation addresses all requirements from issue #12013: adds Mixpanel tracking for yield.xyz provider with tracking events for deposits, withdrawals, and claims, capturing provider information in event payloads.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing Mixpanel tracking for yield.xyz: enum extensions, helper function, and integration with the yield transaction flow hook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-12013

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.

@NeOMakinG
Copy link
Collaborator Author

🧪 QA Report

CI Status: ❌ FAILING

Failed step: Lint (Static checks)

Files Changed

  • src/lib/mixpanel/helpers.ts
  • src/lib/mixpanel/types.ts
  • src/pages/Yields/hooks/useYieldTransactionFlow.ts

Action Required

⚠️ Please check the CI logs for lint errors and fix them before QA can proceed.

Once CI Passes

Testing checklist:

  • Yield.xyz provider transactions should trigger Mixpanel events
  • Verify event payload contains correct provider info

@NeOMakinG
Copy link
Collaborator Author

QA Report ✅

Test Environment

  • Date: 2026-03-03
  • Tester: OpenClaw QA Agent

Feature Description

Issue #12013: Add Mixpanel tracking events for the yield.xyz provider to ensure proper analytics coverage for yield deposits, withdrawals, and claims.

Code Review ✅

1. New MixPanelEvents in types.ts:

  • YieldEnterConfirm - Tracked when a yield deposit is confirmed
  • YieldEnterSuccess - Tracked when a yield deposit completes successfully
  • YieldExitConfirm - Tracked when a yield withdrawal is confirmed
  • YieldExitSuccess - Tracked when a yield withdrawal completes successfully
  • YieldClaimConfirm - Tracked when a yield claim is confirmed
  • YieldClaimSuccess - Tracked when a yield claim completes successfully

2. New trackYieldEvent helper in helpers.ts:

export const trackYieldEvent = (event: MixPanelEvent, properties: TrackYieldEventProps) => {
  // Tracks yield events with provider, yieldType, yieldId, asset, network, amount, action
}

3. Integration in useYieldTransactionFlow.ts:

  • Tracks confirm events when the first non-approval transaction is submitted
  • Identifies the correct event based on action type (enter/exit/manage)
  • Includes all relevant context: provider, yieldType, yieldId, assetSymbol, network, amountCryptoPrecision, action

Testing Limitations

Cannot verify Mixpanel events without access to the Mixpanel dashboard. Code implementation follows existing patterns in the codebase.

Verdict

Code implementation is correct - Follows existing Mixpanel tracking patterns and includes comprehensive event data for yield analytics.


Automated QA by OpenClaw

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/mixpanel/helpers.ts`:
- Around line 90-104: trackYieldEvent currently calls getMixPanel() and
mixpanel.track() without protection, so any thrown error bubbles up; wrap the
body of trackYieldEvent (calls to getMixPanel() and mixpanel.track(event,
eventData)) in a try/catch, swallow any exceptions so they don't affect
transaction UX, and log the error inside the catch (use the project's logger if
available, otherwise console.error) with context (e.g., "trackYieldEvent failed"
and the error) while returning early on failure.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7bf30cf and 8a54ea1.

📒 Files selected for processing (3)
  • src/lib/mixpanel/helpers.ts
  • src/lib/mixpanel/types.ts
  • src/pages/Yields/hooks/useYieldTransactionFlow.ts

@NeOMakinG
Copy link
Collaborator Author

🤖 QABot Report (2026-03-03)

Testing completed. See dashboard for full results.

📊 Dashboard: skills/qabot/reports/2026-03-03/dashboard.md

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

In qabot we trust

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/Yields/hooks/useYieldTransactionFlow.ts`:
- Around line 940-958: The current success analytics fire when
transactions.length === 0 which can produce false positives; update the guard in
useYieldTransactionFlow so that you only emit the success mixpanel event (via
trackYieldEvent and successEvent) when the action's status is actually
YieldActionStatus.Success (in addition to transactions.length === 0) — locate
the block that references transactions, action, YieldActionStatus, yieldItem and
trackYieldEvent and add an explicit status check before computing successEvent
and calling trackYieldEvent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f313f28-63f5-49dd-a7b7-f7423581e631

📥 Commits

Reviewing files that changed from the base of the PR and between 8a54ea1 and cce6013.

📒 Files selected for processing (1)
  • src/pages/Yields/hooks/useYieldTransactionFlow.ts

@gomesalexandre gomesalexandre enabled auto-merge (squash) March 4, 2026 18:43
@gomesalexandre gomesalexandre merged commit 375b040 into develop Mar 4, 2026
4 checks passed
@gomesalexandre gomesalexandre deleted the fix/issue-12013 branch March 4, 2026 19:04
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.

Mixpanel Tracking for Yield XYZ

2 participants