visit
Analytics is the process of collecting and analyzing data about how visitors interact with your website. This information is crucial because it allows you to make informed decisions to improve your website.
Umami Analytics is a simple, fast, and privacy-focused tool that lets you track website usage without compromising user privacy. It is an open-source alternative to Google Analytics. A big plus is that Umami analytics is GDPR (General Data Protection Regulation) compliant.
Create a new account (if you don’t already have one) with Supabase and create new project by pressing + New Project
Provide project name as you like (eg. your_app_name-analytics
)
Table Editor
option
Edit db/postgresql/schema.prisma
file (add directUrl)
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL") //add this line
relationMode = "prisma"
}
DATABASE_URL = postgres://[user]:[password]@aws-0-[aws-region].pooler.supabase.com:6543/postgres?**pgbouncer=true&connection_limit=1**
DIRECT_DATABASE_URL = postgres://[user]:[password]@aws-0-[aws-region].pooler.supabase.com:**5432**/postgres
💡 DATABASE_URL is same as the Connection Url copied from supabase (in step 2) but you have to add ?pgbouncer=true&connect_timeout=1
at the end of Url
💡 DATABASE_URL is same as the Connection Url copied from supabase (in step 2) but you have to replace the port from 6543
to 5432
In step two we did run a sql script in Supabase which created few tables in the database. Now when script is run during deployment it throws an error with error code P3005
saying Database schema is not empty
yarn install
yarn build-db
Run the following command to create a migrations
directory inside with your preferred name. This example will use 01_init
for the migration name:
mkdir -p prisma/migrations/01_init
Generate a migration and save it to a file using prisma migrate diff
npx prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/01_init/migration.sql
Run the prisma migrate resolve
command for each migration that should be ignored:
npx prisma migrate resolve --applied 01_init
This command adds the target migration to the _prisma_migrations
table and marks it as applied. When you run prisma migrate deploy
to apply new migrations, Prisma Migrate:
project
tab of Vercel app.username : admin
password : umami
+ Add website
Name : provide any name of your choice
Domain : your [website](//www.invoizly.com) domain (eg. invoizly.com)
In Next.JS projects to load a for multiple routes, import next/script
and include the script directly in your layout component:
import Script from 'next/script'
export default function Layout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en" className="dark">
<body className={cn(`${inter.className} antialiased`)}>
<Navbar />
{children}
<Footer />
</body>
<Script
defer
src="//[your-analytics-app].vercel.app/script.js"
data-website-id="xxxx-xxx-xxxx-xxxx-xxxxx"
/>
</>
)
}