Skip to content

Commit

Permalink
chore: pass the Extension Version to the Uninstall URL (#28935)
Browse files Browse the repository at this point in the history
## **Description**

Update the uninstall URL to include an application version for all
users, even those with MetaMetrics disabled.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28935?quickstart=1)

## **Related issues**

Fixes: #28414

## **Manual testing steps**

I do not know how to test this manually.
1.
2.
3. 

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.

Co-authored-by: Norbert Elter <[email protected]>
  • Loading branch information
dbrans and itsyoboieltr authored Dec 11, 2024
1 parent 2bd3db8 commit 17fe0d2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
40 changes: 37 additions & 3 deletions app/scripts/controllers/metametrics-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1669,12 +1669,12 @@ describe('MetaMetricsController', function () {
},
ShowNativeTokenAsMainBalance: true,
allNfts: {},
names: {
ethereumAddress: {},
},
participateInMetaMetrics: true,
dataCollectionForMarketing: false,
preferences: { privacyMode: true, tokenNetworkFilter: [] },
names: {
ethereumAddress: {},
},
securityAlertsEnabled: true,
security_providers: ['blockaid'],
currentCurrency: 'usd',
Expand Down Expand Up @@ -1842,6 +1842,40 @@ describe('MetaMetricsController', function () {
);
});
});
describe('updateExtensionUninstallUrl', function () {
it('should include extension version in uninstall URL regardless of MetaMetrics participation', async function () {
await withController(({ controller }) => {
const setUninstallURLSpy = jest.spyOn(
MOCK_EXTENSION.runtime,
'setUninstallURL',
);

// Test with MetaMetrics disabled
controller.updateExtensionUninstallUrl(false, 'test-id');
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.stringContaining(`av=${VERSION}`),
);
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.not.stringContaining('mmi='),
);
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.not.stringContaining('env='),
);

// Test with MetaMetrics enabled
controller.updateExtensionUninstallUrl(true, 'test-id');
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.stringContaining(`av=${VERSION}`),
);
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.stringContaining('mmi='),
);
expect(setUninstallURLSpy).toHaveBeenCalledWith(
expect.stringContaining('env='),
);
});
});
});
});

type WithControllerOptions = {
Expand Down
7 changes: 4 additions & 3 deletions app/scripts/controllers/metametrics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,14 @@ export default class MetaMetricsController extends BaseController<
const query: {
mmi?: string;
env?: string;
av?: string;
} = {};
av: string;
} = {
av: this.version,
};
if (participateInMetaMetrics) {
// We only want to track these things if a user opted into metrics.
query.mmi = Buffer.from(metaMetricsId).toString('base64');
query.env = this.#environment;
query.av = this.version;
}
const queryString = new URLSearchParams(query);

Expand Down

0 comments on commit 17fe0d2

Please sign in to comment.