chore(geofence): remove on-device location-send and add monitoring-distance cap#748
chore(geofence): remove on-device location-send and add monitoring-distance cap#748mrehan27 wants to merge 1 commit into
Conversation
…stance cap Geofence sync no longer transmits device location. The backend returns the full (capped) set and the SDK sends no location to fetch; remote fetch is time/staleness- based and a movement trigger only re-ranks the cached set on-device. The location-based "nearby" fetch path (and its coordinate coarsening) is removed entirely rather than gated, so the SDK has no code path that transmits device location. GeofenceSyncMode is kept as a single-value enum so a location-based mode can be re-introduced deliberately later (backend support + a deliberate SDK release). Adds maxMonitoringDistance: candidates farther than this from the current location aren't registered with the OS; local re-rank re-adds them as the device approaches. Defaults to a finite cap (the server omits the field today) so a user far from a geofence doesn't register, say, another continent's; the server sends 0 to disable the cap. Only meaningful with fetch-all, where the backend returns geofences regardless of distance. When geofences exist but all fall outside the distance, the movement trigger is still registered so an EXIT can re-rank and re-register them as the device approaches. Only a truly empty set (no geofences, or maxBusinessGeofences == 0) registers nothing, so customers without geofences still pay zero runtime cost. Hardens config parsing to coerce server values into sane bounds: non-positive values fall back, positive out-of-range radii/expiries clamp, and a maxMonitoringDistance below the trigger radius (a dead-zone) falls back to the default. MBL-1843 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sample app builds 📱Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 f6c15c0. Configure here.
| val maxBusinessGeofences: Int, | ||
| // Cap (m) on how far a business geofence can be from the device to be registered. | ||
| @SerialName("maxMonitoringDistance") | ||
| val maxMonitoringDistance: Float |
There was a problem hiding this comment.
Cached config breaks on upgrade
Medium Severity
Adding required maxMonitoringDistance without a serialization default makes existing persisted cached_config JSON fail to decode on SDK upgrade. The store wipes that key and treats config as missing, so server-tuned thresholds (including the monitoring cap) revert to SDK fallbacks until a new config is fetched.
Reviewed by Cursor Bugbot for commit f6c15c0. Configure here.
There was a problem hiding this comment.
Not applicable — :geofence is unreleased, so no shipped SDK has a persisted cached_config. When it releases, maxMonitoringDistance ships with every other config field. Keeping it required for consistency.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/geofence-on-device #748 +/- ##
=============================================================
Coverage ? 67.02%
Complexity ? 1069
=============================================================
Files ? 203
Lines ? 6204
Branches ? 859
=============================================================
Hits ? 4158
Misses ? 1740
Partials ? 306 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
📏 SDK Binary Size Comparison Report
|
|
Build available to test |


MBL-1843
Why
The on-device sync used to send a coarsened device location to the backend. Removing it entirely means the SDK has no code path that transmits device location, and lets the backend own "return the right set." Replaces #742 (closed; scope changed from gating fetch-all to removing location-send).
What
fetchGeofences()sends no location; dropped the 2-arg overload andGeofenceCoordinateCoarsener.GeofenceSyncModestays as a single-value (FETCH_ALL) documented seam so re-introducing a location mode is a localized change + deliberate release (prior impl in git history).maxMonitoringDistancecap (wiremax_monitoring_distance). Caps how far a business geofence can be from the device to be registered. Semantics:null→ 1000 km default (don't register another continent's geofence for a local user),0→ disabled, below the trigger radius → fall back (avoids a dead-zone).geofencesremains the only required wire field (missing → parse fails → preserve cache + retry, fail-safe).Testing
:geofenceunit suite green (incl. new cap, three-way-empty, and coercion cases).Note
High Risk
Changes core geofence sync semantics and privacy (no location on wire) and depends on backend supporting location-less
/geofences/nearby; mis-timed release could break sync or leave stale registrations.Overview
Stops sending device location on geofence sync:
fetchGeofences()is location-less (no lat/long query params), andGeofenceSyncMode.FETCH_ALLensures movement no longer escalates to a remote re-fetch based on distance from the last API anchor.refresh()now picks REMOTE / LOCAL / SKIP via a decision table: time staleness still forces fetch; ranking staleness is measured from the last movement-trigger registration (so a missed EXIT while the app was dead triggers local re-rank, not a network call when the cache is time-fresh).handleMovement()re-ranks locally except when there is no API anchor yet.Adds server
max_monitoring_distance(with clamp/fallback semantics) and applies it inGeofenceDistanceFilter. When geofences exist but none are within the cap, the SDK still registers only the movement trigger so EXIT can pull regions in as the user approaches—distinct from a truly empty geofence list.Wire→domain config mapping now clamps radii and expiry windows; default fallbacks for local/remote radii are updated. Tests cover fetch-all behavior, cap filtering, three-way empty handling, and config coercion.
Reviewed by Cursor Bugbot for commit f6c15c0. Bugbot is set up for automated code reviews on this repo. Configure here.