Enable vercel analytics (#424)

This commit is contained in:
Luke Vella 2023-01-21 11:45:35 +00:00 committed by GitHub
parent 2f7f0f8734
commit 10c55ff2b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -32,6 +32,7 @@
"@trpc/next": "^10.0.0-rc.8",
"@trpc/react-query": "^10.0.0-rc.8",
"@trpc/server": "^10.0.0-rc.8",
"@vercel/analytics": "^0.1.8",
"accept-language-parser": "^1.5.0",
"autoprefixer": "^10.4.2",
"axios": "^0.24.0",

View file

@ -3,12 +3,14 @@ import "tailwindcss/tailwind.css";
import "~/style.css";
import { Inter, Noto_Sans_Mono } from "@next/font/google";
import { inject } from "@vercel/analytics";
import { NextPage } from "next";
import { AppProps } from "next/app";
import Head from "next/head";
import { appWithTranslation } from "next-i18next";
import PlausibleProvider from "next-plausible";
import { DefaultSeo } from "next-seo";
import React from "react";
import { Toaster } from "react-hot-toast";
import Maintenance from "@/components/maintenance";
@ -30,6 +32,13 @@ const noto = Noto_Sans_Mono({
const MyApp: NextPage<AppProps> = ({ Component, pageProps }) => {
useCrispChat();
React.useEffect(() => {
if (process.env.NEXT_PUBLIC_ENABLE_ANALYTICS) {
// calling inject directly to avoid having this run for self-hosted instances
inject();
}
}, []);
if (process.env.NEXT_PUBLIC_MAINTENANCE_MODE === "1") {
return <Maintenance />;
}

View file

@ -2115,6 +2115,11 @@
"@typescript-eslint/types" "5.21.0"
eslint-visitor-keys "^3.0.0"
"@vercel/analytics@^0.1.8":
version "0.1.8"
resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-0.1.8.tgz#71f1f8c7bb98ac0c5c47eb3fb8ccbe8141b9fe47"
integrity sha512-PQrOI8BJ9qUiVJuQfnKiJd15eDjDJH9TBKsNeMrtelT4NAk7d9mBVz1CoZkvoFnHQ0OW7Xnqmr1F2nScfAnznQ==
"@xobotyi/scrollbar-width@^1.9.5":
version "1.9.5"
resolved "https://registry.npmjs.org/@xobotyi/scrollbar-width/-/scrollbar-width-1.9.5.tgz"