mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Merge branch 'master' of https://github.com/mikecao/umami
This commit is contained in:
commit
fa20f7f67f
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
.git
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
.gitignore
|
||||
.DS_Store
|
||||
node_modules
|
@ -1,5 +1,10 @@
|
||||
FROM node:12.18-alpine
|
||||
|
||||
ARG DATABASE_TYPE
|
||||
|
||||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \
|
||||
DATABASE_TYPE=$DATABASE_TYPE
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
|
@ -38,7 +38,7 @@ export default function ActiveUsers({ websiteId, className }) {
|
||||
<animated.div className={styles.value}>
|
||||
{props.x.interpolate(x => x.toFixed(0))}
|
||||
</animated.div>
|
||||
<div>{`current vistor${count !== 1 ? 's' : ''}`}</div>
|
||||
<div>{`current visitor${count !== 1 ? 's' : ''}`}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,25 +1,24 @@
|
||||
version: '3.8'
|
||||
---
|
||||
version: '3'
|
||||
services:
|
||||
umami:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
DATABASE_URL: postgresql://umami:umami@postgres:5432/umami
|
||||
DATABASE_URL: postgresql://umami:umami@db:5432/umami
|
||||
DATABASE_TYPE: postgresql
|
||||
HASH_SALT: replace-me-with-a-random-string
|
||||
postgres:
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
image: postgres:alpine
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_DB: umami
|
||||
POSTGRES_USER: umami
|
||||
POSTGRES_PASSWORD: umami
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./sql/schema.postgresql.sql
|
||||
target: /docker-entrypoint-initdb.d/schema.postgresql.sql
|
||||
- type: volume
|
||||
source: postgres-data
|
||||
target: /var/lib/postgresql/data
|
||||
- ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro
|
||||
- umami-db-data:/var/lib/postgresql/data
|
||||
volumes:
|
||||
postgres-data:
|
||||
umami-db-data:
|
||||
|
25
lib/web.js
25
lib/web.js
@ -46,3 +46,28 @@ export const hook = (_this, method, callback) => {
|
||||
return orig.apply(_this, args);
|
||||
};
|
||||
};
|
||||
|
||||
export const doNotTrack = () => {
|
||||
if (
|
||||
window.doNotTrack ||
|
||||
navigator.doNotTrack ||
|
||||
navigator.msDoNotTrack ||
|
||||
'msTrackingProtectionEnabled' in window.external
|
||||
) {
|
||||
if (
|
||||
window.doNotTrack == '1' ||
|
||||
navigator.doNotTrack == 'yes' ||
|
||||
navigator.doNotTrack == '1' ||
|
||||
navigator.msDoNotTrack == '1' ||
|
||||
(window.external &&
|
||||
window.external.msTrackingProtectionEnabled &&
|
||||
window.external.msTrackingProtectionEnabled())
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import NotFound from 'pages/404';
|
||||
import { get } from 'lib/web';
|
||||
|
||||
export default function SharePage() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [websiteId, setWebsiteId] = useState();
|
||||
const [notFound, setNotFound] = useState(false);
|
||||
const router = useRouter();
|
||||
@ -23,10 +24,16 @@ export default function SharePage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
loadData();
|
||||
loadData().finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
} else {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
if (loading) return null;
|
||||
|
||||
if (!id || notFound) {
|
||||
return <NotFound />;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -2,15 +2,15 @@ require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const db = process.env.DATABASE_URL.split(':')[0];
|
||||
const databaseType = process.env.DATABASE_TYPE || process.env.DATABASE_URL.split(':')[0];
|
||||
|
||||
if (!db) {
|
||||
throw new Error('Database not specified');
|
||||
if (!databaseType) {
|
||||
throw new Error('Database schema not specified');
|
||||
}
|
||||
|
||||
console.log(`Database detected: ${db}`);
|
||||
console.log(`Database schema detected: ${databaseType}`);
|
||||
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${db}.prisma`);
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||
|
||||
fs.copyFileSync(src, dest);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'promise-polyfill/src/polyfill';
|
||||
import 'unfetch/polyfill';
|
||||
import { post, hook } from '../lib/web';
|
||||
import { post, hook, doNotTrack } from '../lib/web';
|
||||
|
||||
(window => {
|
||||
const {
|
||||
@ -13,7 +13,7 @@ import { post, hook } from '../lib/web';
|
||||
|
||||
const script = document.querySelector('script[data-website-id]');
|
||||
|
||||
if (!script) return;
|
||||
if (!script || doNotTrack()) return;
|
||||
|
||||
const website = script.getAttribute('data-website-id');
|
||||
const hostUrl = new URL(script.src).origin;
|
||||
@ -53,10 +53,11 @@ import { post, hook } from '../lib/web';
|
||||
|
||||
/* Handle history */
|
||||
|
||||
const handlePush = (state, title, url) => {
|
||||
const handlePush = (state, title, navaigatedUrl) => {
|
||||
removeEvents();
|
||||
currentRef = currentUrl;
|
||||
currentUrl = url;
|
||||
const url = new URL(navaigatedUrl);
|
||||
currentUrl = `${url.pathname}${url.search}`;
|
||||
pageView();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user