Overview
The Area Insights workflow automatically generates comprehensive analytics reports for each product area using AI. It runs daily via cron job to provide teams with up-to-date insights about customer feedback trends, feature request priorities, and product area health.Located at:
apps/www/src/workflows/area-insights/index.tsPurpose
This workflow solves the challenge of maintaining current, actionable insights across multiple product areas without manual reporting work. By analyzing all open requests in each area, it generates:- Trend analysis: What customers are requesting most
- Priority recommendations: Which features to focus on
- Customer sentiment: Aggregate feedback patterns
- Request summaries: Consolidated view of active work
Trigger Conditions
The workflow is triggered by:- Scheduled cron job: Daily at 8:00 AM ET
- Manual invocation: Via API or admin interface
Cron Configuration
Typically configured in your deployment platform:Execution Steps
Fetch Product Areas
Retrieves all product areas from the database:Only processes areas with valid slugs, as insights are stored and accessed via slug-based URLs.
Parallel Processing
Generates insights for all areas concurrently:
Using
Promise.all ensures all areas are processed simultaneously, completing the entire workflow faster than sequential processing.Generate Insights per Area
For each product area, the
generateAreaInsightsStep performs:- Query open requests: Fetches all active feature requests in the area
- Aggregate feedback: Collects associated customer feedback
- AI analysis: Uses the area insights agent to generate report
- Cache results: Stores insights in Redis for fast retrieval
Code Example
Invoking the Workflow
Accessing Generated Insights
Insights are cached in Redis and accessed via API:Workflow Step Reference
generateAreaInsightsStep
generateAreaInsightsStep
Purpose: Generate and cache insights for a single product areaLocation: Delegates to the utility function in
apps/www/src/workflows/area-insights/steps/generate-area-insights.tsImplementation:@/lib/area-insights/generate.ts which:- Queries database for area’s open requests
- Aggregates associated feedback and account data
- Calls AI agent to analyze and generate insights
- Caches results in Redis with TTL
- Returns success status and duration metrics
getAllProductAreas
getAllProductAreas
Purpose: Fetch all product areas from the databaseLocation:
apps/www/src/workflows/shared/get-all-product-areas.tsReturns: Array of product areas with id, name, and slug fieldsConfiguration
Environment Variables
Cache TTL
Insights are cached in Redis with a time-to-live. Configure in your insights generation utility:Logging
The workflow uses structured logging:Error Handling
The workflow gracefully handles failures at the area level:If an area fails to generate insights, the workflow continues processing other areas. Failed areas are logged and returned in the summary.
Performance Considerations
Parallel Execution
The workflow processes all areas concurrently usingPromise.all. For a typical deployment with 8 product areas:
- Sequential: ~40 seconds (5s per area × 8 areas)
- Parallel: ~5-7 seconds (longest area + overhead)
Optimization Tips
- Limit request count: Only process open requests to reduce AI token usage
- Cache results: 24-hour TTL means insights are only regenerated once daily
- Monitor duration: Track
durationMsto identify slow areas
Monitoring & Observability
Recommended monitoring:Related
Area Insights Agent
Learn about the AI agent that generates insights
Product Areas Feature
Understand product area management
Analytics & Insights
See how insights appear in the UI
Redis Package
Learn about caching infrastructure