DEVELOPERS BLOG

Google Analytics in WebWorks

EVENTS / 12.08.14 / timwin1

GoogleAnalytics

Our first ever summer term with the Canadian University program called UCOSP, has just finished. This is the program where upper year university students contribute to open source projects for a term and get course credit. UCOSP decided to try a summer term with a few projects and students this year, and BlackBerry was asked to participate. We ended up with just 3 students this time and we continued to work on porting plugins to the BlackBerry 10 platform.  One of those projects was a Google Analytics plugin, done by Andrew. Here are Andrew’s thoughts on the term:

This summer term I enrolled in UofT CSC494, which gave students an opportunity to work on open source projects coordinated by UCOSP. I got into the BlackBerry team, along with two other students. Our task was to incorporate either pre-existing plugins from other platforms or new plugins into the new BlackBerry WebWorks community APIs .

At the beginning of the term, our mentor, Tim, and us had a two-days meet in the BlackBerry Jam Space at Communitech Hub located in Kitchener, Ontario. It was a fascinating and eye-opening experience to see all the vibrant tech companies and startups inside the building and within the neighborhood. We had the opportunity to see a few of the groups, including a visit to the local startup, Thalmic Labs, which developed the Myo(tm) gesture controlled armband. An armband that you can use to control, say, a RC-helicopter, how cool is that!

Now back on topic, my task for the project was to incorporate Google Analytics (GA) as a WebWorks community plugin. I didn’t have any previous experience in mobile apps development, so there was a particular steep learning curve. Clearly, if I had taken CSC309 in UofT, it would have helped a lot 🙂 There were a lot of things to read to get things started, e.g. how to install debug tokens, how does the Cordova interface work, how to use WebWorks, Momentics and BB Simulator, how is the architecture of a plugin, etc. For GA in particular, Google has a public SDK for Android and iOS, but not for BB10. So in order to incorporate GA, I also needed to go through the documentation and know how to use the functionalities of GA. As it turned out, using GA wasn’t difficult, but it did have a few tricky issues. The coding itself, to incorporate the basic functionalities of GA, was not too much work, when compared to the amount of time needed to understand all those I just mentioned.

Working with this project, one idea that was surely reinforced was to test, and test often. I’m sure every student is taught and told about test-driven development, but we’ll always be tempted to write a lot of code without testing in between. With Javascript, which is used in the non-native side of a WebWorks plugin, there is no compile-time error checking so a simple typo like missing a semicolon could causes us a lot of time to debug. I certainly ran into situations where I had to remove a bigger section of new code, and re-do it in small increments in order to identify that small bug or typo I missed.

The experience working for this UCOSP BlackBerry project was a very positive one for me. While it was not easy, there were a lot of things to learn. It is definitely very different that our typical academic course projects where we may have access to lecture notes and project handouts to tell us exactly what to do. While the UCOSP project is under supervision of our mentors, the project is geared toward real-world applications. There are no notes or handouts, and it’s up to us to find the information we need, solve issues we face and ask the questions we have. It’s also rewarding knowing that our work may turn into something useful for other people in the real world.

Andrew was able to get the plugin working for BlackBerry 10 and this coming term we’ll finish up merging it into the PhoneGap Build plugin and sending it upstream. If you’re interested in following along with the student project, watch #bbucosp on twitter, and all the code will be going into the public BlackBerry repositories on GitHub. If you want to get involved yourself, contact me to get started: @timothywindsor on twitter, https://github.com/timwindsor on GitHub.

About timwin1