Skip to content

feat: add feature_id and batch_id to Unified SwapBridge events#8964

Open
micaelae wants to merge 15 commits into
mainfrom
swaps4468-feature-id-batch-id
Open

feat: add feature_id and batch_id to Unified SwapBridge events#8964
micaelae wants to merge 15 commits into
mainfrom
swaps4468-feature-id-batch-id

Conversation

@micaelae
Copy link
Copy Markdown
Member

@micaelae micaelae commented Jun 2, 2026

Explanation

Metrics changes

  • Add new Unified SwapBridge event properties
    • feature_id (all events)
    • batch_sell (Submitted, Completed, Failed for BatchSell)
  • Publish Submitted/Completed/Failed events for quickBuy and batchSell features

fetchQuotes changes

  • Make featureId a required param of fetchQuotes to identify callers
  • Update transaction-pay-controller's fetchQuotes call

batch-sell submission changes

  • Pre-generate batchId and append it to batch-sell events
  • Pass batchId to transaction-controller to propagate it to the tx meta

Client-side updates

  • run yarn lint:tsc to see where feature_id needs to be added, then fix the type errors
  • search for fetchQuotes usages and add FeatureId

References

Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4468

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

High Risk
Breaking API changes (fetchQuotes signature, mandatory feature_id on events) and broad analytics/transaction-submission behavior changes across bridge and status controllers; clients must adopt new enums and call patterns.

Overview
This PR standardizes Unified SwapBridge analytics around a required feature_id (Segment-style snake_case values) and extends batch tracking for Batch Sell flows.

Bridge controller: FeatureId moves to public types with new values (quick_buy_follow_trading, quick_buy_token_details, batch_sell, unified_swap_bridge, etc.); old camelCase IDs are renamed. feature_id is required on client event context and on quote fetch/stream paths (fetchQuotes, SSE). BridgeController:fetchQuotes now requires a FeatureId argument (breaking). Quotes from streams carry featureId; metrics types gain optional batch_id on submission/completion events.

Bridge status controller: Replaces the old “skip all metrics when featureId is set (e.g. perps)” rule with an allowlist so Submitted / Completed / Failed / PollingStatusUpdated fire for unified swap, quick buy, and batch sell (perps still skips most status events except validation). Batch sell pre-generates batchId via generateBatchId, passes it into transaction batches, and attaches batch_id on Submitted/Completed/Failed. Quick-buy failure tracking is added where perps remains silent.

Reviewed by Cursor Bugbot for commit 5c9a8ea. Bugbot is set up for automated code reviews on this repo. Configure here.

@micaelae micaelae force-pushed the swaps4468-feature-id-batch-id branch from 336313d to 4ddac53 Compare June 3, 2026 17:39
@micaelae micaelae marked this pull request as ready for review June 3, 2026 18:17
@micaelae micaelae requested review from a team as code owners June 3, 2026 18:17
@micaelae micaelae temporarily deployed to default-branch June 3, 2026 18:17 — with GitHub Actions Inactive
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 51dc34e. Configure here.

Comment thread packages/bridge-controller/src/bridge-controller.test.ts Outdated
@micaelae micaelae requested a review from a team as a code owner June 3, 2026 22:59
@micaelae micaelae enabled auto-merge June 3, 2026 23:30
@micaelae micaelae changed the title feat: publish Unified events with feature_id feat: add feature_id and batch_id to Unified SwapBridge events Jun 3, 2026
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.

1 participant