You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@senssoft.apache.org by rf...@apache.org on 2017/09/18 17:28:06 UTC
[01/21] incubator-senssoft-useralejs git commit: Lifted mouse event
handler and event type lists outside of the define function
Repository: incubator-senssoft-useralejs
Updated Branches:
refs/heads/SENSSOFT-192 1b6433951 -> 7087e06fc
Lifted mouse event handler and event type lists outside of the define function
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/722f103d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/722f103d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/722f103d
Branch: refs/heads/SENSSOFT-192
Commit: 722f103d142d27c340a29d3088b6b86d45615437
Parents: d193255
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 08:42:56 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 08:42:56 2017 -0700
----------------------------------------------------------------------
src/attachHandlers.js | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/722f103d/src/attachHandlers.js
----------------------------------------------------------------------
diff --git a/src/attachHandlers.js b/src/attachHandlers.js
index 70f3793..f025a4e 100644
--- a/src/attachHandlers.js
+++ b/src/attachHandlers.js
@@ -19,10 +19,25 @@ import { packageLog } from './packageLogs.js';
import { packageIntervalLog } from './packageLogs';
var events;
-var intervalEvents;
var bufferBools;
var bufferedEvents;
-var windowEvents;
+//@todo: Investigate drag events and their behavior
+var intervalEvents = ['click', 'focus', 'blur', 'input', 'change', 'mouseover', 'submit'];
+var windowEvents = ['load', 'blur', 'focus'];
+
+/**
+ * Maps an event to an object containing useful information.
+ * @param {Object} e Event to extract data from
+ */
+function extractMouseEvent(e) {
+ return {
+ 'clicks' : e.detail,
+ 'ctrl' : e.ctrlKey,
+ 'alt' : e.altKey,
+ 'shift' : e.shiftKey,
+ 'meta' : e.metaKey
+ };
+}
/**
* Defines the way information is extracted from various events.
@@ -34,10 +49,10 @@ export function defineDetails(config) {
// Keys are event types
// Values are functions that return details object if applicable
events = {
- 'click' : function(e) { return { 'clicks' : e.detail, 'ctrl' : e.ctrlKey, 'alt' : e.altKey, 'shift' : e.shiftKey, 'meta' : e.metaKey }; },
- 'dblclick' : function(e) { return { 'clicks' : e.detail, 'ctrl' : e.ctrlKey, 'alt' : e.altKey, 'shift' : e.shiftKey, 'meta' : e.metaKey }; },
- 'mousedown' : function(e) { return { 'clicks' : e.detail, 'ctrl' : e.ctrlKey, 'alt' : e.altKey, 'shift' : e.shiftKey, 'meta' : e.metaKey }; },
- 'mouseup' : function(e) { return { 'clicks' : e.detail, 'ctrl' : e.ctrlKey, 'alt' : e.altKey, 'shift' : e.shiftKey, 'meta' : e.metaKey }; },
+ 'click' : extractMouseEvent,
+ 'dblclick' : extractMouseEvent,
+ 'mousedown' : extractMouseEvent,
+ 'mouseup' : extractMouseEvent,
'focus' : null,
'blur' : null,
'input' : config.logDetails ? function(e) { return { 'value' : e.target.value }; } : null,
@@ -57,11 +72,6 @@ export function defineDetails(config) {
'scroll' : function() { return { 'x' : window.scrollX, 'y' : window.scrollY }; },
'resize' : function() { return { 'width' : window.outerWidth, 'height' : window.outerHeight }; }
};
-
- //@todo: Investigate drag events and their behavior
- intervalEvents = ['click', 'focus', 'blur', 'input', 'change', 'mouseover', 'submit'];
-
- windowEvents = ['load', 'blur', 'focus'];
}
/**
[11/21] incubator-senssoft-useralejs git commit: Added eslint-disable
comments until we set up proper globals definitions
Posted by rf...@apache.org.
Added eslint-disable comments until we set up proper globals definitions
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/c426c42e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/c426c42e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/c426c42e
Branch: refs/heads/SENSSOFT-192
Commit: c426c42e8960a45b524fe8bacf29d6b89f4050e8
Parents: 754759f
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:45:00 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:45:00 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/globals.js | 6 +++++-
src/UserALEWebExtension/options.js | 6 ++++--
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/c426c42e/src/UserALEWebExtension/globals.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/globals.js b/src/UserALEWebExtension/globals.js
index 7680769..9e560f5 100644
--- a/src/UserALEWebExtension/globals.js
+++ b/src/UserALEWebExtension/globals.js
@@ -1,6 +1,10 @@
+/* eslint-disable */
+
// these are default values, which can be overridden by the user on the options page
var userAleHost = 'http://localhost:8000';
var userAleScript = 'userale-0.2.1.min.js';
var toolUser = 'nobody';
var toolName = 'test_app';
-var toolVersion = '0.1.0';
\ No newline at end of file
+var toolVersion = '0.1.0';
+
+/* eslint-enable */
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/c426c42e/src/UserALEWebExtension/options.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js
index 16bbb32..c47ca60 100644
--- a/src/UserALEWebExtension/options.js
+++ b/src/UserALEWebExtension/options.js
@@ -1,4 +1,4 @@
-/* eslint-env node */
+/* eslint-disable */
if (chrome) {
browser = chrome;
@@ -41,4 +41,6 @@ function saveOptions(e) {
document.addEventListener("submit", function() {
saveOptions();
-});
\ No newline at end of file
+});
+
+/* eslint-enable */
[12/21] incubator-senssoft-useralejs git commit: Updated build file
to account for separate options/background/content scripts
Posted by rf...@apache.org.
Updated build file to account for separate options/background/content scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/2f0f253e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/2f0f253e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/2f0f253e
Branch: refs/heads/SENSSOFT-192
Commit: 2f0f253e0532d00ebbcc92ae106d87da029d7331
Parents: c426c42
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 14:16:47 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 14:16:47 2017 -0700
----------------------------------------------------------------------
gulpfile.js | 77 ++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/2f0f253e/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index ebe5dab..7e482bc 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -56,35 +56,64 @@ gulp.task('rollup', function() {
});
});
-// Copy the rolled-up userale.js script into the webext dir
-gulp.task('copy-userale-script', ['rollup'], function() {
- return gulp.src('build/' + userale + '.js')
- .pipe(gulp.dest('build/' + userAleWebExtDirName));
-})
+
+// Build the module with Rollup
+gulp.task('rollup-web-ext-content', function() {
+ return rollup({
+ entry : 'src/' + userAleWebExtDirName + '/content.js',
+ plugins : [
+ json()
+ ]
+ })
+ .then(function(bundle) {
+ return bundle.write({
+ moduleName : 'user-ale-ext-content',
+ dest : 'build/' + userAleWebExtDirName + '/content.js'
+ });
+ });
+});
+
+// Build the module with Rollup
+gulp.task('rollup-web-ext-background', function() {
+ return rollup({
+ entry : 'src/' + userAleWebExtDirName + '/background.js',
+ plugins : [
+ json()
+ ]
+ })
+ .then(function(bundle) {
+ return bundle.write({
+ moduleName : 'user-ale-ext-background',
+ dest : 'build/' + userAleWebExtDirName + '/background.js'
+ });
+ });
+});
+
+// Build the module with Rollup
+gulp.task('rollup-web-ext-options', function() {
+ return rollup({
+ entry : 'src/' + userAleWebExtDirName + '/options.js',
+ plugins : [
+ json()
+ ]
+ })
+ .then(function(bundle) {
+ return bundle.write({
+ moduleName : 'user-ale-ext-options',
+ dest : 'build/' + userAleWebExtDirName + '/options.js'
+ });
+ });
+});
// Build for the browser web extension
-gulp.task('build-web-ext', ['copy-userale-script'], function() {
- // We setup some filters so that we can work on specific files from the stream
- const f1 = filter(['**/*.js'], {restore: true});
- const f2 = filter(['**/manifest.json'], {restore: true});
- const f3 = filter(['**/globals.js'], {restore: true});
-
+gulp.task('build-web-ext', ['rollup-web-ext-options', 'rollup-web-ext-background', 'rollup-web-ext-content'], function() {
return gulp.src(['src/' + userAleWebExtDirName + '/icons/**/*.*',
- 'src/' + userAleWebExtDirName + '/*.*',
- '!src/' + userAleWebExtDirName + '/README.md'],
+ 'src/' + userAleWebExtDirName + '/manifest.json',
+ 'src/' + userAleWebExtDirName + '/optionsPage.html'
+ ],
{ base: 'src/' + userAleWebExtDirName + '' })
- .pipe(f1)
- .pipe(minifier({}, uglifyHarmony))
.on('error', gutil.log)
- .pipe(f1.restore)
- .pipe(f2)
- .pipe(jsonModify({ key: "web_accessible_resources", value: [ userale + '.js' ]}))
- .pipe(f2.restore)
- .pipe(f3)
- .pipe(replace(/userAleScript=\".*?\"/g, 'userAleScript=\'' + userale + '.js\''))
- .pipe(f3.restore)
- .pipe(gulp.dest('build/' + userAleWebExtDirName + '/'));
-
+ .pipe(gulp.dest('build/' + userAleWebExtDirName + '/'));
});
// Minify and output completed build
[04/21] incubator-senssoft-useralejs git commit: Fixed issue where
the log queue would still be cleared even if logging was paused
Posted by rf...@apache.org.
Fixed issue where the log queue would still be cleared even if logging was paused
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/782fb868
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/782fb868
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/782fb868
Branch: refs/heads/SENSSOFT-192
Commit: 782fb868ce2711dfbf5a6064a500ae4a636c9d36
Parents: 5aa96f8
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 08:49:38 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 08:49:38 2017 -0700
----------------------------------------------------------------------
src/sendLogs.js | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/782fb868/src/sendLogs.js
----------------------------------------------------------------------
diff --git a/src/sendLogs.js b/src/sendLogs.js
index c2516b9..bbe72a2 100644
--- a/src/sendLogs.js
+++ b/src/sendLogs.js
@@ -33,6 +33,10 @@ export function initSender(logs, config) {
*/
export function sendOnInterval(logs, config) {
setInterval(function() {
+ if (!config.on) {
+ return;
+ }
+
if (logs.length >= config.logCountThreshold) {
sendLogs(logs.slice(0), config.url, 0); // Send a copy
logs.splice(0); // Clear array reference (no reassignment)
[07/21] incubator-senssoft-useralejs git commit: Added tests for
filtering/mapping logs
Posted by rf...@apache.org.
Added tests for filtering/mapping logs
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/0722ed5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/0722ed5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/0722ed5f
Branch: refs/heads/SENSSOFT-192
Commit: 0722ed5f26e7ffc9149234531ee83aa065ee1525
Parents: 35c7272
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:29:27 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:29:27 2017 -0700
----------------------------------------------------------------------
test/packageLogs_spec.js | 130 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 129 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/0722ed5f/test/packageLogs_spec.js
----------------------------------------------------------------------
diff --git a/test/packageLogs_spec.js b/test/packageLogs_spec.js
index 7d3af1b..3cf33a4 100644
--- a/test/packageLogs_spec.js
+++ b/test/packageLogs_spec.js
@@ -18,13 +18,40 @@ import { expect } from 'chai';
import jsdom from 'jsdom';
import fs from 'fs';
import {
- packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath
+ packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
+ filterHandler, mapHandler, setLogFilter, setLogMapper, logs
} from '../src/packageLogs';
describe('packageLogs', () => {
const url = 'file://' + __dirname + '/packageLogs.html';
const html = fs.readFileSync(__dirname + '/packageLogs.html');
+ describe('setLogFilter', () => {
+ it('assigns the handler to the provided value', () => {
+ const func = x => true;
+ setLogFilter(func);
+ expect(filterHandler).to.equal(func);
+ });
+ it('allows the handler to be nulled', () => {
+ setLogFilter(x => true);
+ setLogFilter(null);
+ expect(filterHandler).to.equal(null);
+ });
+ });
+
+ describe('setLogMapper', () => {
+ it('assigns the handler to the provided value', () => {
+ const func = x => true;
+ setLogMapper(func);
+ expect(mapHandler).to.equal(func);
+ });
+ it('allows the handler to be nulled', () => {
+ setLogMapper(x => true);
+ setLogMapper(null);
+ expect(mapHandler).to.equal(null);
+ });
+ });
+
describe('packageLog', () => {
it('only executes if on', (done) => {
initPackager([], { on: true });
@@ -57,6 +84,107 @@ describe('packageLogs', () => {
expect(packageLog(evt)).to.equal(true);
done();
});
+
+ it('filters logs when a handler is assigned and returns false', () => {
+ let filterCalled = false;
+ const filter = (log) => {
+ filterCalled = true;
+ return false;
+ };
+
+ const evt = {
+ target: {},
+ type: 'test',
+ };
+
+ initPackager([], { on: true });
+ packageLog(evt);
+
+ expect(logs.length).to.equal(1);
+
+ setLogFilter(filter);
+ packageLog(evt);
+
+ expect(logs.length).to.equal(1);
+ });
+
+ it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
+ let mapperCalled = false;
+
+ const mappedLog = { type: 'foo' };
+ const mapper = (log) => {
+ mapperCalled = true;
+ return mappedLog;
+ };
+
+ const evt = {
+ target: {},
+ type: 'test',
+ };
+
+ initPackager([], { on: true });
+
+ setLogMapper(mapper);
+ packageLog(evt);
+
+ expect(mapperCalled).to.equal(true);
+ expect(logs.indexOf(mappedLog)).to.equal(0);
+ });
+
+ it('does not call the map handler if the log is filtered out', () => {
+ let mapperCalled = false;
+ const filter = () => false;
+ const mapper = (log) => {
+ mapperCalled = true;
+ return log;
+ };
+
+ const evt = {
+ target: {},
+ type: 'test',
+ };
+
+ initPackager([], { on: true });
+ setLogFilter(filter);
+ setLogMapper(mapper);
+
+ packageLog(evt);
+
+ expect(mapperCalled).to.equal(false);
+ });
+
+ it('does not attempt to call a non-function filter/mapper', () => {
+ let filterCalled = false;
+ let mapperCalled = false;
+ const filter = () => {
+ filterCalled = true;
+ return true;
+ };
+ const mapper = (log) => {
+ mapperCalled = true;
+ return log;
+ };
+
+ const evt = {
+ target: {},
+ type: 'test',
+ };
+
+ initPackager([], { on: true });
+ setLogFilter(filter);
+ setLogMapper(mapper);
+
+ packageLog(evt);
+
+ expect(filterCalled).to.equal(true);
+ expect(mapperCalled).to.equal(true);
+
+ setLogFilter('foo');
+ setLogMapper('bar');
+
+ packageLog(evt);
+ expect(logs.length).to.equal(2);
+ });
});
describe('getLocation', () => {
[05/21] incubator-senssoft-useralejs git commit: Removed type check
to allow clearing the handler by passing a non-function
Posted by rf...@apache.org.
Removed type check to allow clearing the handler by passing a non-function
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/8e4a9ed5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/8e4a9ed5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/8e4a9ed5
Branch: refs/heads/SENSSOFT-192
Commit: 8e4a9ed56d7c06079cebbcf31c71a54a55391ce4
Parents: 782fb86
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 08:56:19 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 08:56:19 2017 -0700
----------------------------------------------------------------------
src/packageLogs.js | 14 --------------
1 file changed, 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/8e4a9ed5/src/packageLogs.js
----------------------------------------------------------------------
diff --git a/src/packageLogs.js b/src/packageLogs.js
index 3a5d9b3..8e27d28 100644
--- a/src/packageLogs.js
+++ b/src/packageLogs.js
@@ -32,31 +32,17 @@ var mapHandler = null;
/**
* Assigns a handler to filter logs out of the queue.
* @param {Function} callback The handler to invoke when logging.
- * @return {boolean} Whether the operation succeeded.
*/
export function setLogFilter(callback) {
- if (typeof callback !== 'function') {
- return false;
- }
-
filterHandler = callback;
-
- return true;
}
/**
* Assigns a handler to transform logs from their default structure.
* @param {Function} callback The handler to invoke when logging.
- * @return {boolean} Whether the operation succeeded.
*/
export function setLogMapper(callback) {
- if (typeof callback !== 'function') {
- return false;
- }
-
mapHandler = callback;
-
- return true;
}
[10/21] incubator-senssoft-useralejs git commit: Updated tests to
make sure config is on. Added tests for disabling logging
Posted by rf...@apache.org.
Updated tests to make sure config is on. Added tests for disabling logging
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/754759f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/754759f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/754759f7
Branch: refs/heads/SENSSOFT-192
Commit: 754759f70600c2fce0a9d5dd9082decbccbbd9c0
Parents: c66536b
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:42:35 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:42:35 2017 -0700
----------------------------------------------------------------------
test/sendLogs_spec.js | 71 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 68 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/754759f7/test/sendLogs_spec.js
----------------------------------------------------------------------
diff --git a/test/sendLogs_spec.js b/test/sendLogs_spec.js
index 5da5157..5bde8f8 100644
--- a/test/sendLogs_spec.js
+++ b/test/sendLogs_spec.js
@@ -23,7 +23,7 @@ describe('sendLogs', () => {
it('sends logs on an interval', (done) => {
let requests = 0;
const originalXMLHttpRequest = global.XMLHttpRequest;
- const conf = { transmitInterval: 500, url: 'test', logCountThreshold: 2 };
+ const conf = { on: true, transmitInterval: 500, url: 'test', logCountThreshold: 2 };
const logs = [];
const clock = sinon.useFakeTimers();
const xhr = sinon.useFakeXMLHttpRequest();
@@ -52,6 +52,39 @@ describe('sendLogs', () => {
global.XMLHttpRequest = originalXMLHttpRequest;
done();
});
+
+ it('does not send logs if the config is off', (done) => {
+ let requests = 0;
+ const originalXMLHttpRequest = global.XMLHttpRequest;
+ const conf = { on: true, transmitInterval: 500, url: 'test', logCountThreshold: 1 };
+ const logs = [];
+ const clock = sinon.useFakeTimers();
+ const xhr = sinon.useFakeXMLHttpRequest();
+ global.XMLHttpRequest = xhr;
+ xhr.onCreate = () => { requests++; };
+
+ sendOnInterval(logs, conf);
+
+ // Make sure it respects the logCountThreshold
+ logs.push({ foo: 'bar1' });
+ clock.tick(conf.transmitInterval);
+
+ expect(logs.length).to.equal(0);
+ expect(requests).to.equal(1);
+
+ conf.on = false;
+
+ logs.push({ foo: 'bar2' });
+ clock.tick(conf.transmitInterval);
+ expect(logs.length).to.equal(1);
+ expect(requests).to.equal(1);
+
+ xhr.restore();
+ clock.restore();
+ global.XMLHttpRequest = originalXMLHttpRequest;
+ done();
+ });
+
it('sends logs on page exit with navigator', (done) => {
const html = `<html><head></head><body></body></html>`;
jsdom.env({
@@ -69,7 +102,7 @@ describe('sendLogs', () => {
const evt = window.document.createEvent('CustomEvent');
evt.initEvent('unload', true, true);
- sendOnClose([{ foo: 'bar' }], { url: 'test' });
+ sendOnClose([{ foo: 'bar' }], { on: true, url: 'test' });
window.dispatchEvent(evt);
window.close();
@@ -99,7 +132,7 @@ describe('sendLogs', () => {
const evt = window.document.createEvent('CustomEvent');
evt.initEvent('beforeunload', true, true);
- sendOnClose([{ foo: 'bar' }], { url: 'test' });
+ sendOnClose([{ foo: 'bar' }], { on: true, url: 'test' });
window.dispatchEvent(evt);
window.close();
@@ -112,4 +145,36 @@ describe('sendLogs', () => {
}
});
});
+
+ it('does not send logs on page exit if config is off', (done) => {
+ const html = `<html><head></head><body></body></html>`;
+ jsdom.env({
+ html,
+ done: (err, window) => {
+ const originalNavigator = global.navigator;
+ const originalXMLHttpRequest = global.XMLHttpRequest;
+ const originalWindow = global.window;
+ let requests = 0;
+ const xhr = sinon.useFakeXMLHttpRequest();
+ global.XMLHttpRequest = xhr;
+ global.window = window;
+ global.XMLHttpRequest = xhr;
+ global.navigator = { sendBeacon: false, };
+ xhr.onCreate = () => { requests++; };
+
+ const evt = window.document.createEvent('CustomEvent');
+ evt.initEvent('beforeunload', true, true);
+ sendOnClose([{ foo: 'bar' }], { on: false, url: 'test' });
+
+ window.dispatchEvent(evt);
+ window.close();
+
+ expect(requests).to.equal(0);
+ global.window = originalWindow;
+ global.navigator = originalNavigator;
+ global.XMLHttpRequest = originalXMLHttpRequest;
+ done();
+ }
+ });
+ });
});
[02/21] incubator-senssoft-useralejs git commit: Added hooks for
dynamically transforming and filtering event/interval logs as they arrive
Posted by rf...@apache.org.
Added hooks for dynamically transforming and filtering event/interval logs as they arrive
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/bab30eac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/bab30eac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/bab30eac
Branch: refs/heads/SENSSOFT-192
Commit: bab30eacc54dee7b0b549ff0342267959f4cbabe
Parents: 722f103
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 08:44:33 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 08:44:33 2017 -0700
----------------------------------------------------------------------
src/packageLogs.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/bab30eac/src/packageLogs.js
----------------------------------------------------------------------
diff --git a/src/packageLogs.js b/src/packageLogs.js
index 8daa91a..3a5d9b3 100644
--- a/src/packageLogs.js
+++ b/src/packageLogs.js
@@ -26,6 +26,39 @@ var intervalTimer;
var intervalCounter;
var intervalLog;
+var filterHandler = null;
+var mapHandler = null;
+
+/**
+ * Assigns a handler to filter logs out of the queue.
+ * @param {Function} callback The handler to invoke when logging.
+ * @return {boolean} Whether the operation succeeded.
+ */
+export function setLogFilter(callback) {
+ if (typeof callback !== 'function') {
+ return false;
+ }
+
+ filterHandler = callback;
+
+ return true;
+}
+
+/**
+ * Assigns a handler to transform logs from their default structure.
+ * @param {Function} callback The handler to invoke when logging.
+ * @return {boolean} Whether the operation succeeded.
+ */
+export function setLogMapper(callback) {
+ if (typeof callback !== 'function') {
+ return false;
+ }
+
+ mapHandler = callback;
+
+ return true;
+}
+
/**
* Assigns the config and log container to be used by the logging functions.
@@ -75,6 +108,14 @@ export function packageLog(e, detailFcn) {
'sessionID': config.sessionID
};
+ if (typeof filterHandler === 'function' && !filterHandler(log)) {
+ return false;
+ }
+
+ if (typeof mapHandler === 'function') {
+ log = mapHandler(log);
+ }
+
logs.push(log);
return true;
@@ -123,6 +164,14 @@ export function packageIntervalLog(e) {
'sessionID': config.sessionID
};
+ if (typeof filterHandler === 'function' && !filterHandler(intervalLog)) {
+ return false;
+ }
+
+ if (typeof mapHandler === 'function') {
+ intervalLog = mapHandler(intervalLog);
+ }
+
logs.push(intervalLog);
// Reset
[14/21] incubator-senssoft-useralejs git commit: Initial commit for
content and background scripts, as well as message type constants
Posted by rf...@apache.org.
Initial commit for content and background scripts, as well as message type constants
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/ed63be82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/ed63be82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/ed63be82
Branch: refs/heads/SENSSOFT-192
Commit: ed63be82bd36408aaa76c7cf3b28368ee8ee5b6b
Parents: 5178927
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 14:18:17 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 14:18:17 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/background.js | 32 ++++++++++++++
src/UserALEWebExtension/content.js | 63 ++++++++++++++++++++++++++++
src/UserALEWebExtension/messageTypes.js | 3 ++
3 files changed, 98 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ed63be82/src/UserALEWebExtension/background.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js
new file mode 100644
index 0000000..a8e3ddd
--- /dev/null
+++ b/src/UserALEWebExtension/background.js
@@ -0,0 +1,32 @@
+/*
+ eslint-disable
+ */
+
+import * as globals from './globals';
+import * as MessageTypes from './messageTypes.js';
+
+// inherent dependency on globals.js, loaded by the webext
+
+// browser is defined in firefox, but not in chrome. In chrome, they use
+// the 'chrome' global instead. Let's map it to browser so we don't have
+// to have if-conditions all over the place.
+
+var browser = browser || chrome;
+
+function onError(error) {
+ console.log(error);
+}
+
+browser.runtime.onMessage.addListener(function (message) {
+ switch (message.type) {
+ case MessageTypes.CONFIG_CHANGE:
+ console.log('got config ', message.payload);
+ break;
+ default:
+ console.log('got unknown message type ', message);
+ }
+});
+
+/*
+ eslint-enable
+ */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ed63be82/src/UserALEWebExtension/content.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/content.js b/src/UserALEWebExtension/content.js
new file mode 100644
index 0000000..3bf2fda
--- /dev/null
+++ b/src/UserALEWebExtension/content.js
@@ -0,0 +1,63 @@
+/*
+ eslint-disable
+ */
+
+import * as globals from './globals';
+import * as MessageTypes from './messageTypes.js';
+import { map, options, start } from '../main.js';
+
+// inherent dependency on globals.js, loaded by the webext
+
+// browser is defined in firefox, but not in chrome. In chrome, they use
+// the 'chrome' global instead. Let's map it to browser so we don't have
+// to have if-conditions all over the place.
+
+var browser = browser || chrome;
+
+// creates a Future for retrieval of the named keys
+// the value specified is the default value if one doesn't exist in the storage
+let store = browser.storage.local.get({
+ userAleHost: globals.userAleHost,
+ userAleScript: globals.userAleScript,
+ toolUser: globals.toolUser,
+ toolName: globals.toolName,
+ toolVersion: globals.toolVersion,
+}, storeCallback);
+
+function storeCallback(item) {
+ injectScript({
+ url: item.userAleHost,
+ userId: item.toolUser,
+ toolName: item.toolName,
+ toolVersion: item.toolVersion
+ });
+}
+
+function onError(error) {
+ console.log(error);
+}
+
+function injectScript(config) {
+ options(config);
+ start();
+ map(function(log) {
+ return Object.assign({}, log, {
+ pageUrl: document.location.href,
+ });
+ });
+}
+
+browser.runtime.onMessage.addListener(function (message) {
+ if (message.type === MessageTypes.CONFIG_CHANGE) {
+ options({
+ url: message.payload.userAleHost,
+ userId: message.payload.toolUser,
+ toolName: message.payload.toolName,
+ toolVersion: message.payload.toolVersion
+ });
+ }
+});
+
+/*
+ eslint-enable
+ */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ed63be82/src/UserALEWebExtension/messageTypes.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/messageTypes.js b/src/UserALEWebExtension/messageTypes.js
new file mode 100644
index 0000000..907d072
--- /dev/null
+++ b/src/UserALEWebExtension/messageTypes.js
@@ -0,0 +1,3 @@
+var prefix = 'USERALE_';
+
+export var CONFIG_CHANGE = prefix + 'CONFIG_CHANGE';
[13/21] incubator-senssoft-useralejs git commit: Removed single file
to change to separate inline content scripts
Posted by rf...@apache.org.
Removed single file to change to separate inline content scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/51789278
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/51789278
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/51789278
Branch: refs/heads/SENSSOFT-192
Commit: 51789278068ec595304d11ffa2738c8cf1daaae1
Parents: 2f0f253
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 14:17:40 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 14:17:40 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/user-ale-ext.js | 58 ----------------------------
1 file changed, 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/51789278/src/UserALEWebExtension/user-ale-ext.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/user-ale-ext.js b/src/UserALEWebExtension/user-ale-ext.js
deleted file mode 100644
index b421c5e..0000000
--- a/src/UserALEWebExtension/user-ale-ext.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- eslint-disable
- */
-
-// inherent dependency on globals.js, loaded by the webext
-
-// browser is defined in firefox, but not in chrome. In chrome, they use
-// the 'chrome' global instead. Let's map it to browser so we don't have
-// to have if-conditions all over the place.
-if (chrome) {
- browser = chrome;
-}
-
-// creates a Future for retrieval of the named keys
-// the value specified is the default value if one doesn't exist in the storage
-let store = browser.storage.local.get({
- userAleHost: userAleHost,
- userAleScript: userAleScript,
- toolUser: toolUser,
- toolName: toolName,
- toolVersion: toolVersion,
-}, storeCallback);
-
-function storeCallback(item) {
- console.log(item);
- userAleHost = item.userAleHost;
- userAleScript = item.userAleScript;
- toolUser = item.toolUser;
- toolName = item.toolName;
- toolVersion = item.toolVersion;
- injectScript();
-}
-
-function onError(error) {
- console.log(error);
-}
-
-function injectScript() {
- var userAleTag = document.createElement("script");
- userAleTag.type = "text/javascript";
- userAleTag.setAttribute("id", "userale-plugin");
- userAleTag.setAttribute("data-url", userAleHost);
- userAleTag.setAttribute("data-autostart", true);
- userAleTag.setAttribute("data-user", toolUser);
- userAleTag.setAttribute("data-tool", toolName);
- userAleTag.setAttribute("data-version", toolVersion);
- userAleTag.src = browser.extension.getURL(userAleScript);
-
- console.log("Injecting UserALE script into current page! " + userAleHost + " " + userAleScript);
-
- document.head.appendChild(userAleTag);
- // document.body.innerHTML += "<br/><br/>SUCCESS! UserALE has been injected onto the page!";
-}
-
-
-/*
- eslint-enable
- */
\ No newline at end of file
[17/21] incubator-senssoft-useralejs git commit: Updated to log a
bunch of meta tab information and set a global session id to be used by
content scripts
Posted by rf...@apache.org.
Updated to log a bunch of meta tab information and set a global session id to be used by content scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/857c6741
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/857c6741
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/857c6741
Branch: refs/heads/SENSSOFT-192
Commit: 857c6741a7bda418c74fbb97f69dbd6645359215
Parents: a31e513
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 16:01:27 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 16:01:27 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/background.js | 129 +++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/857c6741/src/UserALEWebExtension/background.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js
index 307ed07..a4ce487 100644
--- a/src/UserALEWebExtension/background.js
+++ b/src/UserALEWebExtension/background.js
@@ -4,6 +4,9 @@
import * as globals from './globals';
import * as MessageTypes from './messageTypes.js';
+import { timeStampScale } from '../getInitialSettings.js';
+import { initPackager, packageLog } from '../packageLogs.js';
+import { initSender } from '../sendLogs.js';
// inherent dependency on globals.js, loaded by the webext
@@ -12,6 +15,41 @@ import * as MessageTypes from './messageTypes.js';
// to have if-conditions all over the place.
var browser = browser || chrome;
+var logs = [];
+var config = {
+ autostart: true,
+ url: 'http://localhost:8000',
+ transmitInterval: 5000,
+ logCountThreshold: 5,
+ userId: null,
+ version: null,
+ resolution: 500,
+ time: timeStampScale({}),
+ on: true,
+};
+var sessionId = 'session_' + Date.now();
+browser.storage.local.set({ sessionId: sessionId });
+
+let store = browser.storage.local.get({
+ userAleHost: globals.userAleHost,
+ userAleScript: globals.userAleScript,
+ toolUser: globals.toolUser,
+ toolName: globals.toolName,
+ toolVersion: globals.toolVersion,
+}, storeCallback);
+
+function storeCallback(item) {
+ config = Object.assign({}, config, {
+ url: item.userAleHost,
+ userId: item.toolUser,
+ sessionID: sessionId,
+ toolName: item.toolName,
+ toolVersion: item.toolVersion
+ });
+
+ initPackager(logs, config);
+ initSender(logs, config);
+}
function dispatchTabMessage(message) {
browser.tabs.query({}, function (tabs) {
@@ -21,9 +59,35 @@ function dispatchTabMessage(message) {
});
}
+function packageBrowserLog(type, logDetail) {
+ logs.push({
+ 'target' : null,
+ 'path' : null,
+ 'clientTime' : Date.now(),
+ 'location' : null,
+ 'type' : 'browser.' + type,
+ 'logType': 'raw',
+ 'userAction' : true,
+ 'details' : logDetail,
+ 'userId' : globals.userId,
+ 'toolVersion': null,
+ 'toolName': null,
+ 'useraleVersion': null,
+ 'sessionID': sessionId,
+ });
+}
+
browser.runtime.onMessage.addListener(function (message) {
switch (message.type) {
case MessageTypes.CONFIG_CHANGE:
+ const updatedConfig = Object.assign({}, config, {
+ url: message.payload.userAleHost,
+ userId: message.payload.toolUser,
+ toolName: message.payload.toolName,
+ toolVersion: message.payload.toolVersion
+ });
+ initPackager(logs, updatedConfig);
+ initSender(logs, updatedConfig);
dispatchTabMessage(message);
break;
default:
@@ -31,6 +95,71 @@ browser.runtime.onMessage.addListener(function (message) {
}
});
+function getTabDetailById(tabId, onReady) {
+ browser.tabs.get(tabId, function (tab) {
+ onReady({
+ active: tab.active,
+ audible: tab.audible,
+ incognito: tab.incognito,
+ index: tab.index,
+ muted: tab.mutedInfo ? tab.mutedInfo.muted : null,
+ pinned: tab.pinned,
+ selected: tab.selected,
+ tabId: tab.id,
+ title: tab.title,
+ url: tab.url,
+ windowId: tab.windowId,
+ });
+ });
+}
+
+browser.tabs.onActivated.addListener(function (e) {
+ getTabDetailById(e.tabId, function (detail) {
+ packageBrowserLog('tabs.onActivated', detail);
+ });
+});
+
+browser.tabs.onCreated.addListener(function (tab, e) {
+ packageBrowserLog('tabs.onCreated', {
+ active: tab.active,
+ audible: tab.audible,
+ incognito: tab.incognito,
+ index: tab.index,
+ muted: tab.mutedInfo ? tab.mutedInfo.muted : null,
+ pinned: tab.pinned,
+ selected: tab.selected,
+ tabId: tab.id,
+ title: tab.title,
+ url: tab.url,
+ windowId: tab.windowId,
+ });
+});
+
+browser.tabs.onDetached.addListener(function (tabId) {
+ getTabDetailById(tabId, function (detail) {
+ packageBrowserLog('tabs.onDetached', detail);
+ });
+});
+
+browser.tabs.onMoved.addListener(function (tabId) {
+ getTabDetailById(tabId, function (detail) {
+ packageBrowserLog('tabs.onMoved', detail);
+ });
+});
+
+browser.tabs.onRemoved.addListener(function (tabId) {
+ packageBrowserLog('tabs.onRemoved', { tabId: tabId });
+});
+
+browser.tabs.onZoomChange.addListener(function (e) {
+ getTabDetailById(e.tabId, function (detail) {
+ packageBrowserLog('tabs.onZoomChange', Object.assign({}, {
+ oldZoomFactor: e.oldZoomFactor,
+ newZoomFactor: e.newZoomFactor,
+ }, detail));
+ });
+});
+
/*
eslint-enable
*/
\ No newline at end of file
[16/21] incubator-senssoft-useralejs git commit: Updated to properly
pass messages to tabs
Posted by rf...@apache.org.
Updated to properly pass messages to tabs
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/a31e5138
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/a31e5138
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/a31e5138
Branch: refs/heads/SENSSOFT-192
Commit: a31e51389f6b8433986103f59baf4bd2e10ec55a
Parents: e69812c
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 14:40:21 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 14:40:21 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/background.js | 12 ++++++++----
src/UserALEWebExtension/content.js | 4 ----
src/UserALEWebExtension/options.js | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/a31e5138/src/UserALEWebExtension/background.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js
index a8e3ddd..307ed07 100644
--- a/src/UserALEWebExtension/background.js
+++ b/src/UserALEWebExtension/background.js
@@ -12,15 +12,19 @@ import * as MessageTypes from './messageTypes.js';
// to have if-conditions all over the place.
var browser = browser || chrome;
-
-function onError(error) {
- console.log(error);
+
+function dispatchTabMessage(message) {
+ browser.tabs.query({}, function (tabs) {
+ tabs.forEach(function (tab) {
+ browser.tabs.sendMessage(tab.id, message);
+ });
+ });
}
browser.runtime.onMessage.addListener(function (message) {
switch (message.type) {
case MessageTypes.CONFIG_CHANGE:
- console.log('got config ', message.payload);
+ dispatchTabMessage(message);
break;
default:
console.log('got unknown message type ', message);
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/a31e5138/src/UserALEWebExtension/content.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/content.js b/src/UserALEWebExtension/content.js
index 3bf2fda..1749144 100644
--- a/src/UserALEWebExtension/content.js
+++ b/src/UserALEWebExtension/content.js
@@ -32,10 +32,6 @@ function storeCallback(item) {
toolVersion: item.toolVersion
});
}
-
-function onError(error) {
- console.log(error);
-}
function injectScript(config) {
options(config);
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/a31e5138/src/UserALEWebExtension/options.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js
index 78edc23..0f101cb 100644
--- a/src/UserALEWebExtension/options.js
+++ b/src/UserALEWebExtension/options.js
@@ -47,4 +47,4 @@ document.addEventListener("submit", function() {
saveOptions();
});
- /* eslint-enable */
+/* eslint-enable */
[19/21] incubator-senssoft-useralejs git commit: Updated to be able
to cancel/enable send interval
Posted by rf...@apache.org.
Updated to be able to cancel/enable send interval
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/ead656f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/ead656f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/ead656f6
Branch: refs/heads/SENSSOFT-192
Commit: ead656f6974f92cf9b82b50b1dccd10427bb5973
Parents: 4b7adcc
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 16:02:00 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 16:02:00 2017 -0700
----------------------------------------------------------------------
src/sendLogs.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ead656f6/src/sendLogs.js
----------------------------------------------------------------------
diff --git a/src/sendLogs.js b/src/sendLogs.js
index c311c46..8f1bc86 100644
--- a/src/sendLogs.js
+++ b/src/sendLogs.js
@@ -15,13 +15,19 @@
* limitations under the License.
*/
+var sendIntervalId = null;
+
/**
* Initializes the log queue processors.
* @param {Array} logs Array of logs to append to.
* @param {Object} config Configuration object to use when logging.
*/
export function initSender(logs, config) {
- sendOnInterval(logs, config);
+ if (sendIntervalId !== null) {
+ clearInterval(sendIntervalId);
+ }
+
+ sendIntervalId = sendOnInterval(logs, config);
sendOnClose(logs, config);
}
@@ -30,9 +36,10 @@ export function initSender(logs, config) {
* if the queue has reached the threshold specified by the provided config.
* @param {Array} logs Array of logs to read from.
* @param {Object} config Configuration object to be read from.
+ * @return {Number} The newly created interval id.
*/
export function sendOnInterval(logs, config) {
- setInterval(function() {
+ return setInterval(function() {
if (!config.on) {
return;
}
[18/21] incubator-senssoft-useralejs git commit: Updated to use
global session id
Posted by rf...@apache.org.
Updated to use global session id
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/4b7adcc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/4b7adcc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/4b7adcc7
Branch: refs/heads/SENSSOFT-192
Commit: 4b7adcc7903d5530e02e15011e237bfc7e69c22f
Parents: 857c674
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 16:01:36 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 16:01:36 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/content.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/4b7adcc7/src/UserALEWebExtension/content.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/content.js b/src/UserALEWebExtension/content.js
index 1749144..7dfd37c 100644
--- a/src/UserALEWebExtension/content.js
+++ b/src/UserALEWebExtension/content.js
@@ -6,8 +6,6 @@ import * as globals from './globals';
import * as MessageTypes from './messageTypes.js';
import { map, options, start } from '../main.js';
-// inherent dependency on globals.js, loaded by the webext
-
// browser is defined in firefox, but not in chrome. In chrome, they use
// the 'chrome' global instead. Let's map it to browser so we don't have
// to have if-conditions all over the place.
@@ -17,6 +15,7 @@ var browser = browser || chrome;
// creates a Future for retrieval of the named keys
// the value specified is the default value if one doesn't exist in the storage
let store = browser.storage.local.get({
+ sessionId: null,
userAleHost: globals.userAleHost,
userAleScript: globals.userAleScript,
toolUser: globals.toolUser,
@@ -28,6 +27,7 @@ function storeCallback(item) {
injectScript({
url: item.userAleHost,
userId: item.toolUser,
+ sessionID: item.sessionId,
toolName: item.toolName,
toolVersion: item.toolVersion
});
[21/21] incubator-senssoft-useralejs git commit: Merge branch
'browser-logging' into SENSSOFT-192
Posted by rf...@apache.org.
Merge branch 'browser-logging' into SENSSOFT-192
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/7087e06f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/7087e06f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/7087e06f
Branch: refs/heads/SENSSOFT-192
Commit: 7087e06fcdaa04b49e52f141c776c435a9571208
Parents: aa62945 ead656f
Author: Rob Foley <ro...@gmail.com>
Authored: Mon Sep 18 13:27:42 2017 -0400
Committer: Rob Foley <ro...@gmail.com>
Committed: Mon Sep 18 13:27:42 2017 -0400
----------------------------------------------------------------------
gulpfile.js | 77 +++++++++----
src/UserALEWebExtension/background.js | 165 +++++++++++++++++++++++++++
src/UserALEWebExtension/content.js | 59 ++++++++++
src/UserALEWebExtension/globals.js | 10 +-
src/UserALEWebExtension/manifest.json | 19 +--
src/UserALEWebExtension/messageTypes.js | 3 +
src/UserALEWebExtension/options.js | 54 +++++----
src/UserALEWebExtension/user-ale-ext.js | 58 ----------
src/sendLogs.js | 11 +-
9 files changed, 329 insertions(+), 127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/7087e06f/gulpfile.js
----------------------------------------------------------------------
[20/21] incubator-senssoft-useralejs git commit: Merge branch
'SENSSOFT-192' of
https://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs into
SENSSOFT-192
Posted by rf...@apache.org.
Merge branch 'SENSSOFT-192' of https://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs into SENSSOFT-192
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/aa629458
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/aa629458
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/aa629458
Branch: refs/heads/SENSSOFT-192
Commit: aa629458dc60bdc30c0594f6f2c56e956978b543
Parents: c426c42 1b64339
Author: Rob Foley <ro...@gmail.com>
Authored: Mon Sep 18 13:27:11 2017 -0400
Committer: Rob Foley <ro...@gmail.com>
Committed: Mon Sep 18 13:27:11 2017 -0400
----------------------------------------------------------------------
.gitignore | 1 +
CHANGELOG.md | 36 +++++++++++++++++++--
DISCLAIMER | 7 ++++
NOTICE | 2 +-
README.md | 35 +++++++++++++-------
doap-userale.js.rdf | 57 ++++++++++++++++++++++++++++++++
gulpfile.js | 1 -
package.json | 4 +--
src/UserALEWebExtension/README.md | 59 +++++++++++++++-------------------
9 files changed, 150 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
[09/21] incubator-senssoft-useralejs git commit: Updated sendOnClose
to not send logs if config is off
Posted by rf...@apache.org.
Updated sendOnClose to not send logs if config is off
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/c66536b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/c66536b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/c66536b1
Branch: refs/heads/SENSSOFT-192
Commit: c66536b1ebcb94ecd64801db6a64a7d5ccbe08da
Parents: d96a174
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:41:23 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:41:23 2017 -0700
----------------------------------------------------------------------
src/sendLogs.js | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/c66536b1/src/sendLogs.js
----------------------------------------------------------------------
diff --git a/src/sendLogs.js b/src/sendLogs.js
index bbe72a2..c311c46 100644
--- a/src/sendLogs.js
+++ b/src/sendLogs.js
@@ -50,6 +50,10 @@ export function sendOnInterval(logs, config) {
* @param {Object} config Configuration object to be read from.
*/
export function sendOnClose(logs, config) {
+ if (!config.on) {
+ return;
+ }
+
if (navigator.sendBeacon) {
window.addEventListener('unload', function() {
navigator.sendBeacon(config.url, JSON.stringify(logs));
[15/21] incubator-senssoft-useralejs git commit: Updated to log via
the content script,
without injecting a tag. Switched to using background/content scripts
Posted by rf...@apache.org.
Updated to log via the content script, without injecting a tag. Switched to using background/content scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/e69812c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/e69812c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/e69812c4
Branch: refs/heads/SENSSOFT-192
Commit: e69812c44f0ebb35ee61f3216c2a0d7cd48646db
Parents: ed63be8
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 14:18:48 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 14:18:48 2017 -0700
----------------------------------------------------------------------
src/UserALEWebExtension/globals.js | 10 +++---
src/UserALEWebExtension/manifest.json | 19 ++++------
src/UserALEWebExtension/options.js | 56 ++++++++++++++++--------------
3 files changed, 41 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/globals.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/globals.js b/src/UserALEWebExtension/globals.js
index 9e560f5..10e05c1 100644
--- a/src/UserALEWebExtension/globals.js
+++ b/src/UserALEWebExtension/globals.js
@@ -1,10 +1,10 @@
/* eslint-disable */
// these are default values, which can be overridden by the user on the options page
-var userAleHost = 'http://localhost:8000';
-var userAleScript = 'userale-0.2.1.min.js';
-var toolUser = 'nobody';
-var toolName = 'test_app';
-var toolVersion = '0.1.0';
+export var userAleHost = 'http://localhost:8000';
+export var userAleScript = 'userale-0.2.1.min.js';
+export var toolUser = 'nobody';
+export var toolName = 'test_app';
+export var toolVersion = '0.1.0';
/* eslint-enable */
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/manifest.json
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/manifest.json b/src/UserALEWebExtension/manifest.json
index d0a6688..208f8d4 100644
--- a/src/UserALEWebExtension/manifest.json
+++ b/src/UserALEWebExtension/manifest.json
@@ -9,27 +9,20 @@
"permissions": [
"activeTab",
"storage",
- "http://localhost:8080/",
- "http://localhost:8000/",
- "http://localhost/*",
- "http://localhost/",
- "*://draperlaboratory.github.io/"
- ],
- "web_accessible_resources": [
- "userale-0.2.1.min.js"
+ "tabs"
],
+ "background": {
+ "scripts": ["background.js"]
+ },
"content_scripts": [
{
"matches": [
"<all_urls>"
],
- "js": [
- "globals.js",
- "user-ale-ext.js"
- ]
+ "js": ["content.js"]
}
],
"options_ui": {
- "page": "optionsPage.html"
+ "page": "optionsPage.html"
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/options.js
----------------------------------------------------------------------
diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js
index c47ca60..78edc23 100644
--- a/src/UserALEWebExtension/options.js
+++ b/src/UserALEWebExtension/options.js
@@ -1,46 +1,50 @@
/* eslint-disable */
+import * as globals from './globals.js';
+import * as MessageTypes from './messageTypes.js';
if (chrome) {
- browser = chrome;
+ browser = chrome;
}
// creates a Future for retrieval of the named keys
// the value specified is the default value if one doesn't exist in the storage
let store = browser.storage.local.get({
- userAleHost: userAleHost,
- userAleScript: userAleScript,
- toolUser: toolUser,
- toolName: toolName,
- toolVersion: toolVersion,
+ userAleHost: globals.userAleHost,
+ userAleScript: globals.userAleScript,
+ toolUser: globals.toolUser,
+ toolName: globals.toolName,
+ toolVersion: globals.toolVersion,
}, storeCallback);
-
+
function storeCallback(item) {
- console.log(item);
- document.getElementById("host").value = item.userAleHost;
- document.getElementById("clientScript").value = item.userAleScript;
- document.getElementById("toolUser").value = item.toolUser;
- document.getElementById("toolName").value = item.toolName;
- document.getElementById("toolVersion").value = item.toolVersion;
+ console.log(item);
+ document.getElementById("host").value = item.userAleHost;
+ document.getElementById("clientScript").value = item.userAleScript;
+ document.getElementById("toolUser").value = item.toolUser;
+ document.getElementById("toolName").value = item.toolName;
+ document.getElementById("toolVersion").value = item.toolVersion;
}
-
+
function onError(error) {
- console.log(error);
+ console.log(error);
}
function saveOptions(e) {
- //e.preventDefault();
- browser.storage.local.set({
- userAleHost: document.getElementById("host").value,
- userAleScript: document.getElementById("clientScript").value,
- toolUser: document.getElementById("toolUser").value,
- toolName: document.getElementById("toolName").value,
- toolVersion: document.getElementById("toolVersion").value,
-
- });
+ const updatedConfig = {
+ userAleHost: document.getElementById("host").value,
+ userAleScript: document.getElementById("clientScript").value,
+ toolUser: document.getElementById("toolUser").value,
+ toolName: document.getElementById("toolName").value,
+ toolVersion: document.getElementById("toolVersion").value,
+ };
+
+ browser.storage.local.set(updatedConfig);
+
+ browser.runtime.sendMessage({ type: MessageTypes.CONFIG_CHANGE, payload: updatedConfig });
}
document.addEventListener("submit", function() {
- saveOptions();
+ saveOptions();
});
-/* eslint-enable */
+ /* eslint-enable */
[08/21] incubator-senssoft-useralejs git commit: Updated tests to
account for interval logs
Posted by rf...@apache.org.
Updated tests to account for interval logs
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/d96a174f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/d96a174f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/d96a174f
Branch: refs/heads/SENSSOFT-192
Commit: d96a174f405a84b1b53f1470fe422a1457719742
Parents: 0722ed5
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:29:56 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:29:56 2017 -0700
----------------------------------------------------------------------
test/attachHandlers_spec.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/d96a174f/test/attachHandlers_spec.js
----------------------------------------------------------------------
diff --git a/test/attachHandlers_spec.js b/test/attachHandlers_spec.js
index 743b9f8..e63a097 100644
--- a/test/attachHandlers_spec.js
+++ b/test/attachHandlers_spec.js
@@ -29,8 +29,13 @@ describe('attachHandlers', () => {
'input', 'change', 'dragstart', 'dragend', 'drag', 'drop',
'keydown', 'mouseover', 'submit'
];
+
// List of supported window events
const missingWindowEvents = ['wheel', 'scroll', 'resize', 'load', 'blur', 'focus'];
+
+ // List of supported interval events
+ const missingIntervalEvents = ['click', 'focus', 'blur', 'input', 'change', 'mouseover', 'submit'];
+
// Acts as a kind of Proxy for addEventListener. Keeps track of added listeners.
const listenerHook = eventList => (ev) => {
const evIndex = eventList.indexOf(ev);
@@ -40,13 +45,17 @@ describe('attachHandlers', () => {
duplicateEvents++;
}
};
+
+ const missingDocumentAndIntervalEvents = missingDocumentEvents.concat(missingIntervalEvents);
+
// MOCK
- global.document = { addEventListener: listenerHook(missingDocumentEvents) };
+ global.document = { addEventListener: listenerHook(missingDocumentAndIntervalEvents) };
global.window = { addEventListener: listenerHook(missingWindowEvents) };
attachHandlers({ logDetails: true });
expect(duplicateEvents).to.equal(0);
- expect(missingDocumentEvents.length).to.equal(0);
+ expect(missingDocumentAndIntervalEvents.length).to.equal(0);
expect(missingWindowEvents.length).to.equal(0);
+
// UNMOCK
global.document = initialDocument;
global.window = initialWindow;
[03/21] incubator-senssoft-useralejs git commit: Added re-export of
filter/map functions to expose as part of API
Posted by rf...@apache.org.
Added re-export of filter/map functions to expose as part of API
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/5aa96f8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/5aa96f8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/5aa96f8b
Branch: refs/heads/SENSSOFT-192
Commit: 5aa96f8bdce27211ffb5d7ccce19ac3105cd2fd1
Parents: bab30ea
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 08:45:48 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 08:45:48 2017 -0700
----------------------------------------------------------------------
src/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/5aa96f8b/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index da14d9e..28fe622 100644
--- a/src/main.js
+++ b/src/main.js
@@ -25,7 +25,7 @@ import { initSender } from './sendLogs.js';
var config = {};
var logs = [];
export var started = false;
-
+export { setLogMapper as map, setLogFilter as filter } from './packageLogs.js';
// Start up Userale
config.on = false;
[06/21] incubator-senssoft-useralejs git commit: Added exports for
logs and handlers to make testing easier
Posted by rf...@apache.org.
Added exports for logs and handlers to make testing easier
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/35c7272c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/35c7272c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/35c7272c
Branch: refs/heads/SENSSOFT-192
Commit: 35c7272c2944ee99fb10352edf31c273010606c9
Parents: 8e4a9ed
Author: Rob Foley <ro...@gmail.com>
Authored: Wed Sep 13 09:28:59 2017 -0700
Committer: Rob Foley <ro...@gmail.com>
Committed: Wed Sep 13 09:28:59 2017 -0700
----------------------------------------------------------------------
src/packageLogs.js | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/35c7272c/src/packageLogs.js
----------------------------------------------------------------------
diff --git a/src/packageLogs.js b/src/packageLogs.js
index 8e27d28..12a5374 100644
--- a/src/packageLogs.js
+++ b/src/packageLogs.js
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-var logs;
+export var logs;
var config;
// Interval Logging Globals
@@ -26,8 +26,8 @@ var intervalTimer;
var intervalCounter;
var intervalLog;
-var filterHandler = null;
-var mapHandler = null;
+export var filterHandler = null;
+export var mapHandler = null;
/**
* Assigns a handler to filter logs out of the queue.
@@ -54,6 +54,8 @@ export function setLogMapper(callback) {
export function initPackager(newLogs, newConfig) {
logs = newLogs;
config = newConfig;
+ filterHandler = null;
+ mapHandler = null;
intervalID = null;
intervalType = null;
intervalPath = null;
@@ -94,7 +96,7 @@ export function packageLog(e, detailFcn) {
'sessionID': config.sessionID
};
- if (typeof filterHandler === 'function' && !filterHandler(log)) {
+ if ((typeof filterHandler === 'function') && !filterHandler(log)) {
return false;
}