chore(geofence): emit one transition event per geoset#773
Merged
mrehan27 merged 1 commit intoJul 10, 2026
Conversation
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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/geofence-on-device #773 +/- ##
================================================================
+ Coverage 67.56% 67.73% +0.17%
- Complexity 1115 1127 +12
================================================================
Files 206 206
Lines 6375 6410 +35
Branches 887 890 +3
================================================================
+ Hits 4307 4342 +35
+ Misses 1749 1748 -1
- Partials 319 320 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
📏 SDK Binary Size Comparison Report
|
|
Build available to test |
…nces/nearest
Switch nearby sync to POST /geofences/nearest {latitude, longitude, radius}
and fan out one transition event per geoset_id (empty -> a single no-geoset
event), sharing one transitionId across the fan-out with the geoset in the
pending-delivery key so per-geoset entries don't collide.
The whole fan-out persists in one atomic PendingDeliveryStore write before any
send, so an app kill mid-batch can't save some geosets and lose the rest (the
cooldown is already spent, so a lost row would never retry); geoset ids are
deduped at source. Search radius = max(monitoring cap, re-fetch radius) goes in
the request body; the geoset id is emitted type-preserving (a number when
numeric, matching the server int64). Legacy response fields kept optional.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aab2dff to
aec4dfe
Compare
|
|
mahmoud-elmorabea
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
POST /geofences/nearestwith body{latitude, longitude, radius}(wasGET /geofences/nearby).radius = max(monitoring cap, re-fetch radius), sourced from cached config;limitomitted (SDK caps locally).geoset_ids;name/transition_types/last_updatedkept optional (silently honored if the backend still sends them).geosetIdproperty). A fence with no geosets still emits a single event (nogeosetId), so a real OS transition is never dropped.transitionIdis shared across a crossing's fan-out (it identifies the crossing, not the geoset); the geoset is part of the pending-delivery key so per-geoset rows don't collide. Backend dedup must be keyed(transitionId, geoset_id).geosetIdis emitted type-preserving (a number when numeric, matching the serverint64).Notes
active = NEARBY); its bodyless-POST path is dead code and will be removed — along with iOS'sGET /geofences/nearby— in a follow-up PR.Testing
Unit tests updated/added: nearest POST body, numeric→string geoset decode + ordering, fan-out counts (3→3, 1→1, empty→1, duplicate→deduped), shared-transitionId + distinct-key invariants, type-preserving
geosetIdemission, radius formula, atomic batch append.MBL-2008
PRs Stack
POST /geofences/nearest)Note
Medium Risk
Changes the geofence API contract and multiplies transition events per crossing, requiring backend dedup on (transitionId, geoset); delivery and registration paths are heavily covered by tests but rollout must stay aligned with the server.
Overview
Geofence sync now calls
POST /geofences/nearestwith a JSON body (latitude,longitude,radius) instead ofGET /geofences/nearby.radiusis computed from cached config asmax(monitoring cap, re-fetch radius)viaremoteSearchRadiusMeters(). API regions gaingeoset_ids, stored onGeofenceRegionand decoded from the wire.On a real OS transition, the receiver fans out one pending delivery (and tracked event) per distinct geoset, sharing a single
transitionIdacross the crossing whilegeosetIddistinguishes rows (pending keys, WorkManager input, and event properties). Fences with no geosets still emit one event (nogeosetId). The batch isappendAll’d atomically before scheduling sends.equalsIgnoringGeosetIdsavoids needless GMS re-registration when only geoset membership changes; the region store exposesgetCachedRegionfor fan-out metadata.Reviewed by Cursor Bugbot for commit aec4dfe. Bugbot is set up for automated code reviews on this repo. Configure here.