Problem
Product decisions rely on analytics events that mobile apps send on user actions. A change in unrelated code can silently break an event or its parameters. Teams then learn about it only when someone analyzes the data, after the release. Checking hundreds of events by hand after every release is slow and error-prone.
Example from the article: Trendyol's iOS and Android teams moved event checks into UI tests that simulate real user behavior and assert on the events the app sends.
Solution in brief
Run the existing UI tests with analytics turned on and record the events the app sends during a chosen part of the test. Filter down to the event under test and check it twice: against rule assertions (parameter exists, has a type, has a range) and against a saved reference snapshot. A file shared by the test and the app carries the events out of the app.
Questions this case answers
- How to verify automatically that client-side tracking events keep their exact shape after every code change, when manual checks of hundreds of events do not scale
- How to catch broken analytics events automatically before a mobile release?
- How to verify event names and parameters in a UI test when the test cannot see the app's internals?
- How to detect regressions in event payloads caused by changes in unrelated code?
Tools and methods
- XCUITest — UI tests that drive the app like a user; a black box, so events need a side channel.
- MockingStar — network mocking for smoke and snapshot tests and for flows that cannot use production, such as payments.
- Swift Snapshot Testing — snapshot library behind
assertEventSnapshot. - Event recorder over a shared file — test and app write to and watch one file.
- Rule assertions — checks on event keys and values.
Google or a one-time email code. No password.