1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 03:05:24 -04:00

re-enable vercel analytics

This commit is contained in:
Jake Jarvis 2025-04-13 12:41:49 -04:00
parent 259e23ce8a
commit 794d315c6a
Signed by: jake
SSH Key Fingerprint: SHA256:nCkvAjYA6XaSPUqc4TfbBQTpzr8Xj7ritg/sGInCdkc
11 changed files with 55 additions and 105 deletions

View File

@ -14,5 +14,3 @@ NEXT_PUBLIC_GISCUS_CATEGORY_ID=
NEXT_PUBLIC_GISCUS_REPO_ID= NEXT_PUBLIC_GISCUS_REPO_ID=
NEXT_PUBLIC_ONION_DOMAIN= NEXT_PUBLIC_ONION_DOMAIN=
NEXT_PUBLIC_TURNSTILE_SITE_KEY= NEXT_PUBLIC_TURNSTILE_SITE_KEY=
NEXT_PUBLIC_UMAMI_URL=
NEXT_PUBLIC_UMAMI_WEBSITE_ID=

View File

@ -6,7 +6,7 @@
[![GitHub repo size](https://img.shields.io/github/repo-size/jakejarvis/jarv.is?color=009cdf&label=repo%20size&logo=git&logoColor=white)](https://github.com/jakejarvis/jarv.is) [![GitHub repo size](https://img.shields.io/github/repo-size/jakejarvis/jarv.is?color=009cdf&label=repo%20size&logo=git&logoColor=white)](https://github.com/jakejarvis/jarv.is)
[![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fjarv.is%2Fapi%2Fhits&query=%24.total.hits&logo=googleanalytics&logoColor=white&label=hits&color=salmon&cacheSeconds=1800)](https://jarv.is/api/hits) [![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fjarv.is%2Fapi%2Fhits&query=%24.total.hits&logo=googleanalytics&logoColor=white&label=hits&color=salmon&cacheSeconds=1800)](https://jarv.is/api/hits)
My humble abode on the World Wide Web, created and deployed using [Next.js](https://nextjs.org/), [Vercel](https://vercel.com/), [Upstash Redis](https://upstash.com/), [Giscus](https://giscus.app/), [Umami](https://umami.is/), [and more](https://jarv.is/humans.txt). My humble abode on the World Wide Web, created and deployed using [Next.js](https://nextjs.org/), [Vercel](https://vercel.com/), [Upstash Redis](https://upstash.com/), [Giscus](https://giscus.app/), [and more](https://jarv.is/humans.txt).
## 🕹️ Getting Started ## 🕹️ Getting Started
@ -21,7 +21,6 @@ I highly recommend spinning up a [Codespace](https://github.com/features/codespa
## 🌎 Related ## 🌎 Related
- [💻 /uses](https://jarv.is/uses) Things and stuff I use. - [💻 /uses](https://jarv.is/uses) Things and stuff I use.
- [📈 /stats](https://jarv.is/stats) - Public [Umami](https://umami.is/) dashboard.
- [🕰️ /previously](https://jarv.is/previously) An embarrassing trip down this site's memory lane. - [🕰️ /previously](https://jarv.is/previously) An embarrassing trip down this site's memory lane.
- Visit [/y2k](https://jarv.is/y2k) if you want to experience the _fully_ immersive time machine, but don't say I didn't warn you... - Visit [/y2k](https://jarv.is/y2k) if you want to experience the _fully_ immersive time machine, but don't say I didn't warn you...
- [🧅 Tor (.onion) mirror](http://jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion/) For an excessive level of privacy and security. - [🧅 Tor (.onion) mirror](http://jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion/) For an excessive level of privacy and security.

View File

@ -1,24 +0,0 @@
import { env } from "../lib/env";
import Script from "next/script";
const Analytics = () => {
if (env.VERCEL_ENV !== "production") {
return null;
}
if (!env.NEXT_PUBLIC_UMAMI_WEBSITE_ID) {
return null;
}
return (
<Script
src="/_stream/u/script.js" // see next.config.ts rewrite
id="umami-js"
strategy="afterInteractive"
data-website-id={env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
data-domains={env.VERCEL_PROJECT_PRODUCTION_URL}
/>
);
};
export default Analytics;

View File

@ -1,6 +1,6 @@
import { JsonLd } from "react-schemaorg"; import { JsonLd } from "react-schemaorg";
import { Analytics } from "@vercel/analytics/next";
import clsx from "clsx"; import clsx from "clsx";
import Analytics from "./analytics";
import { ThemeProvider, ThemeScript } from "../contexts/ThemeContext"; import { ThemeProvider, ThemeScript } from "../contexts/ThemeContext";
import Header from "../components/Header"; import Header from "../components/Header";
import Footer from "../components/Footer"; import Footer from "../components/Footer";

View File

@ -26,7 +26,7 @@ A very simple hit counter on each blog post tallies an aggregate number of pagev
The [server component](https://github.com/jakejarvis/jarv.is/blob/main/app/notes/%5Bslug%5D/counter.tsx) and [API endpoint](https://github.com/jakejarvis/jarv.is/blob/main/app/api/hits/route.ts) are open source, and [snapshots of the database](https://github.com/jakejarvis/website-stats) are public. The [server component](https://github.com/jakejarvis/jarv.is/blob/main/app/notes/%5Bslug%5D/counter.tsx) and [API endpoint](https://github.com/jakejarvis/jarv.is/blob/main/app/api/hits/route.ts) are open source, and [snapshots of the database](https://github.com/jakejarvis/website-stats) are public.
A self-hosted [**Umami**](https://umami.is/) instance is also used to gain insights into referrers, search terms, etc. [without collecting anything identifiable](https://umami.is/blog/why-privacy-matters) about you. [The dashboard is even public, too!](https://umami-wine-eight.vercel.app/share/wwTaTpLgC6gP9VyX/jarv.is) [**Vercel Analytics**](https://vercel.com/docs/analytics) is also used to gain insights into referrers, search terms, etc. [without collecting anything identifiable](https://vercel.com/docs/analytics/privacy-policy) about you.
## Third-Party Content ## Third-Party Content

View File

@ -5,7 +5,7 @@ const robots = (): MetadataRoute.Robots => ({
rules: [ rules: [
{ {
userAgent: "*", userAgent: "*",
disallow: ["/_stream/", "/api/", "/404", "/500"], disallow: ["/api/", "/404", "/500"],
}, },
], ],
sitemap: `${BASE_URL}/sitemap.xml`, sitemap: `${BASE_URL}/sitemap.xml`,

View File

@ -93,29 +93,12 @@ export const env = createEnv({
* @see https://developers.cloudflare.com/turnstile/troubleshooting/testing/ * @see https://developers.cloudflare.com/turnstile/troubleshooting/testing/
*/ */
NEXT_PUBLIC_TURNSTILE_SITE_KEY: v.optional(v.string(), "XXXX.DUMMY.TOKEN.XXXX"), NEXT_PUBLIC_TURNSTILE_SITE_KEY: v.optional(v.string(), "XXXX.DUMMY.TOKEN.XXXX"),
/**
* Optional. The base URL of a self-hosted Umami instance (including https://) to proxy requests to. If the website
* ID is set but this isn't, the managed Umami Cloud endpoint at https://cloud.umami.is is used.
*
* @see https://umami.is/docs/bypass-ad-blockers
*/
NEXT_PUBLIC_UMAMI_URL: v.optional(v.pipe(v.string(), v.startsWith("https://"), v.url()), "https://cloud.umami.is"),
/**
* Optional. Enables privacy-friendly tracking via Umami, either managed or self-hosted. This ID can be found in the
* dashboard under Settings > Websites > Edit > Details.
*
* @see https://umami.is/docs/collect-data
*/
NEXT_PUBLIC_UMAMI_WEBSITE_ID: v.optional(v.string()),
}, },
experimental__runtimeEnv: { experimental__runtimeEnv: {
NEXT_PUBLIC_GISCUS_CATEGORY_ID: process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID, NEXT_PUBLIC_GISCUS_CATEGORY_ID: process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID,
NEXT_PUBLIC_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_GISCUS_REPO_ID, NEXT_PUBLIC_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_GISCUS_REPO_ID,
NEXT_PUBLIC_ONION_DOMAIN: process.env.NEXT_PUBLIC_ONION_DOMAIN, NEXT_PUBLIC_ONION_DOMAIN: process.env.NEXT_PUBLIC_ONION_DOMAIN,
NEXT_PUBLIC_TURNSTILE_SITE_KEY: process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY, NEXT_PUBLIC_TURNSTILE_SITE_KEY: process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY,
NEXT_PUBLIC_UMAMI_URL: process.env.NEXT_PUBLIC_UMAMI_URL,
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID,
}, },
emptyStringAsUndefined: true, emptyStringAsUndefined: true,
skipValidation: !!process.env.SKIP_ENV_VALIDATION, skipValidation: !!process.env.SKIP_ENV_VALIDATION,

View File

@ -83,37 +83,11 @@ const nextConfig: NextConfig = {
}, },
], ],
}, },
{
source: "/_stream/(.*)", // https://community.torproject.org/onion-services/advanced/onion-location/
headers: [
{
// https://vercel.com/docs/rewrites#caching-rewrites
key: "x-vercel-enable-rewrite-caching",
value: "1",
},
],
},
...(process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
? [
{
source: "/_stream/u/api/send",
headers: [
{
key: "cache-control",
value: "no-cache, no-store",
},
{
key: "x-vercel-enable-rewrite-caching",
value: "0",
},
],
},
]
: []),
...(process.env.NEXT_PUBLIC_ONION_DOMAIN ...(process.env.NEXT_PUBLIC_ONION_DOMAIN
? [ ? [
{ {
// https://community.torproject.org/onion-services/advanced/onion-location/
// only needed on actual pages, not static assets, so make a best effort by matching any path **without** a file // only needed on actual pages, not static assets, so make a best effort by matching any path **without** a file
// extension (aka a period) and/or an underscore (e.g. /_next/image). // extension (aka a period) and/or an underscore (e.g. /_next/image).
source: "/:path([^._]*)", source: "/:path([^._]*)",
@ -128,15 +102,6 @@ const nextConfig: NextConfig = {
: []), : []),
], ],
rewrites: async () => [ rewrites: async () => [
...(process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
? [
{
// https://umami.is/docs/guides/running-on-vercel#proxy-umami-analytics-via-vercel
source: "/_stream/u/:path(script.js|api/send)",
destination: `${process.env.NEXT_PUBLIC_UMAMI_URL || "https://cloud.umami.is"}/:path`,
},
]
: []),
{ {
// https://github.com/jakejarvis/tweets // https://github.com/jakejarvis/tweets
source: "/tweets/:path*", source: "/tweets/:path*",
@ -145,11 +110,6 @@ const nextConfig: NextConfig = {
], ],
redirects: async () => [ redirects: async () => [
{ source: "/y2k", destination: "https://y2k.pages.dev", permanent: false }, { source: "/y2k", destination: "https://y2k.pages.dev", permanent: false },
{
source: "/stats",
destination: "https://umami-wine-eight.vercel.app/share/wwTaTpLgC6gP9VyX/jarv.is",
permanent: false,
},
{ {
source: "/pubkey.asc", source: "/pubkey.asc",
destination: destination:

View File

@ -29,6 +29,7 @@
"@octokit/graphql-schema": "^15.26.0", "@octokit/graphql-schema": "^15.26.0",
"@t3-oss/env-nextjs": "^0.12.0", "@t3-oss/env-nextjs": "^0.12.0",
"@upstash/redis": "^1.34.7", "@upstash/redis": "^1.34.7",
"@vercel/analytics": "^1.5.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"copy-to-clipboard": "^3.3.3", "copy-to-clipboard": "^3.3.3",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
@ -36,7 +37,7 @@
"feed": "^4.2.2", "feed": "^4.2.2",
"geist": "^1.3.1", "geist": "^1.3.1",
"html-entities": "^2.6.0", "html-entities": "^2.6.0",
"lucide-react": "0.487.0", "lucide-react": "0.488.0",
"next": "15.3.1-canary.6", "next": "15.3.1-canary.6",
"polished": "^4.3.1", "polished": "^4.3.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
@ -72,7 +73,7 @@
"@eslint/js": "^9.24.0", "@eslint/js": "^9.24.0",
"@jakejarvis/eslint-config": "^4.0.7", "@jakejarvis/eslint-config": "^4.0.7",
"@types/mdx": "^2.0.13", "@types/mdx": "^2.0.13",
"@types/node": "^22.14.0", "@types/node": "^22.14.1",
"@types/prop-types": "^15.7.14", "@types/prop-types": "^15.7.14",
"@types/react": "^19.1.1", "@types/react": "^19.1.1",
"@types/react-dom": "^19.1.2", "@types/react-dom": "^19.1.2",

58
pnpm-lock.yaml generated
View File

@ -44,6 +44,9 @@ importers:
'@upstash/redis': '@upstash/redis':
specifier: ^1.34.7 specifier: ^1.34.7
version: 1.34.7 version: 1.34.7
'@vercel/analytics':
specifier: ^1.5.0
version: 1.5.0(next@15.3.1-canary.6(@babel/core@7.26.10)(babel-plugin-react-compiler@19.0.0-beta-e993439-20250405)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)
clsx: clsx:
specifier: ^2.1.1 specifier: ^2.1.1
version: 2.1.1 version: 2.1.1
@ -66,8 +69,8 @@ importers:
specifier: ^2.6.0 specifier: ^2.6.0
version: 2.6.0 version: 2.6.0
lucide-react: lucide-react:
specifier: 0.487.0 specifier: 0.488.0
version: 0.487.0(react@19.1.0) version: 0.488.0(react@19.1.0)
next: next:
specifier: 15.3.1-canary.6 specifier: 15.3.1-canary.6
version: 15.3.1-canary.6(@babel/core@7.26.10)(babel-plugin-react-compiler@19.0.0-beta-e993439-20250405)(react-dom@19.1.0(react@19.1.0))(react@19.1.0) version: 15.3.1-canary.6(@babel/core@7.26.10)(babel-plugin-react-compiler@19.0.0-beta-e993439-20250405)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
@ -169,8 +172,8 @@ importers:
specifier: ^2.0.13 specifier: ^2.0.13
version: 2.0.13 version: 2.0.13
'@types/node': '@types/node':
specifier: ^22.14.0 specifier: ^22.14.1
version: 22.14.0 version: 22.14.1
'@types/prop-types': '@types/prop-types':
specifier: ^15.7.14 specifier: ^15.7.14
version: 15.7.14 version: 15.7.14
@ -905,8 +908,8 @@ packages:
'@types/nlcst@2.0.3': '@types/nlcst@2.0.3':
resolution: {integrity: sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==} resolution: {integrity: sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==}
'@types/node@22.14.0': '@types/node@22.14.1':
resolution: {integrity: sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==} resolution: {integrity: sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==}
'@types/prop-types@15.7.14': '@types/prop-types@15.7.14':
resolution: {integrity: sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==} resolution: {integrity: sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==}
@ -1067,6 +1070,32 @@ packages:
'@upstash/redis@1.34.7': '@upstash/redis@1.34.7':
resolution: {integrity: sha512-EJ/g+ttDL3MFS8WNDLj/Buybo3FpPw2IAFl4X8lxh8/l7YTq6kTqT6FKkq8eYRdN6lGlVw+W6qnmym734m39Tg==} resolution: {integrity: sha512-EJ/g+ttDL3MFS8WNDLj/Buybo3FpPw2IAFl4X8lxh8/l7YTq6kTqT6FKkq8eYRdN6lGlVw+W6qnmym734m39Tg==}
'@vercel/analytics@1.5.0':
resolution: {integrity: sha512-MYsBzfPki4gthY5HnYN7jgInhAZ7Ac1cYDoRWFomwGHWEX7odTEzbtg9kf/QSo7XEsEAqlQugA6gJ2WS2DEa3g==}
peerDependencies:
'@remix-run/react': ^2
'@sveltejs/kit': ^1 || ^2
next: '>= 13'
react: ^18 || ^19 || ^19.0.0-rc
svelte: '>= 4'
vue: ^3
vue-router: ^4
peerDependenciesMeta:
'@remix-run/react':
optional: true
'@sveltejs/kit':
optional: true
next:
optional: true
react:
optional: true
svelte:
optional: true
vue:
optional: true
vue-router:
optional: true
abbrev@2.0.0: abbrev@2.0.0:
resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
@ -2411,8 +2440,8 @@ packages:
lru-cache@5.1.1: lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
lucide-react@0.487.0: lucide-react@0.488.0:
resolution: {integrity: sha512-aKqhOQ+YmFnwq8dWgGjOuLc8V1R9/c/yOd+zDY4+ohsR2Jo05lSGc3WsstYPIzcTpeosN7LoCkLReUUITvaIvw==} resolution: {integrity: sha512-ronlL0MyKut4CEzBY/ai2ZpKPxyWO4jUqdAkm2GNK5Zn3Rj+swDz+3lvyAUXN0PNqPKIX6XM9Xadwz/skLs/pQ==}
peerDependencies: peerDependencies:
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
@ -4414,7 +4443,7 @@ snapshots:
'@types/concat-stream@2.0.3': '@types/concat-stream@2.0.3':
dependencies: dependencies:
'@types/node': 22.14.0 '@types/node': 22.14.1
'@types/debug@4.1.12': '@types/debug@4.1.12':
dependencies: dependencies:
@ -4448,7 +4477,7 @@ snapshots:
dependencies: dependencies:
'@types/unist': 3.0.3 '@types/unist': 3.0.3
'@types/node@22.14.0': '@types/node@22.14.1':
dependencies: dependencies:
undici-types: 6.21.0 undici-types: 6.21.0
@ -4607,6 +4636,11 @@ snapshots:
dependencies: dependencies:
crypto-js: 4.2.0 crypto-js: 4.2.0
'@vercel/analytics@1.5.0(next@15.3.1-canary.6(@babel/core@7.26.10)(babel-plugin-react-compiler@19.0.0-beta-e993439-20250405)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)':
optionalDependencies:
next: 15.3.1-canary.6(@babel/core@7.26.10)(babel-plugin-react-compiler@19.0.0-beta-e993439-20250405)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react: 19.1.0
abbrev@2.0.0: {} abbrev@2.0.0: {}
acorn-jsx@5.3.2(acorn@8.14.1): acorn-jsx@5.3.2(acorn@8.14.1):
@ -6210,7 +6244,7 @@ snapshots:
dependencies: dependencies:
yallist: 3.1.1 yallist: 3.1.1
lucide-react@0.487.0(react@19.1.0): lucide-react@0.488.0(react@19.1.0):
dependencies: dependencies:
react: 19.1.0 react: 19.1.0
@ -7833,7 +7867,7 @@ snapshots:
'@types/concat-stream': 2.0.3 '@types/concat-stream': 2.0.3
'@types/debug': 4.1.12 '@types/debug': 4.1.12
'@types/is-empty': 1.2.3 '@types/is-empty': 1.2.3
'@types/node': 22.14.0 '@types/node': 22.14.1
'@types/unist': 3.0.3 '@types/unist': 3.0.3
concat-stream: 2.0.0 concat-stream: 2.0.0
debug: 4.4.0 debug: 4.4.0

View File

@ -33,7 +33,6 @@
- Upstash Redis - Upstash Redis
- Giscus - Giscus
- Resend - Resend
- Umami
- ...and more: https://jarv.is/uses - ...and more: https://jarv.is/uses
# VIEW SOURCE # VIEW SOURCE