diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index 9e461b2..ce690d6 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -54,8 +54,15 @@ Description is longer than 160 characters in ${Astro.url.pathname} window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); - } - gtag("js", new Date()); +} +gtag("js", new Date()); - gtag("config", "G-1ZSJXCXN8X"); +gtag("config", "G-1ZSJXCXN8X"); + + + diff --git a/src/components/Products/SearchInput.tsx b/src/components/Products/SearchInput.tsx index 3b9a34d..e002f65 100644 --- a/src/components/Products/SearchInput.tsx +++ b/src/components/Products/SearchInput.tsx @@ -1,40 +1,63 @@ -import Button from '@components/Button'; -import FormControl from '@components/FormControl'; -import Input from '@components/Input'; -import type { Signal } from '@preact/signals'; -import type { Product } from '@store/productStore'; -import debounce from '@utils/debounce'; -import getProductsFromUrl from '@utils/getProductsFromUrl'; -import type { FunctionComponent } from 'preact'; +import Button from "@components/Button"; +import FormControl from "@components/FormControl"; +import Input from "@components/Input"; +import type { Signal } from "@preact/signals"; +import type { Product } from "@store/productStore"; +import debounce from "@utils/debounce"; +import getProductsFromUrl from "@utils/getProductsFromUrl"; +import type { FunctionComponent } from "preact"; type TSearchInputProps = { - products: Signal -} + products: Signal; +}; const SearchInput: FunctionComponent = ({ products }) => { const onSearchChange = (e: any) => { - const url = new URL(window.location.href) - url.searchParams.set('q', e.target.value) - window.history.replaceState(undefined, '', url.href) + const url = new URL(window.location.href); + url.searchParams.set("q", e.target.value); + window.history.replaceState(undefined, "", url.href); debounce(async () => { - const { result } = await getProductsFromUrl(url.href) + const { result } = await getProductsFromUrl(url.href); products.value = result.products; - }) - } + + if (e.target.value) { + const searchValue = e.target.value; + window.umami.track(e.target.name, { searchValue }); + } + }); + }; return (
- - -
- ) -} + ); +}; -export default SearchInput \ No newline at end of file +export default SearchInput;