Skip to content

feat: Event Enrichment and Queueing, MetaRouterAnalyticsClient base class#5

Merged
choudlet merged 9 commits into
mainfrom
chrish/sc-31895/android-sdk-4
Jan 21, 2026
Merged

feat: Event Enrichment and Queueing, MetaRouterAnalyticsClient base class#5
choudlet merged 9 commits into
mainfrom
chrish/sc-31895/android-sdk-4

Conversation

@choudlet
Copy link
Copy Markdown
Collaborator

This branch implements the event queuing and enrichment foundation for the MetaRouter Android SDK. This is a critical
middleware layer that sits between event tracking calls and the networking layer (to be implemented in a future PR).

Key Components Added

  1. MetaRouterAnalyticsClient (MetaRouterAnalyticsClient.kt)
  • Main SDK client with full lifecycle management (IDLE → INITIALIZING → READY → RESETTING)
  • Implements all core event tracking methods: track(), identify(), group(), screen(), page(), alias()
  • Uses a Channel-based architecture (similar to Swift actors) to serialize event enrichment and provide natural
    backpressure
  • Channel capacity set to maxQueueEvents / 2 for burst handling
  • Thread-safe operations with AtomicReference for lifecycle state
  • Identity management: advertising ID support with context cache invalidation
  • Debug methods: getDebugInfo(), enableDebugLogging()
  1. EventEnrichmentService (enrichment/EventEnrichmentService.kt)
  • Enriches raw events with identity (anonymousId, userId, groupId)
  • Adds device context (device, app, OS, screen, network, library, locale, timezone)
  • Generates unique messageIds in format {epochMs}-{uuid}
  • Formats timestamps in ISO 8601 UTC format
  • Includes advertising ID in device context when available
  1. EventQueue (queue/EventQueue.kt)
  • Thread-safe FIFO queue with ReadWriteLock
  • Configurable capacity with overflow protection (drops oldest events)
  • Support for bulk drain operations
  • Requeue capability for retry scenarios (adds to front)
  • Debug statistics (size, capacity, utilization %)
  1. Comprehensive Test Suite (MetaRouterAnalyticsClientTest.kt)
  • 30+ unit tests covering all major scenarios
  • Uses MockK for Android context mocking
  • Tests: initialization, event tracking, identity management, lifecycle, error handling, concurrency, queue overflow
  1. Updated Dependencies (build.gradle.kts)
  • Added MockK testing framework (v1.13.9)
  • Added MockK Android support

@choudlet choudlet changed the title Chrish/sc 31895/android sdk 4 feat: Event Enrichment and Queueing, MetaRouterAnalyticsClient base class Oct 29, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 5, 2026

Test Results

 28 files  + 4   28 suites  +4   36s ⏱️ +8s
187 tests  - 16  187 ✅  - 16  0 💤 ±0  0 ❌ ±0 
374 runs   - 32  374 ✅  - 32  0 💤 ±0  0 ❌ ±0 

Results for commit 6560d6e. ± Comparison against base commit 3265beb.

This pull request removes 93 and adds 77 tests. Note that renamed tests count towards both.
com.metarouter.analytics.context.DeviceContextProviderTest ‑ advertising ID with special characters is preserved
com.metarouter.analytics.context.DeviceContextProviderTest ‑ caching returns same context instance for same advertising ID
com.metarouter.analytics.context.DeviceContextProviderTest ‑ caching returns same context instance when no advertising ID
com.metarouter.analytics.context.DeviceContextProviderTest ‑ changing advertising ID invalidates cache and returns new context
com.metarouter.analytics.context.DeviceContextProviderTest ‑ clearCache invalidates cached context
com.metarouter.analytics.context.DeviceContextProviderTest ‑ concurrent cache clears and gets are safe
com.metarouter.analytics.context.DeviceContextProviderTest ‑ context with advertising ID then without uses cache correctly
com.metarouter.analytics.context.DeviceContextProviderTest ‑ device context excludes advertising ID when not provided
com.metarouter.analytics.context.DeviceContextProviderTest ‑ device context includes advertising ID when provided
com.metarouter.analytics.context.DeviceContextProviderTest ‑ empty string advertising ID is treated as present
…
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ alias updates userId and enqueues event
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ alias with empty userId logs warning and does not enqueue
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ all event types can be created and queued
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ enableDebugLogging enables debug mode
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ events cannot be enqueued after reset
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ events include all required fields per spec
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ flush is a no-op stub
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ getDebugInfo masks writeKey correctly
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ getDebugInfo returns complete information
com.metarouter.analytics.MetaRouterAnalyticsClientTest ‑ group updates groupId and enqueues event
…

♻️ This comment has been updated with latest results.

@choudlet choudlet merged commit 69ff5d4 into main Jan 21, 2026
3 checks passed
choudlet added a commit that referenced this pull request Apr 10, 2026
feat: Event Enrichment and Queueing, MetaRouterAnalyticsClient base class
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