Skip to content

Commit

Permalink
feat: pirsch analytics events
Browse files Browse the repository at this point in the history
  • Loading branch information
netpoe committed Jun 14, 2024
1 parent e1e5c5a commit 0ca88d2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/src/layouts/home-layout/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ export const HomeLayout: React.FC<ChatLayoutProps> = ({ children }) => {
return (
<>
{process.env.NEXT_PUBLIC_VERCEL_ENV === "production" && (
<Script defer src="https://api.pirsch.io/pa.js" id="pianjs" data-code="X8onK5mQgqhkgQzuKWUBs08SnTqpig5x" />
<Script
defer
src="https://api.pirsch.io/pa.js"
id="pianjs"
data-code={process.env.NEXT_PUBLIC_PIRSCH_ANALYTICS_PID}
/>
)}
{process.env.NEXT_PUBLIC_VERCEL_ENV === "development" && (
<Script
defer
src="https://api.pirsch.io/pa.js"
id="pianjs"
data-code={process.env.NEXT_PUBLIC_PIRSCH_ANALYTICS_PID}
/>
)}
<Head>
<meta property="og:locale" content={locale} />
Expand Down
7 changes: 7 additions & 0 deletions app/src/providers/analytics/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const EventTracking = {
click: {
homepage: {
collection_item: `click.homepage.collection_item`,
},
},
};
5 changes: 5 additions & 0 deletions app/src/providers/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { EventTracking } from "./events";

export default {
EventTracking,
};
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
/* eslint-disable react/no-unknown-property */
import clsx from "clsx";

import { Grid } from "ui/grid/Grid";
import { Card } from "ui/card/Card";
import { Typography } from "ui/typography/Typography";
import { Icon } from "ui/icon/Icon";
import analytics from "providers/analytics";

import styles from "./GridItem.module.scss";
import { GridItemProps } from "./GridItem.types";

export const GridItem: React.FC<GridItemProps> = ({ item, handleExpand, className }) => (
<Grid.Col lg={2} xs={6} key={item.thumbnail} className={clsx(styles["grid-item"], className)}>
<Card className={styles["grid-item"]} withSpotlightEffect onClick={() => handleExpand(item)}>
<Card
className={styles["grid-item"]}
withSpotlightEffect
onClick={() => handleExpand(item)}
data-pirsch-event={analytics.EventTracking.click.homepage.collection_item}
data-pirsch-name={item.name}
data-pirsch-token-id={item.id}
>
<div className={styles["grid-item__img"]}>
<img src={item.thumbnail} alt={item.name} />
</div>
Expand Down

0 comments on commit 0ca88d2

Please sign in to comment.