Route passes 16 new fields from DB (technical SEO, meta tags, structured
data, performance) plus CrUX/security/image metrics. Template shows new
sections: Meta Tags & Content, CrUX Field Data, Security Headers (score
X/4), Image Optimization (% modern formats), and 9 new Technical SEO
checklist items. Migration 059 adds 16 columns for persisting live data.
AI service now saves CrUX/security/image data to DB during analysis.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sentiment analysis:
- New analyze_review_sentiment_ai() method in GBPAuditService
- Uses Gemini to analyze review text content (not just ratings)
- Extracts themes, strengths, weaknesses, sentiment score (-1 to 1)
- Review sentiment data passed to GBP AI prompt
Competitor benchmarking:
- New benchmark_service.py with BenchmarkService class
- Calculates category averages across all 150 firms (GBP, SEO, Social)
- Metrics: completeness scores, ratings, reviews, photos, PageSpeed,
load time, follower counts, platform coverage
- Benchmark data injected into all 3 AI prompts (SEO, GBP, Social)
- Excluded from cache hash to avoid unnecessary invalidation
All 4 phases of audit completeness plan now implemented.
Estimated completeness: 52% → ~93%
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GBP data fetching migration:
- Replace legacy maps.googleapis.com/maps/api/place/ with GooglePlacesService
- Use Places API (New): places.googleapis.com/v1/places
- Extract 20+ new fields: primaryType, editorialSummary, priceLevel,
paymentOptions, parkingOptions, accessibilityOptions, service options,
amenities, food & drink, detailed photos metadata, review statistics
- Location bias for Wejherowo area in place search
- Backward-compatible return format for existing callers
GBP AI prompt enrichment:
- Add primaryType, editorialSummary, priceLevel to company info section
- Add business attributes section (payment, parking, accessibility,
services, amenities, food & drink) with dynamic rendering
- Use getattr with fallbacks for new DB columns not yet migrated
Completeness: GBP 55% → ~90% (estimated)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New services:
- youtube_service.py: YouTube Data API v3 integration for channel stats
(subscriber count, view count, video count)
- crux_service.py: Chrome UX Report API for real user field data
(INP, LCP, CLS, FCP, TTFB from actual Chrome users)
SEO audit enrichment:
- Security headers check: HSTS, CSP, X-Frame-Options, X-Content-Type-Options
via live requests.head() during data collection
- Image format analysis: WebP/AVIF/SVG vs legacy JPEG/PNG ratio
- CrUX field data complements existing PageSpeed lab data in AI prompt
- All new metrics passed to Gemini for richer analysis
Social media audit enrichment:
- YouTube API data (video count, views, subscribers) integrated into
social media AI prompt when YouTube profile exists
All APIs use existing GOOGLE_PLACES_API_KEY (free tier, $0 cost).
Completeness: ~68% → ~78% (estimated)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GBP audit:
- Fix review_response_rate bug: check ownerResponse instead of authorAttribution.displayName
- Mark has_posts/has_products/has_qa as OAuth-dependent in AI prompt
- Add review_keywords and description_keywords to AI prompt
SEO audit:
- Replace deprecated FID with INP (Core Web Vital since March 2024)
- Pass 10 additional metrics to AI prompt: FCP, TTFB, TBT, Speed Index,
meta title/desc length, html lang, Schema.org field details
- Update templates with INP thresholds (200ms/500ms)
Social media audit:
- Calculate engagement_rate from industry base rates × activity multiplier
- Calculate posting_frequency_score (0-10 based on posts_count_30d)
- Enrich AI prompt with page_name, freq_score, engagement, last_post_date
- Add avg engagement rate and brand name consistency check to prompt
Completeness: 52% → ~68% (estimated)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Switch to Gemini Structured Output (response_schema) for audit AI analysis
- Enforces valid JSON from API, ~95% → ~99% reliability
- Fallback to manual cleaning if structured output fails
2. Add JSON parse failure rate metric - logs to AIUsageLog for monitoring
3. Add Gemini 3 Pro preview model monitoring warning at service init
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace hardcoded logo_present=False with heuristic (photo_count>=1)
- Replace hardcoded cover_photo_present=False with heuristic (>=2)
- Fix has_photos to use photo_count>0 instead of score threshold
- Add descriptive photo_status string for AI context
- Add UWAGA section in Gemini prompt for cautious recommendations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Store previous analysis before regeneration and show comparison table
with priority breakdown, new/removed actions diff.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add per-call model override parameter to generate_text()
- GBP audit, SEO/social audit analysis, and audit content generation
now use gemini-3-pro-preview for highest quality reasoning
- Chat and other features remain on 3-flash (cheaper, faster)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
company.category is a SQLAlchemy Category object. json.dumps(default=str)
converted it to '<database.Category object at 0x...>' with a different
memory address on each request, causing cache hash to always differ.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Cache: exclude volatile citations fields from hash for better hit rate
- Thinking level: reduce from 'high' to 'low' for faster responses (13-24s → ~5-10s)
- UTF-8: html.unescape() on meta_title, meta_description, h1_text
- SEO score: add "(Google Lighthouse)" label and explanatory note
- Spinner: update text to "15-30 seconds" with live timer counter
- Auto-scroll: smooth scroll to results after AI analysis and content generation
- Cache info: show generation date with "Wygeneruj ponownie" link
- Markdown: render non-code AI content with basic markdown formatting
- Error feedback: inline error display with retry button instead of modal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
AI analysis generates action_types dynamically (e.g. add_sitemap, add_nap)
that don't always match predefined CONTENT_PROMPTS. Added fallback that
builds a generic prompt using the action title/description from the DB.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
company.services returns CompanyService join table objects, not Service
objects. Access service name via s.service.name relationship.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Gemini AI integration to SEO, GBP, and Social Media audits that
generates contextual analysis summaries and prioritized action items
with ready-to-use content (Schema.org, meta descriptions, social posts,
GBP descriptions, review responses, content calendars).
New files:
- audit_ai_service.py: Central AI service with caching (7-day TTL)
- blueprints/api/routes_audit_actions.py: 4 API endpoints
- database/migrations/056_audit_actions.sql: 3 new tables
- templates/partials/audit_ai_actions.html: Reusable UI component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>