Skip to content

chore(geofence): enrich transition events with geofence metadata#775

Open
mrehan27 wants to merge 1 commit into
feature/geofence-on-devicefrom
mbl-2045-geofence-transition-metadata
Open

chore(geofence): enrich transition events with geofence metadata#775
mrehan27 wants to merge 1 commit into
feature/geofence-on-devicefrom
mbl-2045-geofence-transition-metadata

Conversation

@mrehan27

@mrehan27 mrehan27 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Enriches the "Geofence Transition" event with workspace-defined metadata from POST /geofences/nearest.

What

  • metadata (scalar string/number/bool map) from the nearby response is cached on the region, snapshotted onto the pending delivery at crossing time, and preferred fresh from cache at send — falling back to the snapshot when the geofence has left the cache (same hybrid as geofenceName).
  • Emitted as a nested metadata object on the event, always present (empty {} when the fence has none). Values keep their type (string/long/double/boolean).
  • Non-scalar values (null/array/object) are dropped at parse; defensive count (100) + payload (100 KB) caps as a runaway-payload backstop — the server does the real validation.
  • geosetId now emitted as a plain string (dropped the numeric coercion).
  • Dropped radius from the /geofences/nearest request body (now optional server-side).

Notes

  • Both delivery paths (WorkManager direct-HTTP + foreground flush) build an identical property set.
  • The worker carries only the pending-store key through WorkManager inputData and loads the full row from the store, so metadata (which can be large) never risks the ~10 KB Data limit and the worker always sends the authoritative snapshot rather than a copy.
  • No public API change (all internal); adds one internal helper PendingDeliveryStore.get(key) in :core (not in the API dump).
  • iOS parity confirmed against the equivalent iOS change (metadata feature fully aligned; iOS is dropping radius too).

Stack

main
 └─ feature/geofence-on-device
     └─ mbl-2045-geofence-transition-metadata  ← this PR

Test plan

  • ./gradlew :core:testDebugUnitTest :core:apiCheck :geofence:testDebugUnitTest :geofence:apiCheck :messagingpush:testDebugUnitTest — green
  • make lint-no-format — green

MBL-2045


Note

Medium Risk
Changes geofence event payload shape (metadata, geosetId typing) and delivery path (worker reads store by key); behavior is well-tested but affects background analytics and nearest-fetch semantics.

Overview
Geofence transition track events now carry workspace metadata from POST /geofences/nearest: parsed and capped at ingest, cached on regions, snapshotted on pending deliveries, and merged at send time via withFreshestEventData (cache wins for name/metadata, same pattern as geofenceName). metadata is always on the event properties (empty map when none); geosetId is emitted as a string.

WorkManager no longer inlines transition fields in inputData—only the pending-store entry_key—so large metadata cannot hit the ~10 KB Data limit; the worker uses new PendingDeliveryStore.get. Direct HTTP and foreground flush both build the same property set.

/geofences/nearest requests drop client radius; remoteSearchRadiusMeters is removed. Metadata/geoset-only region updates skip GMS re-register via equalsForRegistration.

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

@mrehan27 mrehan27 requested a review from a team as a code owner July 10, 2026 21:00
@mrehan27 mrehan27 self-assigned this Jul 10, 2026
@github-actions

Copy link
Copy Markdown

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.


@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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 d334411. Configure here.

Comment thread geofence/src/main/kotlin/io/customer/geofence/worker/GeofenceEventWorker.kt Outdated
Comment thread geofence/src/main/kotlin/io/customer/geofence/worker/GeofenceEventWorker.kt Outdated
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.87324% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.71%. Comparing base (b1e91c0) to head (b901b85).

Files with missing lines Patch % Lines
...io/customer/geofence/worker/GeofenceEventWorker.kt 64.28% 1 Missing and 4 partials ⚠️
...in/io/customer/geofence/api/GeofenceApiResponse.kt 82.35% 2 Missing and 1 partial ⚠️
...customer/geofence/store/PendingGeofenceDelivery.kt 83.33% 1 Missing and 2 partials ⚠️
.../io/customer/geofence/GeofenceBroadcastReceiver.kt 66.66% 0 Missing and 1 partial ⚠️
...main/kotlin/io/customer/geofence/ModuleGeofence.kt 0.00% 1 Missing ⚠️
...lin/io/customer/geofence/api/GeofenceApiService.kt 50.00% 1 Missing ⚠️
.../kotlin/io/customer/geofence/di/DIGraphGeofence.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##             feature/geofence-on-device     #775      +/-   ##
================================================================
- Coverage                         67.76%   67.71%   -0.06%     
+ Complexity                         1127     1126       -1     
================================================================
  Files                               206      206              
  Lines                              6400     6417      +17     
  Branches                            888      896       +8     
================================================================
+ Hits                               4337     4345       +8     
- Misses                             1746     1751       +5     
- Partials                            317      321       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
  • java_layout: mbl-2045-geofence-transition-metadata (1783717331)

@github-actions

Copy link
Copy Markdown
  • kotlin_compose: mbl-2045-geofence-transition-metadata (1783717318)

@github-actions

Copy link
Copy Markdown

Build available to test
Version: mbl-2045-geofence-transition-metadata-SNAPSHOT
Repository: https://central.sonatype.com/repository/maven-snapshots/

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

📏 SDK Binary Size Comparison Report

Module Last Recorded Size Current Size Change in Size
core 43.85 KB 43.70 KB ⬇️ -0.15KB
datapipelines 43.17 KB 43.17 KB ✅ No Change
messagingpush 31.66 KB 31.66 KB ✅ No Change
messaginginapp 123.88 KB 123.88 KB ✅ No Change
tracking-migration 22.89 KB 22.89 KB ✅ No Change
location 18.66 KB 18.66 KB ✅ No Change
geofence 69.52 KB 71.08 KB ⬆️ +1.56KB

@mrehan27 mrehan27 force-pushed the mbl-2045-geofence-transition-metadata branch from d334411 to db30ef4 Compare July 10, 2026 21:30
@github-actions

Copy link
Copy Markdown
  • kotlin_compose: mbl-2045-geofence-transition-metadata (1783719089)

@github-actions

Copy link
Copy Markdown
  • java_layout: mbl-2045-geofence-transition-metadata (1783719079)

Carry `metadata` from POST /geofences/nearest onto the "Geofence
Transition" event. Snapshot metadata+name into the pending delivery at
crossing time, then prefer the still-cached region's current values at
send (hybrid), falling back to the snapshot when the fence is gone.
metadata is stored as Map<String, JsonElement> and unwrapped to Kotlin
primitives at emit; non-scalars are dropped at parse and the payload is
capped as a runaway-payload backstop. Also drops the now-optional
`radius` from the nearby request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mrehan27 mrehan27 force-pushed the mbl-2045-geofence-transition-metadata branch from db30ef4 to b901b85 Compare July 10, 2026 21:48
@github-actions

Copy link
Copy Markdown
  • java_layout: mbl-2045-geofence-transition-metadata (1783720199)

@github-actions

Copy link
Copy Markdown
  • kotlin_compose: mbl-2045-geofence-transition-metadata (1783720199)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant