-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Background
With the recent change to make Analytics Tracker plugin selection a multi-value option and non-required, the NullTracker plugin is no longer necessary. Users can now configure A/B tests successfully without selecting any Analytics Tracker, eliminating the need for the null fallback tracker.
Problem Statement
The NullTracker was originally designed as a fallback when analytics tracking was required but not configured. Now that analytics tracking is optional, this plugin serves no purpose and adds unnecessary complexity to the codebase.
Solution Overview
Remove the NullTracker plugin entirely, including its PHP class, JavaScript implementation, library definitions, and update all references throughout the codebase.
Files Affected
Files to Remove
src/Plugin/AbAnalytics/NullTracker.php- Main plugin classjs/NullTracker.js- JavaScript tracker implementationjs/ab-analytics-tracker-null.js- Drupal behavior initialization
Files to Update
ab_tests.libraries.yml- Removeab_analytics_tracker.nulllibrary definitionsrc/AbAnalyticsPluginBase.php- Remove fallback toab_analytics_tracker.null(line 60).eslintrc.json- RemoveNullTrackerfrom globals (line 44)tests/src/FunctionalJavascript/PluginSelectionTest.php- Update tests that reference null tracker
Task Breakdown
Phase 1: Core Removal (Parallel Execution Possible)
These tasks can be executed independently by different developers/agents:
Task 1.1: Remove PHP Plugin Class
- Files:
src/Plugin/AbAnalytics/NullTracker.php - Action: Delete file entirely
- Dependencies: None
- Estimated Effort: 5 minutes
Task 1.2: Remove JavaScript Implementation Files
- Files:
js/NullTracker.jsjs/ab-analytics-tracker-null.js
- Action: Delete both files entirely
- Dependencies: None
- Estimated Effort: 5 minutes
Task 1.3: Update Library Definitions
- Files:
ab_tests.libraries.yml - Action: Remove the
ab_analytics_tracker.nulllibrary definition (lines 24-30) - Dependencies: None
- Estimated Effort: 5 minutes
Phase 2: Reference Updates (Sequential - depends on Phase 1)
Task 2.1: Update Analytics Plugin Base Class
- Files:
src/AbAnalyticsPluginBase.php - Action: Remove fallback to
ab_analytics_tracker.nullfromtoRenderable()method (line 60) - Implementation:
// Change from: $analytics_library = $this->getPluginDefinition()['analytics_library'] ?? 'ab_analytics_tracker.null'; // To: $analytics_library = $this->getPluginDefinition()['analytics_library'];
- Dependencies: Task 1.3 (library removal)
- Estimated Effort: 10 minutes
Task 2.2: Update ESLint Configuration
- Files:
.eslintrc.json - Action: Remove
NullTrackerfrom globals array (line 44) - Dependencies: Task 1.2 (JS files removal)
- Estimated Effort: 5 minutes
Phase 3: Testing and Documentation Updates
Task 3.1: Update Functional JavaScript Tests
- Files:
tests/src/FunctionalJavascript/PluginSelectionTest.php - Action: Update test methods that reference the null tracker:
- Remove null tracker selection test (lines 121-126)
- Remove assertion about null tracker configuration form
- Update test logic to reflect optional analytics selection
- Dependencies: All previous phases
- Estimated Effort: 15 minutes
Task 3.2: Verify No Other References Exist
- Action: Run comprehensive grep search for any remaining references to:
NullTrackernull_trackerab_analytics_tracker.null
- Dependencies: All previous phases
- Estimated Effort: 10 minutes
Quality Assurance Requirements
Code Quality Checks (Run after each phase)
# PHP Code Standards
vendor/bin/phpcs --standard=Drupal,DrupalPractice web/modules/contrib/ab_tests/
# JavaScript Linting
cd web/modules/contrib/ab_tests && npm run lint
# Static Analysis
vendor/bin/phpstan analyse web/modules/contrib/ab_tests/src/Functional Testing (Run after Phase 3)
# Run all A/B tests module tests
vendor/bin/phpunit web/modules/contrib/ab_tests/tests/
# Specifically run plugin selection tests
vendor/bin/phpunit web/modules/contrib/ab_tests/tests/src/FunctionalJavascript/PluginSelectionTest.phpAcceptance Criteria
- All NullTracker-related files are removed from the codebase
- No references to NullTracker remain in any configuration files
- Analytics plugin base class no longer falls back to null tracker
- All existing tests pass without modification (except those explicitly testing null tracker)
- New A/B test configurations can be created successfully without selecting any analytics tracker
- Code quality checks pass (phpcs, eslint, phpstan)
- No breaking changes for existing A/B test configurations
Parallel Execution Notes
- Phase 1 tasks can be executed simultaneously by different team members
- Phase 2 tasks should be executed after Phase 1 completion to avoid conflicts
- Phase 3 requires completion of all previous phases
Risk Assessment
Low Risk: This change removes unused functionality rather than modifying existing behavior. The multi-value analytics selection already handles the case where no trackers are selected.
Mitigation: Comprehensive testing ensures no regression in core A/B testing functionality.
Labels: enhancement, cleanup, good first issue
Priority: Low
Estimated Total Effort: 1-2 hours