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
+13
-14
@@ -1,15 +1,18 @@
|
||||
import "server-only";
|
||||
import { analyticsConsent as analyticsConsentConfig } from "@shared/config";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import { analyticsConsent as analyticsConsentConfig } from "@shared/config";
|
||||
import { connection } from "next/server";
|
||||
import { Suspense } from "react";
|
||||
|
||||
import { CartDrawer } from "@/components/CartDrawer";
|
||||
import { ConsentBanner } from "@/components/ConsentBanner";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import { ConsentBanner } from "@/components/ConsentBanner";
|
||||
import { Footer } from "@/components/Footer";
|
||||
import { Header } from "@/components/Header";
|
||||
import { HeaderAccountLink, HeaderAccountLinkFallback } from "@/components/HeaderAccountLink";
|
||||
import { ShopifyScriptsClient } from "@/components/ShopifyScriptsClient";
|
||||
import { getAnalyticsShop, getScriptsShop } from "@/lib/analytics-shop";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import { ShopifyScriptsClient } from "@/components/ShopifyScriptsClient";
|
||||
// import { getAnalyticsShop, getScriptsShop } from "@/lib/analytics-shop";
|
||||
import { cartHandlers } from "@/lib/cart-handlers";
|
||||
import { getStorefrontClient } from "@/lib/storefront";
|
||||
|
||||
@@ -47,17 +50,12 @@ export async function AppShell({ children }: { children: React.ReactNode }) {
|
||||
cartData = undefined;
|
||||
}
|
||||
|
||||
// Analytics shop GID: best-effort, non-blocking (F1). Merged with
|
||||
// `@shared/config` metadata (acceptedLanguage/currency/hydrogenSubchannelId).
|
||||
const analyticsShop = await getAnalyticsShop();
|
||||
const scriptsShop = getScriptsShop();
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// const analyticsShop = await getAnalyticsShop();
|
||||
// const scriptsShop = getScriptsShop();
|
||||
|
||||
return (
|
||||
<Providers
|
||||
cartData={cartData}
|
||||
analyticsShop={analyticsShop}
|
||||
analyticsConsent={analyticsConsentConfig}
|
||||
>
|
||||
<Providers cartData={cartData}>
|
||||
<a
|
||||
href="#main-content"
|
||||
className="focus-visible:bg-interactive focus-visible:text-interactive-text sr-only focus-visible:not-sr-only focus-visible:fixed focus-visible:start-4 focus-visible:top-4 focus-visible:z-50 focus-visible:rounded focus-visible:px-4 focus-visible:py-2"
|
||||
@@ -80,9 +78,10 @@ export async function AppShell({ children }: { children: React.ReactNode }) {
|
||||
<Footer />
|
||||
|
||||
<CartDrawer />
|
||||
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||
<ConsentBanner />
|
||||
|
||||
<ShopifyScriptsClient shop={scriptsShop} />
|
||||
*/}
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
|
||||
+4
-1
@@ -2,7 +2,8 @@ import type { Metadata } from "next";
|
||||
|
||||
import { CartCheckoutButton } from "@/components/CartCheckoutButton";
|
||||
import { CartContent } from "@/components/CartContent";
|
||||
import { CartViewedTracker } from "@/components/CartViewedTracker";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import { CartViewedTracker } from "@/components/CartViewedTracker";
|
||||
import { content } from "@/lib/content";
|
||||
import { canonicalUrl } from "@/lib/site";
|
||||
|
||||
@@ -38,7 +39,9 @@ export default function CartPage() {
|
||||
<div className="mx-auto max-w-2xl">
|
||||
<CartContent />
|
||||
<CartCheckoutButton />
|
||||
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||
<CartViewedTracker />
|
||||
*/}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
+14
-10
@@ -1,11 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import type { ConsentConfig, ShopAnalytics } from "@shopify/hydrogen";
|
||||
import { Suspense } from "react";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import type { ConsentConfig, ShopAnalytics } from "@shopify/hydrogen";
|
||||
// import { Suspense } from "react";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { AnalyticsTracker } from "@/components/AnalyticsTracker";
|
||||
import { CartAnalyticsTracker } from "@/components/CartAnalyticsTracker";
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// import { AnalyticsTracker } from "@/components/AnalyticsTracker";
|
||||
// import { CartAnalyticsTracker } from "@/components/CartAnalyticsTracker";
|
||||
import { CartProvider } from "@/lib/cart";
|
||||
import type { cartHandlers } from "@/lib/cart-handlers";
|
||||
|
||||
@@ -30,23 +32,25 @@ export type CartData = Awaited<ReturnType<typeof cartHandlers.get>>["data"];
|
||||
|
||||
export function Providers({
|
||||
cartData,
|
||||
analyticsShop,
|
||||
analyticsConsent,
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// analyticsShop,
|
||||
// analyticsConsent,
|
||||
children,
|
||||
}: {
|
||||
cartData?: CartData;
|
||||
analyticsShop: ShopAnalytics;
|
||||
analyticsConsent: ConsentConfig;
|
||||
// ANALYTICS DISABLED (temporarily commented out):
|
||||
// analyticsShop: ShopAnalytics;
|
||||
// analyticsConsent: ConsentConfig;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<CartProvider initialData={cartData}>
|
||||
{/* Suspense scopes the `useSearchParams()` CSR bailout to the tracker,
|
||||
not the whole layout (hydrogen-analytics / references/react.md). */}
|
||||
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||
<Suspense fallback={null}>
|
||||
<AnalyticsTracker shop={analyticsShop} consent={analyticsConsent} />
|
||||
</Suspense>
|
||||
<CartAnalyticsTracker />
|
||||
*/}
|
||||
{children}
|
||||
</CartProvider>
|
||||
);
|
||||
|
||||
@@ -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" }>;
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user