Template
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:
co-authored by
Claude Fable 5
parent
1e58ba4ca4
commit
97ee90919f
@@ -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" }>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user