Ships `dev` as **v0.11.0**. `main` contains nothing that `dev` does not, so this is a clean sync. ## Headline changes since v0.10.0 - **Journal & Journal Studio** — photo essays at `/journal`, split-screen block editor with live preview, drafts, per-entry passwords, cover images - **First-run setup wizard at `/install`** — configure a fresh deployment from the browser; credentials are verified against Immich before anything is written, and the wizard is gated by a one-time token - **About page editor and toggle** in the admin panel - **Per-album photo order** independent of Immich, with a drag & drop editor - **Custom favicon upload** - **Experimental portfolio features** — justified grid, `cover` hero, unlisted subpages, per-album grid overrides, cover focal points, external nav links - **Security** — asset tokens length-capped before decoding (#423), journal author markdown escaped rather than filtered, journal file paths contained, admin session key derived with scrypt (#432), Next.js 16.3.0 for CVE-2025-13465 - **Fixed** — client proofing honours its own configuration again (#454); journal photo rendering (#432) Full detail in [CHANGELOG.md](CHANGELOG.md#0110--2026-08-15). ## Verified `npx tsc --noEmit` clean · `npx vitest run` 435 tests pass · `npm run build` succeeds · lint 0 errors · `prettier --check` clean · local `docker build` of the release tree. ## After merge Tag `v0.11.0` on `main` and publish the release — that triggers `docker-publish.yml`, which pushes the image and moves `latest`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
import { getConfigOrNull } from '@/lib/config';
|
|
|
|
const CONTENT_DIR = path.join(process.cwd(), 'content');
|
|
const ANALYTICS_FILE = path.join(CONTENT_DIR, 'analytics.json');
|
|
|
|
interface AnalyticsData {
|
|
summary: {
|
|
totalViews: number;
|
|
lastUpdated: string;
|
|
};
|
|
days: Record<
|
|
string,
|
|
{
|
|
pageviews: number;
|
|
pages: Record<string, number>;
|
|
devices: Record<string, number>;
|
|
}
|
|
>;
|
|
}
|
|
|
|
async function getAnalytics(): Promise<AnalyticsData> {
|
|
try {
|
|
const raw = await fs.readFile(ANALYTICS_FILE, 'utf8');
|
|
return JSON.parse(raw);
|
|
} catch {
|
|
return { summary: { totalViews: 0, lastUpdated: new Date().toISOString() }, days: {} };
|
|
}
|
|
}
|
|
|
|
async function saveAnalytics(data: AnalyticsData) {
|
|
try {
|
|
await fs.mkdir(CONTENT_DIR, { recursive: true });
|
|
await fs.writeFile(ANALYTICS_FILE, JSON.stringify(data, null, 2), 'utf8');
|
|
} catch (err) {
|
|
console.error('[Analytics] Failed to save analytics data:', err);
|
|
}
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
try {
|
|
const config = getConfigOrNull();
|
|
if (config?.analytics === false) {
|
|
return NextResponse.json({ ok: true, trackingDisabled: true });
|
|
}
|
|
|
|
const body = await req.json();
|
|
const pagePath = (body.path || '/').split('?')[0];
|
|
const userAgent = req.headers.get('user-agent') || '';
|
|
const isMobile = /mobile|iphone|ipad|android/i.test(userAgent);
|
|
const deviceType = isMobile ? 'mobile' : 'desktop';
|
|
|
|
const dateKey = new Date().toISOString().split('T')[0];
|
|
const data = await getAnalytics();
|
|
|
|
data.summary.totalViews = (data.summary.totalViews || 0) + 1;
|
|
data.summary.lastUpdated = new Date().toISOString();
|
|
|
|
if (!data.days[dateKey]) {
|
|
data.days[dateKey] = { pageviews: 0, pages: {}, devices: {} };
|
|
}
|
|
|
|
const dayObj = data.days[dateKey];
|
|
dayObj.pageviews = (dayObj.pageviews || 0) + 1;
|
|
dayObj.pages[pagePath] = (dayObj.pages[pagePath] || 0) + 1;
|
|
dayObj.devices[deviceType] = (dayObj.devices[deviceType] || 0) + 1;
|
|
|
|
await saveAnalytics(data);
|
|
return NextResponse.json({ ok: true });
|
|
} catch {
|
|
return NextResponse.json({ error: 'Failed to record tracking' }, { status: 500 });
|
|
}
|
|
}
|