Initial commit

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F22Ms5Cxam5UHyxaCrtZzu
This commit is contained in:
Rami Bitar
2026-07-29 11:02:40 -04:00
co-authored by Claude Fable 5
commit f23332e42c
88 changed files with 7947 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
"use client";
import { useEffect } from "react";
import { AnalyticsEvent, getAnalytics } from "@/lib/analytics";
import { useCart } from "@/lib/cart";
/**
* Publishes `CART_VIEWED` when the `/cart` page is viewed
* (`hydrogen-analytics` / `references/react.md`). The cart payload is
* `AnalyticsCart | null`: when a compatible cart is available, include `id` +
* `updatedAt` + connection-shaped `lines`; otherwise pass `cart: null`.
*/
export function CartViewedTracker() {
const cart = useCart((state) => state.data);
useEffect(() => {
const analytics = getAnalytics();
if (!analytics) return;
analytics.publish(AnalyticsEvent.CART_VIEWED, {
cart: cart.id ? cart : null,
prevCart: null,
});
}, [cart]);
return null;
}