Skip to documentation

[ Hooks ]

Developer hooks

Badger emits action hooks you can use to route detections into webhooks, logging, and external workflows. Keep handlers deterministic and non-blocking.

badger_honeypot_triggered

Signature: (string $trap_id, int $depth, array $request_context, array $agent)

Trigger: A bot or scripted client reaches a trap URL.

Use case: Send immediate alerts or trigger webhook notifications.

badger_agent_detected

Signature: (string $agent_id, string $agent_name, array $context)

Trigger: Detection pipeline classifies an agent event.

Use case: Add custom scoring, correlation tags, or outbound webhook delivery.

WordPress hook integration

php
<?php
declare(strict_types=1);

add_action(
    'badger_honeypot_triggered',
    function (string $trap_id, int $depth, array $request_context, array $agent): void {
        error_log(sprintf('[badger] trap=%s depth=%d ua=%s',
            $trap_id,
            $depth,
            (string) ($request_context['user_agent'] ?? 'unknown')
        ));
    },
    10,
    4
);

add_action(
    'badger_agent_detected',
    function (string $agent_id, string $agent_name, array $context): void {
        // Send to your webhook or logging endpoint.
    },
    10,
    3
);