Skip to content

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

Open
micaelae wants to merge 16 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 16 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

Medium Risk
Breaking changes to fetchQuotes and required feature_id on clients; analytics and metrics behavior shifts (including which features emit Completed/Failed).

Overview
This PR standardizes Unified SwapBridge analytics and tightens how callers identify product surfaces.

FeatureId moves to bridge-controller types with Segment-style snake_case values (quick_buy_follow_trading, quick_buy_token_details, dapp_swap, batch_sell, unified_swap_bridge, perps, etc.). feature_id is required on client analytics context and is attached across quote polling, SSE streams, and trackUnifiedSwapBridgeEvent payloads (with defaults from the active quote where applicable).

Breaking API: BridgeController:fetchQuotes now requires a FeatureId argument (no longer optional/null), and quote/update flows thread that id into fetch and streaming. Integrators must pass feature_id when updating quote params and fix any fetchQuotes call sites.

bridge-status-controller pre-generates batch_id for batch sell (via generateBatchId), passes it into transaction batches and Submitted / Completed / Failed events. Post-submit metrics are gated by ALLOWED_FEATURE_IDS_FOR_STATUS_EVENTS: quick buy and batch sell now emit lifecycle events; perps still skips most status events but StatusValidationFailed remains. Optional batch_id is added to relevant Segment-style event types.

Reviewed by Cursor Bugbot for commit f5ff6e5. 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