How Do We Automate Testing of Clickstream Analytics Events on Dolap iOS App ?

Kenan Ulaş Soyubey29 Nov 2024

Problem

The Dolap iOS team at Trendyol sends clickstream events to an analytics service from many app flows. Wrong trigger points or wrong payloads distort the picture of user journeys. Such errors slipped through regression testing: testers could confirm that an event fired, but not that its data was correct. Buggy releases went live and the incoming data was unusable until the bug was fixed. The team wanted a check that runs daily and notices even small changes.

Example from the article: a UI test opens a product page from the home screen and must see one BidAdviceTooltipSeenPDPEvent with the expected payload and nothing else.

Solution in brief

The app forwards every clickstream event over a local socket to the UI test runner. The test compares received events with reference ("mock") events and fails if one is missing, wrong or extra. An event test is an existing regression UI test plus assertions at the end, and a desktop helper app generates them.

Questions this case answers
  • How to verify automatically, before release, that a client application emits the intended analytics events with correct payloads, independent of network delivery
  • How to check automatically that a mobile app sends the right clickstream events with the right payload?
  • How to catch a broken or duplicated analytics event before the release goes live?
  • How to cover analytics events with tests without writing a new test suite from scratch?

Tools and methods

  • Unit tests — check that event code fires at the right points.
  • Socket server and listener (Apple Network framework) — carry each event from the app target to the UI test runner target with no third-party library.
  • UI tests (XCUITest) — drive real user flows and hold the event assertions.
  • Mac desktop helper app — records events from a test run and generates the assertion code.
Continue reading — it's free

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