Sha256: 8cf7c8f7a667fa6cded02425b8903fabc7805d4866aff391c899089a4a84b288
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
var NutellaMixin = { /** * Stores a user interaction as a document in the MongoDB database. * @param action name of the action fired * @param app_id * @param run_id * @param info additional properties to be stored for the specific interaction */ logAction: function(action, app_id, run_id, info) { var cookie = this.getCookie('roomcast_device'); if(cookie === '') { cookie = (+new Date * Math.random()).toString(36).substring(0, 15); this.setCookie('roomcast_device', cookie, 365); } var date = new Date(); var doc = {}; doc.action = action; doc.app_id = app_id; doc.run_id = run_id; doc.device_id = cookie; doc.time = { timestamp: date, year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate(), time: date.getHours() + ":" +date.getMinutes() + ":" +date.getSeconds() }; doc.info = info; nutella.net.publish('roomcast-log-bot/store', doc); }, setCookie: function(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; }, getCookie: function(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; } }; module.exports = NutellaMixin;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nutella_framework-0.6.18 | framework_components/roomcast-main-app/src/app/components/NutellaMixin.js |