Skip to content

Add Analytics API service and Drush commands for AI integration #25

Description

@jjroelofs

Summary

Add a service-based analytics API to the RL module that enables both Drush commands and other Drupal modules (like ai_content_strategy) to access experiment performance data, insights, and recommendations.

Motivation

Currently, analyzing RL experiment data requires direct database queries. This makes it difficult for:

  • AI tools (like Claude Code) to provide experiment insights via Drush
  • Other Drupal modules to integrate with RL data
  • Automation of experiment analysis and reporting

Proposed Solution

1. Service Layer (RlAnalyzer)

Create a service implementing RlAnalyzerInterface with methods:

  • listExperiments() - All experiments with summary stats
  • getStatus($experimentId) - Detailed experiment status
  • getPerformance($experimentId, $options) - Arm performance with human-readable labels
  • getTrends($experimentId, $options) - Historical data
  • export($experimentId) - Full JSON export

2. Drush Commands

Thin CLI wrappers around the service:

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

Key Features

  • Human-readable labels - Resolve entity IDs to titles/names
  • Pre-computed insights - vs_average, confidence levels, trends
  • JSON output - Structured data for AI consumption
  • Self-documenting - Rich help text for AI discoverability

Technical Approach

Following Drupal core patterns (like StateInterface/State):

  1. Interface defines API contract
  2. Service contains all business logic
  3. Drush commands are thin wrappers
  4. Other modules inject service via DI

Tasks

  • Create RlAnalyzerInterface
  • Create RlAnalyzer service
  • Register in rl.services.yml
  • Create RlCommands Drush class
  • Implement all commands
  • Update README.md
  • Update docs/rl_project_desc.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions