From c37c66cbf3af54d2133df01e58b30f268e65c011 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Wed, 4 Feb 2026 23:41:31 +0100 Subject: [PATCH] feat: enhance funnel stats API by normalizing date inputs to RFC3339 format, improving query consistency and accuracy --- lib/api/funnels.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/api/funnels.ts b/lib/api/funnels.ts index de0e62e..ad5fde7 100644 --- a/lib/api/funnels.ts +++ b/lib/api/funnels.ts @@ -64,11 +64,27 @@ export async function deleteFunnel(siteId: string, funnelId: string): Promise { const params = new URLSearchParams() - if (from) params.append('from', from) - if (to) params.append('to', to) - + if (from && to) { + const { from: fromRfc, to: toRfc } = toRFC3339Range(from, to) + params.append('from', fromRfc) + params.append('to', toRfc) + } else if (from) { + params.append('from', DATE_ONLY_REGEX.test(from) ? `${from}T00:00:00.000Z` : from) + } else if (to) { + params.append('to', DATE_ONLY_REGEX.test(to) ? `${to}T23:59:59.999Z` : to) + } const queryString = params.toString() ? `?${params.toString()}` : '' return apiRequest(`/sites/${siteId}/funnels/${funnelId}/stats${queryString}`) }