@trlogic/tracker-web
Version:
Formica Tracker Web SDK
88 lines (87 loc) • 2.94 kB
TypeScript
import { CachedDataCollector } from "src/core/base/CachedDataCollector";
import { TrackerVariableType } from "src/core/model/TrackerVariableType";
/**
* Collects behavioral biometric signals from user interactions.
* Computes aggregate statistics from mouse, keyboard, scroll, session, and touch data.
*
* Design principles:
* - All DOM listeners use `{ passive: true }` to avoid blocking the main thread
* - High-frequency events (mousemove, scroll, touchmove) are throttled
* - All statistics use Welford's online algorithm (O(1) memory)
* - No raw event streams stored — only summary aggregates
* - `collect()` returns pre-computed summaries; called by EventCoordinator on existing events
*/
export declare class BehavioralCollector extends CachedDataCollector {
private mouseVelocityStats;
private mouseAccelStats;
private lastMouseSample;
private pathSegments;
private currentPathLength;
private currentPathStartX;
private currentPathStartY;
private angularVarianceStats;
private lastAngle;
private lastMouseSampleTs;
private lastKeydownTs;
private lastKeyupTs;
private interKeyStats;
private dwellTimeStats;
private flightTimeStats;
private pendingKeydowns;
private lastScrollY;
private lastScrollTs;
private maxScrollDepthPx;
private scrollSpeedStats;
private scrollDirectionChanges;
private lastScrollDirection;
private scrollTotalDistance;
private smoothScrollCount;
private totalScrollSamples;
private lastAnyInteractionTs;
private idleCount;
private totalIdleMs;
private maxIdleMs;
private currentIdleStart;
private tabSwitchCount;
private totalHiddenMs;
private lastHiddenTs;
private interactionTimestamps;
private burstCount;
private touchSupported;
private touchRadiusStats;
private touchPressureStats;
private swipeVelocityStats;
private tapCount;
private swipeCount;
private activeTouchStart;
private listenersAttached;
private idleCheckIntervalId;
private initTs;
private boundMouseHandler;
private boundKeydownHandler;
private boundKeyupHandler;
private boundScrollHandler;
private boundVisibilityHandler;
private boundTouchStartHandler;
private boundTouchMoveHandler;
private boundTouchEndHandler;
collect(): Map<TrackerVariableType, unknown>;
init(): void;
destroy(): void;
resetRollingWindow(): void;
private computeMouseDynamics;
private computeKeystrokeDynamics;
private computeScrollBehavior;
private computeSessionBehavior;
private computeTouchDynamics;
private computeBiometricScore;
private computeBiometricFlags;
private attachListeners;
private detachListeners;
private onMouseSample;
private pushPathSegment;
private onScrollSample;
private recordInteraction;
private startIdleCheck;
private stopIdleCheck;
}