From 54cb35fd5d84eb71299bd4e87db04b2f0a175303 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 11 Dec 2018 17:50:10 +0000 Subject: [PATCH 01/36] GPII-3572: Added the ability to start only metrics via configuration. --- gpii/node_modules/eventLog/src/eventLog.js | 3 --- gpii/node_modules/eventLog/src/metrics.js | 15 +++++++-------- gpii/node_modules/flowManager/src/FlowManager.js | 5 ++++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 96de8dd52..b4d1b133f 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -39,9 +39,6 @@ fluid.defaults("gpii.eventLog", { }, settingsDir: { type: "gpii.settingsDir" - }, - metrics: { - type: "gpii.metrics" } }, invokers: { diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 9a773b099..7da7b32b2 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -37,14 +37,6 @@ fluid.defaults("gpii.metrics", { gradeNames: "gpii.windowsMetrics" } } - }, - metrics: { - checks: { - standaloneMetrics: { - contextValue: "{gpii.contexts.standalone-metrics}" - } - }, - defaultGradeNames: "gpii.metrics.lifecycle" } }, invokers: { @@ -118,6 +110,13 @@ fluid.defaults("gpii.metrics.lifecycle", { } }); +fluid.defaults("gpii.metrics.standalone", { + listeners: { + "onCreate": "{that}.events.onStartMetrics.fire", + "onDestroy": "{that}.events.onStopMetrics.fire" + } +}); + /** * Log the solutions as they're applied. * diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index a530e3e66..796671f0a 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -145,7 +145,10 @@ fluid.defaults("gpii.flowManager.local", { } }, eventLog: { - type: "gpii.eventLog" + type: "gpii.eventLog", + options: { + gradeNames: ["gpii.metrics", "gpii.metrics.lifecycle"] + } }, userListeners: { type: "gpii.userListeners" From 95afd2847cc92c8af459ce0b67541ef8e8d180b4 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 11 Dec 2018 23:48:12 +0000 Subject: [PATCH 02/36] GPII-3572: Added the ability to start with/without metrics via configuration. --- gpii/node_modules/eventLog/src/eventLog.js | 13 +++---------- gpii/node_modules/flowManager/src/FlowManager.js | 5 +---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index b4d1b133f..9a4c865bf 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -22,7 +22,6 @@ var fluid = require("infusion"); var fs = require("fs"), - path = require("path"), moment = require("moment"), net = require("net"); @@ -76,7 +75,7 @@ fluid.defaults("gpii.eventLog", { } }, - logDestination: "tcp://127.0.0.1:51481" + logDestination: null }); /** @@ -228,16 +227,12 @@ fluid.onUncaughtException.addListener(gpii.eventLog.gotError, "gpii-eventLog"); * Gets the path of the new log file for this instance of gpii. * It can use one of the following environment variables to override the configured: * GPII_EVENT_LOG: The path to the log file (a file, or tcp://:). - * GPII_EVENT_LOG_DIRECTORY: A directory where per-instance logs are kept * * @param {Component} that - The gpii.eventLog instance. * @return {String} The path to the new log file. */ gpii.eventLog.getLogFile = function (that) { - var logPath; - if (!process.env.GPII_EVENT_LOG_DIRECTORY) { - logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination; - } + var logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination; if (logPath) { if (logPath.startsWith("tcp:")) { @@ -253,9 +248,7 @@ gpii.eventLog.getLogFile = function (that) { } } else { that.logHost = null; - var startupTime = Date.now(); - var gpiiSettingsDir = process.env.GPII_EVENT_LOG_DIRECTORY || that.getGpiiSettingsDir(); - that.logFilePath = path.join(gpiiSettingsDir, "gpii-" + gpii.journal.formatTimestamp(startupTime) + ".log"); + that.logFilePath = null; } var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath; diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index 796671f0a..a530e3e66 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -145,10 +145,7 @@ fluid.defaults("gpii.flowManager.local", { } }, eventLog: { - type: "gpii.eventLog", - options: { - gradeNames: ["gpii.metrics", "gpii.metrics.lifecycle"] - } + type: "gpii.eventLog" }, userListeners: { type: "gpii.userListeners" From 52397d27ebe919b8733833f3ba9813b10cf7cc8e Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 12 Dec 2018 14:37:33 +0000 Subject: [PATCH 03/36] GPII-3572: Logging the start of metrics --- gpii/node_modules/eventLog/src/metrics.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 7da7b32b2..a7cbb46ca 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -51,6 +51,12 @@ fluid.defaults("gpii.metrics", { events: { "onStartMetrics": null, "onStopMetrics": null + }, + listeners: { + "onStartMetrics.log": { + funcName: "fluid.log", + args: "Metrics started" + } } }); From 61eda5d688b2e6368aec68311285e9610cd26cac Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 12 Dec 2018 14:38:20 +0000 Subject: [PATCH 04/36] NOJIRA: Lower-casing the first character of error objects. --- gpii/node_modules/eventLog/src/eventLog.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 9a4c865bf..a1401be04 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -180,8 +180,11 @@ gpii.eventLog.logError = function (that, moduleName, errType, err, level) { if (err instanceof Error) { // Error doesn't serialise data.error = {}; - fluid.each(Object.getOwnPropertyNames(err), function (a) { - data.error[a] = err[a]; + fluid.each(Object.getOwnPropertyNames(err), function (source) { + // Ensure the first character of the field is lowercase - "Message" vs "message" was causing a duplicate + // field during the analysis. + var dest = source.charAt(0).toLowerCase() + source.slice(1); + data.error[dest] = err[source]; }); } else if (fluid.isPlainObject(err, true)) { data.error = Object.assign({}, err); From 4888c7b463ab816a67cf284238339972ad44f220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 22:21:03 +0100 Subject: [PATCH 05/36] GPII-3780: Fixed 'com.microsoft.windows.desktopBackgroundColor' and 'com.microsoft.windows.desktopBackground' transformations --- testData/solutions/win32.json5 | 45 ++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 2ceae7690..24740907f 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -4811,7 +4811,8 @@ "path": "Control Panel\\Desktop", "dataTypes": { "TileWallpaper": "REG_SZ", - "WallpaperStyle": "REG_SZ" + "WallpaperStyle": "REG_SZ", + "Scaling": "REG_SZ" } }, "supportedSettings": { @@ -4897,15 +4898,15 @@ "type": "fluid.transforms.valueMapper", "defaultInputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackground.Scaling", "match": { - "Fill": "6", - "Fit": "10", + "Fill": "10", + "Fit": "6", "Stretch": "2", "Tile": "0", "Center": "0", "Span": "22" }, "noMatch": { - "outputValue": "6" + "outputValue": "10" } } } @@ -4916,8 +4917,8 @@ "type": "fluid.transforms.valueMapper", "defaultInputPath": "WallpaperStyle", "match": { - "6": "Fill", - "10": "Fit", + "10": "Fill", + "6": "Fit", "2": "Stretch", "0": { "outputValue": { @@ -5028,9 +5029,12 @@ }, "capabilitiesTransformations": { "ImageConfig": { + // This transform is necessary due to issue GPII-3784. "transform": { - "type": "fluid.transforms.literalValue", - "input": "", + "type": "fluid.transforms.condition", + "conditionPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor.r", + "true": "", + "false": "", "outputPath": "value" }, "path": { @@ -5040,9 +5044,6 @@ } } } - }, - "inverseCapabilitiesTransformations": { - "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.Image": "ImageConfig.value" } }, "configureSolidColor": { @@ -5086,9 +5087,23 @@ }, "capabilitiesTransformations": { "SolidColorConfig": { + // This transform is necessary due to issue GPII-3784. "transform": { - "type": "fluid.transforms.value", - "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor", + "type": "fluid.transforms.condition", + "conditionPath": "SolidColor", + "condition": true, + "true": { + "transform": { + "type": "fluid.transforms.value", + "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor" + } + }, + "false": { + "transform": { + "type": "fluid.transforms.value", + "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor" + } + }, "outputPath": "value" } } @@ -5102,6 +5117,10 @@ "settings.configureImage", "settings.configureSolidColor" ], + "restore": [ + "settings.configureImage", + "settings.configureSolidColor" + ], "isInstalled": [ { "type": "gpii.deviceReporter.alwaysInstalled" From e008b49fe40fe74214c88722887b93cae53d33b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 22:22:33 +0100 Subject: [PATCH 06/36] GPII-3780: Improved tests for 'windows.desktopBackground' and 'windows.desktopBackgroundColor' solutions --- ...os_win_2.json5 => os_win_solidColor.json5} | 0 .../preferences/os_win_solidColor_tf.json5 | 14 ++ .../preferences/os_win_wallpaper_fill.json5 | 15 ++ .../preferences/os_win_wallpaper_fit.json5 | 15 ++ .../preferences/os_win_wallpaper_tile.json5 | 15 ++ .../windows/windows-builtIn-testSpec.js | 177 +++++++++++++++++- 6 files changed, 233 insertions(+), 3 deletions(-) rename tests/data/preferences/{os_win_2.json5 => os_win_solidColor.json5} (100%) create mode 100644 tests/data/preferences/os_win_solidColor_tf.json5 create mode 100644 tests/data/preferences/os_win_wallpaper_fill.json5 create mode 100644 tests/data/preferences/os_win_wallpaper_fit.json5 create mode 100644 tests/data/preferences/os_win_wallpaper_tile.json5 diff --git a/tests/data/preferences/os_win_2.json5 b/tests/data/preferences/os_win_solidColor.json5 similarity index 100% rename from tests/data/preferences/os_win_2.json5 rename to tests/data/preferences/os_win_solidColor.json5 diff --git a/tests/data/preferences/os_win_solidColor_tf.json5 b/tests/data/preferences/os_win_solidColor_tf.json5 new file mode 100644 index 000000000..d9d572c71 --- /dev/null +++ b/tests/data/preferences/os_win_solidColor_tf.json5 @@ -0,0 +1,14 @@ +{ + "flat": { + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackgroundColor": { + "SolidColor": { "r": 67, "g": 187, "b": 19 } + } + } + } + } + } +} diff --git a/tests/data/preferences/os_win_wallpaper_fill.json5 b/tests/data/preferences/os_win_wallpaper_fill.json5 new file mode 100644 index 000000000..c1017bf77 --- /dev/null +++ b/tests/data/preferences/os_win_wallpaper_fill.json5 @@ -0,0 +1,15 @@ +{ + "flat": { + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { + "Scaling": "Fill", + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img3.jpg" + } + } + } + } + } +} diff --git a/tests/data/preferences/os_win_wallpaper_fit.json5 b/tests/data/preferences/os_win_wallpaper_fit.json5 new file mode 100644 index 000000000..3a4d1548c --- /dev/null +++ b/tests/data/preferences/os_win_wallpaper_fit.json5 @@ -0,0 +1,15 @@ +{ + "flat": { + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { + "Scaling": "Fit", + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img2.jpg" + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/data/preferences/os_win_wallpaper_tile.json5 b/tests/data/preferences/os_win_wallpaper_tile.json5 new file mode 100644 index 000000000..6cbaf934a --- /dev/null +++ b/tests/data/preferences/os_win_wallpaper_tile.json5 @@ -0,0 +1,15 @@ +{ + "flat": { + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { + "Scaling": "Tile", + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img4.jpg" + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/platform/windows/windows-builtIn-testSpec.js b/tests/platform/windows/windows-builtIn-testSpec.js index eefdb633c..d68db0bcc 100644 --- a/tests/platform/windows/windows-builtIn-testSpec.js +++ b/tests/platform/windows/windows-builtIn-testSpec.js @@ -730,8 +730,8 @@ gpii.tests.windows.builtIn = [ } } }, { - name: "Testing os_win_2 using default matchmaker", - gpiiKey: "os_win_2", + name: "Testing os_win_solidColor using default matchmaker", + gpiiKey: "os_win_solidColor", initialState: {}, settingsHandlers: { "gpii.windows.spiSettingsHandler": { @@ -769,7 +769,178 @@ gpii.tests.windows.builtIn = [ }] } } - }, { + }, + { + name: "Testing os_win_solidColor_tf using default matchmaker", + gpiiKey: "os_win_solidColor_tf", + initialState: {}, + settingsHandlers: { + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.desktopBackgroundColor": [{ + "settings": { + "ImageConfig": { + "path": "pvParam", + "value": "" + } + }, + "options": { + "getAction": "SPI_GETDESKWALLPAPER", + "setAction": "SPI_SETDESKWALLPAPER", + "uiParam": 260, + "pvParam": { + "type": "array", + "valueType": "TCHAR", + "length": 260 + } + } + }] + }, + "gpii.windows.nativeSettingsHandler": { + "com.microsoft.windows.desktopBackgroundColor": [{ + "settings": { + "SolidColorConfig": { + "value": { + "r": 67, "g": 187, "b": 19 + } + } + }, + "options": { + "functionName": "SolidColor" + } + }] + } + } + }, + { + name: "Testing os_win_wallpaper_fill using default matchmaker", + gpiiKey: "os_win_wallpaper_fill", + initialState: {}, + settingsHandlers: { + "gpii.windows.registrySettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "TileWallpaper": "0", + "WallpaperStyle": "10" + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Control Panel\\Desktop", + "dataTypes": { + "TileWallpaper": "REG_SZ", + "WallpaperStyle": "REG_SZ" + } + } + }] + }, + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "ImageConfig": { + "path": "pvParam", + "value": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img3.jpg" + } + }, + "options": { + "getAction": "SPI_GETDESKWALLPAPER", + "setAction": "SPI_SETDESKWALLPAPER", + "uiParam": 260, + "pvParam": { + "type": "array", + "valueType": "TCHAR", + "length": 260 + } + } + }] + } + } + }, + { + name: "Testing os_win_wallpaper_fit using default matchmaker", + gpiiKey: "os_win_wallpaper_fit", + initialState: {}, + settingsHandlers: { + "gpii.windows.registrySettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "TileWallpaper": "0", + "WallpaperStyle": "6" + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Control Panel\\Desktop", + "dataTypes": { + "TileWallpaper": "REG_SZ", + "WallpaperStyle": "REG_SZ" + } + } + }] + }, + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "ImageConfig": { + "path": "pvParam", + "value": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img2.jpg" + } + }, + "options": { + "getAction": "SPI_GETDESKWALLPAPER", + "setAction": "SPI_SETDESKWALLPAPER", + "uiParam": 260, + "pvParam": { + "type": "array", + "valueType": "TCHAR", + "length": 260 + } + } + }] + } + } + }, + { + name: "Testing os_win_wallpaper_tile using default matchmaker", + gpiiKey: "os_win_wallpaper_tile", + initialState: {}, + settingsHandlers: { + "gpii.windows.registrySettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "TileWallpaper": "1", + "WallpaperStyle": "0" + }, + "options": { + "hKey": "HKEY_CURRENT_USER", + "path": "Control Panel\\Desktop", + "dataTypes": { + "TileWallpaper": "REG_SZ", + "WallpaperStyle": "REG_SZ" + } + } + }] + }, + "gpii.windows.spiSettingsHandler": { + "com.microsoft.windows.desktopBackground": [{ + "settings": { + "ImageConfig": { + "path": "pvParam", + "value": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img4.jpg" + } + }, + "options": { + "getAction": "SPI_GETDESKWALLPAPER", + "setAction": "SPI_SETDESKWALLPAPER", + "uiParam": 260, + "pvParam": { + "type": "array", + "valueType": "TCHAR", + "length": 260 + } + } + }] + } + } + }, + { name: "Testing os_common using default matchmaker", gpiiKey: "os_common", initialState: { From 20306069d84a4ab08e4b78821bbfbd9acef32132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 22:26:05 +0100 Subject: [PATCH 07/36] GPII-3780: Added new preference sets for 'windows.desktopBackgroundColor' and 'windows.desktopBackground' --- testData/preferences/brenda.json5 | 23 ++++++++++++++++++++ testData/preferences/bryan.json5 | 25 ++++++++++++++++++++++ testData/preferences/daniel-raw.json5 | 30 +++++++++++++++++++++++++++ testData/preferences/daniel.json5 | 7 ++----- 4 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 testData/preferences/brenda.json5 create mode 100644 testData/preferences/bryan.json5 create mode 100644 testData/preferences/daniel-raw.json5 diff --git a/testData/preferences/brenda.json5 b/testData/preferences/brenda.json5 new file mode 100644 index 000000000..f19cfbc6a --- /dev/null +++ b/testData/preferences/brenda.json5 @@ -0,0 +1,23 @@ +// # Bryan.json5 +// +// This preference sets changes the desktop wallpaper with another default Windows 10 one. +// +// ## Testing +// +// Windows desktop background should be replaced by with other one. +// +{ + "flat": { + "name": "Bryan", + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img3.jpg" + } + } + } + } + } +} diff --git a/testData/preferences/bryan.json5 b/testData/preferences/bryan.json5 new file mode 100644 index 000000000..f206d410f --- /dev/null +++ b/testData/preferences/bryan.json5 @@ -0,0 +1,25 @@ +// # Bryan.json5 +// +// This preference sets changes the desktop wallpaper with another default Windows 10 one, +// at sets the Scaling to "Fill". +// +// ## Testing +// +// Windows desktop background should be replaced by with other one, and scaling set to "Fit". +// +{ + "flat": { + "name": "Bryan", + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { + "Scaling": "Fill", + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img3.jpg" + } + } + } + } + } +} diff --git a/testData/preferences/daniel-raw.json5 b/testData/preferences/daniel-raw.json5 new file mode 100644 index 000000000..8f9df37e7 --- /dev/null +++ b/testData/preferences/daniel-raw.json5 @@ -0,0 +1,30 @@ +// # Daniel-raw.json5 +// +// This preference sets the desktop background to a solid color. This is the same +// preference set as Daniels one, but without using the convenience transforms. +// +// ## Testing +// +// Windows desktop background should be replace by a green image. +// +{ + "flat": { + "name": "Daniel-raw", + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackgroundColor": { + "ImageConfig": { + "path": "pvParam", + "value": "" + }, + "SolidColorConfig": { + "value": { "r": 67, "g": 187, "b": 19 } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/testData/preferences/daniel.json5 b/testData/preferences/daniel.json5 index 6f34ec8a0..2b47eb224 100644 --- a/testData/preferences/daniel.json5 +++ b/testData/preferences/daniel.json5 @@ -13,11 +13,8 @@ "gpii-default": { "name": "Default preferences", "preferences": { - "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { - "BackgroundTypeVal": "SolidColor", - "InputVal": { - "Color": {"r": 67, "g": 187, "b": 19} - } + "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackgroundColor": { + "SolidColor": { "r": 67, "g": 187, "b": 19 } } } } From 4f910c6c4fa11f70b4119e911e218215f0263f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 8 Mar 2019 22:28:26 +0100 Subject: [PATCH 08/36] GPII-3780: Solved linter issues --- testData/preferences/daniel-raw.json5 | 2 +- tests/data/preferences/os_win_wallpaper_fit.json5 | 2 +- tests/data/preferences/os_win_wallpaper_tile.json5 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testData/preferences/daniel-raw.json5 b/testData/preferences/daniel-raw.json5 index 8f9df37e7..95e0c4eea 100644 --- a/testData/preferences/daniel-raw.json5 +++ b/testData/preferences/daniel-raw.json5 @@ -27,4 +27,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/data/preferences/os_win_wallpaper_fit.json5 b/tests/data/preferences/os_win_wallpaper_fit.json5 index 3a4d1548c..0fe76f136 100644 --- a/tests/data/preferences/os_win_wallpaper_fit.json5 +++ b/tests/data/preferences/os_win_wallpaper_fit.json5 @@ -12,4 +12,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/data/preferences/os_win_wallpaper_tile.json5 b/tests/data/preferences/os_win_wallpaper_tile.json5 index 6cbaf934a..38cf5cfad 100644 --- a/tests/data/preferences/os_win_wallpaper_tile.json5 +++ b/tests/data/preferences/os_win_wallpaper_tile.json5 @@ -12,4 +12,4 @@ } } } -} \ No newline at end of file +} From 26bd1a9c5fe03726b42fcef652c21e37d807caff Mon Sep 17 00:00:00 2001 From: ste Date: Mon, 24 Jun 2019 21:06:54 +0100 Subject: [PATCH 09/36] GPII-3853: Implemented sub-sessions. --- gpii/node_modules/eventLog/package.json | 2 +- gpii/node_modules/eventLog/src/eventLog.js | 16 ++-- gpii/node_modules/eventLog/src/metrics.js | 87 +++++++++++++++++-- .../eventLog/test/EventLogTests.js | 9 +- 4 files changed, 100 insertions(+), 14 deletions(-) diff --git a/gpii/node_modules/eventLog/package.json b/gpii/node_modules/eventLog/package.json index 421f79714..b8c2270ce 100644 --- a/gpii/node_modules/eventLog/package.json +++ b/gpii/node_modules/eventLog/package.json @@ -1,7 +1,7 @@ { "name": "eventLog", "description": "Event logging.", - "version": "0.4.0", + "version": "0.5.0", "author": "GPII", "bugs": "http://issues.gpii.net/browse/GPII", "homepage": "http://gpii.net/", diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 96de8dd52..81448d5d1 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -55,14 +55,19 @@ fluid.defaults("gpii.eventLog", { getVersion: "gpii.eventLog.getVersion" }, members: { - // The installation ID - installationID: "@expand:{that}.installID.getInstallID()", - version: "@expand:{that}.getVersion()", sequence: 0, // Buffered log lines while there's not log server connection logBuffer: [], // Maximum number of lines to buffer. - maxBufferlength: 0xfff + maxBufferlength: 0xfff, + // Data to include in every log entry. + eventData: { + // The installation ID + installID: "@expand:{that}.installID.getInstallID()", + version: "@expand:{that}.getVersion()", + sessionID: undefined, + gpiiKey: undefined + } }, listeners: { "onCreate.logFile": { @@ -282,9 +287,8 @@ gpii.eventLog.writeLog = function (that, level, event) { // Log to console before the installation ID and timestamp are added (no one wants to see it). fluid.log(fluid.logLevel.TRACE, event); - event.installID = that.installationID; + Object.assign(event, that.eventData); event.timestamp = gpii.eventLog.getTimestamp(); - event.version = that.version; event.sequence = that.sequence++; var logLine = JSON.stringify(event) + "\n"; diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 4a7ffce6b..cc01c8b1f 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -51,14 +51,46 @@ fluid.defaults("gpii.metrics", { logMetric: { func: "{eventLog}.logEvent", args: ["metrics", "{arguments}.0", "{arguments}.1"] // event, data + }, + startSubSession: { + funcName: "gpii.metrics.startSubSession", + args: ["{that}", "{eventLog}"] + }, + stopSubSession: { + funcName: "gpii.metrics.stopSubSession", + args: ["{that}", "{eventLog}"] } }, members: { - sessionSolutions: {} + sessionSolutions: {}, + // Is the noUser (or nobody) logged on? + isAnonymousUser: true, + // Incrementing sub-session id. + subSessionIncrementer: 0, + // When the current sub-session began + subSessionStart: undefined }, events: { "onStartMetrics": null, - "onStopMetrics": null + "onStopMetrics": null, + // The user has become active (called on the first input after onInactive) + "onActive": null, // args: duration-inactive + // The user has become inactive (no input was received after {that}.config.input.inactiveTime) + "onInactive": null + }, + listeners: { + "onActive": [{ + func: "{that}.logMetric", + args: ["inactive-stop", {duration: "{arguments}.0"}] + }, { + func: "{that}.startSubSession" + }], + "onInactive": [{ + func: "{that}.logMetric", + args: ["inactive-begin"] + }, { + func: "{that}.stopSubSession" + }] } }); @@ -78,6 +110,10 @@ fluid.defaults("gpii.metrics.lifecycle", { }, "{lifecycleManager}.events.onSessionStart": [ { + namespace: "metrics.session", + funcName: "gpii.metrics.sessionStarted", + args: ["{that}", "{eventLog}", "{arguments}.1"] + }, { namespace: "eventLog", func: "{eventLog}.logEvent", args: [ @@ -86,10 +122,13 @@ fluid.defaults("gpii.metrics.lifecycle", { { // onSessionStart fired with [gradeName, gpiiKey] gpiiKey: "{arguments}.1", - session: "@expand:{lifecycleManager}.getSession({arguments}.1)" + session: "{that}.eventData.sessionID" } ] }, { + func: "{that}.startSubSession" + }, { + func: "{that}.events.onStartMetrics" }], "{lifecycleManager}.events.onSessionStop": [{ @@ -104,10 +143,12 @@ fluid.defaults("gpii.metrics.lifecycle", { session: "{arguments}.1.id" } ] + }, { + func: "{that}.stopSubSession" }, { namespace: "metrics.session", funcName: "gpii.metrics.sessionStopped", - args: ["{that}", "{arguments}.1.id"] + args: ["{that}", "{eventLog}", "{arguments}.1.id"] }, { "func": "{that}.events.onStopMetrics", "priority": "before:eventLog" @@ -201,11 +242,30 @@ gpii.metrics.preferenceChanged = function (that, current, previous) { }; /** - * Removes the logged solution IDs for the session. + * Updates the logged gpiiKey * @param {Component} that - The gpii.metrics instance. + * @param {Component} eventLog - The gpii.eventLog instance. + * @param {String} gpiiKey - The gpiiKey used for this session. + */ +gpii.metrics.sessionStarted = function (that, eventLog, gpiiKey) { + eventLog.eventData.sessionID = fluid.allocateGuid(); + that.isAnonymousUser = (gpiiKey === "noUser"); + if (that.isAnonymousUser) { + delete eventLog.eventData.gpiiKey; + } else { + eventLog.eventData.gpiiKey = gpiiKey; + } +}; + +/** + * Removes the logged solution IDs for the session, and the current gpii key. + * @param {Component} that - The gpii.metrics instance. + * @param {Component} eventLog - The gpii.eventLog instance. * @param {String} sessionID - Session ID. */ -gpii.metrics.sessionStopped = function (that, sessionID) { +gpii.metrics.sessionStopped = function (that, eventLog, sessionID) { + that.isAnonymousUser = true; + delete eventLog.eventData.gpiiKey; delete that.sessionSolutions[sessionID]; }; @@ -237,3 +297,18 @@ gpii.metrics.logonStateChanged = function (that, lifecycleManager, oldValue, new } } }; + +gpii.metrics.startSubSession = function (that, eventLog) { + that.subSessionStart = process.hrtime(); + eventLog.eventData.subSessionID = eventLog.eventData.sessionID + "-" + that.subSessionIncrementer++; + that.logMetric("subsession-begin", { subSessionID: eventLog.eventData.subSessionID}); +}; + +gpii.metrics.stopSubSession = function (that, eventLog) { + that.logMetric("subsession-end", { + subSessionID: eventLog.eventData.subSessionID, + duration: process.hrtime(that.subSessionStart)[0] + }); + delete eventLog.eventData.subSessionID; +}; + diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 89c9d06d8..105fb326b 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -66,7 +66,10 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { target: "{that installID}.options.gradeNames" }, members: { - installationID: gpii.tests.eventLog.installID, + eventData: { + installID: gpii.tests.eventLog.installID, + sessionID: gpii.tests.eventLog.sessionID + }, logFilePath: logFile } }); @@ -77,6 +80,7 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { gpii.tests.eventLog.installID = "installation-id"; gpii.tests.eventLog.timestamp = "2000-00-00T00:00:00.000Z"; gpii.tests.eventLog.version = require("../package.json").version; +gpii.tests.eventLog.sessionID = "session-id"; gpii.tests.eventLog.testDefs = fluid.freezeRecursive(fluid.transform([ { @@ -196,6 +200,7 @@ gpii.tests.eventLog.testDefs = fluid.freezeRecursive(fluid.transform([ expected.timestamp = gpii.tests.eventLog.timestamp; expected.installID = gpii.tests.eventLog.installID; expected.version = gpii.tests.eventLog.version; + expected.sessionID = gpii.tests.eventLog.sessionID; }); return item; })); @@ -316,6 +321,7 @@ jqUnit.asyncTest("Uncaught exception test", function () { "installID": gpii.tests.eventLog.installID, "timestamp": gpii.tests.eventLog.timestamp, "version": gpii.tests.eventLog.version, + "sessionID": gpii.tests.eventLog.sessionID, "level": "FAIL", "module": "GPII", "event": "Error.Exception", @@ -367,6 +373,7 @@ jqUnit.asyncTest("fluid.fail test", function () { "installID": gpii.tests.eventLog.installID, "timestamp": gpii.tests.eventLog.timestamp, "version": gpii.tests.eventLog.version, + "sessionID": gpii.tests.eventLog.sessionID, "level": "FAIL", "module": "GPII", "event": "Error.Fail", From cdadc33cea61079f251cc19ff00d75111f8e69d3 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 25 Jun 2019 15:08:51 +0100 Subject: [PATCH 10/36] GPII-3853: Recording inactivity due to entering sleep mode --- gpii/node_modules/eventLog/src/metrics.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index cc01c8b1f..fa3a7368e 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -76,7 +76,7 @@ fluid.defaults("gpii.metrics", { // The user has become active (called on the first input after onInactive) "onActive": null, // args: duration-inactive // The user has become inactive (no input was received after {that}.config.input.inactiveTime) - "onInactive": null + "onInactive": null // args: {sleep:true} }, listeners: { "onActive": [{ @@ -87,7 +87,7 @@ fluid.defaults("gpii.metrics", { }], "onInactive": [{ func: "{that}.logMetric", - args: ["inactive-begin"] + args: ["inactive-begin", "{arguments}.0"] }, { func: "{that}.stopSubSession" }] @@ -305,10 +305,12 @@ gpii.metrics.startSubSession = function (that, eventLog) { }; gpii.metrics.stopSubSession = function (that, eventLog) { - that.logMetric("subsession-end", { - subSessionID: eventLog.eventData.subSessionID, - duration: process.hrtime(that.subSessionStart)[0] - }); + if (eventLog.eventData.subSessionID) { + that.logMetric("subsession-end", { + subSessionID: eventLog.eventData.subSessionID, + duration: process.hrtime(that.subSessionStart)[0] + }); + } delete eventLog.eventData.subSessionID; }; From 1d7ac6478c61da51aba182ae94dca6056a46e56c Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 25 Jun 2019 21:38:07 +0100 Subject: [PATCH 11/36] GPII-3853: Added calculation of duration between related events. --- gpii/node_modules/eventLog/src/eventLog.js | 56 ++- gpii/node_modules/eventLog/src/metrics.js | 16 +- .../eventLog/test/EventLogTests.js | 318 +++++++++++++++++- 3 files changed, 376 insertions(+), 14 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 81448d5d1..272096f98 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -67,7 +67,9 @@ fluid.defaults("gpii.eventLog", { version: "@expand:{that}.getVersion()", sessionID: undefined, gpiiKey: undefined - } + }, + // The start times for events which require durations to be recorded. + eventTimes: {} }, listeners: { "onCreate.logFile": { @@ -83,10 +85,21 @@ fluid.defaults("gpii.eventLog", { args: ["{that}", "stop"] } }, - logDestination: "tcp://127.0.0.1:51481" }); +/** + * A log event + * @typedef {Object} LogEvent + * @property {String} module The area of GPII the event is from. + * @property {String} event The name of the event. + * @property {String} data [optional] Extra information about the event. + * @property {Object} level The severity of the event (from fluid.logLevelsSpec, default: fluid.INFO). + * @property {String} version The eventLog module version. (automatically added) + * @property {String} timestamp Current time of the event. (automatically added) + * @property {String} sequence Ordered unique identifier to the event. (automatically added) + */ + /** * Returns the actual date and time, as a string, in ISO 8601 format with the localtime + offset from UTC. * eg: '2018-07-13T13:03:03.863+01:00' @@ -130,7 +143,7 @@ gpii.eventLog.logStartStop = function (that, state) { * @param {String} event - Name of the event. * @param {Any} [data] - [optional] Event specific data. * @param {Object} level -[optional] Level of the log, see fluid.logLevelsSpec [FATAL,FAIL,WARN,IMPORTANT,INFO,TRACE]. - * @return {Object} The log object. + * @return {LogEvent} The log object. */ gpii.eventLog.createLogObject = function (moduleName, event, data, level) { var eventObject = { @@ -277,15 +290,17 @@ gpii.eventLog.getLogFile = function (that) { * * @param {Component} that - The gpii.eventLog instance. * @param {Object} level - Level of the log, see fluid.logLevelsSpec [FATAL,FAIL,WARN,IMPORTANT,INFO,TRACE]. - * @param {Object} event - The object. This will be modified to what has been sent to the log, adding the installID and + * @param {LogEvent} event - The object. This will be modified to what has been sent to the log, adding the installID and * timestamp fields. */ gpii.eventLog.writeLog = function (that, level, event) { var intLevel = gpii.eventLog.checkLevel(level); event.level = intLevel.value; + gpii.eventLog.recordDuration(that, event); + // Log to console before the installation ID and timestamp are added (no one wants to see it). - fluid.log(fluid.logLevel.TRACE, event); + fluid.log(fluid.logLevel.INFO, event); Object.assign(event, that.eventData); event.timestamp = gpii.eventLog.getTimestamp(); @@ -302,6 +317,37 @@ gpii.eventLog.writeLog = function (that, level, event) { } }; +/** + * Handles the timing of a pair of duration events. + * + * Some events can be paired into having a duration. For example, tooltip-shown and tooltip-hidden. The timestamp for + * the start event is recorded, so when the end event is seen the duration is calculated and added to the event data. + * + * @param {Component} that The gpii.eventLog instance. + * @param {LogEvent} event The event. + */ +gpii.eventLog.recordDuration = function (that, event) { + var endEvent = that.metrics.options.durationEvents[event.event]; + if (endEvent) { + // This is the start of a pair of duration events. + if (!that.eventTimes[endEvent]) { + that.eventTimes[endEvent] = []; + } + that.eventTimes[endEvent].push(process.hrtime()); + } else { + var startTimes = that.eventTimes[event.event]; + var startTime = startTimes && startTimes.pop(); + if (startTime) { + // This is the ending of a pair of duration events. + if (!event.data) { + event.data = {}; + } + var memberName = event.data.hasOwnProperty("duration") ? "duration_auto" : "duration"; + event.data[memberName] = process.hrtime(startTime)[0]; + } + } +}; + /** * Sends a log line to the configured log server. * diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index fa3a7368e..4a05249cc 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -66,9 +66,7 @@ fluid.defaults("gpii.metrics", { // Is the noUser (or nobody) logged on? isAnonymousUser: true, // Incrementing sub-session id. - subSessionIncrementer: 0, - // When the current sub-session began - subSessionStart: undefined + subSessionIncrementer: 0 }, events: { "onStartMetrics": null, @@ -81,7 +79,7 @@ fluid.defaults("gpii.metrics", { listeners: { "onActive": [{ func: "{that}.logMetric", - args: ["inactive-stop", {duration: "{arguments}.0"}] + args: ["inactive-stop"] }, { func: "{that}.startSubSession" }], @@ -91,6 +89,12 @@ fluid.defaults("gpii.metrics", { }, { func: "{that}.stopSubSession" }] + }, + durationEvents: { + "start": "stop", + "inactive-begin": "inactive-stop", + "SessionStart": "SessionStop", + "subsession-begin": "subsession-end" } }); @@ -299,7 +303,6 @@ gpii.metrics.logonStateChanged = function (that, lifecycleManager, oldValue, new }; gpii.metrics.startSubSession = function (that, eventLog) { - that.subSessionStart = process.hrtime(); eventLog.eventData.subSessionID = eventLog.eventData.sessionID + "-" + that.subSessionIncrementer++; that.logMetric("subsession-begin", { subSessionID: eventLog.eventData.subSessionID}); }; @@ -307,8 +310,7 @@ gpii.metrics.startSubSession = function (that, eventLog) { gpii.metrics.stopSubSession = function (that, eventLog) { if (eventLog.eventData.subSessionID) { that.logMetric("subsession-end", { - subSessionID: eventLog.eventData.subSessionID, - duration: process.hrtime(that.subSessionStart)[0] + subSessionID: eventLog.eventData.subSessionID }); } delete eventLog.eventData.subSessionID; diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 105fb326b..83e387157 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -62,8 +62,20 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { var eventLog = gpii.eventLog({ gradeNames: "gpii.lifecycleManager", distributeOptions: { - record: "gpii.installID.test", - target: "{that installID}.options.gradeNames" + installID: { + record: "gpii.installID.test", + target: "{that installID}.options.gradeNames" + }, + duration: { + record: { + "test-start1": "test-end1", + "test-start2": "test-end2", + "test-start3": "test-end3", + "test-start4": "test-end4" + }, + target: "{that metrics}.options.durationEvents" + + } }, members: { eventData: { @@ -194,6 +206,299 @@ gpii.tests.eventLog.testDefs = fluid.freezeRecursive(fluid.transform([ "error": {"error15": "value15", "stack": ""} } } + }, + // Duration events + { + // start + testData: { + func: "log", + args: ["{that}", "module", "test-start1", {"value": "yes"}] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO", + "data": { + "value": "yes" + } + } + }, + { + // end with data + testData: { + func: "log", + args: ["{that}", "module", "test-end1", {"value": "yes"}] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "value": "yes", + "duration": 2 + } + } + }, + { + // start with no data + testData: { + func: "log", + args: ["{that}", "module", "test-start1" ] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO" + } + }, + { + // end with no data + testData: { + func: "log", + args: ["{that}", "module", "test-end1" ] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + // multiple pairs stacked + { + // start 1 + testData: { + func: "log", + args: ["{that}", "module", "test-start1" ] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO" + } + }, + { + // start 2 + testData: { + func: "log", + args: ["{that}", "module", "test-start2" ] + }, + expected: { + "module": "module", + "event": "test-start2", + "level": "INFO" + } + }, + { + // end 2 + testData: { + func: "log", + args: ["{that}", "module", "test-end2" ] + }, + expected: { + "module": "module", + "event": "test-end2", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + { + // end 1 + testData: { + func: "log", + args: ["{that}", "module", "test-end1" ] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + // multiple pairs intersected + { + // start 1 + testData: { + func: "log", + args: ["{that}", "module", "test-start1" ] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO" + } + }, + { + // start 2 + testData: { + func: "log", + args: ["{that}", "module", "test-start2" ] + }, + expected: { + "module": "module", + "event": "test-start2", + "level": "INFO" + } + }, + { + // end 1 + testData: { + func: "log", + args: ["{that}", "module", "test-end1" ] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + { + // end 2 + testData: { + func: "log", + args: ["{that}", "module", "test-end2" ] + }, + expected: { + "module": "module", + "event": "test-end2", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + // same pairs stacked + { + // start 1 + testData: { + func: "log", + args: ["{that}", "module", "test-start1" ] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO" + } + }, + { + // start 1 (again) + testData: { + func: "log", + args: ["{that}", "module", "test-start1" ] + }, + expected: { + "module": "module", + "event": "test-start1", + "level": "INFO" + } + }, + { + // end 1 + testData: { + func: "log", + args: ["{that}", "module", "test-end1" ] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + { + // end 1 (again) + testData: { + func: "log", + args: ["{that}", "module", "test-end1" ] + }, + expected: { + "module": "module", + "event": "test-end1", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + // End without start + { + // end 3 (no start) + testData: { + func: "log", + args: ["{that}", "module", "test-end3" ] + }, + expected: { + "module": "module", + "event": "test-end3", + "level": "INFO" + } + }, + { + // start 3 (prove the test previous is correct) + testData: { + func: "log", + args: ["{that}", "module", "test-start3" ] + }, + expected: { + "module": "module", + "event": "test-start3", + "level": "INFO" + } + }, + { + // end 3 + testData: { + func: "log", + args: ["{that}", "module", "test-end3" ] + }, + expected: { + "module": "module", + "event": "test-end3", + "level": "INFO", + "data": { + "duration": 2 + } + } + }, + // Already has duration data + { + // start 4 + testData: { + func: "log", + args: ["{that}", "module", "test-start3" ] + }, + expected: { + "module": "module", + "event": "test-start3", + "level": "INFO" + } + }, + { + // end 3 + testData: { + func: "log", + args: ["{that}", "module", "test-end3", {"duration": "hello"} ] + }, + expected: { + "module": "module", + "event": "test-end3", + "level": "INFO", + "data": { + "duration": "hello", + "duration_auto": 2 + } + } } ], function (item) { fluid.each(fluid.makeArray(item.expected), function (expected) { @@ -402,6 +707,13 @@ jqUnit.asyncTest("eventLog tests #1", function () { var that = gpii.tests.eventLog.createEventLogComponent(logFile); + // mock hrtime so it return something expected + var hrtime = process.hrtime; + process.hrtime = function (arg) { + return arg ? [2, 0] : [3, 0]; + }; + + // Log the test data for (var n = 0; n < tests.length; n++) { var test = tests[n]; @@ -417,6 +729,8 @@ jqUnit.asyncTest("eventLog tests #1", function () { expected.push.apply(expected, fluid.makeArray(test.expected)); } + process.hrtime = hrtime; + gpii.tests.eventLog.checkLogFile(logFile, expected) .then(jqUnit.start); }); From 1eb3050f95e77051aa4aa345e23eacc0fdb08f9f Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 26 Jun 2019 16:26:43 +0100 Subject: [PATCH 12/36] GPII-3853: Recording setting changes, and noting if they're in response to a key-in. --- gpii/node_modules/eventLog/src/metrics.js | 41 ++++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 4a05249cc..1e2049fdc 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -103,12 +103,11 @@ fluid.defaults("gpii.metrics.lifecycle", { modelListeners: { "{lifecycleManager}.model.logonChange": { funcName: "gpii.metrics.logonStateChanged", - args: ["{that}", "{lifecycleManager}", "{change}.oldValue", "{change}.value"] + args: ["{that}", "{eventLog}", "{lifecycleManager}", "{change}.oldValue", "{change}.value"] } }, listeners: { - "{lifecycleManager}.events.onCreate": { - namespace: "trackContextChange", + "onCreate.trackContextChange": { listener: "gpii.metrics.trackContextChange", args: ["{that}", "{lifecycleManager}"] }, @@ -251,14 +250,8 @@ gpii.metrics.preferenceChanged = function (that, current, previous) { * @param {Component} eventLog - The gpii.eventLog instance. * @param {String} gpiiKey - The gpiiKey used for this session. */ -gpii.metrics.sessionStarted = function (that, eventLog, gpiiKey) { +gpii.metrics.sessionStarted = function (that, eventLog) { eventLog.eventData.sessionID = fluid.allocateGuid(); - that.isAnonymousUser = (gpiiKey === "noUser"); - if (that.isAnonymousUser) { - delete eventLog.eventData.gpiiKey; - } else { - eventLog.eventData.gpiiKey = gpiiKey; - } }; /** @@ -268,8 +261,6 @@ gpii.metrics.sessionStarted = function (that, eventLog, gpiiKey) { * @param {String} sessionID - Session ID. */ gpii.metrics.sessionStopped = function (that, eventLog, sessionID) { - that.isAnonymousUser = true; - delete eventLog.eventData.gpiiKey; delete that.sessionSolutions[sessionID]; }; @@ -278,11 +269,35 @@ gpii.metrics.sessionStopped = function (that, eventLog, sessionID) { * When the login state changes from "login" to "logout", log the solutions that did not get applied for that session. * * @param {Component} that - The gpii.metrics instance. + * @param {Component} eventLog - The eventLog instance. * @param {Component} lifecycleManager - The lifecycleManager instance. * @param {Object} oldValue - The old value. * @param {Object} newValue - The new value. */ -gpii.metrics.logonStateChanged = function (that, lifecycleManager, oldValue, newValue) { +gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, oldValue, newValue) { + if (newValue.type === "login") { + if (newValue.inProgress) { + // Start marking all events with the gpiiKey. + that.isAnonymousUser = (newValue.gpiiKey === "noUser"); + if (that.isAnonymousUser) { + delete eventLog.eventData.gpiiKey; + } else { + eventLog.eventData.gpiiKey = newValue.gpiiKey; + } + // So metrics knows the next set of events is due to someone keying in + eventLog.eventData.keyIn = true; + } else { + // Login is complete, so all further events are unrelated to key-in. There's a 10 second grace period for + // events that may occur shortly after, however. + eventLog.eventData.keyIn = "after"; + setTimeout(function () {delete eventLog.eventData.keyIn;}, 10000); + } + } else if (newValue.type === "logout" && !newValue.inProgress) { + // Stop marking events with the gpiiKey when they've completely logged out + delete eventLog.eventData.gpiiKey; + that.isAnonymousUser = true; + } + if (oldValue && oldValue.type === "login" && (newValue.type === "logout" || !newValue.inProgress)) { var session = lifecycleManager.getSession(oldValue.gpiiKey); // The reason for this null checker is that the lifecyclaManager's "session" may be null after From dc3592dcf1bd7f5ea1435d4671cf854fe34f4c90 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 26 Jun 2019 17:35:42 +0100 Subject: [PATCH 13/36] GPII-3853: Improved the logging of session ends. --- gpii/node_modules/eventLog/src/metrics.js | 64 +++++++++-------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 1e2049fdc..55db7ceb5 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -106,6 +106,12 @@ fluid.defaults("gpii.metrics.lifecycle", { args: ["{that}", "{eventLog}", "{lifecycleManager}", "{change}.oldValue", "{change}.value"] } }, + invokers: { + sessionStopped: { + funcName: "gpii.metrics.sessionStopped", + args: [ "{that}", "{eventLog}"] + } + }, listeners: { "onCreate.trackContextChange": { listener: "gpii.metrics.trackContextChange", @@ -117,40 +123,12 @@ fluid.defaults("gpii.metrics.lifecycle", { funcName: "gpii.metrics.sessionStarted", args: ["{that}", "{eventLog}", "{arguments}.1"] }, { - namespace: "eventLog", - func: "{eventLog}.logEvent", - args: [ - "lifecycle", - "SessionStart", - { - // onSessionStart fired with [gradeName, gpiiKey] - gpiiKey: "{arguments}.1", - session: "{that}.eventData.sessionID" - } - ] - }, { - func: "{that}.startSubSession" - }, { func: "{that}.events.onStartMetrics" }], "{lifecycleManager}.events.onSessionStop": [{ - namespace: "eventLog", - func: "{eventLog}.logEvent", - args: [ - "lifecycle", - "SessionStop", - { - // onSessionStop fired with [{lifecycleManager}, {session}] - gpiiKey: "{arguments}.1.model.gpiiKey", - session: "{arguments}.1.id" - } - ] - }, { - func: "{that}.stopSubSession" - }, { namespace: "metrics.session", - funcName: "gpii.metrics.sessionStopped", + func: "{that}.sessionStopped", args: ["{that}", "{eventLog}", "{arguments}.1.id"] }, { "func": "{that}.events.onStopMetrics", @@ -159,7 +137,10 @@ fluid.defaults("gpii.metrics.lifecycle", { "{lifecycleManager}.events.onSessionSnapshotUpdate": { namespace: "metrics", funcName: "gpii.metrics.snapshotUpdate", - args: ["{that}", "{arguments}.1.id", "{arguments}.2"] + args: ["{that}", "{arguments}.2"] + }, + "onDestroy.session": { + func: "{that}.sessionStopped" } } }); @@ -191,22 +172,20 @@ gpii.metrics.trackContextChange = function (that, lifecycleManager) { * Log the solutions as they're applied. * * @param {Component} that - The gpii.metrics instance. - * @param {String} sessionID - Session ID. * @param {Object} originalSettings - The original settings (only interested in the keys). */ -gpii.metrics.snapshotUpdate = function (that, sessionID, originalSettings) { +gpii.metrics.snapshotUpdate = function (that, originalSettings) { var ids = fluid.keys(originalSettings); - var solutionIDs = that.sessionSolutions[sessionID]; - if (!solutionIDs) { - solutionIDs = that.sessionSolutions[sessionID] = {}; + if (!that.sessionSolutions) { + that.sessionSolutions = {}; } // Log the solution IDs that haven't been logged. fluid.each(ids, function (id) { - if (!solutionIDs[id]) { + if (!that.sessionSolutions[id]) { that.logMetric("solution-applied", { solutionID: id }); - solutionIDs[id] = true; + that.sessionSolutions[id] = true; } }); }; @@ -252,6 +231,8 @@ gpii.metrics.preferenceChanged = function (that, current, previous) { */ gpii.metrics.sessionStarted = function (that, eventLog) { eventLog.eventData.sessionID = fluid.allocateGuid(); + eventLog.logEvent("lifecycle", "SessionStart"); + that.startSubSession(); }; /** @@ -260,8 +241,13 @@ gpii.metrics.sessionStarted = function (that, eventLog) { * @param {Component} eventLog - The gpii.eventLog instance. * @param {String} sessionID - Session ID. */ -gpii.metrics.sessionStopped = function (that, eventLog, sessionID) { - delete that.sessionSolutions[sessionID]; +gpii.metrics.sessionStopped = function (that, eventLog) { + if (eventLog.eventData.sessionID) { + eventLog.logEvent("lifecycle", "SessionStop"); + delete eventLog.eventData.sessionID; + that.sessionSolutions = {}; + that.startSubSession(); + } }; /** From 7c17730d2b980348b0177490b6462354d3949af1 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 26 Jun 2019 21:13:00 +0100 Subject: [PATCH 14/36] GPII-3853: Updated metrics documentation --- gpii/node_modules/eventLog/README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gpii/node_modules/eventLog/README.md b/gpii/node_modules/eventLog/README.md index df88fd68c..2758214b5 100644 --- a/gpii/node_modules/eventLog/README.md +++ b/gpii/node_modules/eventLog/README.md @@ -37,7 +37,13 @@ All logged events contain the following data: "installID": "hK/Dvo1GG8", // Unique identifier of the installation. "sequence": 60689584, // Incrementing number, unique per installation. "timestamp": "2018-10-31T06:45:21.971-07:00", // When the event occurred - "version": "0.4.0" // The version of this module (or the windows metrics, if higher). + "version": "0.4.0", // The version of this module (or the windows metrics, if higher). + // The following are optional, depending on the current state: + "sessionID": "4acr8sks-4069", // unique session identifier + "subSessionID": "4acr8sks-4069-5", // unique sub-session identifier + "keyIn": true, // true if the user is currently keying-in, "after" if shortly after key-in (10 seconds). This can + // used to determine if a preference was set due to a user's preferences, or the quick-strip. + "gpiiKey": "d90eda4e-d1cd-415b-9605-dd9ce8be6359" // gpiiKey currently in use } ``` @@ -66,11 +72,7 @@ When a user session starts. ```json5 { "module": "lifecycle", - "event": "SessionStart", - "data": { - "gpiiKey": "c7584703-a4bd-48d0-ac96-bc3e2028b1a7", - "session": "ea4d17ff-909" - } + "event": "SessionStart" } ``` @@ -79,8 +81,7 @@ When a user session starts. "module": "lifecycle", "event": "SessionStop", "data": { - "gpiiKey": "c7584703-a4bd-48d0-ac96-bc3e2028b1a7", - "session": "ea4d17ff-909" + "duration": 481 // number of seconds the session lasted. } } ``` From a5dbaa733dab15c4825dff191afb87e0d2a0e8de Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 26 Jun 2019 22:33:51 +0100 Subject: [PATCH 15/36] GPII-3853: replaced keyIn field with logon --- gpii/node_modules/eventLog/README.md | 4 ++-- gpii/node_modules/eventLog/src/metrics.js | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gpii/node_modules/eventLog/README.md b/gpii/node_modules/eventLog/README.md index 2758214b5..26e8d7503 100644 --- a/gpii/node_modules/eventLog/README.md +++ b/gpii/node_modules/eventLog/README.md @@ -41,8 +41,8 @@ All logged events contain the following data: // The following are optional, depending on the current state: "sessionID": "4acr8sks-4069", // unique session identifier "subSessionID": "4acr8sks-4069-5", // unique sub-session identifier - "keyIn": true, // true if the user is currently keying-in, "after" if shortly after key-in (10 seconds). This can - // used to determine if a preference was set due to a user's preferences, or the quick-strip. + "logon": "on", // "in" or "out" if currently logging in/out - "in-after"/"out-after" 10 seconds after log in/out. + // for any other time, this field does not exist. "gpiiKey": "d90eda4e-d1cd-415b-9605-dd9ce8be6359" // gpiiKey currently in use } ``` diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 55db7ceb5..af7383c50 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -63,8 +63,6 @@ fluid.defaults("gpii.metrics", { }, members: { sessionSolutions: {}, - // Is the noUser (or nobody) logged on? - isAnonymousUser: true, // Incrementing sub-session id. subSessionIncrementer: 0 }, @@ -264,24 +262,29 @@ gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, old if (newValue.type === "login") { if (newValue.inProgress) { // Start marking all events with the gpiiKey. - that.isAnonymousUser = (newValue.gpiiKey === "noUser"); - if (that.isAnonymousUser) { + if (newValue.gpiiKey === "noUser") { delete eventLog.eventData.gpiiKey; } else { eventLog.eventData.gpiiKey = newValue.gpiiKey; } // So metrics knows the next set of events is due to someone keying in - eventLog.eventData.keyIn = true; + eventLog.eventData.logon = "in"; } else { // Login is complete, so all further events are unrelated to key-in. There's a 10 second grace period for // events that may occur shortly after, however. - eventLog.eventData.keyIn = "after"; + eventLog.eventData.logon = "in-after"; setTimeout(function () {delete eventLog.eventData.keyIn;}, 10000); } } else if (newValue.type === "logout" && !newValue.inProgress) { // Stop marking events with the gpiiKey when they've completely logged out delete eventLog.eventData.gpiiKey; - that.isAnonymousUser = true; + + if (newValue.inProgress) { + eventLog.eventData.logon = "out"; + } else { + eventLog.eventData.logon = "out-after"; + } + setTimeout(function () {delete eventLog.eventData.keyIn;}, 10000); } if (oldValue && oldValue.type === "login" && (newValue.type === "logout" || !newValue.inProgress)) { From 1f556d44a079e7c51c718bef024bb8ca118e0230 Mon Sep 17 00:00:00 2001 From: ste Date: Mon, 1 Jul 2019 22:11:28 +0100 Subject: [PATCH 16/36] GPII-3853: Recording the state of the QSS. --- gpii/node_modules/eventLog/src/eventLog.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 272096f98..44813a7e9 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -52,7 +52,11 @@ fluid.defaults("gpii.eventLog", { logError: "gpii.eventLog.logError", getGpiiSettingsDir: "{settingsDir}.getGpiiSettingsDir", getLogFile: "gpii.eventLog.getLogFile", - getVersion: "gpii.eventLog.getVersion" + getVersion: "gpii.eventLog.getVersion", + setState: { + funcName: "gpii.eventLog.setState", + args: ["{eventLog}", "{arguments}.0", "{arguments}.1"] // name, value + } }, members: { sequence: 0, @@ -427,3 +431,18 @@ gpii.eventLog.checkLevel = function (level) { return fluid.isLogLevel(level) ? level : fluid.logLevel.INFO; } }; + +/** + * Specifies a field which gets logged with every subsequent event. + * + * @param {Component} that The gpii.eventLog instance. + * @param {String} name The name of the field. + * @param {Object} value The field value. undefined or null will remove the field. + */ +gpii.eventLog.setState = function (that, name, value) { + if (value === undefined || value === null) { + delete that.eventData[name]; + } else { + that.eventData[name] = value; + } +}; From bf258bc04eb4c199436824b0b2f1aea904abff3e Mon Sep 17 00:00:00 2001 From: ste Date: Mon, 1 Jul 2019 23:10:03 +0100 Subject: [PATCH 17/36] GPII-3853: Documenting recent changes --- gpii/node_modules/eventLog/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/eventLog/README.md b/gpii/node_modules/eventLog/README.md index 26e8d7503..d85e41939 100644 --- a/gpii/node_modules/eventLog/README.md +++ b/gpii/node_modules/eventLog/README.md @@ -43,7 +43,10 @@ All logged events contain the following data: "subSessionID": "4acr8sks-4069-5", // unique sub-session identifier "logon": "on", // "in" or "out" if currently logging in/out - "in-after"/"out-after" 10 seconds after log in/out. // for any other time, this field does not exist. - "gpiiKey": "d90eda4e-d1cd-415b-9605-dd9ce8be6359" // gpiiKey currently in use + "gpiiKey": "d90eda4e-d1cd-415b-9605-dd9ce8be6359", // gpiiKey currently in use, + "app": "active", // The active window belongs to Morphic. + "hover": "openUSB", // The button that the mouse is currently hovering over. + "focus": "launch-documorph" // The button that currently has focus (combine with "app") } ``` From 17f352e7c6571f8392269522ef3a96e27cc917ed Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 2 Jul 2019 13:23:43 +0100 Subject: [PATCH 18/36] GPII-3853: Disabling metrics via siteConfig --- gpii/node_modules/eventLog/src/eventLog.js | 76 +++++++++++-------- gpii/node_modules/eventLog/src/metrics.js | 3 +- .../eventLog/test/EventLogTests.js | 8 ++ 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 44813a7e9..0e3fe82d0 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -62,6 +62,7 @@ fluid.defaults("gpii.eventLog", { sequence: 0, // Buffered log lines while there's not log server connection logBuffer: [], + logLevel: fluid.logLevel.INFO, // Maximum number of lines to buffer. maxBufferlength: 0xfff, // Data to include in every log entry. @@ -78,7 +79,7 @@ fluid.defaults("gpii.eventLog", { listeners: { "onCreate.logFile": { func: "gpii.eventLog.getLogFile", - args: ["{that}"] + args: ["{that}","{metrics}.options.disable"] }, "onCreate.log": { func: "gpii.eventLog.logStartStop", @@ -256,36 +257,47 @@ fluid.onUncaughtException.addListener(gpii.eventLog.gotError, "gpii-eventLog"); * GPII_EVENT_LOG_DIRECTORY: A directory where per-instance logs are kept * * @param {Component} that - The gpii.eventLog instance. + * @param {Boolean|String} disable true-like to disable logging, "errors-only" to only log errors. * @return {String} The path to the new log file. */ -gpii.eventLog.getLogFile = function (that) { +gpii.eventLog.getLogFile = function (that, disable) { var logPath; if (!process.env.GPII_EVENT_LOG_DIRECTORY) { logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination; } + var errorsOnly = disable === "errors-only"; + if (errorsOnly) { + that.logLevel = fluid.logLevel.FAIL; + } - if (logPath) { - if (logPath.startsWith("tcp:")) { - var m = /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); - if (m) { - that.logHost = m[1]; - that.logPort = m[2]; - that.logFilePath = null; + if (disable && !errorsOnly) { + fluid.log(fluid.logLevel.WARN, "Event logging is disabled"); + that.logLevel = fluid.logLevel.FATAL; + that.logFilePath = null; + that.logHost = null; + } else { + if (logPath) { + if (logPath.startsWith("tcp:")) { + var m = /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); + if (m) { + that.logHost = m[1]; + that.logPort = m[2]; + that.logFilePath = null; + } + } else { + that.logHost = null; + that.logFilePath = logPath; } } else { that.logHost = null; - that.logFilePath = logPath; + var startupTime = Date.now(); + var gpiiSettingsDir = process.env.GPII_EVENT_LOG_DIRECTORY || that.getGpiiSettingsDir(); + that.logFilePath = path.join(gpiiSettingsDir, "gpii-" + gpii.journal.formatTimestamp(startupTime) + ".log"); } - } else { - that.logHost = null; - var startupTime = Date.now(); - var gpiiSettingsDir = process.env.GPII_EVENT_LOG_DIRECTORY || that.getGpiiSettingsDir(); - that.logFilePath = path.join(gpiiSettingsDir, "gpii-" + gpii.journal.formatTimestamp(startupTime) + ".log"); - } - - var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath; - fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest); + var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath; + fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest); + } return that.logFilePath; }; @@ -298,8 +310,8 @@ gpii.eventLog.getLogFile = function (that) { * timestamp fields. */ gpii.eventLog.writeLog = function (that, level, event) { - var intLevel = gpii.eventLog.checkLevel(level); - event.level = intLevel.value; + var eventLevel = gpii.eventLog.checkLevel(level); + event.level = eventLevel.value; gpii.eventLog.recordDuration(that, event); @@ -310,14 +322,16 @@ gpii.eventLog.writeLog = function (that, level, event) { event.timestamp = gpii.eventLog.getTimestamp(); event.sequence = that.sequence++; - var logLine = JSON.stringify(event) + "\n"; + if (eventLevel.priority <= that.logLevel.priority) { + var logLine = JSON.stringify(event) + "\n"; - if (that.logHost && that.logPort) { - gpii.eventLog.writeLogTcp(that, logLine); - } + if (that.logHost && that.logPort) { + gpii.eventLog.writeLogTcp(that, logLine); + } - if (that.logFilePath) { - fs.appendFileSync(that.logFilePath, logLine); + if (that.logFilePath) { + fs.appendFileSync(that.logFilePath, logLine); + } } }; @@ -422,14 +436,16 @@ gpii.eventLog.connectLog = function (that) { * Sets INFO as default loglevel * * @param {Object} level - Level to check, can be a string that represents the value or a property of fluid.logLevel. - * @return {Integer} A valid fluid.logLevel, with INFO as default. + * @return {Object} A valid fluid.logLevel, with INFO as default. */ gpii.eventLog.checkLevel = function (level) { + var togo; if (typeof level === "string" && level in fluid.logLevelsSpec) { - return fluid.logLevel[level]; + togo = fluid.logLevel[level]; } else { - return fluid.isLogLevel(level) ? level : fluid.logLevel.INFO; + togo = fluid.isLogLevel(level) && level; } + return togo || fluid.logLevel.INFO; }; /** diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index af7383c50..fb47a6e61 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -93,7 +93,8 @@ fluid.defaults("gpii.metrics", { "inactive-begin": "inactive-stop", "SessionStart": "SessionStop", "subsession-begin": "subsession-end" - } + }, + siteConfig: {} }); // Mixin grade for gpii.metrics to log lifecycle manager things diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 83e387157..2bd4c7459 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -192,6 +192,14 @@ gpii.tests.eventLog.testDefs = fluid.freezeRecursive(fluid.transform([ "data": {"data0": "value0"} } }, + { + // test log level (dropped) + testData: { + func: "log", + args: ["{that}", "module14b", "event14b", {"data0": "value0"}, fluid.logLevel.TRACE] + }, + expected: null + }, { // logError testData: { From 27ac5984084ecb2ce74580bb08080f0d6ff67c14 Mon Sep 17 00:00:00 2001 From: ste Date: Thu, 4 Jul 2019 16:44:06 +0100 Subject: [PATCH 19/36] GPII-3852: Removed unexpected item in the bagging area --- gpii/node_modules/eventLog/src/metrics.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index fb47a6e61..429aa097b 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -320,4 +320,3 @@ gpii.metrics.stopSubSession = function (that, eventLog) { } delete eventLog.eventData.subSessionID; }; - From e0b926e33d29150ed1083242ddbc2fbe7adf5b6c Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 9 Jul 2019 16:11:31 +0100 Subject: [PATCH 20/36] GPII-3853: Added metrics for notification and error dialogs --- gpii/node_modules/eventLog/src/metrics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 429aa097b..292af7b09 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -274,7 +274,7 @@ gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, old // Login is complete, so all further events are unrelated to key-in. There's a 10 second grace period for // events that may occur shortly after, however. eventLog.eventData.logon = "in-after"; - setTimeout(function () {delete eventLog.eventData.keyIn;}, 10000); + setTimeout(function () {delete eventLog.eventData.logon;}, 10000); } } else if (newValue.type === "logout" && !newValue.inProgress) { // Stop marking events with the gpiiKey when they've completely logged out @@ -285,7 +285,7 @@ gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, old } else { eventLog.eventData.logon = "out-after"; } - setTimeout(function () {delete eventLog.eventData.keyIn;}, 10000); + setTimeout(function () {delete eventLog.eventData.logon;}, 10000); } if (oldValue && oldValue.type === "login" && (newValue.type === "logout" || !newValue.inProgress)) { From 6524c2e6e6c2b1f45eccf1c0405ac1a3a0958101 Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 9 Jul 2019 23:42:54 +0100 Subject: [PATCH 21/36] GPII-3853: Updated documentation --- gpii/node_modules/eventLog/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/eventLog/README.md b/gpii/node_modules/eventLog/README.md index d85e41939..13ba35e67 100644 --- a/gpii/node_modules/eventLog/README.md +++ b/gpii/node_modules/eventLog/README.md @@ -38,15 +38,20 @@ All logged events contain the following data: "sequence": 60689584, // Incrementing number, unique per installation. "timestamp": "2018-10-31T06:45:21.971-07:00", // When the event occurred "version": "0.4.0", // The version of this module (or the windows metrics, if higher). + // The following are optional, depending on the current state: "sessionID": "4acr8sks-4069", // unique session identifier "subSessionID": "4acr8sks-4069-5", // unique sub-session identifier "logon": "on", // "in" or "out" if currently logging in/out - "in-after"/"out-after" 10 seconds after log in/out. // for any other time, this field does not exist. "gpiiKey": "d90eda4e-d1cd-415b-9605-dd9ce8be6359", // gpiiKey currently in use, + // from the UI: "app": "active", // The active window belongs to Morphic. - "hover": "openUSB", // The button that the mouse is currently hovering over. - "focus": "launch-documorph" // The button that currently has focus (combine with "app") + "focus": "openUSB", // The button that currently has focus (combine with "app" to determine if it has system focus) + "hover": "launch-documorph", // The button that the mouse is currently hovering over. + "widget-hover": "openUSB", // The QSS pop-up that the mouse is over. + "field-hover": "ejectUsbButton", // The field within the pop-up that the mouse is over. + "field-focus": "regular-contrast", // The field within the pop-up that has key focus. } ``` From a30aa8ef23ed4c53c2d6d231c8e7c74f32a791ad Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 9 Jul 2019 23:43:21 +0100 Subject: [PATCH 22/36] GPII-3853: Increased login time --- gpii/node_modules/eventLog/src/metrics.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 292af7b09..d966bf8d5 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -271,10 +271,10 @@ gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, old // So metrics knows the next set of events is due to someone keying in eventLog.eventData.logon = "in"; } else { - // Login is complete, so all further events are unrelated to key-in. There's a 10 second grace period for + // Login is complete, so all further events are unrelated to key-in. There's a 15 second grace period for // events that may occur shortly after, however. eventLog.eventData.logon = "in-after"; - setTimeout(function () {delete eventLog.eventData.logon;}, 10000); + setTimeout(function () {delete eventLog.eventData.logon;}, 15000); } } else if (newValue.type === "logout" && !newValue.inProgress) { // Stop marking events with the gpiiKey when they've completely logged out @@ -285,7 +285,7 @@ gpii.metrics.logonStateChanged = function (that, eventLog, lifecycleManager, old } else { eventLog.eventData.logon = "out-after"; } - setTimeout(function () {delete eventLog.eventData.logon;}, 10000); + setTimeout(function () {delete eventLog.eventData.logon;}, 15000); } if (oldValue && oldValue.type === "login" && (newValue.type === "logout" || !newValue.inProgress)) { From 0cd13207591a2292f257c2f671e65b9b49a17ecc Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 17 Jul 2019 13:52:36 +0100 Subject: [PATCH 23/36] GPII-3853: Removed logging of metrics from the log file. --- gpii/node_modules/eventLog/src/eventLog.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 0e3fe82d0..5ef62a9a6 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -315,9 +315,6 @@ gpii.eventLog.writeLog = function (that, level, event) { gpii.eventLog.recordDuration(that, event); - // Log to console before the installation ID and timestamp are added (no one wants to see it). - fluid.log(fluid.logLevel.INFO, event); - Object.assign(event, that.eventData); event.timestamp = gpii.eventLog.getTimestamp(); event.sequence = that.sequence++; From 13d4b5a324b7d09dea1769c2418b9088ac365330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 26 Jul 2019 18:29:01 +0200 Subject: [PATCH 24/36] GPII-3780: Simplified transformation due to GPII-3784 being solve --- testData/solutions/win32.json5 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 3b722b263..508fc09d1 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -5045,13 +5045,9 @@ }, "capabilitiesTransformations": { "ImageConfig": { - // This transform is necessary due to issue GPII-3784. "transform": { - "type": "fluid.transforms.condition", - "conditionPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor.r", - "true": "", - "false": "", - "outputPath": "value" + "type": "fluid.transforms.literalValue", + "input": "" }, "path": { "transform": { From a9d702e637edcb7e1fa0265a4a710e95cbe8533d Mon Sep 17 00:00:00 2001 From: Cindy Qi Li Date: Fri, 26 Jul 2019 14:23:05 -0400 Subject: [PATCH 25/36] GPII-3780: Improve the tranformation for "ImageConfig" in win32.json5. --- testData/solutions/win32.json5 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 508fc09d1..84edb3306 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -5043,11 +5043,15 @@ } } }, + "capabilities": [ + "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor" + ], "capabilitiesTransformations": { "ImageConfig": { "transform": { "type": "fluid.transforms.literalValue", - "input": "" + "input": "", + "outputPath": "value" }, "path": { "transform": { From 0b705aad2454a4e37f36e086ab1e9e4d1fa89efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 6 Aug 2019 11:15:50 +0100 Subject: [PATCH 26/36] GPII-3780: Removed unnecessary transform due to GPII-3784 being already solved --- testData/solutions/win32.json5 | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 84edb3306..a7eb2bb0e 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -5103,23 +5103,9 @@ }, "capabilitiesTransformations": { "SolidColorConfig": { - // This transform is necessary due to issue GPII-3784. "transform": { - "type": "fluid.transforms.condition", - "conditionPath": "SolidColor", - "condition": true, - "true": { - "transform": { - "type": "fluid.transforms.value", - "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor" - } - }, - "false": { - "transform": { - "type": "fluid.transforms.value", - "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor" - } - }, + "type": "fluid.transforms.value", + "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.desktopBackgroundColor.SolidColor", "outputPath": "value" } } From 664fce8a64500a0d0c23ce7248f0685365e023b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Wed, 14 Aug 2019 19:52:17 +0200 Subject: [PATCH 27/36] GPII-3780: Changed preferences for 'test-user' to change to different wallpaper --- testData/preferences/brenda.json5 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testData/preferences/brenda.json5 b/testData/preferences/brenda.json5 index f19cfbc6a..3f31f290d 100644 --- a/testData/preferences/brenda.json5 +++ b/testData/preferences/brenda.json5 @@ -1,4 +1,4 @@ -// # Bryan.json5 +// # Brenda.json5 // // This preference sets changes the desktop wallpaper with another default Windows 10 one. // @@ -8,13 +8,13 @@ // { "flat": { - "name": "Bryan", + "name": "Brenda", "contexts": { "gpii-default": { "name": "Default preferences", "preferences": { "http://registry.gpii.net/applications/com.microsoft.windows.desktopBackground": { - "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img3.jpg" + "Image": "C:\\Windows\\Web\\Wallpaper\\Theme1\\img2.jpg" } } } From db02ca456b13bb03a1cba593b033511522aa1400 Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 22 Nov 2019 20:53:37 +0000 Subject: [PATCH 28/36] GPII-3572: Made the log file initialisation pleasant --- gpii/node_modules/eventLog/src/eventLog.js | 60 +++++++++---------- .../eventLog/test/EventLogTests.js | 7 ++- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index a1401be04..611b353e8 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -47,7 +47,6 @@ fluid.defaults("gpii.eventLog", { }, logError: "gpii.eventLog.logError", getGpiiSettingsDir: "{settingsDir}.getGpiiSettingsDir", - getLogFile: "gpii.eventLog.getLogFile", getVersion: "gpii.eventLog.getVersion" }, members: { @@ -58,12 +57,19 @@ fluid.defaults("gpii.eventLog", { // Buffered log lines while there's not log server connection logBuffer: [], // Maximum number of lines to buffer. - maxBufferlength: 0xfff + maxBufferlength: 0xfff, + // A TCP socket to send the log entries to (filebeat service). + logServer: { + host: null, + port: null + }, + // A file to write the log entries to. + logPath: null }, listeners: { "onCreate.logFile": { - func: "gpii.eventLog.getLogFile", - args: ["{that}"] + func: "gpii.eventLog.initLogDestination", + args: ["{that}", "{that}.options.logDestination"] }, "onCreate.log": { func: "gpii.eventLog.logStartStop", @@ -74,7 +80,7 @@ fluid.defaults("gpii.eventLog", { args: ["{that}", "stop"] } }, - + // File path, or tcp://host:port logDestination: null }); @@ -227,37 +233,25 @@ gpii.eventLog.gotError = function (err, errType) { fluid.onUncaughtException.addListener(gpii.eventLog.gotError, "gpii-eventLog"); /** - * Gets the path of the new log file for this instance of gpii. - * It can use one of the following environment variables to override the configured: - * GPII_EVENT_LOG: The path to the log file (a file, or tcp://:). + * Parses the log path (which can be overridden by the GPII_EVENT_LOG environment variable), and sets either the + * logServer or logPath member. * * @param {Component} that - The gpii.eventLog instance. - * @return {String} The path to the new log file. + * @param {String} logPath - The path to the log file (a file, or a tcp socket in the format of `tcp://:`). */ -gpii.eventLog.getLogFile = function (that) { - var logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination; - - if (logPath) { - if (logPath.startsWith("tcp:")) { - var m = /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); - if (m) { - that.logHost = m[1]; - that.logPort = m[2]; - that.logFilePath = null; - } - } else { - that.logHost = null; - that.logFilePath = logPath; - } +gpii.eventLog.initLogDestination = function (that, logPath) { + logPath = process.env.GPII_EVENT_LOG || logPath; + + var match = logPath && /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); + if (match) { + that.logServer.host = match[1]; + that.logServer.port = match[2]; } else { - that.logHost = null; - that.logFilePath = null; + that.logPath = logPath; } - var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath; + var dest = that.logServer.host ? ("tcp://" + that.logServer.host + ":" + that.logServer.port) : that.logPath; fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest); - - return that.logFilePath; }; /** @@ -282,12 +276,12 @@ gpii.eventLog.writeLog = function (that, level, event) { var logLine = JSON.stringify(event) + "\n"; - if (that.logHost && that.logPort) { + if (that.logServer.host && that.logServer.port) { gpii.eventLog.writeLogTcp(that, logLine); } - if (that.logFilePath) { - fs.appendFileSync(that.logFilePath, logLine); + if (that.logPath) { + fs.appendFileSync(that.logPath, logLine); } }; @@ -327,7 +321,7 @@ gpii.eventLog.connectLog = function (that) { // Connect to the server. that.logSocket = new net.Socket(); - that.logSocket.connect(that.logPort, that.logHost, function () { + that.logSocket.connect(that.logServer.port, that.logServer.host, function () { gpii.eventLog.connectLog.lastError = null; fluid.log("Connected to log server"); // Send the initial data. diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 89c9d06d8..ed100991d 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -66,9 +66,10 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { target: "{that installID}.options.gradeNames" }, members: { - installationID: gpii.tests.eventLog.installID, - logFilePath: logFile - } + installationID: gpii.tests.eventLog.installID + }, + logDestination: logFile + }); teardowns.push(eventLog.destroy); return eventLog; From 93925ade02496dcf1980c92bf61ef246645db8ad Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 22 Nov 2019 20:53:37 +0000 Subject: [PATCH 29/36] GPII-3572: Made the log file initialisation pleasant --- gpii/node_modules/eventLog/src/eventLog.js | 86 +++++++------------ .../eventLog/test/EventLogTests.js | 2 +- 2 files changed, 34 insertions(+), 54 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index 5ef62a9a6..2fed1b590 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -22,7 +22,6 @@ var fluid = require("infusion"); var fs = require("fs"), - path = require("path"), moment = require("moment"), net = require("net"); @@ -51,7 +50,6 @@ fluid.defaults("gpii.eventLog", { }, logError: "gpii.eventLog.logError", getGpiiSettingsDir: "{settingsDir}.getGpiiSettingsDir", - getLogFile: "gpii.eventLog.getLogFile", getVersion: "gpii.eventLog.getVersion", setState: { funcName: "gpii.eventLog.setState", @@ -73,13 +71,20 @@ fluid.defaults("gpii.eventLog", { sessionID: undefined, gpiiKey: undefined }, + // A TCP socket to send the log entries to (filebeat service). + logServer: { + host: null, + port: null + }, + // A file to write the log entries to. + logPath: null, // The start times for events which require durations to be recorded. eventTimes: {} }, listeners: { "onCreate.logFile": { - func: "gpii.eventLog.getLogFile", - args: ["{that}","{metrics}.options.disable"] + func: "gpii.eventLog.initLogDestination", + args: ["{that}", "{that}.options.logDestination"] }, "onCreate.log": { func: "gpii.eventLog.logStartStop", @@ -90,7 +95,8 @@ fluid.defaults("gpii.eventLog", { args: ["{that}", "stop"] } }, - logDestination: "tcp://127.0.0.1:51481" + // File path, or tcp://host:port + logDestination: null }); /** @@ -207,8 +213,11 @@ gpii.eventLog.logError = function (that, moduleName, errType, err, level) { if (err instanceof Error) { // Error doesn't serialise data.error = {}; - fluid.each(Object.getOwnPropertyNames(err), function (a) { - data.error[a] = err[a]; + fluid.each(Object.getOwnPropertyNames(err), function (source) { + // Ensure the first character of the field is lowercase - "Message" vs "message" was causing a duplicate + // field during the analysis. + var dest = source.charAt(0).toLowerCase() + source.slice(1); + data.error[dest] = err[source]; }); } else if (fluid.isPlainObject(err, true)) { data.error = Object.assign({}, err); @@ -251,54 +260,25 @@ gpii.eventLog.gotError = function (err, errType) { fluid.onUncaughtException.addListener(gpii.eventLog.gotError, "gpii-eventLog"); /** - * Gets the path of the new log file for this instance of gpii. - * It can use one of the following environment variables to override the configured: - * GPII_EVENT_LOG: The path to the log file (a file, or tcp://:). - * GPII_EVENT_LOG_DIRECTORY: A directory where per-instance logs are kept + * Parses the log path (which can be overridden by the GPII_EVENT_LOG environment variable), and sets either the + * logServer or logPath member. * * @param {Component} that - The gpii.eventLog instance. - * @param {Boolean|String} disable true-like to disable logging, "errors-only" to only log errors. - * @return {String} The path to the new log file. + * @param {String} logPath - The path to the log file (a file, or a tcp socket in the format of `tcp://:`). */ -gpii.eventLog.getLogFile = function (that, disable) { - var logPath; - if (!process.env.GPII_EVENT_LOG_DIRECTORY) { - logPath = process.env.GPII_EVENT_LOG || that.logFilePath || that.options.logDestination; - } - var errorsOnly = disable === "errors-only"; - if (errorsOnly) { - that.logLevel = fluid.logLevel.FAIL; - } +gpii.eventLog.initLogDestination = function (that, logPath) { + logPath = process.env.GPII_EVENT_LOG || logPath; - if (disable && !errorsOnly) { - fluid.log(fluid.logLevel.WARN, "Event logging is disabled"); - that.logLevel = fluid.logLevel.FATAL; - that.logFilePath = null; - that.logHost = null; + var match = logPath && /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); + if (match) { + that.logServer.host = match[1]; + that.logServer.port = match[2]; } else { - if (logPath) { - if (logPath.startsWith("tcp:")) { - var m = /tcp:\/*([^:]+):([0-9]+)/.exec(logPath); - if (m) { - that.logHost = m[1]; - that.logPort = m[2]; - that.logFilePath = null; - } - } else { - that.logHost = null; - that.logFilePath = logPath; - } - } else { - that.logHost = null; - var startupTime = Date.now(); - var gpiiSettingsDir = process.env.GPII_EVENT_LOG_DIRECTORY || that.getGpiiSettingsDir(); - that.logFilePath = path.join(gpiiSettingsDir, "gpii-" + gpii.journal.formatTimestamp(startupTime) + ".log"); - } - - var dest = that.logHost ? ("tcp://" + that.logHost + ":" + that.logPort) : that.logFilePath; - fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest); + that.logPath = logPath; } - return that.logFilePath; + + var dest = that.logServer.host ? ("tcp://" + that.logServer.host + ":" + that.logServer.port) : that.logPath; + fluid.log(fluid.logLevel.IMPORTANT, "Writing event log to " + dest); }; /** @@ -322,12 +302,12 @@ gpii.eventLog.writeLog = function (that, level, event) { if (eventLevel.priority <= that.logLevel.priority) { var logLine = JSON.stringify(event) + "\n"; - if (that.logHost && that.logPort) { + if (that.logServer.host && that.logServer.port) { gpii.eventLog.writeLogTcp(that, logLine); } - if (that.logFilePath) { - fs.appendFileSync(that.logFilePath, logLine); + if (that.logPath) { + fs.appendFileSync(that.logPath, logLine); } } }; @@ -399,7 +379,7 @@ gpii.eventLog.connectLog = function (that) { // Connect to the server. that.logSocket = new net.Socket(); - that.logSocket.connect(that.logPort, that.logHost, function () { + that.logSocket.connect(that.logServer.port, that.logServer.host, function () { gpii.eventLog.connectLog.lastError = null; fluid.log("Connected to log server"); // Send the initial data. diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 2bd4c7459..7addee5cf 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -82,7 +82,7 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { installID: gpii.tests.eventLog.installID, sessionID: gpii.tests.eventLog.sessionID }, - logFilePath: logFile + logDestination: logFile } }); teardowns.push(eventLog.destroy); From a239f0399c1ed89bf0aea10b3b3be18e69a17c5f Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 4 Dec 2019 13:06:09 +0000 Subject: [PATCH 30/36] GPII-3852: Fixed merge of 3572 --- gpii/node_modules/eventLog/src/eventLog.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gpii/node_modules/eventLog/src/eventLog.js b/gpii/node_modules/eventLog/src/eventLog.js index ae6452a59..3acb2439f 100644 --- a/gpii/node_modules/eventLog/src/eventLog.js +++ b/gpii/node_modules/eventLog/src/eventLog.js @@ -22,7 +22,6 @@ var fluid = require("infusion"); var fs = require("fs"), - path = require("path"), moment = require("moment"), net = require("net"); @@ -320,7 +319,7 @@ gpii.eventLog.writeLog = function (that, level, event) { * @param {LogEvent} event The event. */ gpii.eventLog.recordDuration = function (that, event) { - var endEvent = that.metrics.options.durationEvents[event.event]; + var endEvent = that.options.durationEvents[event.event]; if (endEvent) { // This is the start of a pair of duration events. if (!that.eventTimes[endEvent]) { From 80950ecb0b6038d56c47f925c5b7e6399dd61726 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 4 Dec 2019 14:10:40 +0000 Subject: [PATCH 31/36] GPII-3852: Fixed merge of 3572 (2) --- gpii/node_modules/flowManager/src/FlowManager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index c4cad63c5..ac540260b 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -175,7 +175,10 @@ fluid.defaults("gpii.flowManager.local", { } }, eventLog: { - type: "gpii.eventLog" + type: "gpii.eventLog", + options: { + gradeNames: ["gpii.metrics", "gpii.metrics.lifecycle"] + } }, userListeners: { type: "gpii.userListeners" From 6a3290e26c38a9ff15cb9c150c9debc4a7a0b5a1 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 4 Dec 2019 17:14:53 +0000 Subject: [PATCH 32/36] GPII-3852: Fixed merge of 3572 (missing grade name in test) --- gpii/node_modules/eventLog/test/EventLogTests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 7addee5cf..16b682171 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -60,7 +60,7 @@ gpii.tests.eventLog.getMachineID = function () { */ gpii.tests.eventLog.createEventLogComponent = function (logFile) { var eventLog = gpii.eventLog({ - gradeNames: "gpii.lifecycleManager", + gradeNames: ["gpii.lifecycleManager", "gpii.metrics"], distributeOptions: { installID: { record: "gpii.installID.test", From 1b707a22032c177f05f4741b8a245ea6c8e3063d Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 4 Dec 2019 17:27:15 +0000 Subject: [PATCH 33/36] GPII-3852: Fixed merge of 3572 (fixed unit test) --- gpii/node_modules/eventLog/test/EventLogTests.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index 16b682171..ca82d8492 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -81,9 +81,9 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { eventData: { installID: gpii.tests.eventLog.installID, sessionID: gpii.tests.eventLog.sessionID - }, - logDestination: logFile - } + } + }, + logDestination: logFile }); teardowns.push(eventLog.destroy); return eventLog; From 242fc6b9e59822b9b4300b4816222f1b140146d3 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 4 Dec 2019 18:43:39 +0000 Subject: [PATCH 34/36] GPII-3852: Fixed merge of 3572 Moved duration EventLogTests.js tests --- gpii/node_modules/eventLog/test/EventLogTests.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gpii/node_modules/eventLog/test/EventLogTests.js b/gpii/node_modules/eventLog/test/EventLogTests.js index ca82d8492..b3bb1038a 100644 --- a/gpii/node_modules/eventLog/test/EventLogTests.js +++ b/gpii/node_modules/eventLog/test/EventLogTests.js @@ -65,18 +65,14 @@ gpii.tests.eventLog.createEventLogComponent = function (logFile) { installID: { record: "gpii.installID.test", target: "{that installID}.options.gradeNames" - }, - duration: { - record: { - "test-start1": "test-end1", - "test-start2": "test-end2", - "test-start3": "test-end3", - "test-start4": "test-end4" - }, - target: "{that metrics}.options.durationEvents" - } }, + durationEvents: { + "test-start1": "test-end1", + "test-start2": "test-end2", + "test-start3": "test-end3", + "test-start4": "test-end4" + }, members: { eventData: { installID: gpii.tests.eventLog.installID, From fde4347283ebd1b30dd28d0bc09655c016c7c16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Wed, 8 Jan 2020 12:11:27 +0100 Subject: [PATCH 35/36] GPII-4214.GPII-3572: Revert "Revert "Merge branch 'GPII-4231'"" This reverts commit 32759c38f9e1a5a38072f8c5e60b02a5d20969d7. --- .../deviceReporter/installedSolutions.json | 4 + testData/preferences/caroline.json5 | 22 ++ testData/solutions/win32.json5 | 197 ++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 testData/preferences/caroline.json5 diff --git a/testData/deviceReporter/installedSolutions.json b/testData/deviceReporter/installedSolutions.json index 61e6d7f1f..ff3f394df 100644 --- a/testData/deviceReporter/installedSolutions.json +++ b/testData/deviceReporter/installedSolutions.json @@ -40,6 +40,10 @@ "id": "com.microsoft.windows.cursors" }, + { + "id": "com.microsoft.windows.colorFilters" + }, + { "id": "com.microsoft.windows.filterKeys" }, diff --git a/testData/preferences/caroline.json5 b/testData/preferences/caroline.json5 new file mode 100644 index 000000000..2b4a5895f --- /dev/null +++ b/testData/preferences/caroline.json5 @@ -0,0 +1,22 @@ +//# Caroline +// +// This preference set sets the Windows color filters for a user with deuteranopia. +// +//## Testing +// +// Color should cahnge when the user is logged in, green color should be weaker than before. +{ + "flat": { + "name": "Caroline", + "contexts": { + "gpii-default": { + "name": "Default preferences", + "preferences": { + "http://registry.gpii.net/applications/com.microsoft.windows.colorFilters": { + "FilterType": 3 + } + } + } + } + } +} diff --git a/testData/solutions/win32.json5 b/testData/solutions/win32.json5 index 9b9e5ed58..7c4e30a0d 100644 --- a/testData/solutions/win32.json5 +++ b/testData/solutions/win32.json5 @@ -6287,6 +6287,203 @@ } ] }, + "com.microsoft.windows.colorFilters": { + "name": "Windows Built-in Screen Magnifier", + "contexts": { + "OS": [ + { + "id": "win32", + "version": ">=5.0" + } + ] + }, + "capabilities": [ + ], + "settingsHandlers": { + "configure": { + "type": "gpii.windows.systemSettingsHandler", + "liveness": "live", + "options": { + "CheckResult": true + }, + "supportedSettings": { + "SystemSettings_Accessibility_ColorFiltering_IsEnabled": { + "schema": { + "title": "Enable color filtering", + "description": "Enable or disables Windows color filters.", + "type": "boolean", + "default": false + } + }, + "SystemSettings_Accessibility_ColorFiltering_FilterType": { + "schema": { + "title": "Color filter type", + "description": "Selects the Windows color filter to be used.", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "enumLabels": [ + "Grayscale", + "Inverted", + "Grayscale inverted", + "Red-green (green weak, deuteranopia)", + "Red-green (red weak, protanopia)", + "Blue-yellow (tritanopia)" + ], + "default": 1 + } + }, + "SystemSettings_Accessibility_ColorFiltering_IsShortcutKeyEnabled": { + "schema": { + "title": "Shortcut key for color filters", + "description": "Allow the shurtcut key (Windows + Ctrl + C) to toggle color filter on or off.", + "type": "boolean", + "default": false + } + } + }, + "capabilitiesTransformations": { + "SystemSettings_Accessibility_ColorFiltering_IsEnabled": { + "transform": { + "type": "fluid.transforms.valueMapper", + "defaultInputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.FilterType", + "defaultOutputPath": "value", + "match": [ + { + "inputValue": 0, + "outputValue": false + } + ], + "noMatch": { + "outputValue": true + } + } + }, + "SystemSettings_Accessibility_ColorFiltering_FilterType": { + "transform": { + "type": "fluid.transforms.valueMapper", + "defaultInputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.FilterType", + "defaultOutputPath": "value", + "match": [ + { + "inputValue": 1, + "outputValue": 0 + }, + { + "intputValue": 2, + "outputValue": 1 + }, + { + "inputValue": 3, + "outputValue": 2 + }, + { + "inputValue": 4, + "outputValue": 3 + }, + { + "inputValue": 5, + "outputValue": 4 + }, + { + "inputValue": 6, + "outputValue": 5 + } + ], + "noMatch": { + "outputValue": 0 + } + } + }, + "SystemSettings_Accessibility_ColorFiltering_IsShortcutKeyEnabled": { + "transform": { + "type": "fluid.transforms.value", + "inputPath": "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.ShortcutKeyEnable", + "outputPath": "value" + } + } + }, + "inverseCapabilitiesTransformations": { + "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.Enable": "SystemSettings_Accessibility_ColorFiltering_IsEnabled.value", + "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.FilterType": { + "transform": { + "type": "fluid.transforms.valueMapper", + "defaultInputPath": "SystemSettings_Accessibility_ColorFiltering_IsEnabled.value", + "defaultOutputPath": "value", + "match": [ + { + "inputValue": 0, + "outputValue": 0 + }, + { + "inputValue": 1, + "outputValue": { + "transform": { + "type": "fluid.transforms.valueMapper", + "defaultInputPath": "SystemSettings_Accessibility_ColorFiltering_FilterType.value", + "defaultOutputPath": "value", + "match": [ + { + "inputValue": 0, + "outputValue": 1 + }, + { + "intputValue": 1, + "outputValue": 2 + }, + { + "inputValue": 2, + "outputValue": 3 + }, + { + "inputValue": 3, + "outputValue": 4 + }, + { + "inputValue": 4, + "outputValue": 5 + }, + { + "inputValue": 5, + "outputValue": 6 + } + ], + "noMatch": { + "outputValue": 0 + } + } + } + } + ], + "noMatch": { + "outputValue": 0 + } + } + }, + "http://registry\\.gpii\\.net/applications/com\\.microsoft\\.windows\\.colorFilters.ShortcutKeyEnable": "SystemSettings_Accessibility_ColorFiltering_IsShortcutKeyEnabled.value" + } + } + }, + "update": [ + "settings.configure" + ], + "configure": [ + "settings.configure" + ], + "restore": [ + "settings.configure" + ], + "isInstalled": [ + { + "type": "gpii.deviceReporter.alwaysInstalled" + } + ] + }, "com.microsoft.windows.filterKeys": { "name": "Windows FilterKeys", "contexts": { From b940b2c4f4d1d59ed369de312812aaca021e1d76 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 8 Jan 2020 21:38:42 +0000 Subject: [PATCH 36/36] GPII-3853: Fixed some fields which where incorrectly being stored as numbers in Elasticsearch. --- gpii/node_modules/eventLog/src/metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpii/node_modules/eventLog/src/metrics.js b/gpii/node_modules/eventLog/src/metrics.js index 1492515d9..cde0238ec 100644 --- a/gpii/node_modules/eventLog/src/metrics.js +++ b/gpii/node_modules/eventLog/src/metrics.js @@ -220,7 +220,7 @@ gpii.metrics.preferenceChanged = function (that, current, previous) { fluid.each(changedPreferences, function (value, name) { that.logMetric("preference", { name: name, - value: value + newValue: value.toString() }); }); }