fix Analyse
This commit is contained in:
@@ -13,7 +13,11 @@ function loadDB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveDB(data) {
|
function saveDB(data) {
|
||||||
|
try {
|
||||||
writeFileSync(DB_FILE, JSON.stringify(data, null, 2));
|
writeFileSync(DB_FILE, JSON.stringify(data, null, 2));
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Analytics DB Schreibfehler:', e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = loadDB();
|
let db = loadDB();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ app.use((req, res, next) => {
|
|||||||
if (req.method === 'OPTIONS' || !req.path.startsWith('/api/')) return next();
|
if (req.method === 'OPTIONS' || !req.path.startsWith('/api/')) return next();
|
||||||
if (req.path.startsWith('/api/analytics')) return next();
|
if (req.path.startsWith('/api/analytics')) return next();
|
||||||
|
|
||||||
|
try {
|
||||||
let userId = null;
|
let userId = null;
|
||||||
const authHeader = req.headers.authorization;
|
const authHeader = req.headers.authorization;
|
||||||
if (authHeader && authHeader.startsWith('Bearer ')) {
|
if (authHeader && authHeader.startsWith('Bearer ')) {
|
||||||
@@ -29,8 +30,9 @@ app.use((req, res, next) => {
|
|||||||
if (user) userId = user.id;
|
if (user) userId = user.id;
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
trackEvent('page_view', userId, { path: req.path, method: req.method });
|
trackEvent('page_view', userId, { path: req.path, method: req.method });
|
||||||
|
} catch {}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import fetch from 'node-fetch';
|
|
||||||
|
|
||||||
const INSTAGRAM_TOKEN = process.env.INSTAGRAM_TOKEN;
|
const INSTAGRAM_TOKEN = process.env.INSTAGRAM_TOKEN;
|
||||||
|
|
||||||
export async function getInstagramData(url) {
|
export async function getInstagramData(url) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import fetch from 'node-fetch';
|
|
||||||
|
|
||||||
export async function getTikTokData(url) {
|
export async function getTikTokData(url) {
|
||||||
const oembedUrl = `https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
const oembedUrl = `https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
||||||
const response = await fetch(oembedUrl);
|
const response = await fetch(oembedUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user