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 6afa1b7
Show file tree
Hide file tree
Showing 4 changed files with 29 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 @@
import { ItemMetadata } from "ui/svpervnder/collections/larskristo_hellheads/LarsKristoHellheads.types";

export const EventTracking = {
homepage: {
collection_item: (item: ItemMetadata) => `homepage.collection_item: ${item.name}:${item.id}`,
},
};
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,9 +1,11 @@
/* 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";
Expand All @@ -23,7 +25,7 @@ export const GridItem: React.FC<GridItemProps> = ({ item, handleExpand, classNam
</div>
<div className={styles["grid-item__price-row"]}>
<div />
<div>
<div pirsch-event={analytics.EventTracking.homepage.collection_item(item)}>
<Icon name="icon-expand" className={styles["grid-item__expand"]} />
</div>
</div>
Expand Down

0 comments on commit 6afa1b7

Please sign in to comment.