Improving Etsy for iOS with server-based logging
Article Summary
Etsy's iOS team faced a dilemma: their safety net for preventing crashes was quietly hiding logic bugs across the entire codebase.
Amy Dyer from Etsy's Native Apps team shares how they built a server-based logging system to make iOS crashes visible and debuggable. This 2013 post reveals how a small mobile team maintained stability while scaling their app.
Key Takeaways
- Created Safe category methods to prevent collection crashes from API hiccups
- Split methods into explicit variants: objectOrNilAtIndex vs safeObjectAtIndex
- Built EtsyAssert and EtsyExpect macros that log failures to servers
- Sampled 1% of users to surface thousands of hidden edge cases
- Correlated client logs with server logs for full request tracking
By piggybacking on their analytics framework to send iOS logs to servers, Etsy made rare production bugs visible and fixed issues users hit thousands of times daily.
About This Article
Etsy's iOS team switched from Safe category methods to Apple's subscripted collection indexing (array[0] syntax) in Clang 3.4. This exposed hidden bugs that had been lurking in the code. One example was an NSNumberFormatter that silently returned nil when given bad input. These minor failures suddenly became serious crashes.
Amy Dyer's team built EtsyAssert and EtsyExpect macros to log collection access failures. The logs went to Etsy's server-based logging system through the EtsyAnalytics framework. The macros could tell the difference between expected nil returns and unexpected out-of-bounds errors, assigning different severity levels (ERROR vs INFO) to each.
Etsy collected logs from 1% of app users and found thousands of daily edge cases. One pattern was users swiping through listing images without checking availability first. Developers had only seen these issues a handful of times before. With this data, the team could refactor safely and with minimal risk.