diff --git a/packages/_firstparty-analytics/events/index.ts b/packages/_firstparty-analytics/events/index.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-icon-load.ts b/packages/_firstparty-analytics/events/track-on-icon-load.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-icon-search.ts b/packages/_firstparty-analytics/events/track-on-icon-search.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-image-gen-prompt.ts b/packages/_firstparty-analytics/events/track-on-image-gen-prompt.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-photo-search.ts b/packages/_firstparty-analytics/events/track-on-photo-search.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-preview.ts b/packages/_firstparty-analytics/events/track-on-preview.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-publish.ts b/packages/_firstparty-analytics/events/track-on-publish.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-run-lint.ts b/packages/_firstparty-analytics/events/track-on-run-lint.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/_firstparty-analytics/events/track-on-selection-to-code.ts b/packages/_firstparty-analytics/events/track-on-selection-to-code.ts new file mode 100644 index 00000000..e69de29b diff --git a/web/.env b/web/.env index 0d4b0019..c9f37829 100644 --- a/web/.env +++ b/web/.env @@ -8,3 +8,4 @@ NEXT_PUBLIC_UNSPLASH_TMP_LOCAL_CLIENT_ID= NEXT_PUBLIC_PUSHER_APP_KEY= NEXT_PUBLIC_PUSHER_APP_CLUSTER= NEXT_PUBLIC_CORS_GRIDA_API_KEY=get-it-from-https://github.com/gridaco/base/issues/23 +NEXT_PUBLIC_SEGMENT_WRITE_KEY= \ No newline at end of file diff --git a/web/package.json b/web/package.json index 5e4610dc..c11eb9a9 100644 --- a/web/package.json +++ b/web/package.json @@ -8,6 +8,7 @@ "start": "next start -p 3303" }, "dependencies": { + "@segment/snippet": "^4.15.3", "app": "0.0.1", "languagedetect": "^2.0.0", "next": "^13.1.6", diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index e48b0acd..0096aa5b 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -1,9 +1,22 @@ import React, { useEffect } from "react"; import type { AppProps } from "next/app"; import { useRouter } from "next/router"; +import Script from "next/script"; +import * as snippet from "@segment/snippet"; import * as gtag from "../lib/gtag"; function WebApp({ Component, pageProps }: AppProps) { + const loadSegment = () => { + const options = { + apiKey: process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY, + }; + if (process.env.NEXT_PUBLIC_NODE_ENV) { + return snippet.max(options); + } else { + return snippet.min(options); + } + }; + // region GA const router = useRouter(); useEffect(() => { @@ -17,6 +30,14 @@ function WebApp({ Component, pageProps }: AppProps) { }, [router.events]); // endregion GA - return ; + return ( + <> +