Skip to content

Conversation

@jjroelofs
Copy link
Contributor

Summary

Adds a service-based analytics API (rl.analyzer) that enables both Drush commands and other Drupal modules to access experiment performance data, insights, and recommendations.

Architecture:

RlAnalyzerInterface (contract)
       ↓
  RlAnalyzer (service - all business logic)
       ↓
  ┌────┴────┐
Drush     Other modules
Commands  (via dependency injection)

Features

Service API (rl.analyzer)

  • listExperiments() - All experiments with summary stats
  • getStatus($experimentId) - Detailed status with confidence levels
  • getPerformance($experimentId, $limit) - Arm data with human-readable labels
  • getTrends($experimentId, $period, $periods) - Historical analysis
  • export($experimentId, $includeSnapshots) - Full data export

Drush Commands

  • rl:list - List all experiments
  • rl:status <experiment> - Experiment status
  • rl:performance <experiment> - Arm performance
  • rl:trends <experiment> - Historical trends
  • rl:analyze <experiment> - Full analysis with recommendations
  • rl:export <experiment> - Complete data export

Key Capabilities

  • Human-readable labels - Entity IDs resolved to titles (node titles, etc.)
  • Pre-computed insights - vs_average, confidence, trend direction
  • JSON/YAML output - Structured data for AI consumption
  • Actionable recommendations - "Ready to conclude", "Continue monitoring", etc.

Usage Examples

# List all experiments
drush rl:list --format=json

# Get detailed status
drush rl:status ab_test_button_color --format=yaml

# Get top performers with resolved labels
drush rl:performance ai_sorting-help_center_categories-block_1 --limit=10

# Full AI-friendly analysis
drush rl:analyze my_experiment --format=json
// Other modules can inject the service
$analyzer = \Drupal::service('rl.analyzer');
$performance = $analyzer->getPerformance('my_experiment', limit: 10);

Test Plan

  • Test rl:list command with table and JSON output
  • Test rl:status with YAML output
  • Test rl:performance with entity label resolution
  • Test rl:trends with historical data
  • Test rl:analyze with recommendations
  • Test rl:export with and without snapshots
  • Verify browser charts still work

Implements RlAnalyzerInterface and RlAnalyzer service providing:
- listExperiments() - All experiments with summary stats
- getStatus() - Detailed experiment status with confidence levels
- getPerformance() - Arm performance with human-readable labels
- getTrends() - Historical trend analysis
- export() - Full data export for deep analysis

Drush commands (thin wrappers around service):
- rl:list - List all experiments
- rl:status - Experiment status
- rl:performance - Arm performance with resolved entity labels
- rl:trends - Historical trends
- rl:analyze - Full analysis with recommendations
- rl:export - Complete data export

Key features:
- Entity IDs resolved to human-readable labels (node titles, etc.)
- Pre-computed insights (vs_average, confidence, trends)
- JSON/YAML output formats for AI tool consumption
- Service-based architecture for use by other modules
@jjroelofs
Copy link
Contributor Author

Duplicate of #26 (base branch was changed to 1.x)

@jjroelofs jjroelofs closed this Jan 28, 2026
@jjroelofs jjroelofs reopened this Jan 28, 2026
@jjroelofs jjroelofs merged commit be92fa3 into 1.x Jan 28, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants