-
Notifications
You must be signed in to change notification settings - Fork 5
JavaScript specs #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
JavaScript specs #26
Changes from all commits
e37c84c
4bd7a14
5835e37
c324612
af7fee3
bf6b3af
de5c3e0
918ec3e
609585e
bdfca5e
bf3bf6b
15a6673
16dbf36
b118e80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ language: ruby | |
| rvm: | ||
| - 2.2.3 | ||
| before_install: gem install bundler -v 1.11.2 | ||
| script: rake travis | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| var ActionTracker = (function(self) { | ||
|
|
||
| self.Storage = function() { | ||
| var storage = []; | ||
|
|
||
| function constructor() { | ||
| if(sessionStorage.getItem('action_tracker_storage')) { | ||
| getStorage(); | ||
| } else { | ||
| setStorage(); | ||
| } | ||
| } | ||
|
|
||
| function getStorage() { | ||
| storage = JSON.parse(sessionStorage.getItem('action_tracker_storage')); | ||
| } | ||
|
|
||
| function setStorage() { | ||
| sessionStorage.setItem('action_tracker_storage', JSON.stringify(storage)); | ||
| } | ||
|
|
||
| function queue(list) { | ||
| if(list !== null) { | ||
| getStorage(); | ||
| var i; | ||
| for (i = 0; i < list.length; i += 1) { | ||
| storage.push(list[i]); | ||
| } | ||
| setStorage(); | ||
| } | ||
| } | ||
|
|
||
| function dequeue() { | ||
| getStorage(); | ||
| var first = storage[0]; | ||
| storage.splice(0, 1); | ||
| setStorage(); | ||
| return first; | ||
| } | ||
|
|
||
| function getFirst() { | ||
| getStorage(); | ||
| return storage[0]; | ||
| } | ||
|
|
||
| function clear() { | ||
| storage = []; | ||
| setStorage(); | ||
| } | ||
|
|
||
| function getLocalStorage() { | ||
| return storage; | ||
| } | ||
|
|
||
| constructor(); | ||
|
|
||
| return { | ||
| queue: queue, | ||
| dequeue: dequeue, | ||
| getStorage: getLocalStorage, | ||
| getFirst: getFirst, | ||
| refreshStorage: getStorage, | ||
| clear: clear, | ||
| }; | ||
| }; | ||
|
|
||
| return self; | ||
|
|
||
| }(ActionTracker || {})); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| var ActionTracker = (function(self) { | ||
| self.TimeSeed = function() { | ||
| var seedDate = new Date(); | ||
|
|
||
| function getTimeSeed() { | ||
| seedDate.setSeconds(seedDate.getSeconds() + 1); | ||
| return seedDate; | ||
| } | ||
|
|
||
| return { | ||
| getTimeSeed: getTimeSeed | ||
| }; | ||
| }; | ||
|
|
||
| return self; | ||
|
|
||
| }(ActionTracker || {})); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| var ActionTracker = (function(self) { | ||
|
|
||
| self.Tracker = function(trackerData, cfgOptions, callbacks) { | ||
| var userFlag = false, | ||
| user = null, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'user' is defined but never used. |
||
| options = null, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'options' is defined but never used. |
||
| data = null, | ||
| dataFlag = false, | ||
| logoutFlag = false; | ||
|
|
||
| if(typeof cfgOptions !== 'undefined') { | ||
| options = cfgOptions; | ||
| } | ||
|
|
||
| if(typeof trackerData !== 'undefined') { | ||
| if(typeof trackerData.identify !== 'undefined') { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'trackerData' is not defined. |
||
| userFlag = true; | ||
| user = new self.User(trackerData.identify, callbacks); | ||
| } | ||
| if(typeof trackerData.track !== 'undefined') { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'trackerData' is not defined. |
||
| dataFlag = true; | ||
| data = trackerData.track; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'trackerData' is not defined. |
||
| if(options.timestamp) { | ||
| data.created_at = options.seed.getTimeSeed(); | ||
| } | ||
| } | ||
| if(trackerData.logout) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'trackerData' is not defined. |
||
| logoutFlag = true; | ||
| } | ||
| } | ||
|
|
||
| function send() { | ||
| if(userFlag) { | ||
| callbacks.identify(user.getData()); | ||
| } | ||
| if(dataFlag) { | ||
| callbacks.track(data, function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'callbacks' is not defined. |
||
| if(logoutFlag) { | ||
| callbacks.logout(); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| send: send | ||
| }; | ||
| }; | ||
|
|
||
| return self; | ||
|
|
||
| }(ActionTracker || {})); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| var ActionTracker = (function(self) { | ||
|
|
||
| self.User = function(userData, userCallbacks) { | ||
| var data = userData, | ||
| callbacks = userCallbacks; | ||
|
|
||
| data.id = callbacks.generateID(data.email); | ||
|
|
||
| function getData() { | ||
| return data; | ||
| } | ||
|
|
||
| function getCallbacks() { | ||
| return callbacks; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
|
|
||
| return { | ||
| getData: getData, | ||
| getCallbacks: getCallbacks | ||
| }; | ||
| }; | ||
|
|
||
| return self; | ||
|
|
||
| }(ActionTracker || {})); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'userFlag' is defined but never used.