From 05b0a64c84649ff469f52887b6f63245eb315835 Mon Sep 17 00:00:00 2001 From: Unchained Date: Sun, 29 Mar 2026 20:52:21 +0200 Subject: [PATCH] debug: Add console logging for revenue tracking Add detailed console logs to debug why revenue tracking isn't working: - Log when trackOrderCompleted is called - Log revenue amount and currency - Log success/failure of revenue tracking This will help identify if the issue is with the op.revenue() call or if it's failing silently. --- src/lib/analytics.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/analytics.ts b/src/lib/analytics.ts index 466ddbf..da9e584 100644 --- a/src/lib/analytics.ts +++ b/src/lib/analytics.ts @@ -108,6 +108,8 @@ export function useAnalytics() { customer_email?: string; }) => { try { + console.log("[Analytics] Tracking order completed:", order.order_number, "Total:", order.total, order.currency); + // Track order event op.track("order_completed", { order_id: order.order_id, @@ -120,12 +122,17 @@ export function useAnalytics() { }); // Track revenue + console.log("[Analytics] Tracking revenue:", order.total, order.currency); op.revenue(order.total, { currency: order.currency, transaction_id: order.order_number, + }).then((result) => { + console.log("[Analytics] Revenue tracked successfully:", result); + }).catch((err) => { + console.error("[Analytics] Revenue tracking failed:", err); }); } catch (e) { - console.error("Track error:", e); + console.error("[Analytics] Track error:", e); } }, [op]);