I am trying to use the built-in Titanium Analytics featureEvent method on a click event listener, but for some reason data is not appearing under Analytics in my app dashboard. It says "Analytics are not being gathered for this app." I checked my tiapp.xml and analytics is set to 'true'. Is there a good way to test if the method has fired and Titanium collected data?
I have two events firing on button clicks:
Titanium.Analytics.featureEvent('Camera Button'); Titanium.Analytics.featureEvent('Upload Button');
cameraUpload.js
function cameraUpload(){ var ga = require('googleAnalytics'); var flurry = require('sg.flurry'); var cameraUpload = Ti.UI.createWindow({ title: 'Camera/Upload', barColor:'#e67e22', backgroundColor: '#fff', translucent: false }); flurry.logPageView(); var imagePreview = Ti.UI.createImageView({ width: 200, height: 200, top:20 }); cameraUpload.add(imagePreview); var pictureButton = Ti.UI.createButton({ title: 'Take a Picture', backgroundColor: '#000', color: '#fff', width: 200, height: 50, bottom: 30 }); cameraUpload.add(pictureButton); pictureButton.addEventListener('click', function(){ Titanium.Analytics.featureEvent('Camera Button'); Titanium.Media.showCamera({ success:function(event) { // called when media returned from the camera Ti.API.debug('Our type was: '+event.mediaType); if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { imagePreview.setImage(event.media); } else { alert("got the wrong type back ="+event.mediaType); } }, cancel:function() { // called when user cancels taking a picture }, error:function(error) { // called when there's an error var a = Titanium.UI.createAlertDialog({title:'Camera'}); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, saveToPhotoGallery:true, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO] }); }); var uploadButton = Ti.UI.createButton({ title: 'Upload From Gallery', backgroundColor: '#000', color: '#fff', width: 200, height: 50, bottom: 100 }); cameraUpload.add(uploadButton); uploadButton.addEventListener('click', function(){ Titanium.Analytics.featureEvent('Upload Button'); Titanium.Media.openPhotoGallery({ success:function(event) { // called when media returned from the camera Ti.API.debug('Our type was: '+event.mediaType); if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { imagePreview.setImage(event.media); } else { alert("got the wrong type back ="+event.mediaType); } }, cancel:function() { // called when user cancels taking a picture }, error:function(error) { // called when there's an error var a = Titanium.UI.createAlertDialog({title:'Camera'}); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, saveToPhotoGallery:true, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO] }); }); return cameraUpload; } module.exports = cameraUpload;