Howto
Installation
- Rename
.env.example
to .env
and update config vars npm i
to install node modulesnpx prisma migrate deploy
to apply db schemanpm start
to start the application
How to access API
API_KEY
environment var should be set in order to access API- Get report for site
GET /api?site=$siteId&apiKey=API_KEY
- List all sites
GET /api/sites?apiKey=API_KEY
Fly.io deployment
- Download the source code
- Register an account at Fly.io, download the flyctl and sign in
- Install dependencies: Run
npm i
- Initiate setup: Execute
fly launch
- Add Environment Variables
USERS
and API_KEY
. This can be done either via the flyctl or the web UI- Command:
fly secrets set USERS=user:pass321,user2:pass123 API_KEY=MyS3cret
DATABASE_URL
is automaticlly set by Fly.io so you don't have to set it
- Deploy the application by running
fly deploy
- Now you will get assigned a subdomain from fly.io, or you can assign your own domain through fly.io UI. Whichever domain you choose, set a new environment variable
DOMAIN
:- Command:
fly secrets set DOMAIN=https://yourdomain.com
Render.com deployment
- Download the source code.
- Register an account at render.com
- Create a PostgreSQL database on Render.com
- Choose PostgreSQL version 15
- While the PostgreSQL service is setting up, you can set up the Web Service
- Add your analytics code to your private GitHub or GitLab repository. This is required before setting up the Web Service
- Create a Web Service:
- Choose "Build and deploy from a Git repository"
- Connect to your GitHub or GitLab repository and select the repo where your analytics code is located
- Select Runtime: Docker
- Add Environment Variables:
DATABASE_URL
, USERS
, API_KEY
- Retrieve the "Internal Database URL" from the PostgreSQL service set up earlier. Set this as the
DATABASE_URL
environment variable - Click "Create Web Service"
- Render will now deploy your analytics. The app should be up and running within 2-3 minutes
- Inside Render Dashboard, you will find the assigned domain. Now add that domain as the
DOMAIN
environment variable and restart the service.