chore: add detailed debug for inject advanced

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-12-10 11:29:28 -06:00
parent 09d87835b8
commit 18bf3d191c
2 changed files with 17 additions and 5 deletions

View File

@@ -3,7 +3,8 @@
"allow": [
"Bash(mkdir:*)",
"mcp__serena__activate_project",
"mcp__serena__find_symbol"
"mcp__serena__find_symbol",
"Bash(ssh:*)"
]
}
}

View File

@@ -120,6 +120,7 @@ final class ContentAdInjector
private function injectAdvanced(string $content): string
{
$config = $this->settings['incontent_advanced'] ?? [];
$debugSteps = []; // DEBUG
// Obtener configuracion
$maxAds = (int)($config['incontent_max_total_ads'] ?? 8);
@@ -127,26 +128,31 @@ final class ContentAdInjector
$priorityMode = $config['incontent_priority_mode'] ?? 'position';
$format = $config['incontent_format'] ?? 'in-article';
$debugSteps['config'] = "maxAds=$maxAds, minSpacing=$minSpacing, priority=$priorityMode"; // DEBUG
// PASO 1: Escanear contenido para encontrar todas las ubicaciones
$locations = $this->scanContent($content);
$debugSteps['step1_scan'] = count($locations); // DEBUG
if (empty($locations)) {
return $content;
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
}
// PASO 2: Filtrar por configuracion (enabled)
$locations = $this->filterByEnabled($locations, $config);
$debugSteps['step2_enabled'] = count($locations); // DEBUG
if (empty($locations)) {
return $content;
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
}
// PASO 3: Aplicar probabilidad deterministica
$postId = get_the_ID() ?: 0;
$locations = $this->applyProbability($locations, $config, $postId);
$debugSteps['step3_probability'] = count($locations); // DEBUG
if (empty($locations)) {
return $content;
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
}
// PASO 4-5: Filtrar por espaciado y limite (segun priority_mode)
@@ -155,13 +161,18 @@ final class ContentAdInjector
} else {
$locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds);
}
$debugSteps['step4_spacing'] = count($locations); // DEBUG
if (empty($locations)) {
return $content;
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
}
// Ordenar por posicion para insercion correcta
usort($locations, fn($a, $b) => $a['position'] <=> $b['position']);
$debugSteps['final_ads'] = count($locations); // DEBUG
// Insertar debug comment
$content = '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
// PASO 6: Insertar anuncios
return $this->insertAds($content, $locations, $format);