-
Notifications
You must be signed in to change notification settings - Fork 0
Open
2 / 52 of 5 issues completedLabels
π·οΈ type:productionProduction codebase (src/, modules/, core functionality)Production codebase (src/, modules/, core functionality)π area:blocksLayout Builder block A/B testing featuresLayout Builder block A/B testing featuresπ area:coreCore plugin system, interfaces, managers, and base functionalityCore plugin system, interfaces, managers, and base functionalityπ₯ priority:highImportant features, significant bugs affecting many usersImportant features, significant bugs affecting many users
Description
Add A/B Testing Proxy Block Plugin
Summary
Create a new block plugin that acts as a proxy for other blocks, allowing A/B testing by dynamically selecting which block to render based on the configured A/B test decision. This will enable testing different block types/configurations or testing presence vs absence of blocks.
Problem Statement
Currently, A/B testing with blocks is limited to testing different configurations of the same block type. There's no way to:
- Test completely different block types against each other (e.g. a Custom HTML block vs a View block)
- Test having a block vs not having any block at all
- Easily swap between different pre-configured blocks in an A/B test
Proposed Solution
Create a new block plugin called AbTestProxyBlock that:
Core Functionality
- Block Selection: Configuration form allows selecting an existing block from the system
- Empty Rendering: Option to render nothing (empty/hidden state)
- Proxy Behavior: Renders the selected block with its original configuration
- A/B Integration: Works seamlessly with the existing ab_blocks A/B testing system
Configuration Options
- Target Block: Dropdown/autocomplete to select which block to proxy
- Should list all available block plugins
- Include block instance selection for blocks that have multiple instances
- Render Mode:
- "Render selected block" - Shows the proxied block
- "Render empty" - Shows nothing (for testing block presence vs absence)
- Block Configuration:
- If proxying a block, allow configuring the target block's settings
- Or reference an existing configured block instance
A/B Testing Integration
The proxy block will work with existing A/B testing infrastructure:
- Decider plugins can choose between different proxy configurations
- One variant might proxy Block A, another might proxy Block B, another might render empty
- Analytics tracking continues to work on the proxy block container
Technical Implementation
Block Plugin Structure
modules/ab_blocks/src/Plugin/Block/AbTestProxyBlock.php
Key Methods to Implement
blockForm(): Configuration form for block selection and render modeblockSubmit(): Save proxy configurationbuild(): Render logic to instantiate and build the target blockgetCacheContexts(),getCacheTags(),getCacheMaxAge(): Proxy cache metadata from target block
Configuration Schema
# In ab_blocks.schema.yml
block.settings.ab_test_proxy_block:
type: mapping
mapping:
target_block_plugin:
type: string
label: 'Target block plugin ID'
target_block_config:
type: sequence
label: 'Target block configuration'
render_mode:
type: string
label: 'Render mode (block|empty)'Dependencies
- Depends on existing
ab_blocksmodule - Uses Drupal's Block Plugin API
- Integrates with Layout Builder (if target blocks support it)
Use Cases
Use Case 1: Block Type A/B Testing
Test a custom "Featured Product" block vs a "Product Carousel" view block:
- Variant A: Proxy renders Featured Product block
- Variant B: Proxy renders Product Carousel block
- Variant C: Proxy renders empty (no product promotion)
Use Case 2: Content Strategy Testing
Test different approaches to newsletter signup:
- Variant A: Proxy renders Newsletter Signup form block
- Variant B: Proxy renders Custom HTML block with social links
- Variant C: Proxy renders empty (no call-to-action)
Use Case 3: Layout Optimization
Test sidebar content effectiveness:
- Variant A: Proxy renders Related Articles block
- Variant B: Proxy renders Advertisement block
- Variant C: Proxy renders empty (cleaner layout)
Acceptance Criteria
- New block plugin
AbTestProxyBlockis created in ab_blocks module - Configuration form allows selecting target block plugin and configuration
- "Render empty" option is available and functional
- Target block is rendered with proper cache contexts, tags, and max-age
- Works with existing A/B testing decider and analytics plugins
- Proper error handling when target block fails to render
- Unit and functional tests are included
- Documentation updated to describe the proxy block functionality
Testing Requirements
Unit Tests
- Test block configuration form submission
- Test render logic for different render modes
- Test cache metadata propagation
Functional Tests
- Test block placement and configuration via Layout Builder
- Test A/B testing integration with different proxy configurations
- Test empty rendering mode
- Test error handling for missing/invalid target blocks
JavaScript Tests (if applicable)
- Verify A/B testing JavaScript works with proxy blocks
- Test analytics tracking on proxy block container
Documentation Needs
- Update README with proxy block usage examples
- Add configuration examples to CLAUDE.md
- Include proxy block in A/B testing workflow documentation
Implementation Notes
- The proxy block should handle access control by respecting the target block's access restrictions
- Cache metadata must be properly bubbled up from the target block to ensure correct caching behavior
- Consider performance implications of instantiating target blocks dynamically
- Ensure compatibility with contrib modules that extend block functionality
Related Issues
- Extends functionality from existing ab_blocks A/B testing system
- May relate to future block management improvements
- Consider integration with Block Content module for reusable block instances
Sub-issues
Metadata
Metadata
Assignees
Labels
π·οΈ type:productionProduction codebase (src/, modules/, core functionality)Production codebase (src/, modules/, core functionality)π area:blocksLayout Builder block A/B testing featuresLayout Builder block A/B testing featuresπ area:coreCore plugin system, interfaces, managers, and base functionalityCore plugin system, interfaces, managers, and base functionalityπ₯ priority:highImportant features, significant bugs affecting many usersImportant features, significant bugs affecting many users