|
| 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 a Sylius plugin that integrates Google Ads conversion tracking with Sylius e-commerce stores. The plugin uses the Google Ads API directly (server-side) instead of JavaScript tracking, providing better control over consent, conversion values, and avoiding ad blockers. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +```bash |
| 13 | +# Run all tests |
| 14 | +./vendor/bin/phpunit |
| 15 | + |
| 16 | +# Run specific test |
| 17 | +./vendor/bin/phpunit tests/Resolver/CustomerIdsResolverTest.php |
| 18 | +``` |
| 19 | + |
| 20 | +### Code Quality |
| 21 | +```bash |
| 22 | +# Code style checking |
| 23 | +composer check-style |
| 24 | + |
| 25 | +# Fix code style issues |
| 26 | +composer fix-style |
| 27 | + |
| 28 | +# Static analysis |
| 29 | +composer analyse |
| 30 | +``` |
| 31 | + |
| 32 | +### Database Operations |
| 33 | +```bash |
| 34 | +# Create migration after model changes |
| 35 | +php bin/console doctrine:migrations:diff |
| 36 | + |
| 37 | +# Run migrations |
| 38 | +php bin/console doctrine:migrations:migrate |
| 39 | +``` |
| 40 | + |
| 41 | +### Plugin Console Commands |
| 42 | +```bash |
| 43 | +# Process Google Ads conversions (run regularly, e.g., every 5 minutes) |
| 44 | +php bin/console setono:sylius-google-ads:process-conversions |
| 45 | + |
| 46 | +# Prune old conversions from database (run daily) |
| 47 | +php bin/console setono:sylius-google-ads:prune-conversions |
| 48 | +``` |
| 49 | + |
| 50 | +## Architecture |
| 51 | + |
| 52 | +### Core Components |
| 53 | + |
| 54 | +**Models**: Connection, Conversion, CustomerList, ConnectionMapping, MerchantMapping |
| 55 | +- Connection: Stores Google Ads API credentials and configuration |
| 56 | +- Conversion: Represents tracked conversions with state workflow |
| 57 | +- CustomerList: Manages Google Ads customer lists for remarketing |
| 58 | + |
| 59 | +**Processing Flow**: |
| 60 | +1. **Event Capture**: PurchaseListener captures order events |
| 61 | +2. **Conversion Creation**: ConversionFactory creates conversion records |
| 62 | +3. **Qualification**: QualificationVoters determine if conversion should be processed |
| 63 | +4. **Processing**: ConversionProcessor handles API calls to Google Ads |
| 64 | +5. **State Management**: ConversionWorkflow manages conversion states |
| 65 | + |
| 66 | +**Message System**: Uses Symfony Messenger for async processing |
| 67 | +- ProcessConversion: Handles individual conversion processing |
| 68 | +- ProcessCustomerList/UploadCustomerList: Manages customer list operations |
| 69 | + |
| 70 | +### Key Directories |
| 71 | + |
| 72 | +- `src/Model/`: Core domain models and interfaces |
| 73 | +- `src/ConversionProcessor/`: Conversion processing logic with qualification voters |
| 74 | +- `src/Message/`: Symfony Messenger commands and handlers |
| 75 | +- `src/Client/`: Google Ads API client wrapper and resources |
| 76 | +- `src/EventSubscriber/`: Event-driven processing subscribers |
| 77 | +- `src/Factory/`: Object creation factories |
| 78 | +- `src/Repository/`: Data access layer |
| 79 | +- `src/Resources/config/`: Service definitions and configuration |
| 80 | + |
| 81 | +### Google Ads Integration |
| 82 | + |
| 83 | +The plugin integrates with Google Ads through: |
| 84 | +- **OAuth2 Flow**: Managed via Controller/Action classes for setup |
| 85 | +- **API Client**: Wraps Google Ads PHP library with custom resource classes |
| 86 | +- **Conversion Tracking**: Server-side conversion uploads with user identifiers |
| 87 | +- **Customer Lists**: Audience management for remarketing campaigns |
| 88 | + |
| 89 | +### State Management |
| 90 | + |
| 91 | +Conversions follow a workflow with states: |
| 92 | +- Created → Processing → Delivered/Failed |
| 93 | +- Managed by ConversionWorkflow class |
| 94 | +- Supports retry logic for failed conversions |
| 95 | + |
| 96 | +## Configuration |
| 97 | + |
| 98 | +Plugin configuration is in `src/Resources/config/app/config.yaml` and requires: |
| 99 | +- Google Ads API credentials (client ID, secret, developer token) |
| 100 | +- Customer ID mapping for multi-account setups |
| 101 | +- Conversion action mapping for different event types |
| 102 | + |
| 103 | +## Testing |
| 104 | + |
| 105 | +The plugin includes both unit tests and integration tests. Live testing can be enabled by setting `GOOGLE_ADS_LIVE=1` and providing real API credentials in phpunit.xml. |
| 106 | + |
| 107 | +## Important Notes |
| 108 | + |
| 109 | +- Customer Lists feature is marked as experimental |
| 110 | +- Requires gRPC PHP extension for optimal performance |
| 111 | +- Uses Doctrine ORM for persistence |
| 112 | +- Integrates with Sylius workflow and event systems |
| 113 | +- Supports multi-channel and multi-customer configurations |
0 commit comments