summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/reader/Tracker.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/reader/Tracker.js')
-rw-r--r--public/assets/javascripts/ui/reader/Tracker.js41
1 files changed, 28 insertions, 13 deletions
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
})