Skip to content

Commit 7005dc7

Browse files
authored
chore(ramps): remove the rampsEnabled feature flag (#47459)
## **Description** Removes the fully rolled-out `rampsEnabled` remote feature flag. Its production default is already `{ enabled: true, minimumVersion: '13.48.0' }`, so this deletes the off-path rather than changing behavior for supported versions. This is a prerequisite for the `/buy` deep-link work in #46498, which currently has to thread the flag through the deep-link router. Landing the removal first keeps that PR free of rollout-gate plumbing. Changes: - Deletes `getIsRampsEnabled` from `ui/selectors/ramps-feature-flags.ts` and its selector tests. - Removes the `!isEnabled → open Portfolio` branch from `useRampsNavigation`. - Removes the analytics no-op guard from `useRampsAnalytics` and the flag check from `useRampsScreenViewed`. - Removes `rampsEnabled` from the e2e feature-flag registry. - Keeps `rampsServiceDisruption` as the service kill switch. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** 1. Run the extension. 2. Open the Buy flow from the wallet (e.g. the Buy button or token list) and verify it opens the in-app unified buy flow. 3. Advance through token selection and provider selection, then verify `ramps-*` events still fire in the Segment debugger. 4. Turn on the `rampsServiceDisruption` remote flag (or override it locally) and verify the service-disruption modal is still shown. 5. Open a `/buy` deep link from a dapp and verify its routing is unchanged by this PR (the routing change is in #46498). <!-- ## **Screenshots/Recordings** ### **Before** ### **After** --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes default Buy routing for any client that still had `rampsEnabled` off, and removes analytics silencing tied to that flag; `rampsServiceDisruption` behavior is unchanged. > > **Overview** > Removes the fully rolled-out **`rampsEnabled`** remote flag so the in-app ramps buy path is always used instead of treating “flag off” as “open Portfolio.” **`getIsRampsEnabled`** and its selector tests are deleted; **`rampsEnabled`** is dropped from the E2E feature-flag registry. **`rampsServiceDisruption`** stays as the kill switch. > > **`useRampsNavigation.goToBuy`** no longer short-circuits to **`openBuyCryptoInPdapp`** when the rollout flag was false—Portfolio migration, geo, disruption, and native routing behave as they did when the flag was on. **`useRampsAnalytics`** and **`useRampsScreenViewed`** no longer skip **`ramps-*`** events when the flag was off. > > Tests drop flag-gating cases and align Buy entry assertions with **`goToBuy`** (wallet overviews, asset page); ramps UI tests stub analytics where the background connection is not initialized. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6cc38b5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent b151b6f commit 7005dc7

14 files changed

Lines changed: 66 additions & 210 deletions

File tree

‎test/e2e/feature-flags/feature-flag-registry.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,17 +3936,6 @@ export const FEATURE_FLAG_REGISTRY: Record<string, FeatureFlagRegistryEntry> = {
39363936
type: FeatureFlagType.Remote,
39373937
},
39383938

3939-
rampsEnabled: {
3940-
inProd: true,
3941-
name: 'rampsEnabled',
3942-
productionDefault: {
3943-
enabled: true,
3944-
minimumVersion: '13.48.0',
3945-
},
3946-
status: FeatureFlagStatus.Active,
3947-
type: FeatureFlagType.Remote,
3948-
},
3949-
39503939
rampsServiceDisruption: {
39513940
inProd: true,
39523941
name: 'rampsServiceDisruption',

‎ui/components/app/wallet-overview/eth-overview.test.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ jest.mock('../../../hooks/ramps/useRamps/useRamps', () => ({
8888
},
8989
}));
9090

91+
const mockGoToBuy = jest.fn().mockResolvedValue('native');
92+
jest.mock('../../../hooks/ramps/useRampsNavigation/useRampsNavigation', () => ({
93+
__esModule: true,
94+
default: jest.fn(() => ({
95+
goToBuy: mockGoToBuy,
96+
})),
97+
}));
98+
9199
const mockGetIntlLocale = getIntlLocale;
92100

93101
let openTabSpy;
@@ -639,9 +647,7 @@ describe('EthOverview', () => {
639647
expect(buyButton).not.toBeDisabled();
640648

641649
fireEvent.click(buyButton);
642-
await waitFor(() =>
643-
expect(mockOpenBuyCryptoInPdapp).toHaveBeenCalledTimes(1),
644-
);
650+
await waitFor(() => expect(mockGoToBuy).toHaveBeenCalledTimes(1));
645651
});
646652
});
647653

‎ui/components/app/wallet-overview/non-evm-overview.test.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ jest.mock('../../../hooks/ramps/useRamps/useRamps', () => ({
8484
},
8585
}));
8686

87+
const mockGoToBuy = jest.fn().mockResolvedValue('native');
88+
jest.mock('../../../hooks/ramps/useRampsNavigation/useRampsNavigation', () => ({
89+
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
90+
// eslint-disable-next-line @typescript-eslint/naming-convention
91+
__esModule: true,
92+
default: jest.fn(() => ({
93+
goToBuy: mockGoToBuy,
94+
})),
95+
}));
96+
8797
const BUY_BUTTON = 'coin-overview-buy';
8898
const BTC_OVERVIEW_BRIDGE = 'coin-overview-bridge';
8999
const BTC_OVERVIEW_RECEIVE = 'coin-overview-receive';
@@ -323,7 +333,7 @@ describe('NonEvmOverview', () => {
323333
expect(buyButton).not.toBeDisabled();
324334
});
325335

326-
it('calls openBuyInPdapp when clicking on "Buy & Sell" button', async () => {
336+
it('calls the in-app buy flow when clicking on "Buy & Sell" button', async () => {
327337
const { queryByTestId } = renderWithProvider(
328338
<NonEvmOverview />,
329339
getStore(),
@@ -332,9 +342,7 @@ describe('NonEvmOverview', () => {
332342
const buyButton = queryByTestId(BUY_BUTTON);
333343
expect(buyButton).toBeInTheDocument();
334344
fireEvent.click(buyButton as HTMLElement);
335-
await waitFor(() =>
336-
expect(mockOpenBuyCryptoInPdapp).toHaveBeenCalledTimes(1),
337-
);
345+
await waitFor(() => expect(mockGoToBuy).toHaveBeenCalledTimes(1));
338346
});
339347

340348
it('sends an event when clicking the Buy button', async () => {

‎ui/hooks/ramps/useRampsAnalytics.test.tsx‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ jest.mock('../../store/controller-actions/ramps-controller', () => ({
2828
setRampsUserRegion: jest.fn(),
2929
}));
3030

31-
function renderRampsAnalytics(rampsEnabled = true) {
32-
const store = createRampsMockStore({
33-
remoteFeatureFlags: { rampsEnabled },
34-
});
31+
function renderRampsAnalytics() {
32+
const store = createRampsMockStore();
3533
return renderHook(() => useRampsAnalytics(), {
3634
wrapper: createRampsTestWrapper(store),
3735
});
@@ -84,16 +82,4 @@ describe('useRampsAnalytics', () => {
8482
region: 'us-ca',
8583
});
8684
});
87-
88-
it('does not track when rampsEnabled is off', () => {
89-
const { result } = renderRampsAnalytics(false);
90-
91-
result.current.trackScreenViewed('Amount Input');
92-
result.current.trackProviderSelected({
93-
provider: 'Transak',
94-
location: 'Provider Selection',
95-
});
96-
97-
expect(mockTrackEvent).not.toHaveBeenCalled();
98-
});
9985
});

‎ui/hooks/ramps/useRampsAnalytics.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
/* eslint-disable @typescript-eslint/naming-convention */
88
import { useCallback, useEffect, useRef } from 'react';
9-
import { useSelector } from 'react-redux';
109
import {
1110
MetaMetricsEventCategory,
1211
MetaMetricsEventName,
@@ -15,7 +14,6 @@ import {
1514
RAMPS_RAMP_ROUTING,
1615
RAMPS_RAMP_TYPE,
1716
} from '../../../shared/lib/ramps/analytics';
18-
import { getIsRampsEnabled } from '../../selectors/ramps-feature-flags';
1917
import { useAnalytics } from '../useAnalytics';
2018
import { useRampsUserRegion } from './useRampsUserRegion';
2119

@@ -38,14 +36,9 @@ export type RampsProviderSelectedArgs = {
3836
* Analytics for the in-app ramps buy flow. Wraps `useAnalytics` and injects the
3937
* shared context (region, currency source, ramp type) every `ramps-*` event
4038
* needs, so call sites only pass event-specific properties.
41-
*
42-
* All tracking is a no-op when the `rampsEnabled` flag is off — the flow is
43-
* already unreachable in that case, this is belt-and-suspenders for the AC
44-
* "no events fire when the flag is off".
4539
*/
4640
export function useRampsAnalytics() {
4741
const { trackEvent, createEventBuilder } = useAnalytics();
48-
const isRampsEnabled = useSelector(getIsRampsEnabled);
4942
const { userRegion } = useRampsUserRegion();
5043

5144
// Region/currency load asynchronously. Read them through refs so the track
@@ -62,9 +55,6 @@ export function useRampsAnalytics() {
6255

6356
const track = useCallback(
6457
(name: MetaMetricsEventName, properties: Record<string, unknown>) => {
65-
if (!isRampsEnabled) {
66-
return;
67-
}
6858
trackEvent(
6959
createEventBuilder(name)
7060
.addCategory(MetaMetricsEventCategory.Ramps)
@@ -76,7 +66,7 @@ export function useRampsAnalytics() {
7666
.build(),
7767
);
7868
},
79-
[createEventBuilder, isRampsEnabled, trackEvent],
69+
[createEventBuilder, trackEvent],
8070
);
8171

8272
const trackScreenViewed = useCallback(

‎ui/hooks/ramps/useRampsNavigation/useRampsNavigation.test.tsx‎

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const connectedPortfolioHistory = {
7979

8080
type MetamaskOverrides = Partial<{
8181
remoteFeatureFlags: {
82-
rampsEnabled: boolean;
8382
rampsServiceDisruption: boolean;
8483
};
8584
userRegion: UserRegion | null;
@@ -96,7 +95,7 @@ type MetamaskOverrides = Partial<{
9695
const buildState = (over: MetamaskOverrides = {}) => ({
9796
metamask: {
9897
...mockNetworkState({ chainId: CHAIN_IDS.MAINNET }),
99-
remoteFeatureFlags: { rampsEnabled: true, rampsServiceDisruption: false },
98+
remoteFeatureFlags: { rampsServiceDisruption: false },
10099
userRegion: region,
101100
countries: { ...loaded, data: [region.country] },
102101
providers: {
@@ -159,23 +158,7 @@ beforeEach(() => {
159158
});
160159

161160
describe('useRampsNavigation goToBuy', () => {
162-
it('flag off → opens Portfolio (no modal, no geolocation lookup)', async () => {
163-
const { result, getModalName } = run(
164-
buildState({
165-
remoteFeatureFlags: {
166-
rampsEnabled: false,
167-
rampsServiceDisruption: false,
168-
},
169-
}),
170-
);
171-
const destination = await goToBuy(result);
172-
expect(destination).toBe('portfolio');
173-
expect(openTab).toHaveBeenCalled();
174-
expect(mockGetGeolocation).not.toHaveBeenCalled();
175-
expect(getModalName()).toBeNull();
176-
});
177-
178-
it('flag on + connected to Portfolio + no orders → opens Portfolio once', async () => {
161+
it('connected to Portfolio + no orders → opens Portfolio once', async () => {
179162
const { result, getModalName } = run(
180163
buildState({
181164
subjects: {
@@ -287,7 +270,7 @@ describe('useRampsNavigation goToBuy', () => {
287270
`);
288271
});
289272

290-
it('flag on + connected to Portfolio + migration attempted → opens native buy', async () => {
273+
it('connected to Portfolio + migration attempted → opens native buy', async () => {
291274
mockHasAttemptedPortfolioBuyMigration.mockResolvedValue(true);
292275
const { result } = run(
293276
buildState({
@@ -317,7 +300,7 @@ describe('useRampsNavigation goToBuy', () => {
317300
`);
318301
});
319302

320-
it('flag on + connected to Portfolio + synced orders → opens native buy', async () => {
303+
it('connected to Portfolio + synced orders → opens native buy', async () => {
321304
const { result } = run(
322305
buildState({
323306
permissionHistory: connectedPortfolioHistory,
@@ -347,7 +330,7 @@ describe('useRampsNavigation goToBuy', () => {
347330
`);
348331
});
349332

350-
it('flag on + never connected to Portfolio → in-app token selection', async () => {
333+
it('never connected to Portfolio → in-app token selection', async () => {
351334
const { result, getModalName } = run(buildState());
352335
const opened = await goToBuy(result);
353336
expect(opened).toBe('native');
@@ -377,7 +360,6 @@ describe('useRampsNavigation goToBuy', () => {
377360
const { result, getModalName } = run(
378361
buildState({
379362
remoteFeatureFlags: {
380-
rampsEnabled: true,
381363
rampsServiceDisruption: true,
382364
},
383365
}),

‎ui/hooks/ramps/useRampsNavigation/useRampsNavigation.ts‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
} from '../../../helpers/constants/routes';
1717
import { showModal } from '../../../store/actions';
1818
import { submitRequestToBackground } from '../../../store/background-connection';
19-
import {
20-
getIsRampsEnabled,
21-
getIsRampsServiceDisruptionActive,
22-
} from '../../../selectors/ramps-feature-flags';
19+
import { getIsRampsServiceDisruptionActive } from '../../../selectors/ramps-feature-flags';
2320
import { getIsRampRegionUnsupported } from '../../../selectors/ramps';
2421
import {
2522
selectRampsOrders,
@@ -121,8 +118,6 @@ async function preselectToken(assetId: CaipAssetType): Promise<boolean> {
121118
/**
122119
* Provides the `goToBuy` navigation gate for the Ramps buy entry point.
123120
*
124-
* When the flag is off, everyone is redirected to Portfolio.
125-
*
126121
* @returns An object with `goToBuy`, an async callback taking an optional
127122
* {@link RampIntent}. It runs the gate and either shows a blocking modal or
128123
* opens the buy destination. Resolves to the destination when it proceeded and
@@ -133,7 +128,6 @@ export default function useRampsNavigation() {
133128
const navigate = useNavigate();
134129
const { openBuyCryptoInPdapp } = useRamps();
135130

136-
const isEnabled = useSelector(getIsRampsEnabled);
137131
const isDisruption = useSelector(getIsRampsServiceDisruptionActive);
138132
const isRegionUnsupported = useSelector(getIsRampRegionUnsupported);
139133
const providers = useSelector(selectProviders);
@@ -146,14 +140,6 @@ export default function useRampsNavigation() {
146140

147141
const goToBuy = useCallback(
148142
async (intent?: RampIntent): Promise<RampsNavigationResult> => {
149-
// Rollout gate off → unchanged Portfolio behavior.
150-
if (!isEnabled) {
151-
// `getBuyURI` accepts any hex chain id; the narrower `ChainId` param is
152-
// just an over-tight annotation.
153-
await openBuyCryptoInPdapp(intent?.chainId as ChainId | CaipChainId);
154-
return 'portfolio';
155-
}
156-
157143
// Returning Portfolio users get one migration visit before native Buy.
158144
// This precedes native eligibility gates because Portfolio performs the
159145
// migration from its app shell, independently of native Buy support.
@@ -258,7 +244,6 @@ export default function useRampsNavigation() {
258244
return 'native';
259245
},
260246
[
261-
isEnabled,
262247
isDisruption,
263248
isRegionUnsupported,
264249
providers,
Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import React from 'react';
2-
import { Provider } from 'react-redux';
3-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4-
import { act, renderHook } from '@testing-library/react';
1+
import { renderHook } from '@testing-library/react';
52
import { MetaMetricsEventName } from '../../../shared/constants/metametrics';
63
import { useRampsScreenViewed } from './useRampsScreenViewed';
74
import { createRampsMockStore, createRampsTestWrapper } from './test-utils';
@@ -27,9 +24,7 @@ jest.mock('./useRampsUserRegion', () => ({
2724
}));
2825

2926
function renderScreenViewed(location: string, waitForRegion?: boolean) {
30-
const store = createRampsMockStore({
31-
remoteFeatureFlags: { rampsEnabled: true },
32-
});
27+
const store = createRampsMockStore();
3328
return renderHook(() => useRampsScreenViewed(location, { waitForRegion }), {
3429
wrapper: createRampsTestWrapper(store),
3530
});
@@ -77,57 +72,4 @@ describe('useRampsScreenViewed', () => {
7772
expect(built.properties.location).toBe('Order Details');
7873
expect(built.properties.region).toBe('');
7974
});
80-
81-
it('fires once after rampsEnabled becomes true on the same mount', () => {
82-
mockUserRegion = { regionCode: 'us-ca', country: { currency: 'USD' } };
83-
const setRampsEnabledRef: {
84-
current: (enabled: boolean) => void;
85-
} = { current: () => undefined };
86-
const queryClient = new QueryClient({
87-
defaultOptions: { queries: { retry: false } },
88-
});
89-
90-
// eslint-disable-next-line @typescript-eslint/naming-convention -- test-only component
91-
function RampsEnabledTestWrapper({
92-
children,
93-
}: {
94-
children: React.ReactNode;
95-
}) {
96-
const [rampsEnabled, setEnabled] = React.useState(false);
97-
setRampsEnabledRef.current = setEnabled;
98-
const store = React.useMemo(
99-
() =>
100-
createRampsMockStore({
101-
remoteFeatureFlags: { rampsEnabled },
102-
}),
103-
[rampsEnabled],
104-
);
105-
return (
106-
<Provider store={store}>
107-
<QueryClientProvider client={queryClient}>
108-
{children}
109-
</QueryClientProvider>
110-
</Provider>
111-
);
112-
}
113-
114-
const { rerender } = renderHook(
115-
() => useRampsScreenViewed('Token Selection'),
116-
{ wrapper: RampsEnabledTestWrapper },
117-
);
118-
119-
expect(mockTrackEvent).not.toHaveBeenCalled();
120-
121-
// Wrap the wrapper's state update so React doesn't warn about an update
122-
// outside act().
123-
act(() => {
124-
setRampsEnabledRef.current(true);
125-
});
126-
rerender();
127-
128-
expect(mockTrackEvent).toHaveBeenCalledTimes(1);
129-
expect(mockTrackEvent.mock.calls[0][0].properties.location).toBe(
130-
'Token Selection',
131-
);
132-
});
13375
});

‎ui/hooks/ramps/useRampsScreenViewed.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { useEffect, useRef } from 'react';
2-
import { useSelector } from 'react-redux';
3-
import { getIsRampsEnabled } from '../../selectors/ramps-feature-flags';
42
import { useRampsAnalytics } from './useRampsAnalytics';
53
import { useRampsUserRegion } from './useRampsUserRegion';
64

@@ -25,7 +23,6 @@ export function useRampsScreenViewed(
2523
{ waitForRegion = true }: { waitForRegion?: boolean } = {},
2624
): void {
2725
const { trackScreenViewed } = useRampsAnalytics();
28-
const isRampsEnabled = useSelector(getIsRampsEnabled);
2926
const { userRegion } = useRampsUserRegion();
3027
const isReady = waitForRegion ? userRegion !== null : true;
3128

@@ -40,10 +37,10 @@ export function useRampsScreenViewed(
4037
const hasTrackedRef = useRef(false);
4138

4239
useEffect(() => {
43-
if (!isReady || !isRampsEnabled || hasTrackedRef.current) {
40+
if (!isReady || hasTrackedRef.current) {
4441
return;
4542
}
4643
hasTrackedRef.current = true;
4744
trackScreenViewed(locationRef.current);
48-
}, [isReady, isRampsEnabled, trackScreenViewed]);
45+
}, [isReady, trackScreenViewed]);
4946
}

0 commit comments

Comments
 (0)