feat(mem0-plugin): add PostHog telemetry across all hooks
Wire fire-and-forget PostHog telemetry into every lifecycle hook (session_start, stop, pre_compact, task_completed, user_prompt, post_tool_use) matching the same project key, endpoint, and payload structure used by the Python SDK, CLI, and OpenClaw. - 10% sampling on ALL events to keep PostHog costs predictable - Anonymous distinct_id: MD5(api_key) or SHA-256(username) - Opt-out via MEM0_TELEMETRY=false - Platform detection: Claude Code / Cursor / Codex - Never sends user content, API keys, or raw identifiers - 16 new tests (110 total passing)
This commit is contained in:
@@ -33,6 +33,10 @@ if [ "$STOP_HOOK_ACTIVE" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Telemetry: fire before report() deletes stats file
|
||||
_TELEM_CAT=$(python3 "$SCRIPT_DIR/session_stats.py" peek 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(len(d.get('categories',[])))" 2>/dev/null || echo "0")
|
||||
python3 "$SCRIPT_DIR/telemetry.py" stop --categories_count="$_TELEM_CAT" 2>/dev/null &
|
||||
|
||||
# Session-end report (best-effort, must not break JSON output)
|
||||
REPORT=$(python3 "$SCRIPT_DIR/session_stats.py" report 2>/dev/null || echo "")
|
||||
REPORT_BLOCK=""
|
||||
|
||||
Reference in New Issue
Block a user