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 "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 { connection } from "next/server";
|
||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
|
|
||||||
import { CartDrawer } from "@/components/CartDrawer";
|
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 { Footer } from "@/components/Footer";
|
||||||
import { Header } from "@/components/Header";
|
import { Header } from "@/components/Header";
|
||||||
import { HeaderAccountLink, HeaderAccountLinkFallback } from "@/components/HeaderAccountLink";
|
import { HeaderAccountLink, HeaderAccountLinkFallback } from "@/components/HeaderAccountLink";
|
||||||
import { ShopifyScriptsClient } from "@/components/ShopifyScriptsClient";
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
import { getAnalyticsShop, getScriptsShop } from "@/lib/analytics-shop";
|
// import { ShopifyScriptsClient } from "@/components/ShopifyScriptsClient";
|
||||||
|
// import { getAnalyticsShop, getScriptsShop } from "@/lib/analytics-shop";
|
||||||
import { cartHandlers } from "@/lib/cart-handlers";
|
import { cartHandlers } from "@/lib/cart-handlers";
|
||||||
import { getStorefrontClient } from "@/lib/storefront";
|
import { getStorefrontClient } from "@/lib/storefront";
|
||||||
|
|
||||||
@@ -47,17 +50,12 @@ export async function AppShell({ children }: { children: React.ReactNode }) {
|
|||||||
cartData = undefined;
|
cartData = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analytics shop GID: best-effort, non-blocking (F1). Merged with
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
// `@shared/config` metadata (acceptedLanguage/currency/hydrogenSubchannelId).
|
// const analyticsShop = await getAnalyticsShop();
|
||||||
const analyticsShop = await getAnalyticsShop();
|
// const scriptsShop = getScriptsShop();
|
||||||
const scriptsShop = getScriptsShop();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Providers
|
<Providers cartData={cartData}>
|
||||||
cartData={cartData}
|
|
||||||
analyticsShop={analyticsShop}
|
|
||||||
analyticsConsent={analyticsConsentConfig}
|
|
||||||
>
|
|
||||||
<a
|
<a
|
||||||
href="#main-content"
|
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"
|
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 />
|
<Footer />
|
||||||
|
|
||||||
<CartDrawer />
|
<CartDrawer />
|
||||||
|
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||||
<ConsentBanner />
|
<ConsentBanner />
|
||||||
|
|
||||||
<ShopifyScriptsClient shop={scriptsShop} />
|
<ShopifyScriptsClient shop={scriptsShop} />
|
||||||
|
*/}
|
||||||
</Providers>
|
</Providers>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -2,7 +2,8 @@ import type { Metadata } from "next";
|
|||||||
|
|
||||||
import { CartCheckoutButton } from "@/components/CartCheckoutButton";
|
import { CartCheckoutButton } from "@/components/CartCheckoutButton";
|
||||||
import { CartContent } from "@/components/CartContent";
|
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 { content } from "@/lib/content";
|
||||||
import { canonicalUrl } from "@/lib/site";
|
import { canonicalUrl } from "@/lib/site";
|
||||||
|
|
||||||
@@ -38,7 +39,9 @@ export default function CartPage() {
|
|||||||
<div className="mx-auto max-w-2xl">
|
<div className="mx-auto max-w-2xl">
|
||||||
<CartContent />
|
<CartContent />
|
||||||
<CartCheckoutButton />
|
<CartCheckoutButton />
|
||||||
|
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||||
<CartViewedTracker />
|
<CartViewedTracker />
|
||||||
|
*/}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+14
-10
@@ -1,11 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ConsentConfig, ShopAnalytics } from "@shopify/hydrogen";
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
import { Suspense } from "react";
|
// import type { ConsentConfig, ShopAnalytics } from "@shopify/hydrogen";
|
||||||
|
// import { Suspense } from "react";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
import { AnalyticsTracker } from "@/components/AnalyticsTracker";
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
import { CartAnalyticsTracker } from "@/components/CartAnalyticsTracker";
|
// import { AnalyticsTracker } from "@/components/AnalyticsTracker";
|
||||||
|
// import { CartAnalyticsTracker } from "@/components/CartAnalyticsTracker";
|
||||||
import { CartProvider } from "@/lib/cart";
|
import { CartProvider } from "@/lib/cart";
|
||||||
import type { cartHandlers } from "@/lib/cart-handlers";
|
import type { cartHandlers } from "@/lib/cart-handlers";
|
||||||
|
|
||||||
@@ -30,23 +32,25 @@ export type CartData = Awaited<ReturnType<typeof cartHandlers.get>>["data"];
|
|||||||
|
|
||||||
export function Providers({
|
export function Providers({
|
||||||
cartData,
|
cartData,
|
||||||
analyticsShop,
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
analyticsConsent,
|
// analyticsShop,
|
||||||
|
// analyticsConsent,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
cartData?: CartData;
|
cartData?: CartData;
|
||||||
analyticsShop: ShopAnalytics;
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
analyticsConsent: ConsentConfig;
|
// analyticsShop: ShopAnalytics;
|
||||||
|
// analyticsConsent: ConsentConfig;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<CartProvider initialData={cartData}>
|
<CartProvider initialData={cartData}>
|
||||||
{/* Suspense scopes the `useSearchParams()` CSR bailout to the tracker,
|
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||||
not the whole layout (hydrogen-analytics / references/react.md). */}
|
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<AnalyticsTracker shop={analyticsShop} consent={analyticsConsent} />
|
<AnalyticsTracker shop={analyticsShop} consent={analyticsConsent} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<CartAnalyticsTracker />
|
<CartAnalyticsTracker />
|
||||||
|
*/}
|
||||||
{children}
|
{children}
|
||||||
</CartProvider>
|
</CartProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import {
|
|||||||
import { CollectionProvider, useCollection, useCollectionForm } from "@shopify/hydrogen/react";
|
import { CollectionProvider, useCollection, useCollectionForm } from "@shopify/hydrogen/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
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 { Breadcrumbs } from "@/components/Breadcrumbs";
|
||||||
import { ProductCard, type ProductCardData } from "@/components/ProductCard";
|
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 { content } from "@/lib/content";
|
||||||
import { FilterGroup } from "@/lib/filters";
|
import { FilterGroup } from "@/lib/filters";
|
||||||
|
|
||||||
@@ -94,39 +96,42 @@ export function CollectionBrowser(props: CollectionBrowserProps) {
|
|||||||
router.refresh();
|
router.refresh();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||||
{props.mode === "collection" ? (
|
{props.mode === "collection" ? (
|
||||||
<CollectionViewedTracker id={props.collection.id} handle={props.collection.handle} />
|
<CollectionViewedTracker id={props.collection.id} handle={props.collection.handle} />
|
||||||
) : (
|
) : (
|
||||||
<SearchViewedTracker term={props.term} totalCount={props.totalCount} />
|
<SearchViewedTracker term={props.term} totalCount={props.totalCount} />
|
||||||
)}
|
)}
|
||||||
|
*/}
|
||||||
{props.mode === "collection" ? <CollectionPage {...props} /> : <SearchPage {...props} />}
|
{props.mode === "collection" ? <CollectionPage {...props} /> : <SearchPage {...props} />}
|
||||||
</CollectionProvider>
|
</CollectionProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CollectionViewedTracker({ id, handle }: { id: string; handle: string }) {
|
// ANALYTICS DISABLED (temporarily commented out):
|
||||||
useEffect(() => {
|
// function CollectionViewedTracker({ id, handle }: { id: string; handle: string }) {
|
||||||
const analytics = getAnalytics();
|
// useEffect(() => {
|
||||||
if (!analytics) return;
|
// const analytics = getAnalytics();
|
||||||
analytics.publish(AnalyticsEvent.COLLECTION_VIEWED, {
|
// if (!analytics) return;
|
||||||
collection: { id, handle },
|
// analytics.publish(AnalyticsEvent.COLLECTION_VIEWED, {
|
||||||
});
|
// collection: { id, handle },
|
||||||
}, [id, handle]);
|
// });
|
||||||
return null;
|
// }, [id, handle]);
|
||||||
}
|
// return null;
|
||||||
|
// }
|
||||||
function SearchViewedTracker({ term, totalCount }: { term: string; totalCount: number }) {
|
//
|
||||||
useEffect(() => {
|
// function SearchViewedTracker({ term, totalCount }: { term: string; totalCount: number }) {
|
||||||
if (!term) return;
|
// useEffect(() => {
|
||||||
const analytics = getAnalytics();
|
// if (!term) return;
|
||||||
if (!analytics) return;
|
// const analytics = getAnalytics();
|
||||||
analytics.publish(AnalyticsEvent.SEARCH_VIEWED, {
|
// if (!analytics) return;
|
||||||
searchTerm: term,
|
// analytics.publish(AnalyticsEvent.SEARCH_VIEWED, {
|
||||||
searchResults: { totalCount },
|
// searchTerm: term,
|
||||||
});
|
// searchResults: { totalCount },
|
||||||
}, [term, totalCount]);
|
// });
|
||||||
return null;
|
// }, [term, totalCount]);
|
||||||
}
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
type CollectionPageProps = Extract<CollectionBrowserProps, { mode: "collection" }>;
|
type CollectionPageProps = Extract<CollectionBrowserProps, { mode: "collection" }>;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { ShopPayButton } from "@shopify/hydrogen/react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
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 { QuantityStepper } from "@/components/QuantityStepper";
|
||||||
import { openCartDrawer } from "@/lib/cart-drawer";
|
import { openCartDrawer } from "@/lib/cart-drawer";
|
||||||
import { content } from "@/lib/content";
|
import { content } from "@/lib/content";
|
||||||
@@ -40,7 +41,9 @@ export function ProductDetails({ product }: { product: ProductData }) {
|
|||||||
router.replace(next, { scroll: false });
|
router.replace(next, { scroll: false });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* ANALYTICS DISABLED (temporarily commented out):
|
||||||
<ProductViewedTracker product={product} />
|
<ProductViewedTracker product={product} />
|
||||||
|
*/}
|
||||||
<ProductPage product={product} />
|
<ProductPage product={product} />
|
||||||
</ProductProvider>
|
</ProductProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user