Comment out all analytics (trackers, Shopify scripts, consent banner)

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 12:52:28 -04:00
co-authored by Claude Fable 5
parent 1e58ba4ca4
commit 97ee90919f
5 changed files with 65 additions and 51 deletions
+30 -25
View File
@@ -10,11 +10,13 @@ import {
import { CollectionProvider, useCollection, useCollectionForm } from "@shopify/hydrogen/react";
import Link from "next/link";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";
// ANALYTICS DISABLED: `useEffect` was only used by the viewed-trackers below.
import { useMemo } from "react";
import { Breadcrumbs } from "@/components/Breadcrumbs";
import { ProductCard, type ProductCardData } from "@/components/ProductCard";
import { AnalyticsEvent, getAnalytics } from "@/lib/analytics";
// ANALYTICS DISABLED (temporarily commented out):
// import { AnalyticsEvent, getAnalytics } from "@/lib/analytics";
import { content } from "@/lib/content";
import { FilterGroup } from "@/lib/filters";
@@ -94,39 +96,42 @@ export function CollectionBrowser(props: CollectionBrowserProps) {
router.refresh();
}}
>
{/* ANALYTICS DISABLED (temporarily commented out):
{props.mode === "collection" ? (
<CollectionViewedTracker id={props.collection.id} handle={props.collection.handle} />
) : (
<SearchViewedTracker term={props.term} totalCount={props.totalCount} />
)}
*/}
{props.mode === "collection" ? <CollectionPage {...props} /> : <SearchPage {...props} />}
</CollectionProvider>
);
}
function CollectionViewedTracker({ id, handle }: { id: string; handle: string }) {
useEffect(() => {
const analytics = getAnalytics();
if (!analytics) return;
analytics.publish(AnalyticsEvent.COLLECTION_VIEWED, {
collection: { id, handle },
});
}, [id, handle]);
return null;
}
function SearchViewedTracker({ term, totalCount }: { term: string; totalCount: number }) {
useEffect(() => {
if (!term) return;
const analytics = getAnalytics();
if (!analytics) return;
analytics.publish(AnalyticsEvent.SEARCH_VIEWED, {
searchTerm: term,
searchResults: { totalCount },
});
}, [term, totalCount]);
return null;
}
// ANALYTICS DISABLED (temporarily commented out):
// function CollectionViewedTracker({ id, handle }: { id: string; handle: string }) {
// useEffect(() => {
// const analytics = getAnalytics();
// if (!analytics) return;
// analytics.publish(AnalyticsEvent.COLLECTION_VIEWED, {
// collection: { id, handle },
// });
// }, [id, handle]);
// return null;
// }
//
// function SearchViewedTracker({ term, totalCount }: { term: string; totalCount: number }) {
// useEffect(() => {
// if (!term) return;
// const analytics = getAnalytics();
// if (!analytics) return;
// analytics.publish(AnalyticsEvent.SEARCH_VIEWED, {
// searchTerm: term,
// searchResults: { totalCount },
// });
// }, [term, totalCount]);
// return null;
// }
type CollectionPageProps = Extract<CollectionBrowserProps, { mode: "collection" }>;
+4 -1
View File
@@ -5,7 +5,8 @@ import { ShopPayButton } from "@shopify/hydrogen/react";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
import { ProductViewedTracker } from "@/components/ProductViewedTracker";
// ANALYTICS DISABLED (temporarily commented out):
// import { ProductViewedTracker } from "@/components/ProductViewedTracker";
import { QuantityStepper } from "@/components/QuantityStepper";
import { openCartDrawer } from "@/lib/cart-drawer";
import { content } from "@/lib/content";
@@ -40,7 +41,9 @@ export function ProductDetails({ product }: { product: ProductData }) {
router.replace(next, { scroll: false });
}}
>
{/* ANALYTICS DISABLED (temporarily commented out):
<ProductViewedTracker product={product} />
*/}
<ProductPage product={product} />
</ProductProvider>
);