From 9c1bb5bf2ec9f34a03c2ba80025ec408c6a856a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Sander?= Date: Wed, 11 Sep 2024 19:08:17 +0000 Subject: [PATCH] feat(qs-event): Categorise events from Qlik Sense as user created or automated Implements #889 --- src/lib/config-file-schema.js | 10 ++++++---- src/lib/post-to-influxdb.js | 2 ++ src/lib/udp_handlers_log_events.js | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/lib/config-file-schema.js b/src/lib/config-file-schema.js index 36c77aba..74616fbc 100755 --- a/src/lib/config-file-schema.js +++ b/src/lib/config-file-schema.js @@ -75,9 +75,11 @@ export const confifgFileSchema = { enable: 'boolean', influxdb: { measurementName: 'string', - "tags?": [ - "tag": 'string', - value: 'string', + 'tags?': [ + { + tag: 'string', + value: 'string', + }, ], }, }, @@ -204,7 +206,7 @@ export const confifgFileSchema = { }, trackRejectedEvents: { enable: 'boolean', - "tags?": [ + 'tags?': [ { tag: 'string', value: 'string', diff --git a/src/lib/post-to-influxdb.js b/src/lib/post-to-influxdb.js index 6e036f4a..a88a3c77 100755 --- a/src/lib/post-to-influxdb.js +++ b/src/lib/post-to-influxdb.js @@ -1002,6 +1002,7 @@ export async function postLogEventToInfluxdb(msg) { object_type: msg.object_type, proxy_session_id: msg.proxy_session_id, session_id: msg.session_id, + event_activity_source: msg.event_activity_source, }; // Tags that are empty in some cases. Only add if they are non-empty @@ -1241,6 +1242,7 @@ export async function postLogEventToInfluxdb(msg) { .tag('object_type', msg.object_type) .tag('proxy_session_id', msg.proxy_session_id) .tag('session_id', msg.session_id) + .tag('event_activity_source', msg.event_activity_source) .stringField('app_id', msg.app_id) .floatField('process_time', parseFloat(msg.process_time)) .floatField('work_time', parseFloat(msg.work_time)) diff --git a/src/lib/udp_handlers_log_events.js b/src/lib/udp_handlers_log_events.js index d9733a04..13c9b010 100644 --- a/src/lib/udp_handlers_log_events.js +++ b/src/lib/udp_handlers_log_events.js @@ -374,6 +374,28 @@ export function udpInitLogEventServer() { return; } + // Get source of event activity. + // + // The source is either user activity of some kind (e.g. opening an app, making a selection), or + // the result of some automated process (e.g. a scheduled app reload). + // + // The proxy session ID is used to determine the source of the event. + // If the proxy session ID is '0', the event is considered to be non-user activity, for example a scheduled reload. + // Otherwise, the event is considered to be the result of an action by a user, for example opening an app, making a selection, etc. + let eventActivitySource; + console.log(msg[15] + '---' + msg[8] + ': ' + msg[8]?.length); + if (msg[8] === '0') { + // Event is the result of an automated process + globals.logger.debug( + 'LOG EVENT: Qix performance event is non-user activity.' + ); + eventActivitySource = 'non-user'; + } else { + // Event is user activity + globals.logger.debug('LOG EVENT: Qix performance event is user activity.'); + eventActivitySource = 'user'; + } + // Does event match filters in the config file? // // There are two types of filters: @@ -784,6 +806,7 @@ export function udpInitLogEventServer() { ? parseInt(msg[24], 10) : -1, object_type: msg[25], + event_activity_source: eventActivitySource, }; // Different log events deliver QSEoW user directory/user differently.