Skip to content

Remove NullTracker analytics plugin as it's no longer required #37

@e0ipso

Description

@e0ipso

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 class
  • js/NullTracker.js - JavaScript tracker implementation
  • js/ab-analytics-tracker-null.js - Drupal behavior initialization

Files to Update

  • ab_tests.libraries.yml - Remove ab_analytics_tracker.null library definition
  • src/AbAnalyticsPluginBase.php - Remove fallback to ab_analytics_tracker.null (line 60)
  • .eslintrc.json - Remove NullTracker from 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.js
    • js/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.null library 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.null from toRenderable() 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 NullTracker from 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:
    • NullTracker
    • null_tracker
    • ab_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.php

Acceptance 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🏷️ type:productionProduction codebase (src/, modules/, core functionality)📂 area:analyticsAnalytics tracking, decision recording, and external integrations🔥 priority:lowNice-to-have features, minor bugs, cosmetic issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions