@axeptio/behavior-detection 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,226 +0,0 @@
1
- "use strict";
2
- /**
3
- * Browser Build - Auto-initializing standalone bundle for CDN usage
4
- *
5
- * Usage:
6
- * <script src="https://cdn.../behavior-detector.js"></script>
7
- * <script>
8
- * window.bdSettings = {
9
- * strategies: {
10
- * mouse: { weight: 0.3 },
11
- * scroll: { weight: 0.15 },
12
- * click: { weight: 0.3 },
13
- * keyboard: { weight: 0.1 },
14
- * environment: { weight: 0.08 },
15
- * resize: { weight: 0.02 }
16
- * },
17
- * autoStart: true,
18
- * checkMs: 2000,
19
- * pauseOnHidden: true, // Auto-pause when tab hidden (default: true)
20
- * onScore: (result) => {
21
- * console.log('Human likelihood:', result.score);
22
- * if (result.score < 0.3) {
23
- * // Likely bot
24
- * }
25
- * },
26
- * ifBot: (result) => {
27
- * // Called when score < threshold
28
- * console.warn('Bot detected:', result);
29
- * },
30
- * botThreshold: 0.3
31
- * }
32
- * </script>
33
- */
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const behavior_detector_js_1 = require("./behavior-detector.js");
36
- const index_js_1 = require("./strategies/index.js");
37
- /**
38
- * Detect if the current device is mobile
39
- */
40
- function isMobileDevice() {
41
- const hasTouchScreen = navigator.maxTouchPoints > 0 || 'ontouchstart' in window;
42
- const mobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
43
- const smallScreen = window.innerWidth < 768 && window.innerHeight < 1024;
44
- return (hasTouchScreen && smallScreen) || mobileUA;
45
- }
46
- class BehaviorDetectionAPI {
47
- constructor() {
48
- this.detector = null;
49
- this.checkInterval = null;
50
- this.settings = null;
51
- }
52
- /**
53
- * Initialize the detector with settings
54
- */
55
- init(settings) {
56
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
57
- if (this.detector) {
58
- this.stop();
59
- }
60
- this.settings = settings;
61
- this.detector = new behavior_detector_js_1.BehaviorDetector({
62
- pauseOnHidden: settings.pauseOnHidden !== undefined ? settings.pauseOnHidden : true
63
- });
64
- // Detect if mobile to adjust strategy selection and weights
65
- const isMobile = isMobileDevice();
66
- const strategies = settings.strategies || {};
67
- // Mobile-adjusted default weights
68
- const defaultWeights = isMobile ? {
69
- mouse: 0, // Disabled on mobile
70
- scroll: 0.35, // Increased (more reliable on mobile)
71
- click: 0, // Disabled on mobile (use tap instead)
72
- tap: 0.35, // Mobile tap detection
73
- keyboard: 0.15,
74
- environment: 0.10,
75
- resize: 0.05, // Orientation changes
76
- } : {
77
- mouse: 0.30,
78
- scroll: 0.15,
79
- click: 0.30,
80
- tap: 0, // Disabled on desktop
81
- keyboard: 0.10,
82
- environment: 0.08,
83
- resize: 0.02,
84
- };
85
- // Mouse - Desktop only
86
- if (!isMobile && ((_a = strategies.mouse) === null || _a === void 0 ? void 0 : _a.enabled) !== false) {
87
- const strategy = new index_js_1.MouseStrategy();
88
- const weight = (_c = (_b = strategies.mouse) === null || _b === void 0 ? void 0 : _b.weight) !== null && _c !== void 0 ? _c : defaultWeights.mouse;
89
- this.detector.addStrategy(strategy, weight);
90
- }
91
- // Scroll - Universal
92
- if (((_d = strategies.scroll) === null || _d === void 0 ? void 0 : _d.enabled) !== false) {
93
- const strategy = new index_js_1.ScrollStrategy();
94
- const weight = (_f = (_e = strategies.scroll) === null || _e === void 0 ? void 0 : _e.weight) !== null && _f !== void 0 ? _f : defaultWeights.scroll;
95
- this.detector.addStrategy(strategy, weight);
96
- }
97
- // Click - Desktop only
98
- if (!isMobile && ((_g = strategies.click) === null || _g === void 0 ? void 0 : _g.enabled) !== false) {
99
- const strategy = new index_js_1.ClickStrategy();
100
- const weight = (_j = (_h = strategies.click) === null || _h === void 0 ? void 0 : _h.weight) !== null && _j !== void 0 ? _j : defaultWeights.click;
101
- this.detector.addStrategy(strategy, weight);
102
- }
103
- // Tap - Mobile only
104
- if (isMobile && ((_k = strategies.tap) === null || _k === void 0 ? void 0 : _k.enabled) !== false) {
105
- const strategy = new index_js_1.TapStrategy();
106
- const weight = (_m = (_l = strategies.tap) === null || _l === void 0 ? void 0 : _l.weight) !== null && _m !== void 0 ? _m : defaultWeights.tap;
107
- this.detector.addStrategy(strategy, weight);
108
- }
109
- // Keyboard - Universal
110
- if (((_o = strategies.keyboard) === null || _o === void 0 ? void 0 : _o.enabled) !== false) {
111
- const strategy = new index_js_1.KeyboardStrategy();
112
- const weight = (_q = (_p = strategies.keyboard) === null || _p === void 0 ? void 0 : _p.weight) !== null && _q !== void 0 ? _q : defaultWeights.keyboard;
113
- this.detector.addStrategy(strategy, weight);
114
- }
115
- // Environment - Universal
116
- if (((_r = strategies.environment) === null || _r === void 0 ? void 0 : _r.enabled) !== false) {
117
- const strategy = new index_js_1.EnvironmentStrategy();
118
- const weight = (_t = (_s = strategies.environment) === null || _s === void 0 ? void 0 : _s.weight) !== null && _t !== void 0 ? _t : defaultWeights.environment;
119
- this.detector.addStrategy(strategy, weight);
120
- }
121
- // Resize - Universal
122
- if (((_u = strategies.resize) === null || _u === void 0 ? void 0 : _u.enabled) !== false) {
123
- const strategy = new index_js_1.ResizeStrategy();
124
- const weight = (_w = (_v = strategies.resize) === null || _v === void 0 ? void 0 : _v.weight) !== null && _w !== void 0 ? _w : defaultWeights.resize;
125
- this.detector.addStrategy(strategy, weight);
126
- }
127
- // Start if autoStart is enabled
128
- if (settings.autoStart !== false) {
129
- this.start();
130
- }
131
- // Set up periodic checking if checkMs is specified
132
- if (settings.checkMs && settings.checkMs > 0) {
133
- this.startPeriodicCheck(settings.checkMs);
134
- }
135
- // Call onReady callback
136
- if (settings.onReady) {
137
- settings.onReady(this);
138
- }
139
- }
140
- /**
141
- * Start detection
142
- */
143
- start() {
144
- if (!this.detector) {
145
- console.warn('BehaviorDetector: Call init() before start()');
146
- return;
147
- }
148
- this.detector.start();
149
- }
150
- /**
151
- * Stop detection
152
- */
153
- stop() {
154
- if (this.detector) {
155
- this.detector.stop();
156
- }
157
- if (this.checkInterval !== null) {
158
- clearInterval(this.checkInterval);
159
- this.checkInterval = null;
160
- }
161
- }
162
- /**
163
- * Get current score
164
- */
165
- async score() {
166
- if (!this.detector) {
167
- console.warn('BehaviorDetector: Call init() before score()');
168
- return null;
169
- }
170
- return this.detector.score({ breakdown: true });
171
- }
172
- /**
173
- * Start periodic checking
174
- */
175
- startPeriodicCheck(intervalMs) {
176
- if (this.checkInterval !== null) {
177
- clearInterval(this.checkInterval);
178
- }
179
- this.checkInterval = window.setInterval(async () => {
180
- var _a, _b;
181
- const result = await this.score();
182
- if (!result || !this.settings)
183
- return;
184
- // Call onScore callback
185
- if (this.settings.onScore) {
186
- this.settings.onScore(result);
187
- }
188
- // Check thresholds
189
- const botThreshold = (_a = this.settings.botThreshold) !== null && _a !== void 0 ? _a : 0.3;
190
- const humanThreshold = (_b = this.settings.humanThreshold) !== null && _b !== void 0 ? _b : 0.7;
191
- if (result.score < botThreshold && this.settings.ifBot) {
192
- this.settings.ifBot(result);
193
- }
194
- else if (result.score >= humanThreshold && this.settings.ifHuman) {
195
- this.settings.ifHuman(result);
196
- }
197
- }, intervalMs);
198
- }
199
- /**
200
- * Get the underlying detector instance for advanced usage
201
- */
202
- getDetector() {
203
- return this.detector;
204
- }
205
- }
206
- // Create global API instance
207
- const api = new BehaviorDetectionAPI();
208
- // Auto-initialize if settings are already present
209
- if (typeof window !== 'undefined') {
210
- // Expose API globally
211
- window.BehaviorDetector = api;
212
- // Check for settings on load
213
- const checkAndInit = () => {
214
- const settings = window.bdSettings;
215
- if (settings) {
216
- api.init(settings);
217
- }
218
- };
219
- // Try immediate init
220
- checkAndInit();
221
- // Also try after DOM ready
222
- if (document.readyState === 'loading') {
223
- document.addEventListener('DOMContentLoaded', checkAndInit);
224
- }
225
- }
226
- // No exports needed for browser IIFE build - window.BehaviorDetector is sufficient
@@ -1,38 +0,0 @@
1
- /**
2
- * @axeptio/behavior-detection
3
- *
4
- * Lightweight behavior detection library to assess human likelihood of user sessions
5
- *
6
- * @example Settings-based (all strategies included)
7
- * ```ts
8
- * import { BehaviorDetector } from '@axeptio/behavior-detection';
9
- *
10
- * const detector = new BehaviorDetector({
11
- * weights: {
12
- * mouseMovement: 0.3,
13
- * clickAccuracy: 0.3,
14
- * },
15
- * });
16
- *
17
- * detector.start();
18
- * const result = await detector.score({ breakdown: true });
19
- * ```
20
- *
21
- * @example Strategy-based (tree-shakeable, import only what you need)
22
- * ```ts
23
- * import { BehaviorDetector, Mouse, Click, Keyboard } from '@axeptio/behavior-detection';
24
- *
25
- * const detector = new BehaviorDetector()
26
- * .addStrategy(new Mouse())
27
- * .addStrategy(new Click())
28
- * .addStrategy(new Keyboard());
29
- *
30
- * detector.start();
31
- * const result = await detector.score();
32
- * ```
33
- */
34
- export { BehaviorDetector } from './behavior-detector.js';
35
- export type { DetectionStrategy, StrategyConfig } from './strategy.js';
36
- export { Mouse, Scroll, Click, Tap, Keyboard, Environment, Resize, MouseStrategy, ScrollStrategy, ClickStrategy, TapStrategy, KeyboardStrategy, EnvironmentStrategy, ResizeStrategy, } from './strategies/index.js';
37
- export type { BehaviorSettings, ScoreOptions, ScoreResult, ScoreBreakdown, TrackedEvent, EventType, ScoringFunction, } from './types.js';
38
- export { DEFAULT_SETTINGS } from './types.js';
package/dist/cjs/index.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /**
3
- * @axeptio/behavior-detection
4
- *
5
- * Lightweight behavior detection library to assess human likelihood of user sessions
6
- *
7
- * @example Settings-based (all strategies included)
8
- * ```ts
9
- * import { BehaviorDetector } from '@axeptio/behavior-detection';
10
- *
11
- * const detector = new BehaviorDetector({
12
- * weights: {
13
- * mouseMovement: 0.3,
14
- * clickAccuracy: 0.3,
15
- * },
16
- * });
17
- *
18
- * detector.start();
19
- * const result = await detector.score({ breakdown: true });
20
- * ```
21
- *
22
- * @example Strategy-based (tree-shakeable, import only what you need)
23
- * ```ts
24
- * import { BehaviorDetector, Mouse, Click, Keyboard } from '@axeptio/behavior-detection';
25
- *
26
- * const detector = new BehaviorDetector()
27
- * .addStrategy(new Mouse())
28
- * .addStrategy(new Click())
29
- * .addStrategy(new Keyboard());
30
- *
31
- * detector.start();
32
- * const result = await detector.score();
33
- * ```
34
- */
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.DEFAULT_SETTINGS = exports.ResizeStrategy = exports.EnvironmentStrategy = exports.KeyboardStrategy = exports.TapStrategy = exports.ClickStrategy = exports.ScrollStrategy = exports.MouseStrategy = exports.Resize = exports.Environment = exports.Keyboard = exports.Tap = exports.Click = exports.Scroll = exports.Mouse = exports.BehaviorDetector = void 0;
37
- var behavior_detector_js_1 = require("./behavior-detector.js");
38
- Object.defineProperty(exports, "BehaviorDetector", { enumerable: true, get: function () { return behavior_detector_js_1.BehaviorDetector; } });
39
- var index_js_1 = require("./strategies/index.js");
40
- Object.defineProperty(exports, "Mouse", { enumerable: true, get: function () { return index_js_1.Mouse; } });
41
- Object.defineProperty(exports, "Scroll", { enumerable: true, get: function () { return index_js_1.Scroll; } });
42
- Object.defineProperty(exports, "Click", { enumerable: true, get: function () { return index_js_1.Click; } });
43
- Object.defineProperty(exports, "Tap", { enumerable: true, get: function () { return index_js_1.Tap; } });
44
- Object.defineProperty(exports, "Keyboard", { enumerable: true, get: function () { return index_js_1.Keyboard; } });
45
- Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return index_js_1.Environment; } });
46
- Object.defineProperty(exports, "Resize", { enumerable: true, get: function () { return index_js_1.Resize; } });
47
- Object.defineProperty(exports, "MouseStrategy", { enumerable: true, get: function () { return index_js_1.MouseStrategy; } });
48
- Object.defineProperty(exports, "ScrollStrategy", { enumerable: true, get: function () { return index_js_1.ScrollStrategy; } });
49
- Object.defineProperty(exports, "ClickStrategy", { enumerable: true, get: function () { return index_js_1.ClickStrategy; } });
50
- Object.defineProperty(exports, "TapStrategy", { enumerable: true, get: function () { return index_js_1.TapStrategy; } });
51
- Object.defineProperty(exports, "KeyboardStrategy", { enumerable: true, get: function () { return index_js_1.KeyboardStrategy; } });
52
- Object.defineProperty(exports, "EnvironmentStrategy", { enumerable: true, get: function () { return index_js_1.EnvironmentStrategy; } });
53
- Object.defineProperty(exports, "ResizeStrategy", { enumerable: true, get: function () { return index_js_1.ResizeStrategy; } });
54
- var types_js_1 = require("./types.js");
55
- Object.defineProperty(exports, "DEFAULT_SETTINGS", { enumerable: true, get: function () { return types_js_1.DEFAULT_SETTINGS; } });
@@ -1,84 +0,0 @@
1
- /**
2
- * Mathematical utility functions for continuous scoring
3
- * Replaces magic number if-else chains with smooth mathematical functions
4
- */
5
- /**
6
- * Sigmoid function - Maps any value to [0, 1] with smooth S-curve
7
- * @param x - Input value
8
- * @param midpoint - Value that maps to 0.5
9
- * @param steepness - How steep the curve is (higher = steeper)
10
- */
11
- export declare function sigmoid(x: number, midpoint?: number, steepness?: number): number;
12
- /**
13
- * Inverse sigmoid - High values map to low scores
14
- */
15
- export declare function inverseSigmoid(x: number, midpoint?: number, steepness?: number): number;
16
- /**
17
- * Gaussian (bell curve) - Peak at ideal value, falls off on both sides
18
- * @param x - Input value
19
- * @param ideal - Optimal value (peak of curve)
20
- * @param width - How wide the acceptable range is
21
- */
22
- export declare function gaussian(x: number, ideal?: number, width?: number): number;
23
- /**
24
- * Exponential decay - High values get penalized exponentially
25
- */
26
- export declare function exponentialDecay(x: number, decayRate?: number): number;
27
- /**
28
- * Normalize value to [0, 1] range
29
- */
30
- export declare function normalize(value: number, min?: number, max?: number): number;
31
- /**
32
- * Clamp value to [0, 1]
33
- */
34
- export declare function clamp01(value: number): number;
35
- /**
36
- * Statistical metrics for an array of numbers
37
- */
38
- export interface Statistics {
39
- mean: number;
40
- variance: number;
41
- stdDev: number;
42
- cv: number;
43
- }
44
- /**
45
- * Calculate statistical metrics for an array of numbers
46
- * @param values - Array of numerical values
47
- * @returns Statistical metrics (mean, variance, stdDev, cv)
48
- */
49
- export declare function calculateStatistics(values: number[]): Statistics;
50
- /**
51
- * Analysis result for interval patterns
52
- */
53
- export interface IntervalAnalysis {
54
- statistics: Statistics;
55
- uniqueCount: number;
56
- allIdentical: boolean;
57
- }
58
- /**
59
- * Analyze timing intervals for bot-like patterns
60
- * Returns raw analysis data without scoring - caller decides heuristics
61
- *
62
- * @param intervals - Array of time intervals (ms)
63
- * @returns Analysis of interval patterns including stats and uniqueness
64
- */
65
- export declare function analyzeIntervals(intervals: number[]): IntervalAnalysis | undefined;
66
- /**
67
- * Score coefficient of variation
68
- * Maps CV to human-likeness score using Gaussian
69
- * Ideal CV is around 0.4-0.5 (moderate variation)
70
- */
71
- export declare function scoreCoefficientOfVariation(cv: number): number;
72
- /**
73
- * Score entropy - Higher is better (more random = more human)
74
- * Uses sigmoid to smoothly map entropy to score
75
- */
76
- export declare function scoreEntropy(normalizedEntropy: number): number;
77
- /**
78
- * Score autocorrelation - Lower is better (less periodic = more human)
79
- */
80
- export declare function scoreAutocorrelation(autocorr: number): number;
81
- /**
82
- * Score jerk - Lower is better (smoother = more human)
83
- */
84
- export declare function scoreJerk(avgJerk: number): number;
@@ -1,141 +0,0 @@
1
- "use strict";
2
- /**
3
- * Mathematical utility functions for continuous scoring
4
- * Replaces magic number if-else chains with smooth mathematical functions
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.sigmoid = sigmoid;
8
- exports.inverseSigmoid = inverseSigmoid;
9
- exports.gaussian = gaussian;
10
- exports.exponentialDecay = exponentialDecay;
11
- exports.normalize = normalize;
12
- exports.clamp01 = clamp01;
13
- exports.calculateStatistics = calculateStatistics;
14
- exports.analyzeIntervals = analyzeIntervals;
15
- exports.scoreCoefficientOfVariation = scoreCoefficientOfVariation;
16
- exports.scoreEntropy = scoreEntropy;
17
- exports.scoreAutocorrelation = scoreAutocorrelation;
18
- exports.scoreJerk = scoreJerk;
19
- /**
20
- * Sigmoid function - Maps any value to [0, 1] with smooth S-curve
21
- * @param x - Input value
22
- * @param midpoint - Value that maps to 0.5
23
- * @param steepness - How steep the curve is (higher = steeper)
24
- */
25
- function sigmoid(x, midpoint = 0, steepness = 1) {
26
- return 1 / (1 + Math.exp(-steepness * (x - midpoint)));
27
- }
28
- /**
29
- * Inverse sigmoid - High values map to low scores
30
- */
31
- function inverseSigmoid(x, midpoint = 0, steepness = 1) {
32
- return 1 - sigmoid(x, midpoint, steepness);
33
- }
34
- /**
35
- * Gaussian (bell curve) - Peak at ideal value, falls off on both sides
36
- * @param x - Input value
37
- * @param ideal - Optimal value (peak of curve)
38
- * @param width - How wide the acceptable range is
39
- */
40
- function gaussian(x, ideal = 0, width = 1) {
41
- const exponent = -Math.pow(x - ideal, 2) / (2 * width * width);
42
- return Math.exp(exponent);
43
- }
44
- /**
45
- * Exponential decay - High values get penalized exponentially
46
- */
47
- function exponentialDecay(x, decayRate = 0.1) {
48
- return Math.exp(-decayRate * x);
49
- }
50
- /**
51
- * Normalize value to [0, 1] range
52
- */
53
- function normalize(value, min = 0, max = 1) {
54
- if (max === min)
55
- return 0.5;
56
- return Math.max(0, Math.min(1, (value - min) / (max - min)));
57
- }
58
- /**
59
- * Clamp value to [0, 1]
60
- */
61
- function clamp01(value) {
62
- return Math.max(0, Math.min(1, value));
63
- }
64
- /**
65
- * Calculate statistical metrics for an array of numbers
66
- * @param values - Array of numerical values
67
- * @returns Statistical metrics (mean, variance, stdDev, cv)
68
- */
69
- function calculateStatistics(values) {
70
- if (values.length === 0) {
71
- return { mean: 0, variance: 0, stdDev: 0, cv: 0 };
72
- }
73
- const mean = values.reduce((a, b) => a + b, 0) / values.length;
74
- const variance = values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / values.length;
75
- const stdDev = Math.sqrt(variance);
76
- const cv = mean > 0 ? stdDev / mean : 0;
77
- return { mean, variance, stdDev, cv };
78
- }
79
- /**
80
- * Analyze timing intervals for bot-like patterns
81
- * Returns raw analysis data without scoring - caller decides heuristics
82
- *
83
- * @param intervals - Array of time intervals (ms)
84
- * @returns Analysis of interval patterns including stats and uniqueness
85
- */
86
- function analyzeIntervals(intervals) {
87
- if (intervals.length < 2)
88
- return undefined;
89
- // Check for identical intervals (round to 10ms to account for floating point)
90
- const uniqueCount = new Set(intervals.map(i => Math.round(i / 10))).size;
91
- const allIdentical = uniqueCount === 1;
92
- // Calculate statistics
93
- const statistics = calculateStatistics(intervals);
94
- return {
95
- statistics,
96
- uniqueCount,
97
- allIdentical,
98
- };
99
- }
100
- /**
101
- * Score coefficient of variation
102
- * Maps CV to human-likeness score using Gaussian
103
- * Ideal CV is around 0.4-0.5 (moderate variation)
104
- */
105
- function scoreCoefficientOfVariation(cv) {
106
- // Too low (<0.1) = bot-like (too consistent)
107
- // Too high (>1.5) = random noise
108
- // Ideal = 0.4-0.6 (natural human variation)
109
- if (cv < 0.05)
110
- return 0.1; // Almost zero variation - definitely bot
111
- if (cv > 2.0)
112
- return 0.3; // Too random
113
- // Gaussian centered at 0.45 with width of 0.35
114
- return gaussian(cv, 0.45, 0.35);
115
- }
116
- /**
117
- * Score entropy - Higher is better (more random = more human)
118
- * Uses sigmoid to smoothly map entropy to score
119
- */
120
- function scoreEntropy(normalizedEntropy) {
121
- // Entropy of 0.7+ is very human
122
- // Entropy < 0.3 is very bot-like
123
- return sigmoid(normalizedEntropy, 0.5, 8); // Steep curve at midpoint 0.5
124
- }
125
- /**
126
- * Score autocorrelation - Lower is better (less periodic = more human)
127
- */
128
- function scoreAutocorrelation(autocorr) {
129
- // Low autocorrelation (<0.2) is natural
130
- // High autocorrelation (>0.6) is periodic/bot-like
131
- return inverseSigmoid(autocorr, 0.4, 10);
132
- }
133
- /**
134
- * Score jerk - Lower is better (smoother = more human)
135
- */
136
- function scoreJerk(avgJerk) {
137
- // Human jerk typically < 0.01
138
- // Bot jerk often > 0.1
139
- // Use inverse sigmoid
140
- return inverseSigmoid(avgJerk, 0.05, 50);
141
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Click Behavior Detection Strategy
3
- * Monitors specific elements for click positioning patterns
4
- */
5
- import { BaseStrategy } from '../strategy.js';
6
- export declare class ClickStrategy extends BaseStrategy {
7
- readonly name = "click";
8
- readonly defaultWeight = 0.3;
9
- private events;
10
- private targetSelectors;
11
- private lastMousePosition;
12
- private mouseListener;
13
- private clickListeners;
14
- private isActive;
15
- constructor(options?: {
16
- targetSelectors?: string[];
17
- });
18
- start(): void;
19
- /**
20
- * Add a new target selector at runtime
21
- */
22
- addTarget(selector: string): void;
23
- private attachClickListeners;
24
- private attachClickListenersForSelector;
25
- stop(): void;
26
- reset(): void;
27
- score(): number | undefined;
28
- getDebugInfo(): {
29
- eventCount: number;
30
- positions: {
31
- noMouseData: number;
32
- outside: number;
33
- deadCenter: number;
34
- overElement: number;
35
- };
36
- inViewport: number;
37
- trackedElements: number;
38
- };
39
- }