This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the StellarWP Telemetry Library - a PHP library for WordPress plugins that provides opt-in telemetry data collection. The library is designed to be included via Composer (preferably with Strauss for namespace isolation) and provides a complete telemetry solution with user privacy controls.
# Run unit tests using slic (StellarWP's testing framework)
slic run wpunit
# Run static analysis
composer test:analysis# Check coding standards
phpcs ./src
# Auto-fix coding standard issues
phpcbf ./src
# Check PHP compatibility for all supported versions (7.1-8.3)
composer compatibility
# Check specific PHP version compatibility
composer compatibility:php-8.0# Start local development environment
lando start
# Install dependencies via Lando
lando composer install
# Local site will be available at: https://telemetry-library.lndo.site/-
Dependency Injection Container: The library requires a DI container compatible with
stellarwp/container-contract. The container must be configured before initializing the library. -
Opt-In System:
Opt_In/- Manages user consent through modal interfacesExit_Interview/- Collects feedback when plugins are deactivated- Privacy-first approach with explicit user consent required
-
Data Collection:
Data_Providers/- Abstract data collection with providers likeDebug_Datafor Site Health integrationEvents/- Event tracking system for capturing user actionsTelemetry/- Core functionality for sending telemetry data to the server
-
Integration Points:
Admin/- WordPress admin integration and resource managementLast_Send/- Tracks when telemetry was last sent- Uses subscriber pattern (
Abstract_Subscriber) for WordPress hooks
- Subscriber Pattern: All WordPress hook integrations use the subscriber pattern through
Abstract_Subscriber - Template System: UI components use template interfaces for rendering
- Modular Design: Clear separation between opt-in, telemetry, events, and exit interview functionality
- Multi-Plugin Support: Designed to be shared across multiple plugins using
Config::add_stellar_slug()
- Initialize with a compatible DI container
- Configure server URL and hook prefix
- Set a unique stellar slug for plugin identification
- Call
Telemetry::instance()->init(__FILE__)to start
- Uses Codeception with WordPress browser testing
- Tests run via
sliccommand in CI/CD - PHPStan level 5 for static analysis
- PHPCS with WordPress VIP Go and TEC standards