INNER CODE UNIT · TypeScript

createBehavioralClientDetector

okasi/bot-signal · src/behavioral/index.ts:61

export function createBehavioralClientDetector(
  options: BehavioralDetectorOptions = {},
): BehavioralClientDetector {
  const context = options.context ?? (globalThis as unknown as ExtendedWindow);
  const minObservationMs = options.minObservationMs ?? DEFAULT_MIN_OBSERVATION_MS;
  const scoreThreshold = options.scoreThreshold ?? DEFAULT_SCORE_THRESHOLD;
  const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
  const sampleWindowMs = options.sampleWindowMs ?? DEFAULT_SAMPLE_WINDOW_MS;

  let samples = createEmptySamples();
  let startedAt: number | undefined;
  let listeners: Listener[] = [];
  let pollTimer: ReturnType<typeof setInterval> | undefined;
  let isActive = false;
  let observeTimer: ReturnType<typeof setTimeout> | undefined;
  let observeResolve: ((result: BehavioralClientResult) => void) | undefined;

  const pruneRetainedSamples = (now = Date.now()): void => {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…