-
-
Save srahim/bff34ea35a653ae2b252 to your computer and use it in GitHub Desktop.
Complete Analytics Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var adView = Ti.UI.iOS.createAdView({ | |
width : 'auto', | |
height : 'auto', | |
top : 0, | |
zIndex : 100 | |
}); | |
var win = Ti.UI.createWindow({backgroundColor:'white'}); | |
var startDate = new Date(); | |
if (Ti.UI.Android){win.windowSoftInputMode = Ti.UI.Android.SOFT_INPUT_ADJUST_PAN;} | |
function timeOut(){setTimeout(function(){if(Ti.Platform.osname == 'ios' || 'android'){label.text = Ti.Analytics.lastEvent;}},1000);} | |
function createRow(i) { | |
var row = Ti.UI.createView({backgroundColor: 'white', width:'100%', height: '10%', top: 5, left: 0}); | |
return row; | |
} | |
var column1 = Ti.UI.createView({top: 0, left: 0, layout: 'vertical', height:"60%", width:'33%'}); | |
var column2 = Ti.UI.createView({top: 0, layout: 'vertical', height:"60%", width:'33%'}); | |
var column3 = Ti.UI.createView({top: 0, right: 0, layout: 'vertical', height:"60%", width:'33%'}); | |
if(Ti.Platform.osname == 'android'){ | |
var label = Ti.UI.createLabel({backgroundColor:'#FFF', color:'black', textAlign: 'center', bottom:0, width: '98%', height:'40%'});} | |
else{ | |
var label = Ti.UI.createLabel({backgroundColor:'#FFF', color:'black', font: {fontSize: 11}, textAlign: 'center', bottom:0, width: '98%', height:'40%'});} | |
var border = Ti.UI.createLabel({top:0, height:'1', borderColor:'#EEE', width: Titanium.UI.FILL}); | |
var deprecated = Ti.UI.createLabel({backgroundColor:'#FFF', color:'red', textAlign: 'center', bottom:0, width: Titanium.UI.FILL}); | |
//Testing the Ti.Analytics.addEvent | |
var testOneButton = Ti.UI.createButton({title: "addEvent", height: '33%', color:'red', width: '100%', top: 0}); | |
testOneButton.addEventListener('click', function(e){ | |
Ti.Analytics.addEvent('addEventOne', 'addEventTwo', 'addEvent.testButton'); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Add Event"; } | |
deprecated.setText("Deprecated 2.0.0"); | |
win.add(deprecated); | |
}); | |
//Testing the Ti.Analytics.getLastEvent | |
var testTwoButton = Ti.UI.createButton({title: "getLastEvent", height: '33%', width: '100%', top: 0}); | |
testTwoButton.addEventListener('click', function(e){ | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Get Last Event"; } | |
win.remove(deprecated); | |
}); | |
//Testing the Ti.Analytics.getBubbleParent | |
var testThreeButton = Ti.UI.createButton({title: "getBubble", height: '33%', width: '100%', top: 0}); | |
testThreeButton.addEventListener('click', function(e){ | |
Ti.Analytics.getBubbleParent(); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Get Bubble Event"; } | |
win.remove(deprecated); | |
}); | |
//Testing the Ti.Analytics.featureEvent | |
var testFourButton = Ti.UI.createButton({title: "featureEvent", height: '33%', width: '100%', top: 0}); | |
testFourButton.addEventListener('click', function(e){ | |
Ti.Analytics.featureEvent('featureEvent', {"value1":"key1"}); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Feature Event"; } | |
win.remove(deprecated); | |
}); | |
//Testing the Ti.Analytics.navEvent | |
var testFiveButton = Ti.UI.createButton({title: "navEvent", height: '33%', width: '100%', top: 0}); | |
testFiveButton.addEventListener('click', function(e){ | |
Ti.Analytics.navEvent('navEventOne', 'navEventTwo', 'navEvent.testButton'); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Navigation Event"; } | |
win.remove(deprecated); | |
}); | |
//Testing the Ti.Analytics.timedEvent | |
var testSixButton = Ti.UI.createButton({title: "timedEvent", height: '33%', color:'red', width: '100%', top: 0}); | |
testSixButton.addEventListener('click', function(e){ | |
var stopDate = new Date(); | |
var duration = stopDate - startDate; | |
Ti.Analytics.timedEvent('timedEvent.testButton', startDate, stopDate, duration); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Timed Event"; } | |
deprecated.setText("Deprecated 2.0.0"); | |
win.add(deprecated); | |
}); | |
//Testing the Ti.Analytics.settingsEvent | |
var testSevenButton = Ti.UI.createButton({title: "settingsEvent", height: '33%', color:'red', width: '100%', top: 0}); | |
testSevenButton.addEventListener('click', function(e){ | |
Ti.Analytics.settingsEvent('settingsEvent', 'settingsEvent.testButton'); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Settings Event"; } | |
deprecated.setText("Deprecated 2.0.0"); | |
win.add(deprecated); | |
}); | |
//Testing the Ti.Analytics.userEvent | |
var testEightButton = Ti.UI.createButton({title: "userEvent", height: '33%', color:'red', width: '100%', top: 0}); | |
testEightButton.addEventListener('click', function(e){ | |
Ti.Analytics.userEvent('userEvent', 'userEvent.testButton'); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "User Event"; } | |
deprecated.setText("Deprecated 2.0.0"); | |
win.add(deprecated); | |
}); | |
//Testing the Ti.Analytics.setBubbleParent | |
var testNineButton = Ti.UI.createButton({title: "setBubble", height: '33%', width: '100%', top: 0}); | |
testNineButton.addEventListener('click', function(e){ | |
Ti.Analytics.setBubbleParent(true); | |
if(Ti.Platform.osname != 'mobileweb'){ timeOut(); } else { label.text = "Set Event"; } | |
win.remove(deprecated); | |
}); | |
column1.add(testOneButton); | |
column1.add(testTwoButton); | |
if(Ti.Platform.osname != 'mobileweb'){ | |
column1.add(testThreeButton); | |
} | |
column2.add(testFourButton); | |
column2.add(testFiveButton); | |
column2.add(testSixButton); | |
column3.add(testSevenButton); | |
column3.add(testEightButton); | |
if(Ti.Platform.osname != 'mobileweb'){ | |
column3.add(testNineButton); | |
} | |
if(Ti.Platform.osname != 'mobileweb'){ label.text = Ti.Analytics.lastEvent; } | |
label.add(border); | |
win.add(column1); | |
win.add(column2); | |
win.add(column3); | |
win.add(label); | |
win.add(adView); | |
adView.show(); | |
win.addEventListener("focus",function(){ | |
Ti.Geolocation.preferredProvider = "gps"; | |
Ti.Geolocation.purpose = "GPS demo"; | |
var authorization = Titanium.Geolocation.locationServicesAuthorization; | |
Ti.API.info('Authorization: '+authorization); | |
if (authorization == Titanium.Geolocation.AUTHORIZATION_DENIED) { | |
Ti.UI.createAlertDialog({ | |
title:'Your app', | |
message:'You have disallowed Titanium from running geolocation services.' | |
}).show(); | |
} | |
else if (authorization == Titanium.Geolocation.AUTHORIZATION_RESTRICTED) { | |
Ti.UI.createAlertDialog({ | |
title:'Your app', | |
message:'Your system has disallowed Titanium from running geolocation services.' | |
}).show(); | |
} | |
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; | |
var locationCallback = function(e) | |
{ | |
Ti.API.info("Location Update :: " + JSON.stringify(e)); | |
}; | |
Titanium.Geolocation.addEventListener('location', locationCallback); | |
}); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment