From 7977f8ec35e4410c384d8cb832f48a5fd0c23d6e Mon Sep 17 00:00:00 2001 From: JimmyLv Date: Mon, 6 Mar 2023 17:38:25 +0800 Subject: [PATCH] fix: log the shopLink --- pages/[...slug].tsx | 1 + pages/index.tsx | 2 +- pages/shop.tsx | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/[...slug].tsx b/pages/[...slug].tsx index 23567df4..eaf34bdc 100644 --- a/pages/[...slug].tsx +++ b/pages/[...slug].tsx @@ -235,6 +235,7 @@ export const Home: NextPage = () => { href={CHECKOUT_URL} target="_blank" rel="noopener noreferrer" + onClick={() => analytics.track("ShopLink Clicked")} > 「购买次数」 diff --git a/pages/index.tsx b/pages/index.tsx index 2d78713b..8baa9b84 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -17,7 +17,7 @@ function Home(): React.ReactElement { setAnalytics(response); // @ts-ignore window.analytics = response; - window.analytics?.identify("'hello world' from segmentio analytics"); + window.analytics?.page(); } catch (err) { console.error(err); setAnalytics(undefined); diff --git a/pages/shop.tsx b/pages/shop.tsx index 2ffdc5ee..582f4e5a 100644 --- a/pages/shop.tsx +++ b/pages/shop.tsx @@ -1,7 +1,10 @@ +import { useAnalytics } from "~/components/context/analytics"; import SquigglyLines from "../components/SquigglyLines"; import { CHECKOUT_URL, RATE_LIMIT_COUNT } from "../utils/constants"; export default () => { + const { analytics } = useAnalytics(); + return (

@@ -11,6 +14,7 @@ export default () => { analytics.track("ShopLink Clicked")} > 点击购买