diff --git a/app/components/cart/MutateCartButton.tsx b/app/components/cart/MutateCartButton.tsx index 1887fe5..e5f6687 100644 --- a/app/components/cart/MutateCartButton.tsx +++ b/app/components/cart/MutateCartButton.tsx @@ -135,13 +135,19 @@ export const MutateCartButton: FC = ({ className )}> { + e.stopPropagation(); + incrementProductQuantity(); + }} size={iconConfig?.plusIconSize} strokeWidth={iconConfig?.plusIconStrokeWidth} /> {cartItem.quantity} { + e.stopPropagation(); + decrementProductQuantity(); + }} size={iconConfig?.minusIconSize} strokeWidth={iconConfig?.minusIconStrokeWidth} /> diff --git a/app/components/header/Header.tsx b/app/components/header/Header.tsx index a0dc208..9a02437 100644 --- a/app/components/header/Header.tsx +++ b/app/components/header/Header.tsx @@ -18,7 +18,7 @@ export const Header = () => { -
+
diff --git a/app/components/header/breadcrumb/CategoryPart.tsx b/app/components/header/breadcrumb/CategoryPart.tsx index 0fe4d46..c01c94d 100644 --- a/app/components/header/breadcrumb/CategoryPart.tsx +++ b/app/components/header/breadcrumb/CategoryPart.tsx @@ -1,5 +1,7 @@ 'use client'; import {useGetCategoryQuery} from '@/app/lib/api/categories-slice'; +import {dispatchUserEvent} from '@/app/lib/kafka/dispatch/user-events'; +import {useUser} from '@clerk/nextjs'; import {HomeIcon} from 'lucide-react'; import Link from 'next/link'; import {FC, useMemo} from 'react'; @@ -13,6 +15,8 @@ export const BreadcrumbCategoryPart: FC = ({ }) => { // fetch data const categoryFetch = useGetCategoryQuery(categoryId); + // user data for recording events + const {user} = useUser(); // Method to get the categories part of the breadcrumb const getCategoriesPart = useMemo(() => { @@ -28,7 +32,19 @@ export const BreadcrumbCategoryPart: FC = ({ + className="cursor-pointer" + onClick={(e) => { + e.preventDefault(); + if (user) { + dispatchUserEvent({ + user_id: user.id, + event_type: 'click', + core_component: 'breadcrumb', + description: `Clicked on category in breadcrumb for category ${categoryFetch.data?.name}`, + metadata: {category_id: categoryId}, + }); + } + }}> {categoryFetch.data.name} diff --git a/app/components/header/breadcrumb/ProductPart.tsx b/app/components/header/breadcrumb/ProductPart.tsx index a33aa2a..acfe380 100644 --- a/app/components/header/breadcrumb/ProductPart.tsx +++ b/app/components/header/breadcrumb/ProductPart.tsx @@ -1,5 +1,7 @@ 'use client'; import {useGetProductQuery} from '@/app/lib/api/products-api-slice'; +import {dispatchUserEvent} from '@/app/lib/kafka/dispatch/user-events'; +import {useUser} from '@clerk/nextjs'; import Link from 'next/link'; import {FC, useMemo} from 'react'; @@ -16,6 +18,8 @@ export const BreadcrumbProductPart: FC = ({ }) => { // fetch data const productFetch = useGetProductQuery(productId); + // user data for recording events + const {user} = useUser(); // Method to get the products part of the breadcrumb const getProductsPart = useMemo(() => { @@ -28,7 +32,19 @@ export const BreadcrumbProductPart: FC = ({ + className="cursor-pointer" + onClick={(e) => { + e.preventDefault(); + if (user) { + dispatchUserEvent({ + user_id: user.id, + event_type: 'click', + core_component: 'breadcrumb', + description: `Clicked on product in breadcrumb for product ${productFetch.data?.name}`, + metadata: {product_id: productId}, + }); + } + }}> {productFetch.data.name} diff --git a/app/components/header/breadcrumb/SubCategoryPart.tsx b/app/components/header/breadcrumb/SubCategoryPart.tsx index 038752f..eabcb33 100644 --- a/app/components/header/breadcrumb/SubCategoryPart.tsx +++ b/app/components/header/breadcrumb/SubCategoryPart.tsx @@ -1,5 +1,7 @@ 'use client'; import {useGetSubCategoryQuery} from '@/app/lib/api/categories-slice'; +import {dispatchUserEvent} from '@/app/lib/kafka/dispatch/user-events'; +import {useUser} from '@clerk/nextjs'; import Link from 'next/link'; import {FC, useMemo} from 'react'; @@ -13,6 +15,8 @@ export const BreadcrumbSubCategortPart: FC = ({ subCategoryId, }) => { const subCategoryFetch = useGetSubCategoryQuery(subCategoryId); + // user data for recording events + const {user} = useUser(); // Method to get the subcategories part of the breadcrumb const getSubCategoriesPart = useMemo(() => { @@ -25,7 +29,19 @@ export const BreadcrumbSubCategortPart: FC = ({ + className="cursor-pointer" + onClick={(e) => { + e.preventDefault(); + if (user) { + dispatchUserEvent({ + user_id: user.id, + event_type: 'click', + core_component: 'breadcrumb', + description: `Clicked on subcategory in breadcrumb for subcategory ${subCategoryFetch.data?.name}`, + metadata: {subcategory_id: subCategoryId}, + }); + } + }}> {subCategoryFetch.data.name}