<?php
require_once __DIR__ . '/../config/config_enhanced.php';
require_once __DIR__ . '/../classes/Database.php';
try {
    $db = Database::getInstance();
    $rows = $db->fetchAll('SELECT id, request_body, created_at FROM webhook_logs ORDER BY created_at DESC LIMIT 20');
    foreach ($rows as $r) {
        $rb = $r['request_body'];
        $has = strpos($rb, '"conversations"') !== false ? 'HAS_conversations' : (strpos($rb, '"statuses"') !== false ? 'ONLY_STATUSES' : 'OTHER');
        echo $r['created_at'] . ' | id:' . $r['id'] . ' | ' . $has . PHP_EOL;
    }
} catch (Exception $e) {
    echo 'ERROR: ' . $e->getMessage() . PHP_EOL;
}
