Skip to content

Commit

Permalink
feat(qs-event): Categorise events from Qlik Sense as user created or …
Browse files Browse the repository at this point in the history
…automated

Implements #889
  • Loading branch information
Göran Sander committed Sep 11, 2024
1 parent e8d8a13 commit 9c1bb5b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/config-file-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ export const confifgFileSchema = {
enable: 'boolean',
influxdb: {
measurementName: 'string',
"tags?": [
"tag": 'string',
value: 'string',
'tags?': [
{
tag: 'string',
value: 'string',
},
],
},
},
Expand Down Expand Up @@ -204,7 +206,7 @@ export const confifgFileSchema = {
},
trackRejectedEvents: {
enable: 'boolean',
"tags?": [
'tags?': [
{
tag: 'string',
value: 'string',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/post-to-influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
23 changes: 23 additions & 0 deletions src/lib/udp_handlers_log_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9c1bb5b

Please sign in to comment.