deleted: dump.rdb modified: config/socket.io.js new file: dump.rdb modified: package.json modified: public/dist/application.js modified: public/dist/application.min.js modified: public/modules/core/services/socket.io.client.service.js modified: public/modules/forms/directives/analytics-service.client.directive.js deleted: dump.rdb
44 lines
842 B
JavaScript
44 lines
842 B
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
// Create the SendVisitorData service
|
|
angular
|
|
.module('forms')
|
|
.factory('SendVisitorData', SendVisitorData);
|
|
|
|
SendVisitorData.$inject = ['Socket', '$state'];
|
|
|
|
function SendVisitorData(Socket, $state) {
|
|
|
|
// Create a controller method for sending visitor data
|
|
function send(form, lastActiveIndex, timeElapsed) {
|
|
|
|
// Create a new message object
|
|
var visitorData = {
|
|
referrer: document.referrer,
|
|
isSubmitted: form.submitted,
|
|
formId: form._id,
|
|
lastActiveField: form.form_fields[lastActiveIndex]._id,
|
|
timeElapsed: timeElapsed
|
|
};
|
|
Socket.emit('form-visitor-data', visitorData);
|
|
}
|
|
|
|
function init(){
|
|
// Make sure the Socket is connected
|
|
if (!Socket.socket) {
|
|
Socket.connect();
|
|
}
|
|
}
|
|
|
|
var service = {
|
|
send: send
|
|
};
|
|
|
|
init();
|
|
return service;
|
|
|
|
}
|
|
}());
|
|
|