From fe1f5d51508ce1d06f20a21eaa8c40ca467bae02 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 16 Feb 2025 19:13:10 -0300 Subject: [PATCH] new(whatsapp.gblib): FB Analytics. --- packages/whatsapp.gblib/services/WhatsappDirectLine.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 9a8e2beb..d564303c 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -1579,9 +1579,9 @@ private async sendButtonList(to: string, buttons: string[]) { const templateId = latestTemplate.id; // Step 2: Fetch template analytics - const startTime = Math.floor(Date.now() / 1000) - 86400; // Last 24h + const startTime = Math.floor(Date.now() / 1000) - 604800; // Last 7 days const endTime = Math.floor(Date.now() / 1000); - + const analyticsResponse = await fetch( `https://graph.facebook.com/v21.0/${businessAccountId}/template_analytics?` + `start=${startTime}&end=${endTime}&granularity=daily&metric_types=sent,delivered,read,clicked&template_ids=[${templateId}]`, {