Skip to content

feat(wallet)!: wire GeolocationController into default initialization - #11058

Merged
gauthierpetetin merged 3 commits into
mainfrom
feat/wallet-geolocation-controller
Oct 26, 2026
Merged

gauthierpetetin merged 3 commits into
mainfrom
feat/wallet-geolocation-controller

Conversation

@gauthierpetetin

@gauthierpetetin gauthierpetetin commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

AnalyticsController and SubscriptionController already call GeolocationController:getGeolocationData through the wallet root messenger, but hosts still had to construct and register GeolocationController (and GeolocationApiService) themselves. That left a race when hosts called wallet.init() before registering geolocation on a later init path.

This PR adds GeolocationController and GeolocationApiService to the default @metamask/wallet initialization configurations, matching other migrated controllers. Optional instanceOptions.geolocationApiService accepts env, fetch, ttlMs, and policyOptions (defaults to production and globalThis.fetch). GeolocationController delegates GeolocationApiService:fetchGeolocationData. Hosts that enable Analytics geolocation enrichment no longer need to register GeolocationController themselves.

References

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
    • Hosts that already register GeolocationController or GeolocationApiService on the wallet root messenger must remove them before upgrading, or messenger registration will collide.

Note

Medium Risk
Breaking messenger registration change for existing hosts; default init also enables outbound geolocation API fetches when those code paths run.

Overview
Breaking: @metamask/wallet now constructs GeolocationController and GeolocationApiService as part of default initialization, so analytics/subscription flows can call GeolocationController:getGeolocationData without hosts wiring geolocation first.

Hosts may tune the API client via optional instanceOptions.geolocationApiService (env, fetch, ttlMs, policyOptions; defaults are production + globalThis.fetch). The controller’s messenger delegates GeolocationApiService:fetchGeolocationData. Documentation for analyticsController.isGeolocationEnabled now states wallet supplies geolocation instead of requiring host registration.

Upgrade note: remove any existing GeolocationController / GeolocationApiService registrations on the wallet root messenger before upgrading, or initialization will collide.

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

Co-authored-by: Cursor <cursoragent@cursor.com>
gauthierpetetin and others added 2 commits October 26, 2026 06:23
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review found no blocking issues in initialization, messenger wiring, or migration guidance; tests were inspected but not executed.

No open issues 🎉

What changed in this PR

Adds wallet-owned geolocation initialization so Analytics and Subscription controllers no longer depend on hosts registering geolocation separately, addressing the initialization race.

Changes:

  • Registers GeolocationController and GeolocationApiService by default, with messenger delegation and optional service settings.
  • Adds tests for registration, initialization, environment selection, and geolocation requests.
  • Updates dependencies, TypeScript references, and breaking-change guidance requiring hosts to remove duplicate registrations.
File Description
yarn.lock Records the wallet’s geolocation dependency.
packages/​wallet/​tsconfig.lint.json Adds the geolocation lint project reference.
packages/​wallet/​tsconfig.json Adds the geolocation development project reference.
packages/​wallet/​tsconfig.build.json Adds the geolocation build project reference.
packages/​wallet/​src/​types.ts Exposes optional geolocation service settings.
packages/​wallet/​src/​initialization/​instances/​index.ts Exports both default geolocation configurations.
packages/​wallet/​src/​initialization/​instances/​geolocation-controller/​geolocation-controller.ts Initializes the controller and delegates API access.
packages/​wallet/​src/​initialization/​instances/​geolocation-controller/​geolocation-controller.test.ts Tests registration, state, delegation, and service integration.
packages/​wallet/​src/​initialization/​instances/​geolocation-api-service/​types.ts Defines optional environment, fetch, cache, and policy settings.
packages/​wallet/​src/​initialization/​instances/​geolocation-api-service/​geolocation-api-service.ts Initializes the service with configurable options.
packages/​wallet/​src/​initialization/​instances/​geolocation-api-service/​geolocation-api-service.test.ts Tests registration, construction, and environment selection.
packages/​wallet/​src/​initialization/​instances/​analytics-controller/​types.ts Updates documentation to describe wallet-owned geolocation.
packages/​wallet/​package.json Declares the geolocation package dependency.
packages/​wallet/​CHANGELOG.md Documents default initialization and migration requirements.

Review effort: Balanced

@gauthierpetetin
gauthierpetetin added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 57f023d Oct 26, 2026
51 checks passed
@gauthierpetetin
gauthierpetetin deleted the feat/wallet-geolocation-controller branch October 26, 2026 09:24
@gauthierpetetin gauthierpetetin mentioned this pull request Oct 26, 2026
1 of 4 tasks
gaohan1994 pushed a commit to gaohan1994/core that referenced this pull request Oct 27, 2026
## Explanation

Major release of `@metamask/wallet` (`19.1.0` → `20.0.0`).

- **Breaking:** Add `GeolocationController` and `GeolocationApiService`
to the default initialization configurations. Optional
`instanceOptions.geolocationApiService` accepts `env`, `fetch`, `ttlMs`,
and `policyOptions` (defaults to production and `globalThis.fetch`).
Hosts that already register these on the wallet root messenger must
remove them before upgrading, or messenger registration will collide.
Hosts no longer need to register `GeolocationController` when
`AnalyticsController` `isGeolocationEnabled` is `true`.
([MetaMask#11058](MetaMask#11058))
- Add `@metamask/geolocation-controller` as a dependency.
([MetaMask#11058](MetaMask#11058))

Minor release of `@metamask/analytics-controller` (`4.0.0` → `4.1.0`).

- Add support for Node.js 26.
([MetaMask#10981](MetaMask#10981))
- Accept partial initial `state` as long as `analyticsId` is provided.
([MetaMask#10901](MetaMask#10901))
- Bump `@metamask/base-controller` from `^10.0.0` to `^10.1.0`.
([MetaMask#10864](MetaMask#10864))

Dependent packages (`@metamask/marketing-consent-controller`,
`@metamask/network-controller`,
`@metamask/notification-services-controller`,
`@metamask/seedless-onboarding-controller`, `@metamask/wallet`) now
depend on `@metamask/analytics-controller` `^4.1.0`.

## References

- [MetaMask#11058](MetaMask#11058)
- [MetaMask#10981](MetaMask#10981)
- [MetaMask#10901](MetaMask#10901)
- [MetaMask#10864](MetaMask#10864)

## 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
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them


Made with [Cursor](https://cursor.com)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Wallet 20.0.0 carries a documented breaking change to default
controller registration (geolocation), so consumers upgrading from this
release can hit messenger collisions or required migration steps even
though this PR only versions and documents prior work.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
16059ef. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
default-branch — 852175b7 Deployed Oct 26, 2026 by gauthierpetetin via Determine whether this PR is a release PR #5999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants