@algoholics/aegis-core
v1.0.8
Published
Aegis Core
Downloads
20
Readme
Aegis Core
Description
The Aegis Core NPM package adds core passive tracking functionality to any framework website. It provides various tracking methods like mouse movement, keystroke dynamics, browser properties, device information, network details, and touch gestures. Additionally, it allows sending buffered tracking data to the backend.
Installation
To install the package, run the following command: NPM package
npm i @algoholics/aegis-core
Usage
To use the package, import the createTrackerInstance
factory function and create a tracker instance by providing either an apiKey
or an engineURL
:
import { createTrackerInstance } from '@algoholics/aegis-core';
const tracker = createTrackerInstance({ apiKey: 'your-api-key' });
// or
const tracker = createTrackerInstance({ engineURL: 'https://your-engine-url.com' });
TrackerInstance Methods
trackMouseMovement: Tracks and buffers mouse movements, including speed and distance.
tracker.trackMouseMovement();
trackKeystrokeDynamics: Tracks keystroke dynamics (key press duration and count).
tracker.trackKeystrokeDynamics();
getBrowserProperties: Retrieves and buffers browser properties, such as user agent, window size, and timezone.
tracker.getBrowserProperties();
getDeviceInfo: Retrieves and buffers device information like screen dimensions and whether the device is mobile.
tracker.getDeviceInfo();
getNetworkDetails: Retrieves and buffers network details such as connection type, round-trip time (RTT), and downlink speed.
tracker.getNetworkDetails();
trackTouchGestures: Tracks touch gestures on mobile devices, including touch start, move, and end events.
tracker.trackTouchGestures();
sendToBackend: Sends the buffered data to the backend server specified by either the
apiKey
orengineURL
. Data is automatically cleared from local storage after sending.const response = await tracker.sendToBackend();
Example
import { createTrackerInstance } from '@algoholics/aegis-core';
const tracker = createTrackerInstance({ apiKey: 'your-api-key' });
tracker.trackMouseMovement();
tracker.trackKeystrokeDynamics();
tracker.getBrowserProperties();
tracker.getDeviceInfo();
tracker.getNetworkDetails();
tracker.trackTouchGestures();
// Send data to the backend when ready
const response = await tracker.sendToBackend();
console.log(response);
API Details
apiKey
: Used to authenticate the tracking instance with a backend.engineURL
: Infer URL to the self hosted python engine using Aegis-EngineaddToBuffer(data)
: Adds tracking data to the buffer and saves it in localStorage.saveToStorage()
: Persists the buffered data into localStorage.sendToBackend()
: Sends all buffered data to the backend and clears the local storage after a successful response.