Infrastructure & Data

Manorama Lens Tracker SDK

FlutterSDKSQLiteOffline-first

Overview

About the Project

Ported the client's existing native iOS/Android tracking infrastructure into a unified Flutter SDK. Architected an offline-first solution handling event capture, crash logging, batching, schema validation, and local DB persistence. Currently deployed in 2 production applications for Manorama.

How it works

Engineering Flow

01

Initialize config

Load assets/lens.json, auto-detect platform metadata (appId, appVersion), and apply schema type structures.

02

In-memory buffering

Buffer incoming events dynamically in an in-memory queue to prevent SQLite transaction congestion.

03

Atomic SQLite writes

Commit events in batch transactions when the queue size reaches 50 or after a 50ms time threshold.

04

Smart Burst flush

Read batches of 15 and flush back-to-back rapidly upon network recovery, returning the radio to sleep to save battery.

Problems solved

Challenges & Resolution

Challenge
SQLite concurrency bottleneck causing database locked errors during event bursts.
Resolution
Designed an in-memory write buffer backed by dual triggers (50ms timer / 50 event count) to batch database operations into a single atomic transaction.
Benefit
Eliminated all database lock exceptions and achieved sub-50ms write latency for high-frequency tracking.
Challenge
Varying payload schemas between different app types (news apps wrapping in data vs general apps wrapping in event).
Resolution
Built a dynamic EventTracker schema abstraction layer that formats payloads and context keys on-the-fly under a single unified public API.
Benefit
Simplified developer integration, enabling multiple Flutter applications to consume the same SDK.
Challenge
Local database size growth during prolonged offline periods on customer devices.
Resolution
Introduced a mutex-guarded CapacityManager that actively enforces a 10MB limit and drops the oldest events if capacity is exceeded.
Benefit
Guaranteed the SDK does not consume excessive storage or impact the host application's stability.

Result

Outcome

Successfully ported native tracking mechanisms into a unified, high-performance Flutter analytics SDK. By introducing transaction batching, memory queuing, and a Smart Burst network emitter, the project established reliable event telemetry with 100% data integrity across Manorama's production applications.