Skip to content

Instantly share code, notes, and snippets.

@iotashan
Created September 14, 2011 20:14
Show Gist options
  • Save iotashan/1217648 to your computer and use it in GitHub Desktop.
Save iotashan/1217648 to your computer and use it in GitHub Desktop.
Neat file that combines TestFlight and Google Analytics into one easy-to-use Module
exports.Analytics = function() {
// testflight
if (Ti.Platform.osname !== 'android') {
this.testflight = require("ti.testflight");
this.testflight.token('teamtokengoeshere');
Ti.API.debug("module is => " + this.testflight);
}
// Google
Titanium.include('/lib/analytics.js');
this.analytics = new Analytics('UA-XXXXXXX-XX');
this.analytics.start(35);
};
exports.Analytics.prototype.trackPageview = function(pageName) {
this.analytics.trackPageview(pageName);
if (Ti.Platform.osname !== 'android') {
this.testflight.checkpoint(pageName);
}
};
exports.Analytics.prototype.trackAction = function(category, action, label, value) {
this.analytics.trackPageview(category, action, label, value);
if (Ti.Platform.osname !== 'android') {
this.testflight.checkpoint('Action: '+category+'/'+action);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment