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
The following commit(s) were added to refs/heads/FLAGON-469 by this push:
new 1df7a3c [FLAGON-483, 486] fixed issues with examples that prevented
them from being indexed. Fixed issue with toolName not properly writing to log.
1df7a3c is described below
commit 1df7a3c540157ba9083166db41d29b37a815fc75
Author: poorejc <[email protected]>
AuthorDate: Thu Jan 30 00:05:23 2020 -0500
[FLAGON-483, 486] fixed issues with examples that prevented them from being
indexed. Fixed issue with toolName not properly writing to log.
---
build/UserAleWebExtension/content.js | 8 ++++----
build/userale-2.1.0.js | 15 ++++++--------
build/userale-2.1.0.min.js | 2 +-
example/index.html | 2 +-
example/index.js | 25 +++++++++++++----------
example/webpackUserAleExample/dist/main.js | 4 ++--
example/webpackUserAleExample/index.js | 32 ++++++++++++++++++------------
example/webpackUserAleExample/package.json | 2 +-
src/getInitialSettings.js | 4 ++--
src/packageLogs.js | 7 ++-----
10 files changed, 52 insertions(+), 49 deletions(-)
diff --git a/build/UserAleWebExtension/content.js
b/build/UserAleWebExtension/content.js
index 6f60307..c63e083 100644
--- a/build/UserAleWebExtension/content.js
+++ b/build/UserAleWebExtension/content.js
@@ -99,8 +99,8 @@ 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;
- settings.custIndex = get ('data-index') || null;
+ settings.authHeader = get('data-auth') || null;
+ settings.custIndex = get('data-index') || null;
return settings;
}
@@ -461,7 +461,7 @@ function initPackager(newLogs, newConfig) {
}
/**
- * Transforms the provided event into a log and appends it to the log
container.
+ * Transforms the provided HTML event into a log and appends it to the log
queue.
* @param {Object} e The event to be logged.
* @param {Function} detailFcn The function to extract additional log
parameters from the event.
* @return {boolean} Whether the event was logged.
@@ -499,7 +499,7 @@ function packageLog(e, detailFcn) {
'toolVersion' : config.version,
'toolName' : config.toolName,
'useraleVersion': config.useraleVersion,
- 'sessionID': config.sessionID
+ 'sessionID': config.sessionID,
};
if ((typeof filterHandler === 'function') && !filterHandler(log)) {
diff --git a/build/userale-2.1.0.js b/build/userale-2.1.0.js
index b45e366..67be8a7 100644
--- a/build/userale-2.1.0.js
+++ b/build/userale-2.1.0.js
@@ -73,8 +73,8 @@
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;
- settings.custIndex = get ('data-index') || null;
+ settings.authHeader = get('data-auth') || null;
+ settings.custIndex = get('data-index') || null;
return settings;
}
@@ -443,7 +443,7 @@
}
/**
- * Transforms the provided event into a log and appends it to the log
container.
+ * Transforms the provided HTML event into a log and appends it to the log
queue.
* @param {Object} e The event to be logged.
* @param {Function} detailFcn The function to extract additional log
parameters from the event.
* @return {boolean} Whether the event was logged.
@@ -481,7 +481,7 @@
'toolVersion' : config.version,
'toolName' : config.toolName,
'useraleVersion': config.useraleVersion,
- 'sessionID': config.sessionID
+ 'sessionID': config.sessionID,
};
if ((typeof filterHandler === 'function') && !filterHandler(log)) {
@@ -498,7 +498,7 @@
}
/**
- * Packages the provided customLog to include standard meta data and appends
it to the log container.
+ * Packages the provided customLog to include standard meta data and appends
it to the log queue.
* @param {Object} customLog The behavior to be logged.
* @param {Function} detailFcn The function to extract additional log
parameters from the event.
* @param {boolean} userAction Indicates user behavior (true) or system
behavior (false)
@@ -514,15 +514,12 @@
details = detailFcn();
}
- var timeFields = extractTimeFields(Date.now());
-
var metaData = {
'pageUrl': window.location.href,
'pageTitle': document.title,
'pageReferrer': document.referrer,
'browser': detectBrowser$1(),
- 'clientTime' : timeFields.milli,
- 'microTime' : timeFields.micro,
+ 'clientTime' : Date.now(),
'scrnRes' : getSreenRes(),
'logType': 'custom',
'userAction' : userAction,
diff --git a/build/userale-2.1.0.min.js b/build/userale-2.1.0.min.js
index 05c5065..a68fbb8 100644
--- a/build/userale-2.1.0.min.js
+++ b/build/userale-2.1.0.min.js
@@ -15,4 +15,4 @@
* limitations under the License.
* @preserved
*/
-!function(e,n){"object"==typeof exports&&"undefined"!=typeof
module?n(exports):"function"==typeof
define&&define.amd?define(["exports"],n):n((e=e||self).userale={})}(this,function(t){"use
strict";var e="2.1.0",r=null;function
n(t,o){Object.keys(o).forEach(function(e){if("userFromParams"===e){var
n=function(e){var n=new
RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),t=window.location.href.match(n);return
t&&t[2]?decodeURIComponent(t[2].replace(/\+/g,"
")):null}(o[e]);n&&(t.userId=n)}t[e]=o[e]})}var [...]
\ No newline at end of file
+!function(e,n){"object"==typeof exports&&"undefined"!=typeof
module?n(exports):"function"==typeof
define&&define.amd?define(["exports"],n):n((e=e||self).userale={})}(this,function(t){"use
strict";var e="2.1.0",r=null;function
n(t,o){Object.keys(o).forEach(function(e){if("userFromParams"===e){var
n=function(e){var n=new
RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),t=window.location.href.match(n);return
t&&t[2]?decodeURIComponent(t[2].replace(/\+/g,"
")):null}(o[e]);n&&(t.userId=n)}t[e]=o[e]})}var [...]
\ No newline at end of file
diff --git a/example/index.html b/example/index.html
index 7b647cc..ab59944 100644
--- a/example/index.html
+++ b/example/index.html
@@ -21,7 +21,7 @@ limitations under the License.
src="../build/userale-2.1.0.min.js"
data-url="http://localhost:8000/"
data-user="example-user"
- data-log-details="true" <!--careful! 'true' will give you keys and
inputs-->
+ data-log-details="true"
data-version="2.1.0"
data-tool="Apache UserALE.js Example"
></script>
diff --git a/example/index.js b/example/index.js
index 89d9d89..67699c2 100644
--- a/example/index.js
+++ b/example/index.js
@@ -15,13 +15,15 @@
*
* the 'options' API allows you to dynamically change UserALE.js params and
set meta data values
* pass in variables or properties into the options object, such as from
sessionStorage or localStorage
+ * NOTE: logDetails is set to true (default:false), this will log key strokes,
inputs, and change events
+ * (be careful of your form data and auth workflows!)
*/
const changeMe = "me";
window.userale.options({
- "userId": changeMe,
- "version": "next",
- "logDetails": false,
- "sessionID": "this one"
+ 'userId': changeMe,
+ 'logDetails': true,
+ 'sessionID': 'this one',
+ 'toolName': 'Apache UserALE.js Example (Custom)'
});
/**Filter API
@@ -49,7 +51,7 @@ document.addEventListener('click', function(e){
window.userale.map(function (log) {
return Object.assign({}, log, { logType: 'custom', customLabel:
'map & packageLog Example' });
});
- window.userale.packageLog(e,
window.userale.details(window.userale.options(),'click'));
+ window.userale.packageLog(e,
window.userale.details(window.userale.options(),e.type));
/**you'll want to reset the map callback function, or set a
conditional (e.g., return log), else
* the callback may be applied to other events of the same class
(e.g., click) */
window.userale.map();
@@ -84,18 +86,19 @@ document.addEventListener('change', function(e) {
window.userale.log({
target: window.userale.getSelector(e.target),
path: window.userale.buildPath(e),
+ clientTime: Date.now(),
type: e.type,
logType: 'custom',
userAction: false,
- details: 'I can make this log look like anything I want',
- customField1: 'foo',
- customField2: 'bar',
+ details: {'foo': 'bar', 'bar': 'foo'},
+ customField1: 'I can make this log look like anything I want',
+ customField2: 'foo',
userId: window.userale.options().userId,
toolVersion: window.userale.options().version,
toolName: window.userale.options().toolName,
useraleVersion: window.userale.options().useraleVersion,
sessionID: window.userale.options().sessionID,
- customLabel: "(custom) Log Example"
+ customLabel: "Custom Log Example"
});
}
});
@@ -115,7 +118,7 @@ document.addEventListener('change', function(e){
}
});
/**You can also use the details function to package additional log
meta data, or add custom details*/
- window.userale.packageLog(e,
window.userale.details(window.userale.options(),'change'));
+ window.userale.packageLog(e,
window.userale.details(window.userale.options(),e.type));
} else {
return false
}
@@ -130,7 +133,7 @@ document.addEventListener('change', function(e) {
customLabel: 'packageCustomLog Example',
customField1: 'foo',
customField2: 'bar'},
- function(){return 'add additional details here!'},
+ function(){return {'foo': 'bar', 'bar': 'foo'}},
true
);
} else {
diff --git a/example/webpackUserAleExample/dist/main.js
b/example/webpackUserAleExample/dist/main.js
index 2919a82..49d3665 100644
--- a/example/webpackUserAleExample/dist/main.js
+++ b/example/webpackUserAleExample/dist/main.js
@@ -94,7 +94,7 @@
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var
flagon_userale__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
flagon-userale */
\"./node_modules/flagon-userale/build/userale-2.1.0.js\");\n/* harmony import
*/ var flagon_userale__WEBPACK_IMPORTED_MODULE_0___default =
/*#__PURE__*/__webpack_require__.n(flagon_userale__WEBPACK_IMPORTED_MODULE_0__);\n//
Licensed to the Apache Software Foundation (ASF) under one or more\n//
contributor license agreements. [...]
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var
flagon_userale__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
flagon-userale */
\"./node_modules/flagon-userale/build/userale-2.1.0.js\");\n/* harmony import
*/ var flagon_userale__WEBPACK_IMPORTED_MODULE_0___default =
/*#__PURE__*/__webpack_require__.n(flagon_userale__WEBPACK_IMPORTED_MODULE_0__);\n//
Licensed to the Apache Software Foundation (ASF) under one or more\n//
contributor license agreements. [...]
/***/ }),
@@ -105,7 +105,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/*
harmony import */ var flag
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
-eval("/* WEBPACK VAR INJECTION */(function(global, process) {/**\n * Licensed
to the Apache Software Foundation (ASF) under one or more\n * contributor
license agreements. See the NOTICE file distributed with\n * this work for
additional information regarding copyright ownership.\n * The ASF licenses this
file to You under the Apache License, Version 2.0\n * (the \"License\"); you
may not use this file except in compliance with\n * the License. You may
obtain a copy of the License at\n [...]
+eval("/* WEBPACK VAR INJECTION */(function(global, process) {/**\n * Licensed
to the Apache Software Foundation (ASF) under one or more\n * contributor
license agreements. See the NOTICE file distributed with\n * this work for
additional information regarding copyright ownership.\n * The ASF licenses this
file to You under the Apache License, Version 2.0\n * (the \"License\"); you
may not use this file except in compliance with\n * the License. You may
obtain a copy of the License at\n [...]
/***/ }),
diff --git a/example/webpackUserAleExample/index.js
b/example/webpackUserAleExample/index.js
index 17f61cd..6743502 100644
--- a/example/webpackUserAleExample/index.js
+++ b/example/webpackUserAleExample/index.js
@@ -21,14 +21,19 @@ import * as userale from 'flagon-userale';
*
* the 'options' API allows you to dynamically change UserALE.js params and
set meta data values
* pass in variables or properties into the options object, such as from
sessionStorage or localStorage
+ * NOTE1: if you are using userale in a package bundler, you will need to set
options via this API, including
+ * "url" to tell userale where to send your logs!
+ * NOTE2: logDetails is set to true (default:false), this will log key
strokes, inputs, and change events
+ * (be careful of your form data and auth workflows!)
*/
const changeMe = "me";
userale.options({
- "userId": changeMe,
- "url": "http://localhost:8000/",
- "version": "next",
- "logDetails": false,
- "sessionID": "this one"
+ 'userId': changeMe,
+ 'url': 'http://localhost:8000/',
+ 'version': '2.1.1',
+ 'logDetails': true,
+ 'sessionID': 'this one',
+ 'toolName': 'Apache UserALE.js Example (Custom)'
});
/**Filter API
@@ -41,7 +46,7 @@ userale.options({
* the same is true for the 'map' API. See examples below:
*/
userale.filter(function (log) {
- var type_array = ['mouseup', 'mouseover', 'mousedown', 'keydown',
'dblclick', 'blur', 'focus', 'input', 'wheel'];
+ var type_array = ['mouseup', 'mouseover', 'mousedown', 'keydown',
'dblclick', 'blur', 'focus', 'input', 'wheel', 'scroll'];
var logType_array = ['interval'];
return !type_array.includes(log.type) &&
!logType_array.includes(log.logType);
});
@@ -56,7 +61,7 @@ document.addEventListener('click', function(e){
userale.map(function (log) {
return Object.assign({}, log, { logType: 'custom', customLabel:
'map & packageLog Example' });
});
- userale.packageLog(e, userale.details(userale.options(),'click'));
+ userale.packageLog(e, userale.details(userale.options(),e.type));
/**you'll want to reset the map callback function, or set a
conditional (e.g., return log), else
* the callback may be applied to other events of the same class
(e.g., click) */
userale.map();
@@ -91,18 +96,19 @@ document.addEventListener('change', function(e) {
userale.log({
target: userale.getSelector(e.target),
path: userale.buildPath(e),
+ clientTime: Date.now(),
type: e.type,
logType: 'custom',
userAction: false,
- details: 'I can make this log look like anything I want',
- customField1: 'foo',
- customField2: 'bar',
+ details: {'foo': 'bar', 'bar': 'foo'},
+ customField1: 'I can make this log look like anything I want',
+ customField2: 'foo',
userId: userale.options().userId,
toolVersion: userale.options().version,
toolName: userale.options().toolName,
useraleVersion: userale.options().useraleVersion,
sessionID: userale.options().sessionID,
- customLabel: "(custom) Log Example"
+ customLabel: "Custom Log Example"
});
}
});
@@ -122,7 +128,7 @@ document.addEventListener('change', function(e){
}
});
/**You can also use the details function to package additional log
meta data, or add custom details*/
- userale.packageLog(e, userale.details(userale.options(),'change'));
+ userale.packageLog(e, userale.details(userale.options(),e.type));
} else {
return false
}
@@ -137,7 +143,7 @@ document.addEventListener('change', function(e) {
customLabel: 'packageCustomLog Example',
customField1: 'foo',
customField2: 'bar'},
- function(){return 'add additional details here!'},
+ function(){return {'foo': 'bar', 'bar': 'foo'}},
true
);
} else {
diff --git a/example/webpackUserAleExample/package.json
b/example/webpackUserAleExample/package.json
index b39662a..f78a178 100755
--- a/example/webpackUserAleExample/package.json
+++ b/example/webpackUserAleExample/package.json
@@ -38,7 +38,7 @@
"npm": "6.4.1 || 6.7.0 - 6.10.0 || 6.13.1"
},
"dependencies": {
- "flagon-userale": "2.1.0"
+ "flagon-userale": "^2.1.0"
},
"devDependencies": {
"webpack": "^4.41.5",
diff --git a/src/getInitialSettings.js b/src/getInitialSettings.js
index 7982846..4b04d6f 100644
--- a/src/getInitialSettings.js
+++ b/src/getInitialSettings.js
@@ -47,8 +47,8 @@ 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;
- settings.custIndex = get ('data-index') || null;
+ settings.authHeader = get('data-auth') || null;
+ settings.custIndex = get('data-index') || null;
return settings;
}
diff --git a/src/packageLogs.js b/src/packageLogs.js
index 26ad1ed..e571943 100644
--- a/src/packageLogs.js
+++ b/src/packageLogs.js
@@ -106,7 +106,7 @@ export function packageLog(e, detailFcn) {
'toolVersion' : config.version,
'toolName' : config.toolName,
'useraleVersion': config.useraleVersion,
- 'sessionID': config.sessionID
+ 'sessionID': config.sessionID,
};
if ((typeof filterHandler === 'function') && !filterHandler(log)) {
@@ -139,15 +139,12 @@ export function packageCustomLog(customLog, detailFcn,
userAction) {
details = detailFcn();
}
- var timeFields = extractTimeFields(Date.now());
-
var metaData = {
'pageUrl': window.location.href,
'pageTitle': document.title,
'pageReferrer': document.referrer,
'browser': detectBrowser(),
- 'clientTime' : timeFields.milli,
- 'microTime' : timeFields.micro,
+ 'clientTime' : Date.now(),
'scrnRes' : getSreenRes(),
'logType': 'custom',
'userAction' : userAction,