Skip to content

Commit 4cc1b52

Browse files
borkwebclaude
andcommitted
Add CLAUDE.md for Claude Code guidance
This file provides guidance to Claude Code (claude.ai/code) when working with the StellarWP Telemetry library codebase. It includes common development commands, high-level architecture overview, and testing approach. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 74c7b81 commit 4cc1b52

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

CLAUDE.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
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.
8+
9+
## Common Development Commands
10+
11+
### Testing
12+
```bash
13+
# Run unit tests using slic (StellarWP's testing framework)
14+
slic run wpunit
15+
16+
# Run static analysis
17+
composer test:analysis
18+
```
19+
20+
### Code Quality
21+
```bash
22+
# Check coding standards
23+
phpcs ./src
24+
25+
# Auto-fix coding standard issues
26+
phpcbf ./src
27+
28+
# Check PHP compatibility for all supported versions (7.1-8.3)
29+
composer compatibility
30+
31+
# Check specific PHP version compatibility
32+
composer compatibility:php-8.0
33+
```
34+
35+
### Local Development
36+
```bash
37+
# Start local development environment
38+
lando start
39+
40+
# Install dependencies via Lando
41+
lando composer install
42+
43+
# Local site will be available at: https://telemetry-library.lndo.site/
44+
```
45+
46+
## High-Level Architecture
47+
48+
### Core Components
49+
50+
1. **Dependency Injection Container**: The library requires a DI container compatible with `stellarwp/container-contract`. The container must be configured before initializing the library.
51+
52+
2. **Opt-In System**:
53+
- `Opt_In/` - Manages user consent through modal interfaces
54+
- `Exit_Interview/` - Collects feedback when plugins are deactivated
55+
- Privacy-first approach with explicit user consent required
56+
57+
3. **Data Collection**:
58+
- `Data_Providers/` - Abstract data collection with providers like `Debug_Data` for Site Health integration
59+
- `Events/` - Event tracking system for capturing user actions
60+
- `Telemetry/` - Core functionality for sending telemetry data to the server
61+
62+
4. **Integration Points**:
63+
- `Admin/` - WordPress admin integration and resource management
64+
- `Last_Send/` - Tracks when telemetry was last sent
65+
- Uses subscriber pattern (`Abstract_Subscriber`) for WordPress hooks
66+
67+
### Key Design Patterns
68+
69+
- **Subscriber Pattern**: All WordPress hook integrations use the subscriber pattern through `Abstract_Subscriber`
70+
- **Template System**: UI components use template interfaces for rendering
71+
- **Modular Design**: Clear separation between opt-in, telemetry, events, and exit interview functionality
72+
- **Multi-Plugin Support**: Designed to be shared across multiple plugins using `Config::add_stellar_slug()`
73+
74+
### Integration Requirements
75+
76+
1. Initialize with a compatible DI container
77+
2. Configure server URL and hook prefix
78+
3. Set a unique stellar slug for plugin identification
79+
4. Call `Telemetry::instance()->init(__FILE__)` to start
80+
81+
### Testing Approach
82+
83+
- Uses Codeception with WordPress browser testing
84+
- Tests run via `slic` command in CI/CD
85+
- PHPStan level 5 for static analysis
86+
- PHPCS with WordPress VIP Go and TEC standards

0 commit comments

Comments
 (0)