Merge remote-tracking branch 'bitbucket/development' into development
diff --git a/Vagrantfile b/Vagrantfile
index de5709f..276875f 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -3,13 +3,13 @@
     # Setting proxy configurations for the host box. This also sets common proxy settings
     # and files for other applications, such as apt-get/yum
     if Vagrant.has_plugin?("vagrant-proxyconf")
-         config.proxy.http = "http://plcyber06.draper.com:3128"
-         config.proxy.https = "http://plcyber06.draper.com:3128"
-         config.proxy.no_proxy = "localhost, 127.0.0.1"
-     end
+       config.proxy.http = "http://plcyber06.draper.com:3128"
+       config.proxy.https = "http://plcyber06.draper.com:3128"
+       config.proxy.no_proxy = "localhost, 127.0.0.1"
+   end
 
-    config.vm.define "elk" do |elk|
-        elk.vm.box = "ubuntu/trusty64"
+   config.vm.define "elk" do |elk|
+    elk.vm.box = "ubuntu/trusty64"
 
         # Change the default elk vagrant box folder to point to the 
         # elk directory within the project. This will allow separation between
@@ -22,8 +22,8 @@
         # boxes.
         # - Expose the following ports to be used within this box to
         # host data being sent between the web server and the ELK server.
-        elk.vm.network "private_network", ip: "192.168.1.100"
-     
+        elk.vm.network "private_network", ip: "172.16.1.100"
+
         # Provisioner: Runs the provisioning script that will provision
         # the vagrant box for the first time, or forced. 
         elk.vm.provision "shell" do |s| 
@@ -50,12 +50,12 @@
         # Setup a static IP to allow both vagrant boxes to know where 
         # to contact each other. This will allow communication between the
         # web developer and the logging server.
-        dev.vm.network "private_network", ip: "192.168.1.10"
+        dev.vm.network "private_network", ip: "172.16.1.10"
 
         # Specify the provisioning script that will be used in order to 
         # install the necessary files needed for this vagrant box
         dev.vm.provision "shell", inline: "twistd -y /vagrant/twisted_client.py &", 
-            run: "always"
+        run: "always"
 
         # Change the default client vagrant box folder to point to the 
         # client directory within the project. This will allow separation between
diff --git a/helper-libs/javascript/userale-worker.js b/helper-libs/javascript/userale-worker.js
index 1b6c667..b95f3ac 100644
--- a/helper-libs/javascript/userale-worker.js
+++ b/helper-libs/javascript/userale-worker.js
@@ -53,12 +53,12 @@
     // If we don't have any logs to send to the server, just return 
     // back to the caller. There are no actions that need to be done
     // when it comes to logging.
-    else
-    {
-        // If we have debugging enabled, send a debug message saying there
-        // are no logs present to be sent to the logging server.
-        debug('No log sent, buffer empty.');
-    }
+    //else
+    //{
+    //    // If we have debugging enabled, send a debug message saying there
+    //    // are no logs present to be sent to the logging server.
+    //    debug('No log sent, buffer empty.');
+    //}
 }
 
 /**
diff --git a/helper-libs/javascript/userale.coffee b/helper-libs/javascript/userale.coffee
index 81fd280..1fc1f87 100644
--- a/helper-libs/javascript/userale.coffee
+++ b/helper-libs/javascript/userale.coffee
@@ -58,9 +58,6 @@
   'OTHER'
 ]
 
-
-console.log('in userale')
-
 extend = (objects...) ->
   out = {}
   for object in objects
@@ -97,6 +94,23 @@
   meta: {}
 }
 
+setCookie = (cname, cvalue, exdays) ->
+  d = new Date()
+  d.setTime(d.getTime() + (exdays*24*60*60*1000))
+  expires = "expires="+d.toUTCString()
+  document.cookie = cname + "=" + cvalue + "; " + expires
+
+getCookie = (name) ->
+  nameEQ = name + "="
+  ca = document.cookie.split(";")
+  i = 0
+  while i < ca.length
+    c = ca[i]
+    c = c.substring(1, c.length)  while c.charAt(0) is " "
+    return c.substring(nameEQ.length, c.length).replace(/"/g, '')  if c.indexOf(nameEQ) is 0
+    i++
+  ""
+
 class userale
   constructor: (options)->
     @options = extend(defaults, options)
@@ -104,7 +118,7 @@
     if @options.elementGroups.constructor is not Array
       @options.elementGroups = [@options.elementGroups]
 
-    @options.version = '3.0.0'
+    @options.version = '3.0.1'
 
     @worker = new Worker(@options.workerUrl)
 
@@ -117,19 +131,31 @@
     @sendLogs(@options.sendLogs)
 
   register: () ->
-    @options.sessionID = getParameterByName('USID')
-    @options.client = getParameterByName('client')
-
-    console.log(@options.sessionID)
-
-    if !@options.sessionID
+    if getParameterByName('USID')
+      @options.sessionID = getParameterByName('USID')
+      setCookie('USID', @options.sessionID, 2)
+      console.info('USERALE: SESSION ID FOUND IN URL - ' + @options.sessionID)
+    else if getCookie('USID')
+      @options.sessionID = getCookie('USID')
+      console.info('USERALE: SESSION ID FOUND IN COOKIE - ' + @options.sessionID)
+    else
       @options.sessionID = @options.toolName[0..2].toUpperCase() + new Date().getTime()
+      setCookie('USID', @options.sessionID, 2)
       console.warn('USERALE: NO SESSION ID, MAKING ONE UP.  You can pass one in as url parameter (127.0.0.1?USID=12345)')
 
-    if !@options.client
+    if getParameterByName('client')
+      @options.client = getParameterByName('client')
+      setCookie('USERALECLIENT', @options.client, 2)
+      console.info('USERALE: CLIENT FOUND IN URL - ' + @options.client)
+    else if getCookie('USERALECLIENT')
+      @options.client = getCookie('USERALECLIENT')
+      console.info('USERALE: CLIENT FOUND IN COOKIE - ' + @options.client)
+    else
       @options.client = 'UNK'
+      setCookie('USERALECLIENT', @options.client, 2)
       console.warn('USERALE: NO CLIENT, MAKING ONE UP.   You can pass one in as url parameter (127.0.0.1?client=roger)')
 
+
     @worker.postMessage({cmd: 'sendBuffer', msg: ''})
 
     window.onload = =>
diff --git a/helper-libs/javascript/userale.js b/helper-libs/javascript/userale.js
index d8d9d38..48b7725 100644
--- a/helper-libs/javascript/userale.js
+++ b/helper-libs/javascript/userale.js
@@ -1,6 +1,6 @@
-// Generated by CoffeeScript 1.9.1
+// Generated by CoffeeScript 1.9.3
 (function() {
-  var ACTIVITIES, ELEMENTS, default_msg, defaults, extend, getParameterByName, userale,
+  var ACTIVITIES, ELEMENTS, default_msg, defaults, extend, getCookie, getParameterByName, setCookie, userale,
     slice = [].slice,
     indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
 
@@ -8,14 +8,12 @@
 
   ELEMENTS = ['BUTTON', 'CANVAS', 'CHECKBOX', 'COMBOBOX', 'DATAGRID', 'DIALOG_BOX', 'DROPDOWNLIST', 'FRAME', 'ICON', 'INFOBAR', 'LABEL', 'LINK', 'LISTBOX', 'LISTITEM', 'MAP', 'MENU', 'MODALWINDOW', 'PALETTEWINDOW', 'PANEL', 'PROGRESSBAR', 'RADIOBUTTON', 'SLIDER', 'SPINNER', 'STATUSBAR', 'TAB', 'TABLE', 'TAG', 'TEXTBOX', 'THROBBER', 'TOAST', 'TOOLBAR', 'TOOLTIP', 'TREEVIEW', 'WINDOW', 'WORKSPACE', 'OTHER'];
 
-  console.log('in userale');
-
   extend = function() {
-    var i, key, len, object, objects, out, value;
+    var j, key, len, object, objects, out, value;
     objects = 1 <= arguments.length ? slice.call(arguments, 0) : [];
     out = {};
-    for (i = 0, len = objects.length; i < len; i++) {
-      object = objects[i];
+    for (j = 0, len = objects.length; j < len; j++) {
+      object = objects[j];
       for (key in object) {
         value = object[key];
         out[key] = value;
@@ -54,13 +52,39 @@
     meta: {}
   };
 
+  setCookie = function(cname, cvalue, exdays) {
+    var d, expires;
+    d = new Date();
+    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
+    expires = "expires=" + d.toUTCString();
+    return document.cookie = cname + "=" + cvalue + "; " + expires;
+  };
+
+  getCookie = function(name) {
+    var c, ca, i, nameEQ;
+    nameEQ = name + "=";
+    ca = document.cookie.split(";");
+    i = 0;
+    while (i < ca.length) {
+      c = ca[i];
+      while (c.charAt(0) === " ") {
+        c = c.substring(1, c.length);
+      }
+      if (c.indexOf(nameEQ) === 0) {
+        return c.substring(nameEQ.length, c.length).replace(/"/g, '');
+      }
+      i++;
+    }
+    return "";
+  };
+
   userale = (function() {
     function userale(options) {
       this.options = extend(defaults, options);
       if (this.options.elementGroups.constructor === !Array) {
         this.options.elementGroups = [this.options.elementGroups];
       }
-      this.options.version = '3.0.0';
+      this.options.version = '3.0.1';
       this.worker = new Worker(this.options.workerUrl);
       this.worker.postMessage({
         cmd: 'setLoggingUrl',
@@ -71,15 +95,28 @@
     }
 
     userale.prototype.register = function() {
-      this.options.sessionID = getParameterByName('USID');
-      this.options.client = getParameterByName('client');
-      console.log(this.options.sessionID);
-      if (!this.options.sessionID) {
+      if (getParameterByName('USID')) {
+        this.options.sessionID = getParameterByName('USID');
+        setCookie('USID', this.options.sessionID, 2);
+        console.info('USERALE: SESSION ID FOUND IN URL - ' + this.options.sessionID);
+      } else if (getCookie('USID')) {
+        this.options.sessionID = getCookie('USID');
+        console.info('USERALE: SESSION ID FOUND IN COOKIE - ' + this.options.sessionID);
+      } else {
         this.options.sessionID = this.options.toolName.slice(0, 3).toUpperCase() + new Date().getTime();
+        setCookie('USID', this.options.sessionID, 2);
         console.warn('USERALE: NO SESSION ID, MAKING ONE UP.  You can pass one in as url parameter (127.0.0.1?USID=12345)');
       }
-      if (!this.options.client) {
+      if (getParameterByName('client')) {
+        this.options.client = getParameterByName('client');
+        setCookie('USERALECLIENT', this.options.client, 2);
+        console.info('USERALE: CLIENT FOUND IN URL - ' + this.options.client);
+      } else if (getCookie('USERALECLIENT')) {
+        this.options.client = getCookie('USERALECLIENT');
+        console.info('USERALE: CLIENT FOUND IN COOKIE - ' + this.options.client);
+      } else {
         this.options.client = 'UNK';
+        setCookie('USERALECLIENT', this.options.client, 2);
         console.warn('USERALE: NO CLIENT, MAKING ONE UP.   You can pass one in as url parameter (127.0.0.1?client=roger)');
       }
       this.worker.postMessage({
@@ -145,7 +182,7 @@
     };
 
     userale.prototype.log = function(msg) {
-      var activities, activity, i, key, len, value, x;
+      var activities, activity, j, key, len, value, x;
       msg = extend(default_msg, msg);
       for (key in msg) {
         value = msg[key];
@@ -165,17 +202,17 @@
         }
         if (key === 'activity') {
           activities = (function() {
-            var i, len, ref, results1;
+            var j, len, ref, results1;
             ref = value.split('_');
             results1 = [];
-            for (i = 0, len = ref.length; i < len; i++) {
-              x = ref[i];
+            for (j = 0, len = ref.length; j < len; j++) {
+              x = ref[j];
               results1.push(x.toUpperCase());
             }
             return results1;
           })();
-          for (i = 0, len = activities.length; i < len; i++) {
-            activity = activities[i];
+          for (j = 0, len = activities.length; j < len; j++) {
+            activity = activities[j];
             if (indexOf.call(ACTIVITIES, activity) < 0) {
               console.warn("USERALE: Unrecognized activity - " + activity);
             }