0.20.6 • Published 3 months ago

@appsensorlike/appsensorlike_ui_console v0.20.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@appsensorlike/appsensorlike Console is utilized to monitor and/or export report(s) to an excel file.

Installation

npm i @appsensorlike/appsensorlike_ui_console

Run

1) Run locally to installation of the module:

npx @appsensorlike/appsensorlike_ui_console [options]

2) If you install the module globally (-g flag), you can run it with

AppSensorLikeConsole [options]

Command line options

optionvaluedescription
rreportNameReport to be displayed/exported, one of: All,AllActivities, MostActiveDetPoints, MostActiveUsers, Trends, DetPointConfig, DetPointCategorization
eearliestDateReport earliest date (server UTC) in format YYYY-MM-DDTHH:mm:ss.sss (fraction part .sss is optional)
xExport report(s) to an excel file in the working directory. If this option is set, report(s) are not displayed!
aSet on auto reload
tintervalAuto reload interval in milliseconds
imaxItemsAtOnceMaximum displayed items at once
hPrints this usage guide

For example: AppSensorLikeConsole -a -t 5000 -r AllActivities -e 2023-07-11T13:34:37.181 -i 2

Monitoring

You have to have running websocket reporting engine server connected to running AppSensorLike server.

For example:

import { AppSensorLocal } from '@appsensorlike/appsensorlike/execution-modes/appsensor-local/appsensor_local.js';
import { AppSensorEvent, Category, DetectionPoint, DetectionSystem, User } from "@appsensorlike/appsensorlike/core/core.js";
import { AppSensorReportingWebSocketServer } from "@appsensorlike/appsensorlike_reporting_engines_websocket/server";

const appSensorLocal = new AppSensorLocal();
const eventManager = appSensorLocal.getAppSensorClient().getEventManager();

//following lines are added just for purpose of demonstration
//
const user1 = new User("user1");
const detectionPoint = new DetectionPoint(Category.REQUEST, "RE7");
const detectionSystem = new DetectionSystem("localhostme");

if (eventManager) {
    await eventManager.addEvent(new AppSensorEvent(user1, detectionPoint, detectionSystem)); 
    await eventManager.addEvent(new AppSensorEvent(user1, detectionPoint, detectionSystem)); //new instance every time to set timestamp
}

//create and start the reporting engine server
const wsServer = new AppSensorReportingWebSocketServer(appSensorLocal.getAppSensorServer());
await wsServer.startServer();

Please mind that console utilizes a websocket reporting engine client, which by default tries to connect to ws://localhost:3000. By default it will try to reconnect on connection lost. You can change configuration as pointed in @appsensorlike/appsensorlike_reporting_engines_websocket under Configuration section.

With each start are shown the new items since you last closed the console.

If this is your first time running the console, the items since epoch (midnight at the beginning of 1 January 1970 UTC) are shown.

You can manually set the earliest date of report(s) within the console or with -e options.

By default new items are displayed as soon as "emerge" from the server. If you instead, prefer report to be reloaded on specified interval of tile, you can run with -a and set interval in milliseconds with -t option. By default auto reload is off. Default interval is 30000 ms..

Export

You have two options to export report(s) data:

1) In background with command line options -x

2) From within the console

Exported file is in the working directory with name AppSensorLikeReports{fromDateStr}-{toDateStr}.xlsx. {fromDateStr} and {toDateStr} are replaced with actual dates.

Configuration

You can configure auto reload, reload interval and maximum displayed items at once in appsensor-console-ui-settings.json file in your working directory. You can copy the default configuration from the module's dist/appsensor-ui/console. Please mind that command line options take precedence.