My first week at Mixpanel, or how I didn’t take down the Internet
The Design Process
When designing a new feature like this, I aim to create a simple interface. I started the process by analyzing how a user currently implemented link tracking. The recommended pattern was the following:
This pattern has a couple of problems:
- It requires that the user knows to call preventDefault() on the event object
- It requires a selection library to be installed, in addition to our library
- It increases the time required to integrate with our library, and confuses some users
Next, I wrote up what I wanted the new interface to be:
One major design choice was to not include a full featured dom querying library. This choice meant that the interface would only be able to select by a single class/id without the help of jQuery/other selector engine. To help me make this decision, I considered embedding a number of selection engines including SizzleJS, Qwery and the Essential Selector Library. I then worked out the code required to implement a super simple selection engine (only selects by single class or single id):
Based on the minimal amount of code required to implement our own simple selection library, I decided to go that route and allow users to pass in jQuery objects if they wanted to select something more complex.
Another way our library fails gracefully is by ensuring that we wait only 300 ms for the Mixpanel servers to respond. In this way our user’s sites stay responsive even if our servers are having problems. I chose 300 ms based on a browser benchmark I wrote to evaluate the response time for the mpmetrics.track() method.
101 Big Ones
After a final code review with our lead front-end engineer, Tim Trefren, it was time to deploy. Seconds after our deploy scripts finished, thousands of browsers around the world downloaded and ran my code, no Internet apocalypse in sight. I never imagined that I would be pushing something of this magnitude out in my first week, let alone as an intern. Mixpanel has welcomed me as a core member of the team from day one, putting just as much trust on me as everyone else. I know that every day I come into the office I will be making a difference rather than just fixing bugs and writing tests. For a rewarding internship contact me and help us change the world of analytics.
“Enjoy the little things, for one day you may look back and realize they were the big things.”
Originally published at https://engineering.mixpanel.com on May 23, 2011.