Revolut Arsen Gasparyan Sep 25, 2017

How to Extract Analytics Data from Your iOS Application

Article Summary

Arsen Gasparyan from Revolut breaks down how to build an analytics system that's actually testable. Most teams bolt on tracking as an afterthought—here's the protocol-oriented approach that scales.

Revolut's iOS team needed a way to track user behavior across multiple analytics platforms (Google Analytics and Amplitude) without creating a maintenance nightmare. This article walks through their Swift implementation using protocols and enums to create a flexible, testable analytics layer.

Key Takeaways

Critical Insight

A protocol-oriented analytics wrapper gives you multi-platform tracking, full test coverage, and zero vendor lock-in.

The bonus section reveals how this architecture makes analytics code fully unit testable without mocking frameworks.

About This Article

Problem

Revolut's iOS team had to track user behavior across Google Analytics and Amplitude while keeping the code flexible, reliable, and testable. They also wanted to avoid getting locked into any single vendor.

Solution

Arsen Gasparyan's team built a protocol-oriented architecture. They created a TrackingEventType protocol, added provider classes for each analytics system, and set up a TrackingClient that sends events to all providers at once.

Impact

The dummy provider pattern made it possible to test analytics events without calling real APIs. Developers could check what events were tracked by looking at an exposed events property on TestTrackingClient.