File: //proc/self/root/tmp/dateweb_patch_backlog_campaign_tasks.cjs
const fs = require('fs');
const file = 'scripts/growth-backlog.mjs';
let s = fs.readFileSync(file, 'utf8');
if (!s.includes("const mtmCampaigns = parseTable(insights, 'Matomo-Kampagnen');")) {
s = s.replace("const topRoutes = parseTable(insights, 'Top human-nahe HTML-Routen');", "const topRoutes = parseTable(insights, 'Top human-nahe HTML-Routen');\nconst mtmCampaigns = parseTable(insights, 'Matomo-Kampagnen');\nconst fromSignals = parseTable(insights, 'Interne from-Parameter');");
}
if (!s.includes("Kampagnenlinks ausspielen")) {
const block = `
if (mtmCampaigns.size === 0 && (markerExists('growth-distribution-plan.mjs') || markerExists('local-distribution-plan.mjs') || markerExists('mtm_campaign'))) {
tasks.push(priorityLine('P2', 'Kampagnenlinks ausspielen', '/feed/', 'Keine mtm_campaign-Signale im aktuellen Logfenster, obwohl Kampagnen-URLs für Ratgeber und lokale Seiten erzeugt werden.', 'Newsletter-, Social- und Community-Links aus den Distribution-Reports aktiv ausspielen; nach 48 Stunden mtm_campaign und mtm_source im Growth-Insights-Report prüfen.'));
}
if (fromSignals.size > 0) {
tasks.push(priorityLine('P2', 'Beste from-Parameter priorisieren', '/register/', 'Interne Bridge-Signale sind im Logfenster sichtbar.', 'Top from-Parameter aus Growth Insights auf Register-Referrer und Conversion-Weg prüfen; erfolgreiche CTA-Texte auf ähnliche Routen übertragen.'));
}
`;
s = s.replace("for (const [route, count] of [...topRoutes.entries()].slice(0, 8)) {", `${block}\nfor (const [route, count] of [...topRoutes.entries()].slice(0, 8)) {`);
}
fs.writeFileSync(file, s, 'utf8');