You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flagon.apache.org by po...@apache.org on 2021/04/03 02:40:04 UTC
[incubator-flagon-useralejs] branch UncleGedd-sendOnClose updated:
removed unused imports (logs and sendOnRefresh) from attachHandlers
This is an automated email from the ASF dual-hosted git repository.
poorejc pushed a commit to branch UncleGedd-sendOnClose
in repository https://gitbox.apache.org/repos/asf/incubator-flagon-useralejs.git
The following commit(s) were added to refs/heads/UncleGedd-sendOnClose by this push:
new 948cda1 removed unused imports (logs and sendOnRefresh) from attachHandlers
948cda1 is described below
commit 948cda190455c55e411a211a58fac3f2918cf427
Author: poorejc <po...@apache.org>
AuthorDate: Fri Apr 2 22:39:37 2021 -0400
removed unused imports (logs and sendOnRefresh) from attachHandlers
---
build/UserALEWebExtension/content.js | 252 +++++++++++++++++------------------
build/userale-2.1.1.js | 252 +++++++++++++++++------------------
build/userale-2.1.1.min.js | 2 +-
example/index.js | 2 +-
src/attachHandlers.js | 2 -
5 files changed, 254 insertions(+), 256 deletions(-)
diff --git a/build/UserALEWebExtension/content.js b/build/UserALEWebExtension/content.js
index edd2857..0da5ffd 100644
--- a/build/UserALEWebExtension/content.js
+++ b/build/UserALEWebExtension/content.js
@@ -746,132 +746,6 @@ function detectBrowser() {
};
}
-function workerSendLog(e) {
- var _e$data = e.data,
- url = _e$data.url,
- logs = _e$data.logs;
- fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(logs && logs.length > 0 ? logs : [])
- });
-}
-function createWorker(fn) {
- var blob = new Blob(['self.onmessage = ', fn.toString()], {
- type: 'text/javascript'
- });
- var url = URL.createObjectURL(blob);
- return new Worker(url);
-}
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * 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.
- */
-
-function initSender(logs, config) {
- if (sendIntervalId !== null) {
- clearInterval(sendIntervalId);
- }
-
- sendIntervalId = sendOnInterval(logs, config);
- sendOnClose(logs, config);
-}
-/**
- * Checks the provided log array on an interval, flushing the logs
- * 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.
- */
-
-function sendOnInterval(logs, config) {
- return setInterval(function () {
- if (!config.on) {
- return;
- }
-
- if (logs.length >= config.logCountThreshold) {
- sendLogs(logs.slice(0), config, 0); // Send a copy
-
- logs.splice(0); // Clear array reference (no reassignment)
- }
- }, config.transmitInterval);
-}
-/**
- * Attempts to flush the remaining logs when the window is closed.
- * @param {Array} logs Array of logs to be flushed.
- * @param {Object} config Configuration object to be read from.
- */
-
-function sendOnClose(logs, config) {
- if (!config.on) {
- return;
- }
-
- var worker = createWorker(workerSendLog);
- document.addEventListener('visibilitychange', function () {
- if (document.visibilityState === 'hidden' && logs.length > 0) {
- worker.postMessage({
- url: config.url,
- logs: logs
- });
- logs.splice(0, logs.length);
- }
- });
-}
-/**
- * Sends the provided array of logs to the specified url,
- * retrying the request up to the specified number of retries.
- * @param {Array} logs Array of logs to send.
- * @param {string} config configuration parameters (e.g., to extract URL from & 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
-
-function sendLogs(logs, config, retries) {
- var req = new XMLHttpRequest(); // @todo setRequestHeader for Auth
-
- var data = JSON.stringify(logs);
- req.open('POST', config.url);
-
- if (config.authHeader) {
- req.setRequestHeader('Authorization', config.authHeader);
- }
-
- req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
-
- req.onreadystatechange = function () {
- if (req.readyState === 4 && req.status !== 200) {
- if (retries > 0) {
- sendLogs(logs, config, retries--);
- }
- }
- };
-
- req.send(data);
-}
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -1025,6 +899,132 @@ function attachHandlers(config) {
return true;
}
+function workerSendLog(e) {
+ var _e$data = e.data,
+ url = _e$data.url,
+ logs = _e$data.logs;
+ fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(logs && logs.length > 0 ? logs : [])
+ });
+}
+function createWorker(fn) {
+ var blob = new Blob(['self.onmessage = ', fn.toString()], {
+ type: 'text/javascript'
+ });
+ var url = URL.createObjectURL(blob);
+ return new Worker(url);
+}
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * 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.
+ */
+
+function initSender(logs, config) {
+ if (sendIntervalId !== null) {
+ clearInterval(sendIntervalId);
+ }
+
+ sendIntervalId = sendOnInterval(logs, config);
+ sendOnClose(logs, config);
+}
+/**
+ * Checks the provided log array on an interval, flushing the logs
+ * 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.
+ */
+
+function sendOnInterval(logs, config) {
+ return setInterval(function () {
+ if (!config.on) {
+ return;
+ }
+
+ if (logs.length >= config.logCountThreshold) {
+ sendLogs(logs.slice(0), config, 0); // Send a copy
+
+ logs.splice(0); // Clear array reference (no reassignment)
+ }
+ }, config.transmitInterval);
+}
+/**
+ * Attempts to flush the remaining logs when the window is closed.
+ * @param {Array} logs Array of logs to be flushed.
+ * @param {Object} config Configuration object to be read from.
+ */
+
+function sendOnClose(logs, config) {
+ if (!config.on) {
+ return;
+ }
+
+ var worker = createWorker(workerSendLog);
+ document.addEventListener('visibilitychange', function () {
+ if (document.visibilityState === 'hidden' && logs.length > 0) {
+ worker.postMessage({
+ url: config.url,
+ logs: logs
+ });
+ logs.splice(0, logs.length);
+ }
+ });
+}
+/**
+ * Sends the provided array of logs to the specified url,
+ * retrying the request up to the specified number of retries.
+ * @param {Array} logs Array of logs to send.
+ * @param {string} config configuration parameters (e.g., to extract URL from & 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
+
+function sendLogs(logs, config, retries) {
+ var req = new XMLHttpRequest(); // @todo setRequestHeader for Auth
+
+ var data = JSON.stringify(logs);
+ req.open('POST', config.url);
+
+ if (config.authHeader) {
+ req.setRequestHeader('Authorization', config.authHeader);
+ }
+
+ req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
+
+ req.onreadystatechange = function () {
+ if (req.readyState === 4 && req.status !== 200) {
+ if (retries > 0) {
+ sendLogs(logs, config, retries--);
+ }
+ }
+ };
+
+ req.send(data);
+}
+
var config = {};
var logs = [];
var startLoadTimestamp = Date.now();
diff --git a/build/userale-2.1.1.js b/build/userale-2.1.1.js
index 80f8247..bfccd42 100644
--- a/build/userale-2.1.1.js
+++ b/build/userale-2.1.1.js
@@ -748,132 +748,6 @@
};
}
- function workerSendLog(e) {
- var _e$data = e.data,
- url = _e$data.url,
- logs = _e$data.logs;
- fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(logs && logs.length > 0 ? logs : [])
- });
- }
- function createWorker(fn) {
- var blob = new Blob(['self.onmessage = ', fn.toString()], {
- type: 'text/javascript'
- });
- var url = URL.createObjectURL(blob);
- return new Worker(url);
- }
-
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * 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.
- */
-
- function initSender(logs, config) {
- if (sendIntervalId !== null) {
- clearInterval(sendIntervalId);
- }
-
- sendIntervalId = sendOnInterval(logs, config);
- sendOnClose(logs, config);
- }
- /**
- * Checks the provided log array on an interval, flushing the logs
- * 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.
- */
-
- function sendOnInterval(logs, config) {
- return setInterval(function () {
- if (!config.on) {
- return;
- }
-
- if (logs.length >= config.logCountThreshold) {
- sendLogs(logs.slice(0), config, 0); // Send a copy
-
- logs.splice(0); // Clear array reference (no reassignment)
- }
- }, config.transmitInterval);
- }
- /**
- * Attempts to flush the remaining logs when the window is closed.
- * @param {Array} logs Array of logs to be flushed.
- * @param {Object} config Configuration object to be read from.
- */
-
- function sendOnClose(logs, config) {
- if (!config.on) {
- return;
- }
-
- var worker = createWorker(workerSendLog);
- document.addEventListener('visibilitychange', function () {
- if (document.visibilityState === 'hidden' && logs.length > 0) {
- worker.postMessage({
- url: config.url,
- logs: logs
- });
- logs.splice(0, logs.length);
- }
- });
- }
- /**
- * Sends the provided array of logs to the specified url,
- * retrying the request up to the specified number of retries.
- * @param {Array} logs Array of logs to send.
- * @param {string} config configuration parameters (e.g., to extract URL from & 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
-
- function sendLogs(logs, config, retries) {
- var req = new XMLHttpRequest(); // @todo setRequestHeader for Auth
-
- var data = JSON.stringify(logs);
- req.open('POST', config.url);
-
- if (config.authHeader) {
- req.setRequestHeader('Authorization', config.authHeader);
- }
-
- req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
-
- req.onreadystatechange = function () {
- if (req.readyState === 4 && req.status !== 200) {
- if (retries > 0) {
- sendLogs(logs, config, retries--);
- }
- }
- };
-
- req.send(data);
- }
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -1092,6 +966,132 @@
return true;
}
+ function workerSendLog(e) {
+ var _e$data = e.data,
+ url = _e$data.url,
+ logs = _e$data.logs;
+ fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(logs && logs.length > 0 ? logs : [])
+ });
+ }
+ function createWorker(fn) {
+ var blob = new Blob(['self.onmessage = ', fn.toString()], {
+ type: 'text/javascript'
+ });
+ var url = URL.createObjectURL(blob);
+ return new Worker(url);
+ }
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * 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.
+ */
+
+ function initSender(logs, config) {
+ if (sendIntervalId !== null) {
+ clearInterval(sendIntervalId);
+ }
+
+ sendIntervalId = sendOnInterval(logs, config);
+ sendOnClose(logs, config);
+ }
+ /**
+ * Checks the provided log array on an interval, flushing the logs
+ * 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.
+ */
+
+ function sendOnInterval(logs, config) {
+ return setInterval(function () {
+ if (!config.on) {
+ return;
+ }
+
+ if (logs.length >= config.logCountThreshold) {
+ sendLogs(logs.slice(0), config, 0); // Send a copy
+
+ logs.splice(0); // Clear array reference (no reassignment)
+ }
+ }, config.transmitInterval);
+ }
+ /**
+ * Attempts to flush the remaining logs when the window is closed.
+ * @param {Array} logs Array of logs to be flushed.
+ * @param {Object} config Configuration object to be read from.
+ */
+
+ function sendOnClose(logs, config) {
+ if (!config.on) {
+ return;
+ }
+
+ var worker = createWorker(workerSendLog);
+ document.addEventListener('visibilitychange', function () {
+ if (document.visibilityState === 'hidden' && logs.length > 0) {
+ worker.postMessage({
+ url: config.url,
+ logs: logs
+ });
+ logs.splice(0, logs.length);
+ }
+ });
+ }
+ /**
+ * Sends the provided array of logs to the specified url,
+ * retrying the request up to the specified number of retries.
+ * @param {Array} logs Array of logs to send.
+ * @param {string} config configuration parameters (e.g., to extract URL from & 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
+
+ function sendLogs(logs, config, retries) {
+ var req = new XMLHttpRequest(); // @todo setRequestHeader for Auth
+
+ var data = JSON.stringify(logs);
+ req.open('POST', config.url);
+
+ if (config.authHeader) {
+ req.setRequestHeader('Authorization', config.authHeader);
+ }
+
+ req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
+
+ req.onreadystatechange = function () {
+ if (req.readyState === 4 && req.status !== 200) {
+ if (retries > 0) {
+ sendLogs(logs, config, retries--);
+ }
+ }
+ };
+
+ req.send(data);
+ }
+
var config = {};
var logs = [];
var startLoadTimestamp = Date.now();
diff --git a/build/userale-2.1.1.min.js b/build/userale-2.1.1.min.js
index 13323fd..ad1f22b 100644
--- a/build/userale-2.1.1.min.js
+++ b/build/userale-2.1.1.min.js
@@ -16,4 +16,4 @@
* @preserved
*/
-!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).userale={})}(this,(function(e){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t="2.1.1",o=null;fun [...]
+!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).userale={})}(this,(function(e){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t="2.1.1",o=null;fun [...]
diff --git a/example/index.js b/example/index.js
index 21d5113..5b4c006 100644
--- a/example/index.js
+++ b/example/index.js
@@ -35,7 +35,7 @@ window.userale.options({
* the same is true for the 'map' API. See examples below:
*/
window.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);
});
diff --git a/src/attachHandlers.js b/src/attachHandlers.js
index 1981629..e440c99 100644
--- a/src/attachHandlers.js
+++ b/src/attachHandlers.js
@@ -15,10 +15,8 @@
* limitations under the License.
*/
-import { logs } from './packageLogs';
import { packageLog } from './packageLogs.js';
import { packageIntervalLog} from './packageLogs';
-import { sendOnRefresh } from "./sendLogs";
let events;
let bufferBools;