8 Commits

Author SHA1 Message Date
f1fba2dfb2 Show git commit hash as version in Slack header
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 23:10:26 +02:00
4848253c49 Fix leadform double-attribution and Slack message truncation
- airtable_client: restrict leadform cursoid path (path 5) to PMX-only
  campaigns, preventing triple-attribution to search+pmx+leadform companion
- slack_reporter: derive margen from ingreso-coste instead of stale MetricasDiarias
  field; split monthly rankings from fields to separate section blocks; add
  _trunc() helper to clamp all text blocks under Slack's 3000-char limit
- agent: increase portfolio_daily_analysis max_tokens 500→800
- backfill: extend to June 11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 23:04:40 +02:00
a94c18c13c Add daily portfolio analysis and weekly strategic report
- agent.py: portfolio_daily_analysis() for daily Slack block,
  weekly_strategic_analysis() for deep weekly report
- run.py: call portfolio analysis before Slack send
- slack_reporter.py: add strategic diagnosis block at end of daily report
- weekly_report.py: standalone weekly report script
- .github/workflows/weekly.yml: runs Mondays at 9am (CEST)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 20:22:37 +02:00
a489a08785 Fix margin consistency: use MetricasDiarias for sumatorio cost
Both the monthly summary and the daily table now derive coste
from MetricasDiarias entries, so totals match exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 12:46:07 +02:00
624f5e484d Slack daily margin table: show only sumatorio margin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 11:48:43 +02:00
bdc0d5ede3 Add GAMes table and daily margin table in Slack
- GAMes: new Airtable table aggregating daily fco_ metrics (coste, ingreso_sum, ingreso_lxp, leads, leads_lake)
- run.py: accumulate fco_ daily aggregate and write to GAMes each run
- slack_reporter.py: replace sparkline with daily margin % table (Sumatorio + LeadsxPPL per day)
- backfill_games_mayo.py: populated GAMes with all 17 existing May days

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 11:44:18 +02:00
a85bc90b80 Fix Slack monthly summary: correct investment, conversions and margin calculations
- Use CosteMes and ConvMes from all previous month fco_ campaigns (not just
  those active in current month) to avoid missing paused campaigns
- Show day-1 cierre block with Google Ads data labeled explicitly
- Show current month as 0 on day 1 (no data yet)
- Fetch Campaign Name in get_metricas_diarias_prev_month for fco_ filtering
- Fetch prev month data for days 1-5 (last 5 days can span two months)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 10:55:58 +02:00
3eec871d93 Add Slack summary report with daily metrics and campaign rankings
- New slack_reporter.py: posts daily summary to Slack after each run
- Shows monthly investment, revenue (sumatorio + leadsxPPL) and margins
- Rankings of best/worst fco_ campaigns for last 5 days and current month
- Alerts for campaigns with losses > 200€ or margin < -50%
- MetricasDiarias uses yesterday's data (Google Ads lag)
- SLACK_WEBHOOK_URL added to config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 12:38:10 +02:00