Implementation:0xSteph Pentest ai Telemetry
| Knowledge Sources | |
|---|---|
| Domains | Telemetry, Privacy, Opt_In |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for opt-in anonymous usage telemetry that sends only counts and durations — no PII, targets, or findings, provided by the pentest-ai engine.
Description
The telemetry module implements opt-in usage telemetry. Off by default; users enable via ptai telemetry enable or PENTEST_AI_TELEMETRY=1. When enabled, sends a small JSON payload at engagement start/end and agent/tool execution to a Cloudflare Worker endpoint. No target URLs, IP addresses, findings content, credentials, or PII are sent — only timestamps, client_id (random UUID), version, event type, agent/tool names, model, duration, success, platform, and Python version.
Usage
Import this module when you need to emit telemetry events. Used by the orchestrator, agent loop, and tool wrappers.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/telemetry.py
- Lines: 1-238
Signature
def is_enabled() -> bool: ...
def enable() -> None: ...
def disable() -> None: ...
def emit(event: str, **fields: Any) -> None: ...
Import
from engine.telemetry import is_enabled, enable, disable, emit
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| event | str | Yes | Event type (engagement.start, engagement.end, agent.run, tool.exec) |
| **fields | kwargs | No | Additional fields (agent, tool, model, duration_seconds, success) |
| PENTEST_AI_TELEMETRY | str (env) | No | Set to "1" to enable |
Outputs
| Name | Type | Description |
|---|---|---|
| HTTP POST | None | JSON payload sent to telemetry endpoint (fire-and-forget) |
Usage Examples
Emit Telemetry Events
from engine.telemetry import is_enabled, emit
if is_enabled():
emit("engagement.start", agent="recon")
emit("tool.exec", tool="nmap", duration_seconds=142, success=True)
emit("engagement.end", duration_seconds=3600, success=True)