Analytics are common in iOS applications. They help inform our decisions about products. Since analytics are so common, Artsy developed a library called ARAnalytics. This library provides a single interface to many different backend analytics providers, freeing developers from having to write code for each of the providers that they’re using.
Let’s consider a typical view controller on iOS. View controllers on iOS represent the glue code between models and views. When a model changes, the view controller updates the appearance of the UI. Similarly, when the UI is interacted with by the user, the view controller updates the model. This is the core of any standard iOS application.
So let’s say that a button is pressed. We’ll handle that interaction in a
method called buttonWasPressed:. We’ll want to update our model, but also to
track the analytics event.
- (void)buttonWasPressed:(id)sender
{
self.model.hearted = YES;
[ARAnalytics event:@"hearted"];
}
Simple enough, but consider that the analytics tracking code doesn’t fall within our definition of a view controller – the button handler just happens to be a convenient place to put the tracking code. Also consider that every single button handler is going to have to have similar code implemented.

