This is an automated email from the ASF dual-hosted git repository.

poorejc pushed a commit to branch FLAGON-469
in repository https://gitbox.apache.org/repos/asf/incubator-flagon-useralejs.git


View the commit online:
https://github.com/apache/incubator-flagon-useralejs/commit/18bbfe4b4d2ff63c1bb9be0d5951790100676788

The following commit(s) were added to refs/heads/FLAGON-469 by this push:
     new 18bbfe4  [FLAGON-471] WIP auth headers and todos
18bbfe4 is described below

commit 18bbfe4b4d2ff63c1bb9be0d5951790100676788
Author: poorejc <[email protected]>
AuthorDate: Wed Nov 20 22:47:42 2019 -0500

    [FLAGON-471] WIP auth headers and todos
---
 build/UserAleWebExtension/background.js |  5 +++++
 build/UserAleWebExtension/content.js    | 14 +++++++++++---
 build/userale-2.0.2.js                  | 14 +++++++++++---
 build/userale-2.0.2.min.js              |  2 +-
 example/aleAPI.js                       |  4 +++-
 src/attachHandlers.js                   |  3 ++-
 src/getInitialSettings.js               |  3 ++-
 src/packageLogs.js                      |  3 ++-
 src/sendLogs.js                         |  7 +++++++
 9 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/build/UserAleWebExtension/background.js 
b/build/UserAleWebExtension/background.js
index ddd48e8..3c3a538 100644
--- a/build/UserAleWebExtension/background.js
+++ b/build/UserAleWebExtension/background.js
@@ -218,9 +218,14 @@ function sendOnClose(logs, config) {
 function sendLogs(logs, url, retries) {
   var req = new XMLHttpRequest();
 
+  // @todo setRequestHeader for Auth
   var data = JSON.stringify(logs);
 
   req.open('POST', url);
+  //if (config.authHeader) {
+  //  req.setRequestHeader('Authorization', config.authHeader)
+  //}
+
   req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
 
   req.onreadystatechange = function() {
diff --git a/build/UserAleWebExtension/content.js 
b/build/UserAleWebExtension/content.js
index 1edd011..f225e95 100644
--- a/build/UserAleWebExtension/content.js
+++ b/build/UserAleWebExtension/content.js
@@ -87,7 +87,7 @@ function getInitialSettings() {
   })();
 
   var get = script ? script.getAttribute.bind(script) : function() { return 
null; };
-
+  // @todo add authHeader setting
   settings.autostart = get('data-autostart') === 'false' ? false : true;
   settings.url = get('data-url') || 'http://localhost:8000';
   settings.transmitInterval = +get('data-interval') || 5000;
@@ -100,6 +100,7 @@ function getInitialSettings() {
   settings.userFromParams = get('data-user-from-params') || null;
   settings.time = timeStampScale(document.createEvent('CustomEvent'));
   settings.sessionID = get('data-session') || sessionId;
+//  settings.authHeader = get ('data-auth') || null;
 
   return settings;
 }
@@ -286,6 +287,7 @@ function packageLog(e, detailFcn) {
     (e.timeStamp && e.timeStamp > 0) ? config.time(e.timeStamp) : Date.now()
   );
 
+  // @todo add host IP in meta data properties
   var log = {
     'target' : getSelector(e.target),
     'path' : buildPath(e),
@@ -311,7 +313,7 @@ function packageLog(e, detailFcn) {
   }
 
   if (typeof mapHandler === 'function') {
-    log = mapHandler(log);
+    log = mapHandler(log, e);
   }
 
   logs.push(log);
@@ -577,9 +579,14 @@ function sendOnClose(logs, config) {
 function sendLogs(logs, url, retries) {
   var req = new XMLHttpRequest();
 
+  // @todo setRequestHeader for Auth
   var data = JSON.stringify(logs);
 
   req.open('POST', url);
+  //if (config.authHeader) {
+  //  req.setRequestHeader('Authorization', config.authHeader)
+  //}
+
   req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
 
   req.onreadystatechange = function() {
@@ -610,7 +617,7 @@ function sendLogs(logs, url, retries) {
  * limitations under the License.
  */
 
-
+// @todo var>let
 var events;
 var bufferBools;
 var bufferedEvents;
@@ -623,6 +630,7 @@ var windowEvents = ['load', 'blur', 'focus'];
  * Maps an event to an object containing useful information.
  * @param  {Object} e Event to extract data from
  */
+// @todo add extract text (inner, by event class) to mouse events
 function extractMouseEvent(e) {
   return {
     'clicks' : e.detail,
diff --git a/build/userale-2.0.2.js b/build/userale-2.0.2.js
index aa1e182..0a47977 100644
--- a/build/userale-2.0.2.js
+++ b/build/userale-2.0.2.js
@@ -58,7 +58,7 @@ var userale = (function (exports) {
     })();
 
     var get = script ? script.getAttribute.bind(script) : function() { return 
null; };
-
+    // @todo add authHeader setting
     settings.autostart = get('data-autostart') === 'false' ? false : true;
     settings.url = get('data-url') || 'http://localhost:8000';
     settings.transmitInterval = +get('data-interval') || 5000;
@@ -71,6 +71,7 @@ var userale = (function (exports) {
     settings.userFromParams = get('data-user-from-params') || null;
     settings.time = timeStampScale(document.createEvent('CustomEvent'));
     settings.sessionID = get('data-session') || sessionId;
+  //  settings.authHeader = get ('data-auth') || null;
 
     return settings;
   }
@@ -265,6 +266,7 @@ var userale = (function (exports) {
       (e.timeStamp && e.timeStamp > 0) ? config.time(e.timeStamp) : Date.now()
     );
 
+    // @todo add host IP in meta data properties
     var log = {
       'target' : getSelector(e.target),
       'path' : buildPath(e),
@@ -290,7 +292,7 @@ var userale = (function (exports) {
     }
 
     if (typeof mapHandler === 'function') {
-      log = mapHandler(log);
+      log = mapHandler(log, e);
     }
 
     logs.push(log);
@@ -556,9 +558,14 @@ var userale = (function (exports) {
   function sendLogs(logs, url, retries) {
     var req = new XMLHttpRequest();
 
+    // @todo setRequestHeader for Auth
     var data = JSON.stringify(logs);
 
     req.open('POST', url);
+    //if (config.authHeader) {
+    //  req.setRequestHeader('Authorization', config.authHeader)
+    //}
+
     req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
 
     req.onreadystatechange = function() {
@@ -589,7 +596,7 @@ var userale = (function (exports) {
    * limitations under the License.
    */
 
-
+  // @todo var>let
   var events;
   var bufferBools;
   var bufferedEvents;
@@ -602,6 +609,7 @@ var userale = (function (exports) {
    * Maps an event to an object containing useful information.
    * @param  {Object} e Event to extract data from
    */
+  // @todo add extract text (inner, by event class) to mouse events
   function extractMouseEvent(e) {
     return {
       'clicks' : e.detail,
diff --git a/build/userale-2.0.2.min.js b/build/userale-2.0.2.min.js
index 8578afd..fcefba3 100644
--- a/build/userale-2.0.2.min.js
+++ b/build/userale-2.0.2.min.js
@@ -15,4 +15,4 @@
  * limitations under the License.
  * @preserved
  */
-var userale=function(n){"use strict";var 
a,i,u,l,s,c,d,f,t="2.0.2",r=null;function 
e(n,o){Object.keys(o).forEach(function(t){if("userFromParams"===t){var 
e=function(t){var e=new 
RegExp("[?&]"+t+"(=([^&#]*)|&|#|$)"),n=window.location.href.match(e);return 
n&&n[2]?decodeURIComponent(n[2].replace(/\+/g," 
")):null}(o[t]);e&&(n.userId=e)}n[t]=o[t]})}var m=null,p=null;function 
o(t,e){if(!i.on)return!1;var n=null;e&&(n=e(t));var 
o=function(t){return{milli:Math.floor(t),micro:Number((t%1).toFixed [...]
\ No newline at end of file
+var userale=function(n){"use strict";var 
a,i,u,l,s,c,d,f,t="2.0.2",r=null;function 
e(n,o){Object.keys(o).forEach(function(t){if("userFromParams"===t){var 
e=function(t){var e=new 
RegExp("[?&]"+t+"(=([^&#]*)|&|#|$)"),n=window.location.href.match(e);return 
n&&n[2]?decodeURIComponent(n[2].replace(/\+/g," 
")):null}(o[t]);e&&(n.userId=e)}n[t]=o[t]})}var m=null,p=null;function 
o(t,e){if(!i.on)return!1;var n=null;e&&(n=e(t));var 
o=function(t){return{milli:Math.floor(t),micro:Number((t%1).toFixed [...]
\ No newline at end of file
diff --git a/example/aleAPI.js b/example/aleAPI.js
index 6172390..51c5f65 100644
--- a/example/aleAPI.js
+++ b/example/aleAPI.js
@@ -17,7 +17,7 @@
 const changeMe = "me";
 window.userale.options({
     "userId": changeMe,
-    "version": "4.2.0",
+    "version": "4.2.1",
     "sessionID": "42"
 });
 
@@ -88,3 +88,5 @@ window.userale.map(function (log) {
     }
 });
 
+// @todo example for extracting text from click events
+
diff --git a/src/attachHandlers.js b/src/attachHandlers.js
index 43b8aba..f56aa2e 100644
--- a/src/attachHandlers.js
+++ b/src/attachHandlers.js
@@ -20,7 +20,7 @@ import { packageLog } from './packageLogs.js';
 import { packageIntervalLog} from './packageLogs';
 import { sendOnRefresh } from "./sendLogs";
 
-
+// @todo var>let
 var events;
 var bufferBools;
 var bufferedEvents;
@@ -33,6 +33,7 @@ var windowEvents = ['load', 'blur', 'focus'];
  * Maps an event to an object containing useful information.
  * @param  {Object} e Event to extract data from
  */
+// @todo add extract text (inner, by event class) to mouse events
 function extractMouseEvent(e) {
   return {
     'clicks' : e.detail,
diff --git a/src/getInitialSettings.js b/src/getInitialSettings.js
index 987d5c8..2514ce2 100644
--- a/src/getInitialSettings.js
+++ b/src/getInitialSettings.js
@@ -35,7 +35,7 @@ export function getInitialSettings() {
   })();
 
   var get = script ? script.getAttribute.bind(script) : function() { return 
null; };
-
+  // @todo add authHeader setting
   settings.autostart = get('data-autostart') === 'false' ? false : true;
   settings.url = get('data-url') || 'http://localhost:8000';
   settings.transmitInterval = +get('data-interval') || 5000;
@@ -48,6 +48,7 @@ export function getInitialSettings() {
   settings.userFromParams = get('data-user-from-params') || null;
   settings.time = timeStampScale(document.createEvent('CustomEvent'));
   settings.sessionID = get('data-session') || sessionId;
+//  settings.authHeader = get ('data-auth') || null;
 
   return settings;
 }
diff --git a/src/packageLogs.js b/src/packageLogs.js
index 81553cf..3702b95 100644
--- a/src/packageLogs.js
+++ b/src/packageLogs.js
@@ -84,6 +84,7 @@ export function packageLog(e, detailFcn) {
     (e.timeStamp && e.timeStamp > 0) ? config.time(e.timeStamp) : Date.now()
   );
 
+  // @todo add host IP in meta data properties
   var log = {
     'target' : getSelector(e.target),
     'path' : buildPath(e),
@@ -109,7 +110,7 @@ export function packageLog(e, detailFcn) {
   }
 
   if (typeof mapHandler === 'function') {
-    log = mapHandler(log);
+    log = mapHandler(log, e);
   }
 
   logs.push(log);
diff --git a/src/sendLogs.js b/src/sendLogs.js
index b057a3e..bd1579c 100644
--- a/src/sendLogs.js
+++ b/src/sendLogs.js
@@ -99,12 +99,19 @@ export function sendOnClose(logs, config) {
  * @param  {string} url     URL to send the POST request to.
  * @param  {Number} retries Maximum number of attempts to send the logs.
  */
+
+// @todo expose config object to sendLogs replate url with config.url
 export function sendLogs(logs, url, retries) {
   var req = new XMLHttpRequest();
 
+  // @todo setRequestHeader for Auth
   var data = JSON.stringify(logs);
 
   req.open('POST', url);
+  //if (config.authHeader) {
+  //  req.setRequestHeader('Authorization', config.authHeader)
+  //}
+
   req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
 
   req.onreadystatechange = function() {

Reply via email to