feat: Add debug logging for webhook registration and env vars

main
borja (aider) 3 months ago
parent ea79efab54
commit 08ad11a719

@ -92,6 +92,12 @@ export class WebhookServer {
}
static validateEnv() {
console.log(' Checking environment variables...');
console.log('EVOLUTION_API_URL:', process.env.EVOLUTION_API_URL ? '***' : 'MISSING');
console.log('EVOLUTION_API_INSTANCE:', process.env.EVOLUTION_API_INSTANCE ? '***' : 'MISSING');
console.log('INSTANCE_NAME:', process.env.INSTANCE_NAME || 'MISSING');
console.log('WEBHOOK_URL:', process.env.WEBHOOK_URL ? `${process.env.WEBHOOK_URL.substring(0, 20)}...` : 'MISSING');
const missing = REQUIRED_ENV.filter(v => !process.env[v]);
if (missing.length) {
console.error('❌ Missing required environment variables:');

@ -70,14 +70,31 @@ export class WebhookManager {
static async registerWebhook(): Promise<WebhookResponse> {
this.validateConfig();
const response = await fetch(this.getApiUrl(), {
const config = this.getConfig();
const apiUrl = this.getApiUrl();
console.log(' Attempting to register webhook:', {
apiUrl,
config: {
...config,
// Don't log full URL for security
url: `${config.url.substring(0, 20)}...`
}
});
const response = await fetch(apiUrl, {
method: 'POST',
headers: this.getHeaders(),
body: JSON.stringify(this.getConfig()),
body: JSON.stringify(config),
});
if (!response.ok) {
throw new Error(`Failed to register webhook: ${response.statusText}`);
let errorDetails = response.statusText;
try {
const errorBody = await response.text();
errorDetails += ` - ${errorBody}`;
} catch {}
throw new Error(`Failed to register webhook: ${errorDetails}`);
}
const data = await response.json();

Loading…
Cancel
Save