fix Analyse

This commit is contained in:
nadja
2026-08-26 15:18:50 +02:00
parent eab8e82674
commit 146dad6f79
4 changed files with 17 additions and 15 deletions

View File

@@ -13,7 +13,11 @@ function loadDB() {
}
function saveDB(data) {
try {
writeFileSync(DB_FILE, JSON.stringify(data, null, 2));
} catch (e) {
console.error('Analytics DB Schreibfehler:', e.message);
}
}
let db = loadDB();

View File

@@ -20,6 +20,7 @@ app.use((req, res, next) => {
if (req.method === 'OPTIONS' || !req.path.startsWith('/api/')) return next();
if (req.path.startsWith('/api/analytics')) return next();
try {
let userId = null;
const authHeader = req.headers.authorization;
if (authHeader && authHeader.startsWith('Bearer ')) {
@@ -29,8 +30,9 @@ app.use((req, res, next) => {
if (user) userId = user.id;
} catch {}
}
trackEvent('page_view', userId, { path: req.path, method: req.method });
} catch {}
next();
});

View File

@@ -1,5 +1,3 @@
import fetch from 'node-fetch';
const INSTAGRAM_TOKEN = process.env.INSTAGRAM_TOKEN;
export async function getInstagramData(url) {

View File

@@ -1,5 +1,3 @@
import fetch from 'node-fetch';
export async function getTikTokData(url) {
const oembedUrl = `https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
const response = await fetch(oembedUrl);