@metamask/bridge-status-controller 68.0.2 → 68.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [68.1.0]
11
+
12
+ ### Added
13
+
14
+ - Added optional `activeAbTests` context support so Unified SwapBridge events can include `active_ab_tests` independently of `ab_tests`. ([#8152](https://github.com/MetaMask/core/pull/8152))
15
+
16
+ ### Changed
17
+
18
+ - Bump `@metamask/bridge-controller` from `^69.0.1` to `^69.1.0` ([#8168](https://github.com/MetaMask/core/pull/8168))
19
+
10
20
  ## [68.0.2]
11
21
 
12
22
  ### Changed
@@ -1010,7 +1020,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
1020
 
1011
1021
  - Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
1012
1022
 
1013
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.2...HEAD
1023
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.1.0...HEAD
1024
+ [68.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.2...@metamask/bridge-status-controller@68.1.0
1014
1025
  [68.0.2]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.1...@metamask/bridge-status-controller@68.0.2
1015
1026
  [68.0.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.0...@metamask/bridge-status-controller@68.0.1
1016
1027
  [68.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@67.0.1...@metamask/bridge-status-controller@68.0.0
@@ -208,7 +208,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
208
208
  });
209
209
  });
210
210
  _BridgeStatusController_addTxToHistory.set(this, (startPollingForBridgeTxStatusArgs, actionId) => {
211
- const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
211
+ const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, activeAbTests, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
212
212
  // Determine the key for this history item:
213
213
  // - For pre-submission (non-batch EVM): use actionId
214
214
  // - For post-submission or other cases: use bridgeTxMeta.id
@@ -250,6 +250,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
250
250
  featureId: quoteResponse.featureId,
251
251
  location,
252
252
  ...(abTests && { abTests }),
253
+ ...(activeAbTests && { activeAbTests }),
253
254
  };
254
255
  this.update((state) => {
255
256
  // Use actionId as key for pre-submission, or txMeta.id for post-submission
@@ -714,10 +715,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
714
715
  * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
715
716
  * @param quotesReceivedContext - The context for the QuotesReceived event
716
717
  * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)
717
- * @param abTests - A/B test context to attribute events to specific experiments
718
+ * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
719
+ * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
718
720
  * @returns The transaction meta
719
721
  */
720
- this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = bridge_controller_1.MetaMetricsSwapsEventSource.MainView, abTests) => {
722
+ this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = bridge_controller_1.MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests) => {
721
723
  this.messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted,
722
724
  // If trade is submitted before all quotes are loaded, the QuotesReceived event is published
723
725
  // If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published
@@ -727,7 +729,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
727
729
  throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
728
730
  }
729
731
  const isHardwareAccount = (0, bridge_controller_1.isHardwareWallet)(selectedAccount);
730
- const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabledOnClient, isHardwareAccount, location, abTests);
732
+ const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabledOnClient, isHardwareAccount, location, abTests, activeAbTests);
731
733
  // Emit Submitted event after submit button is clicked
732
734
  !quoteResponse.featureId &&
733
735
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
@@ -850,6 +852,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
850
852
  approvalTxId,
851
853
  location,
852
854
  abTests,
855
+ activeAbTests,
853
856
  }, actionId);
854
857
  // Pass txFee when gasIncluded is true to use the quote's gas fees
855
858
  // instead of re-estimating (which would fail for max native token swaps)
@@ -891,6 +894,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
891
894
  approvalTxId,
892
895
  location,
893
896
  abTests,
897
+ activeAbTests,
894
898
  });
895
899
  }
896
900
  if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
@@ -915,16 +919,17 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
915
919
  * @param params.quoteResponse - Quote carrying intent data
916
920
  * @param params.accountAddress - The EOA submitting the order
917
921
  * @param params.location - The entry point from which the user initiated the swap or bridge
918
- * @param params.abTests - A/B test context to attribute events to specific experiments
922
+ * @param params.abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
923
+ * @param params.activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
919
924
  * @returns A lightweight TransactionMeta-like object for history linking
920
925
  */
921
926
  this.submitIntent = async (params) => {
922
- const { quoteResponse, accountAddress, location, abTests } = params;
927
+ const { quoteResponse, accountAddress, location, abTests, activeAbTests } = params;
923
928
  this.messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted);
924
929
  // Build pre-confirmation properties for error tracking parity with submitTx
925
930
  const account = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
926
931
  const isHardwareAccount = Boolean(account) && (0, bridge_controller_1.isHardwareWallet)(account);
927
- const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, false, isHardwareAccount, location, abTests);
932
+ const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, false, isHardwareAccount, location, abTests, activeAbTests);
928
933
  try {
929
934
  const intent = (0, transaction_1.getIntentFromQuote)(quoteResponse);
930
935
  // If backend provided an approval tx for this intent quote, submit it first (on-chain),
@@ -1024,6 +1029,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1024
1029
  startTime,
1025
1030
  location,
1026
1031
  abTests,
1032
+ activeAbTests,
1027
1033
  });
1028
1034
  // Start polling using the orderId key to route to intent manager
1029
1035
  __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
@@ -1050,11 +1056,15 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1050
1056
  * @param eventProperties - The properties for the event
1051
1057
  */
1052
1058
  _BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txMetaId, eventProperties) => {
1053
- const { ab_tests: eventAbTests } = eventProperties ?? {};
1059
+ // Legacy/new metrics fields are intentionally kept independent during migration.
1054
1060
  const historyAbTests = txMetaId
1055
1061
  ? this.state.txHistory?.[txMetaId]?.abTests
1056
1062
  : undefined;
1057
- const resolvedAbTests = eventAbTests ?? historyAbTests ?? undefined;
1063
+ const historyActiveAbTests = txMetaId
1064
+ ? this.state.txHistory?.[txMetaId]?.activeAbTests
1065
+ : undefined;
1066
+ const resolvedAbTests = eventProperties?.ab_tests ?? historyAbTests;
1067
+ const resolvedActiveAbTests = eventProperties?.active_ab_tests ?? historyActiveAbTests;
1058
1068
  const baseProperties = {
1059
1069
  action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
1060
1070
  location: eventProperties?.location ??
@@ -1065,6 +1075,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1065
1075
  Object.keys(resolvedAbTests).length > 0 && {
1066
1076
  ab_tests: resolvedAbTests,
1067
1077
  }),
1078
+ ...(resolvedActiveAbTests &&
1079
+ resolvedActiveAbTests.length > 0 && {
1080
+ active_ab_tests: resolvedActiveAbTests,
1081
+ }),
1068
1082
  };
1069
1083
  // This will publish events for PERPS dropped tx failures as well
1070
1084
  if (!txMetaId) {