diff --git a/README.md b/README.md index ae4e83ee..3023d5ea 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,7 @@ document.addEventListener('change', function(e) { customField1: 'foo', customField2: 'bar', userId: userale.options().userId, - toolVersion: userale.options().version, + toolVersion: userale.options().toolVersion, toolName: userale.options().toolName, useraleVersion: userale.options().useraleVersion, sessionID: userale.options().sessionID, diff --git a/example/custom-non-user-events-example/index.js b/example/custom-non-user-events-example/index.js index 252361e8..76008021 100644 --- a/example/custom-non-user-events-example/index.js +++ b/example/custom-non-user-events-example/index.js @@ -77,6 +77,8 @@ function getData(url, resolve) { userAction: 'false', details: JSON.parse(req.response), userId: userale.options().userId, + toolVersion: userale.options().toolVersion, + toolName: userale.options().toolName, useraleVersion: userale.options().useraleVersion, sessionID: userale.options().sessionID, traceId: trace.getSpan(context.active())._spanContext.traceId diff --git a/example/index.js b/example/index.js index 44bb1e27..91f4462a 100644 --- a/example/index.js +++ b/example/index.js @@ -22,6 +22,7 @@ const changeMe = "me"; window.userale.options({ 'userId': changeMe, 'logDetails': true, + 'toolVersion': '2.3.0', 'toolName': 'Apache UserALE.js Example (Custom)' }); @@ -100,7 +101,7 @@ document.addEventListener('change', function(e) { customField1: 'I can make this log look like anything I want', customField2: 'foo', userId: window.userale.options().userId, - toolVersion: window.userale.options().version, + toolVersion: window.userale.options().toolVersion, toolName: window.userale.options().toolName, useraleVersion: window.userale.options().useraleVersion, sessionID: window.userale.options().sessionID, diff --git a/example/webpackUserAleExample/index.js b/example/webpackUserAleExample/index.js index e41fbdd5..d13d4819 100644 --- a/example/webpackUserAleExample/index.js +++ b/example/webpackUserAleExample/index.js @@ -30,7 +30,7 @@ const changeMe = "me"; userale.options({ 'userId': changeMe, 'url': 'http://localhost:8000/', - 'version': '2.3.0', + 'toolVersion': '2.3.0', 'logDetails': true, 'toolName': 'Apache UserALE.js Example (Custom)', 'logCountThreshold': '1', @@ -112,7 +112,7 @@ document.addEventListener('change', function(e) { customField1: 'I can make this log look like anything I want', customField2: 'foo', userId: userale.options().userId, - toolVersion: userale.options().version, + toolVersion: userale.options().toolVersion, toolName: userale.options().toolName, useraleVersion: userale.options().useraleVersion, sessionID: userale.options().sessionID, diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js index 90160ad7..a01a3fee 100644 --- a/src/UserALEWebExtension/background.js +++ b/src/UserALEWebExtension/background.js @@ -30,6 +30,7 @@ const defaultConfig = { userId: 'pluginUser', authHeader: null, toolName: 'useralePlugin', + toolVersion: '2.4.0', version: userale.version, }, pluginConfig: { @@ -41,6 +42,14 @@ const defaultConfig = { var urlWhitelist; function updateConfig(config) { + if (!config.toolName) { + throw "Please set the tool name before use."; + } + + if (!config.toolVersion) { + throw "Please set the app version before use."; + } + urlWhitelist = new RegExp(config.pluginConfig.urlWhitelist); userale.options(config.useraleConfig); // TODO: tabs need a page load to apply this config change. diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js index caa442a6..4feb7b95 100644 --- a/src/UserALEWebExtension/options.js +++ b/src/UserALEWebExtension/options.js @@ -30,7 +30,7 @@ function setConfig() { url: document.getElementById("url").value, userId: document.getElementById("user").value, toolName: document.getElementById("tool").value, - version: document.getElementById("version").value + toolVersion: document.getElementById("version").value }; // Set a basic auth header if given credentials. @@ -58,7 +58,7 @@ function getConfig() { document.getElementById("url").value = config.url; document.getElementById("user").value = config.userId; document.getElementById("tool").value = config.toolName; - document.getElementById("version").value = config.version; + document.getElementById("version").value = config.toolVersion; }); browser.storage.local.get("pluginConfig", (res) => { document.getElementById("filter").value = res.pluginConfig.urlWhitelist; diff --git a/src/getInitialSettings.js b/src/getInitialSettings.js index b9624ebe..44b7c69b 100644 --- a/src/getInitialSettings.js +++ b/src/getInitialSettings.js @@ -42,7 +42,7 @@ export function getInitialSettings() { settings.transmitInterval = +get('data-interval') || 5000; settings.logCountThreshold = +get('data-threshold') || 5; settings.userId = get('data-user') || null; - settings.version = get('data-version') || null; + settings.toolVersion = get('data-version') || null; settings.logDetails = get('data-log-details') === 'true' ? true : false; settings.resolution = +get('data-resolution') || 500; settings.toolName = get('data-tool') || null; @@ -52,6 +52,15 @@ export function getInitialSettings() { settings.authHeader = get('data-auth') || null; settings.custIndex = get('data-index') || null; settings.headers = get('data-headers') || null; + + if (!settings.toolName) { + throw "Please set the tool name before use."; + } + + if (!settings.toolVersion) { + throw "Please set the app version before use."; + } + return settings; } diff --git a/src/packageLogs.js b/src/packageLogs.js index 637a986d..15d31ec4 100644 --- a/src/packageLogs.js +++ b/src/packageLogs.js @@ -140,7 +140,7 @@ export function packageLog(e, detailFcn) { 'userAction' : true, 'details' : details, 'userId' : config.userId, - 'toolVersion' : config.version, + 'toolVersion' : config.toolVersion, 'toolName' : config.toolName, 'useraleVersion': config.useraleVersion, 'sessionID': config.sessionID, @@ -195,7 +195,7 @@ export function packageCustomLog(customLog, detailFcn, userAction) { 'userAction' : userAction, 'details' : details, 'userId' : config.userId, - 'toolVersion' : config.version, + 'toolVersion' : config.toolVersion, 'toolName' : config.toolName, 'useraleVersion': config.useraleVersion, 'sessionID': config.sessionID @@ -279,7 +279,7 @@ export function packageIntervalLog(e) { 'typeChange': intervalType !== type, 'userAction': false, 'userId': config.userId, - 'toolVersion': config.version, + 'toolVersion': config.toolVersion, 'toolName': config.toolName, 'useraleVersion': config.useraleVersion, 'sessionID': config.sessionID diff --git a/test/getInitialSettings_spec.js b/test/getInitialSettings_spec.js index ec128077..ebf0f33c 100644 --- a/test/getInitialSettings_spec.js +++ b/test/getInitialSettings_spec.js @@ -68,7 +68,7 @@ describe('getInitialSettings', () => { expect(config).to.have.property('transmitInterval', 100); expect(config).to.have.property('logCountThreshold', 10); expect(config).to.have.property('userId', 'testuser'); - expect(config).to.have.property('version', '1.0.0'); + expect(config).to.have.property('toolVersion', '1.0.0'); expect(config).to.have.property('logDetails', false); expect(config).to.have.property('resolution', 100); expect(config).to.have.property('toolName', 'testtool'); diff --git a/test/getInitialSettings_userParam.html b/test/getInitialSettings_userParam.html index f3314086..0ab2b25b 100644 --- a/test/getInitialSettings_userParam.html +++ b/test/getInitialSettings_userParam.html @@ -18,6 +18,8 @@
diff --git a/test/main.html b/test/main.html index 539c3203..eb8d1426 100644 --- a/test/main.html +++ b/test/main.html @@ -17,7 +17,7 @@ - + diff --git a/test/main_spec.js b/test/main_spec.js index 5bc045ab..efed001b 100644 --- a/test/main_spec.js +++ b/test/main_spec.js @@ -32,7 +32,7 @@ describe('Userale API', () => { 'logCountThreshold', 'userId', 'sessionID', - 'version', + 'toolVersion', 'logDetails', 'resolution', 'toolName',