summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-09-30 18:34:58 -0400
committerJules Laplace <jules@okfoc.us>2014-09-30 18:42:56 -0400
commita4eb980bcb2cce616abfb6300e1b80d8323899e4 (patch)
tree7f7465daeed6d90f6feb216379fd763e634f9de8 /public/assets/javascripts/ui
parent5d567454d7d2f4f7e885720d310d42063eeba4dd (diff)
trackin stuff
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js2
-rw-r--r--public/assets/javascripts/ui/reader/Tracker.js41
2 files changed, 30 insertions, 13 deletions
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js
index c43dc9c..82db048 100644
--- a/public/assets/javascripts/ui/reader/ReaderView.js
+++ b/public/assets/javascripts/ui/reader/ReaderView.js
@@ -75,10 +75,12 @@ var ReaderView = View.extend({
pick: function(scenery){
this.mediaPlayer.pick(scenery)
+ app.tube("pick-scenery", { scenery: scenery })
},
hideExtras: function(){
this.mediaPlayer.hide()
+ app.tube("close-scenery")
}
})
diff --git a/public/assets/javascripts/ui/reader/Tracker.js b/public/assets/javascripts/ui/reader/Tracker.js
index 7d9d936..beef071 100644
--- a/public/assets/javascripts/ui/reader/Tracker.js
+++ b/public/assets/javascripts/ui/reader/Tracker.js
@@ -17,21 +17,28 @@ var Tracker = Fiber.extend(function(base){
},
bind: function () {
- //
window.addEventListener("click", this.trackClick.bind(this), true)
+ app.on("change-wall", this.changeWall.bind(this))
+ app.on("pick-scenery", this.pickScenery.bind(this))
+ app.on("close-scenery", this.trackScenery.bind(this))
+ app.on("change-room", this.changeRoom.bind(this))
+ },
+
+ pushEvent: function(event){
+ this.events.push(event)
},
trackPageview: function(opt){
- this.events.push([ "view" ])
+ this.pushEvent([ "view" ])
},
//
// how long they spend in front of each wall
- trackChangeWall: function(opt){
+ changeWall: function(opt){
var duration = this.wallTimer.currentTime()
if (this.wall_id && duration > 5000) {
- this.events.push([ "wall", this.wall_id, duration ])
+ this.pushEvent([ "wall", this.wall_id, duration ])
}
this.wall_id = opt.wall.id
this.wallTimer.start()
@@ -41,14 +48,19 @@ var Tracker = Fiber.extend(function(base){
// how long the user spends on each item they click
pickScenery: function(opt){
- this.sceneryTimer.start()
+ if (this.scenery_id && opt.scenery.id !== this.scenery_id) {
+ this.trackScenery()
+ }
+ else {
+ this.sceneryTimer.start()
+ }
this.scenery_id = opt.scenery.id
},
trackScenery: function(){
var duration = this.sceneryTimer.currentTime()
if (this.scenery_id && duration > 5000) {
- this.events.push([ "scenery", this.scenery_id, duration ])
+ this.pushEvent([ "scenery", this.scenery_id, duration ])
}
this.scenery_id = null
this.sceneryTimer.reset()
@@ -57,24 +69,26 @@ var Tracker = Fiber.extend(function(base){
//
// how long they spend in the room
- trackChangeRoom: function(opt){
+ changeRoom: function(opt){
var duration = this.roomTimer.currentTime()
- if (this.room_id && duration > 5000) {
- this.events.push([ "room", this.room_id, duration ])
+ if (this.room_id !== opt.room.id) {
+ if (this.room_id && duration > 5000) {
+ this.pushEvent([ "room", this.room_id, duration ])
+ }
+ this.roomTimer.start()
+ this.room_id = opt.room.id
}
- this.room_id = opt.room.id
- this.roomTimer.start()
},
//
// how many clicks per room
trackClick: function(opt){
- console.log("track click")
this.clicks += 1
},
save: function () {
+ // possibly just push to google analytics
},
}
@@ -101,8 +115,9 @@ var Timer = Fiber.extend(function(base){
currentTime: function(){
return this.time ? Date.now() - this.time : 0
},
-
}
+
+ return exports
})