How We Evolved Analytics Event Reporting on Trendyol Mobile Apps

İbrahim Süren23 Sep 2022

Problem

Trendyol's mobile apps keep growing, and analytics events must reach the data teams in a usable form. Event models changed for years, so events took different structures per platform and channel, and analysts struggled to interpret the data. There are three event types: click, screen and impression. Impression events fire for every widget shown while the user scrolls, so they produce many requests in a short time and drain device resources. Server timeouts under concurrent requests from millions of users lose some events.

Example from the article: a user scrolls quickly through a widget list and every widget fires an impression event, which would mean about 50 extra database queries per second if the queue were checked on each dispatch.

Solution in brief

Trendyol built an internal client library, Demeter. Every event goes through a chain of interceptors and validators, so all channels share one structure. Click and screen events are sent immediately, while impression events go to a persistent local queue and are sent in batches by a lifecycle-aware timer.

Questions this case answers
  • How to collect high-frequency client-side events with one schema and without data loss when the network is unreliable and the app can be closed at any moment
  • How to keep event payloads consistent across channels when event parameters keep changing over years of development
  • How to make analytics events from several mobile channels share one structure so analysts can use them?
  • How to stop losing impression events when millions of users send bursts of requests?

Tools and methods

  • Interceptor and validator chains — add common parameters and check each payload.
  • SingleEventDispatcher / BatchEventDispatcher — send click and screen events at once, queue impressions.
  • Local database queue — keeps pending events across app restarts.
  • OperationQueue — runs one batch send at a time.
  • Osiris — open-source layer routing events to Demeter instances by scope.
Continue reading — it's free

Google or a one-time email code. No password.