After hearing about Atlassian's Codegeist hackathon we knew we wanted to build a bot for HipChat, but weren't sure how many were out there. Obviously, our first choice would be Google Analytics because it's the most popular analytics tools on Earth, so we searched for it on the marketplace. After realizing that there was not yet a bot for Google Analytics we decided this would be the challenge we would take head on.
What it does
Analytics Bot simply connects your HipChat room to your Google Analytics account.
The current version of our add-on has all basic support for any metric or dimension. Our next version will have support for basic graphs, but beautiful also. After we complete the graphing logic we are going to move onto commands that can be saved and ran by any team member - we are calling these "snippets."
How we built it
We started with the Atlassian Connect Express template that Atlassian so generously created. It was a huge help when trying to learn how the data was passed from front end to back end and visa versa.
Challenges we ran into
This first challenge we ran into was both of us were running Windows, so we had to figure out how to connect our add-on to Redis for Windows. This was pretty easy to figure out thanks to the team maintaining the Redis for Windows project. Another challenge was understanding the OAuth2 flow with Google because neither of us had yet worked with it before. After an entire weekend we were able to build out a functional prototype of the OAuth2 flow inside the add-on configuration page and query all related Google Analytics properties & views. But how were we going to store that data? Again, Atlassian made is super easy to store and retrieve settings from their service using addon.get and addon.set - these were our bread and butter when working with the configuration page. After learning how those two methods worked from the front end and how it stored data on the back end we only had to query Google Analytics for the command a user sends. Parsing their response and making into a table was a pretty big pain, but Corey prevailed and was able to send some beautiful HTML from their massive responses.
Accomplishments that we're proud of
Refactored table builder - very clean way to parse Google's response and build an HTML table to send to HipChat. Beautiful configuration page & authorization flow - very easy to use and works like a charm.
What we learned
Neither of us had a ton of experience with node or express, so everything we did was learned. Everything.
What's next for Analytics Bot
As I mentioned previously, we will be focusing on deploying chart functionality, save-able snippets, and I forgot to mention that we're working on parseing the commands so they can use UI-friendly names (landing page) as well as API names (landingpagepath).