Merge branch 'dev' into analytics

This commit is contained in:
Mike Cao 2023-10-23 09:42:55 -07:00
commit 047aad1283
8 changed files with 2181 additions and 2303 deletions

View File

@ -35,7 +35,7 @@ ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
RUN yarn add npm-run-all dotenv prisma RUN yarn add npm-run-all dotenv prisma semver
# You only need to copy next.config.js if you are NOT using the default configuration # You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js . COPY --from=builder /app/next.config.js .

View File

@ -72,13 +72,13 @@ docker compose up -d
Alternatively, to pull just the Umami Docker image with PostgreSQL support: Alternatively, to pull just the Umami Docker image with PostgreSQL support:
```bash ```bash
docker pull docker.umami.dev/umami-software/umami:postgresql-latest docker pull ghcr.io/umami-software/umami:postgresql-latest
``` ```
Or with MySQL support: Or with MySQL support:
```bash ```bash
docker pull docker.umami.dev/umami-software/umami:mysql-latest docker pull ghcr.io/umami-software/umami:mysql-latest
``` ```
## Getting updates ## Getting updates

View File

@ -63,11 +63,11 @@
"dependencies": { "dependencies": {
"@clickhouse/client": "^0.2.2", "@clickhouse/client": "^0.2.2",
"@fontsource/inter": "^4.5.15", "@fontsource/inter": "^4.5.15",
"@prisma/client": "5.3.1", "@prisma/client": "5.4.2",
"@react-spring/web": "^9.7.3", "@react-spring/web": "^9.7.3",
"@tanstack/react-query": "^4.33.0", "@tanstack/react-query": "^4.33.0",
"@umami/prisma-client": "^0.3.0", "@umami/prisma-client": "^0.3.0",
"@umami/redis-client": "^0.15.0", "@umami/redis-client": "^0.16.0",
"chalk": "^4.1.1", "chalk": "^4.1.1",
"chart.js": "^4.2.1", "chart.js": "^4.2.1",
"chartjs-adapter-date-fns": "^3.0.0", "chartjs-adapter-date-fns": "^3.0.0",
@ -92,10 +92,11 @@
"kafkajs": "^2.1.0", "kafkajs": "^2.1.0",
"maxmind": "^4.3.6", "maxmind": "^4.3.6",
"moment-timezone": "^0.5.35", "moment-timezone": "^0.5.35",
"next": "13.5.3", "next": "13.5.6",
"next-basics": "^0.36.0", "next-basics": "^0.37.0",
"node-fetch": "^3.2.8", "node-fetch": "^3.2.8",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prisma": "5.4.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-basics": "^0.105.0", "react-basics": "^0.105.0",
"react-beautiful-dnd": "^13.1.0", "react-beautiful-dnd": "^13.1.0",
@ -106,7 +107,7 @@
"react-use-measure": "^2.0.4", "react-use-measure": "^2.0.4",
"react-window": "^1.8.6", "react-window": "^1.8.6",
"request-ip": "^3.3.0", "request-ip": "^3.3.0",
"semver": "^7.5.2", "semver": "^7.5.4",
"thenby": "^1.3.4", "thenby": "^1.3.4",
"timezone-support": "^2.0.2", "timezone-support": "^2.0.2",
"uuid": "^9.0.0", "uuid": "^9.0.0",
@ -146,7 +147,6 @@
"postcss-preset-env": "7.8.3", "postcss-preset-env": "7.8.3",
"postcss-rtlcss": "^4.0.1", "postcss-rtlcss": "^4.0.1",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"prisma": "5.3.1",
"prompts": "2.4.2", "prompts": "2.4.2",
"rollup": "^3.28.0", "rollup": "^3.28.0",
"rollup-plugin-copy": "^3.4.0", "rollup-plugin-copy": "^3.4.0",

View File

@ -7,19 +7,15 @@ import WebsiteChart from '../../(main)/websites/[id]/WebsiteChart';
import useApi from 'components/hooks/useApi'; import useApi from 'components/hooks/useApi';
import Head from 'next/head'; import Head from 'next/head';
import Link from 'next/link'; import Link from 'next/link';
import { useRouter } from 'next/navigation'; import useNavigation from 'components/hooks/useNavigation';
import Script from 'next/script'; import Script from 'next/script';
import { Button } from 'react-basics'; import { Button } from 'react-basics';
import styles from './TestConsole.module.css'; import styles from './TestConsole.module.css';
export function TestConsole() { export function TestConsole({ websiteId }) {
const { get, useQuery } = useApi(); const { get, useQuery } = useApi();
const { data, isLoading, error } = useQuery(['websites:me'], () => get('/me/websites')); const { data, isLoading, error } = useQuery(['websites:me'], () => get('/me/websites'));
const router = useRouter(); const { router } = useNavigation();
const {
basePath,
query: { id },
} = router;
function handleChange(value) { function handleChange(value) {
router.push(`/console/${value}`); router.push(`/console/${value}`);
@ -72,7 +68,6 @@ export function TestConsole() {
return null; return null;
} }
const [websiteId] = id || [];
const website = data?.data.find(({ id }) => websiteId === id); const website = data?.data.find(({ id }) => websiteId === id);
return ( return (
@ -87,8 +82,8 @@ export function TestConsole() {
<> <>
<Script <Script
async async
data-website-id={website.id} data-website-id={websiteId}
src={`${basePath}/script.js`} src={`${process.env.basePath}/script.js`}
data-cache="true" data-cache="true"
/> />
<div className={styles.test}> <div className={styles.test}>

View File

@ -5,14 +5,14 @@ async function getEnabled() {
return !!process.env.ENABLE_TEST_CONSOLE; return !!process.env.ENABLE_TEST_CONSOLE;
} }
export default async function ConsolePage() { export default async function ({ params: { id } }) {
const enabled = await getEnabled(); const enabled = await getEnabled();
if (!enabled) { if (!enabled) {
return null; return null;
} }
return <TestConsole />; return <TestConsole websiteId={id?.[0]} />;
} }
export const metadata: Metadata = { export const metadata: Metadata = {

View File

@ -3,57 +3,57 @@ import redis from '@umami/redis-client';
import { getSession, getUserById, getWebsiteById } from '../queries'; import { getSession, getUserById, getWebsiteById } from '../queries';
async function fetchWebsite(id): Promise<Website> { async function fetchWebsite(id): Promise<Website> {
return redis.fetchObject(`website:${id}`, () => getWebsiteById(id), 86400); return redis.getCache(`website:${id}`, () => getWebsiteById(id), 86400);
} }
async function storeWebsite(data) { async function storeWebsite(data) {
const { id } = data; const { id } = data;
const key = `website:${id}`; const key = `website:${id}`;
const obj = await redis.storeObject(key, data); const obj = await redis.setCache(key, data);
await redis.expire(key, 86400); await redis.expire(key, 86400);
return obj; return obj;
} }
async function deleteWebsite(id) { async function deleteWebsite(id) {
return redis.deleteObject(`website:${id}`); return redis.deleteCache(`website:${id}`);
} }
async function fetchUser(id): Promise<User> { async function fetchUser(id): Promise<User> {
return redis.fetchObject(`user:${id}`, () => getUserById(id, { includePassword: true }), 86400); return redis.getCache(`user:${id}`, () => getUserById(id, { includePassword: true }), 86400);
} }
async function storeUser(data) { async function storeUser(data) {
const { id } = data; const { id } = data;
const key = `user:${id}`; const key = `user:${id}`;
const obj = await redis.storeObject(key, data); const obj = await redis.setCache(key, data);
await redis.expire(key, 86400); await redis.expire(key, 86400);
return obj; return obj;
} }
async function deleteUser(id) { async function deleteUser(id) {
return redis.deleteObject(`user:${id}`); return redis.deleteCache(`user:${id}`);
} }
async function fetchSession(id) { async function fetchSession(id) {
return redis.fetchObject(`session:${id}`, () => getSession(id), 86400); return redis.getCache(`session:${id}`, () => getSession(id), 86400);
} }
async function storeSession(data) { async function storeSession(data) {
const { id } = data; const { id } = data;
const key = `session:${id}`; const key = `session:${id}`;
const obj = await redis.storeObject(key, data); const obj = await redis.setCache(key, data);
await redis.expire(key, 86400); await redis.expire(key, 86400);
return obj; return obj;
} }
async function deleteSession(id) { async function deleteSession(id) {
return redis.deleteObject(`session:${id}`); return redis.deleteCache(`session:${id}`);
} }
async function fetchUserBlock(userId: string) { async function fetchUserBlock(userId: string) {

View File

@ -15,7 +15,7 @@ export function salt() {
export function uuid(...args) { export function uuid(...args) {
if (!args.length) return v4(); if (!args.length) return v4();
return v5(hash(...args), v5.DNS); return v5(hash(...args, salt()), v5.DNS);
} }
export function isUuid(value) { export function isUuid(value) {

4427
yarn.lock

File diff suppressed because it is too large Load Diff