Compare commits

...

4 commits

Author SHA1 Message Date
Mike Cao
5398cd89fe Reordered IP headers.
Some checks are pending
Create docker images (cloud) / Build, push, and deploy (push) Waiting to run
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
2025-11-03 21:01:12 -08:00
Mike Cao
79e324aace Updated Dockerfile to match current Prisma version.
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
2025-11-03 16:54:58 -08:00
Mike Cao
684863d6c7 Added laptop detection. Reorganized IP headers. 2025-11-03 16:44:01 -08:00
Francis Cao
c9f522b24d remove MySQL references from README
Some checks failed
Node.js CI / build (postgresql, 18.18, 10) (push) Has been cancelled
2025-10-31 09:12:32 -07:00
5 changed files with 22 additions and 25 deletions

View file

@ -42,7 +42,7 @@ RUN set -x \
&& apk add --no-cache curl
# Script dependencies
RUN pnpm add npm-run-all dotenv chalk semver prisma@6.16.3 @prisma/adapter-pg@6.16.3
RUN pnpm add npm-run-all dotenv chalk semver prisma@6.18.0 @prisma/adapter-pg@6.18.0
# Permissions for prisma
RUN chown -R nextjs:nodejs node_modules/.pnpm/

View file

@ -36,7 +36,7 @@ A detailed getting started guide can be found at [umami.is/docs](https://umami.i
### Requirements
- A server with Node.js version 18.18 or newer
- A database. Umami supports [MariaDB](https://www.mariadb.org/) (minimum v10.5), [MySQL](https://www.mysql.com/) (minimum v8.0) and [PostgreSQL](https://www.postgresql.org/) (minimum v12.14) databases.
- A database. Umami supports [PostgreSQL](https://www.postgresql.org/) (minimum v12.14) databases.
### Get the Source Code and Install Packages
@ -58,7 +58,6 @@ The connection URL format:
```bash
postgresql://username:mypassword@localhost:5432/mydb
mysql://username:mypassword@localhost:3306/mydb
```
### Build the Application
@ -93,12 +92,6 @@ Alternatively, to pull just the Umami Docker image with PostgreSQL support:
docker pull docker.umami.is/umami-software/umami:postgresql-latest
```
Or with MySQL support:
```bash
docker pull docker.umami.is/umami-software/umami:mysql-latest
```
---
## 🔄 Getting Updates

View file

@ -1,6 +1,5 @@
export const PRISMA = 'prisma';
export const POSTGRESQL = 'postgresql';
export const MYSQL = 'mysql';
export const CLICKHOUSE = 'clickhouse';
export const KAFKA = 'kafka';
export const KAFKA_PRODUCER = 'kafka-producer';
@ -31,7 +30,7 @@ export async function runQuery(queries: any) {
const db = getDatabaseType();
if (db === POSTGRESQL || db === MYSQL) {
if (db === POSTGRESQL) {
return queries[PRISMA]();
}
}

View file

@ -30,10 +30,18 @@ const PROVIDER_HEADERS = [
},
];
export function getDevice(userAgent: string) {
export function getDevice(userAgent: string, screen: string = '') {
const { device } = UAParser(userAgent);
return device?.type || 'desktop';
const [width] = screen.split('x');
const type = device?.type || 'desktop';
if (type === 'desktop' && screen && +width <= 1920) {
return 'laptop';
}
return type;
}
function getRegionCode(country: string, region: string) {
@ -108,7 +116,7 @@ export async function getClientInfo(request: Request, payload: Record<string, an
const city = safeDecodeURIComponent(location?.city);
const browser = browserName(userAgent);
const os = detectOS(userAgent) as string;
const device = getDevice(userAgent);
const device = getDevice(userAgent, payload?.screen);
return { userAgent, browser, os, ip, country, region, city, device };
}

View file

@ -1,19 +1,16 @@
// The order here is important and influences how IPs are detected by lib/detect.ts
// Please do not change the order unless you know exactly what you're doing - read https://developers.cloudflare.com/fundamentals/reference/http-headers/
export const IP_ADDRESS_HEADERS = [
'x-client-ip',
'true-client-ip', // CDN
'x-real-ip', // Reverse proxy
'x-forwarded-for',
'cf-connecting-ip', // This should be *after* x-forwarded-for, so that x-forwarded-for is respected if present
'do-connecting-ip',
'fastly-client-ip',
'true-client-ip',
'x-real-ip',
'cf-connecting-ip', // Cloudflare
'fastly-client-ip', // Fastly
'x-nf-client-connection-ip', // Netlify
'do-connecting-ip', // Digital Ocean
'x-appengine-user-ip', // Google App Ending
'x-client-ip',
'x-cluster-client-ip',
'x-forwarded',
'forwarded',
'x-appengine-user-ip',
'x-nf-client-connection-ip',
'x-real-ip',
];
export function getIpAddress(headers: Headers) {