3brs / sylius-analytics-plugin
Analytics tracking plugin for Sylius front store and product views.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Type:sylius-plugin
pkg:composer/3brs/sylius-analytics-plugin
Requires
- php: ^8.2
- sylius/sylius: 2.0.*
Requires (Dev)
- behat/behat: ^v3.24.1
- dmore/behat-chrome-extension: ^1.4.0
- dmore/chrome-mink-driver: ^2.9.3
- friends-of-behat/mink: ^v1.11.0
- friends-of-behat/mink-browserkit-driver: ^v1.6.2
- friends-of-behat/mink-debug-extension: ^v2.1.0
- friends-of-behat/mink-extension: ^v2.7.5
- friends-of-behat/page-object-extension: ^v0.3.2
- friends-of-behat/suite-settings-extension: ^v1.1.0
- friends-of-behat/symfony-extension: v2.6.0
- friends-of-behat/variadic-extension: ^v1.6.0
- php-http/message-factory: ^1.1.0
- phpstan/phpstan: ^2.1.10
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-strict-rules: ^2.0.4
- phpstan/phpstan-symfony: ^2.0.3
- phpstan/phpstan-webmozart-assert: ^2.0.0
- phpunit/phpunit: ^11.5 || ^12.0.10
- polishsymfonycommunity/symfony-mocker-container: ^v1.0.8
- rector/rector: ^2.0.10
- sylius-labs/coding-standard: ^v4.4.0
- sylius/sylius-rector: ^v3.0.0
- symfony/asset: ^v6.4|^v7.1
- symfony/browser-kit: ^v6.4|^v7.1
- symfony/cache: ^v6.4|^v7.1
- symfony/clock: ^v6.4|^v7.1
- symfony/config: ^v6.4|^v7.1
- symfony/console: ^v6.4|^v7.1
- symfony/css-selector: ^v6.4|^v7.1
- symfony/debug-bundle: ^v6.4|^v7.1
- symfony/dependency-injection: ^v6.4|^v7.1
- symfony/doctrine-bridge: ^v6.4|^v7.1
- symfony/doctrine-messenger: ^v6.4|^v7.1
- symfony/dom-crawler: ^v6.4|^v7.1
- symfony/dotenv: ^v6.4|^v7.1
- symfony/error-handler: ^v6.4|^v7.1
- symfony/event-dispatcher: ^v6.4|^v7.1
- symfony/expression-language: ^v6.4|^v7.1
- symfony/filesystem: ^v6.4|^v7.1
- symfony/finder: ^v6.4|^v7.1
- symfony/form: ^v6.4|^v7.1
- symfony/framework-bundle: ^v6.4|^v7.1
- symfony/http-client: ^v6.4|^v7.1
- symfony/http-foundation: ^v6.4|^v7.1
- symfony/http-kernel: ^v6.4|^v7.1
- symfony/intl: ^v6.4|^v7.1
- symfony/mailer: ^v6.4|^v7.1
- symfony/messenger: ^v6.4|^v7.1
- symfony/mime: ^v6.4|^v7.1
- symfony/monolog-bridge: ^v6.4|^v7.1
- symfony/options-resolver: ^v6.4|^v7.1
- symfony/password-hasher: ^v6.4|^v7.1
- symfony/process: ^v6.4|^v7.1
- symfony/property-access: ^v6.4|^v7.1
- symfony/property-info: ^v6.4|^v7.1
- symfony/routing: ^v6.4|^v7.1
- symfony/security-bundle: ^v6.4|^v7.1
- symfony/security-core: ^v6.4|^v7.1
- symfony/security-csrf: ^v6.4|^v7.1
- symfony/security-http: ^v6.4|^v7.1
- symfony/serializer: ^v6.4|^v7.1
- symfony/stopwatch: ^v6.4|^v7.1
- symfony/string: ^v6.4|^v7.1
- symfony/translation: ^v6.4|^v7.1
- symfony/uid: ^v6.4|^v7.1
- symfony/var-dumper: ^v6.4|^v7.1
- symfony/var-exporter: ^v6.4|^v7.1
- symfony/web-link: ^v6.4|^v7.1
- symfony/web-profiler-bundle: ^v6.4|^v7.1
- symfony/workflow: ^v6.4|^v7.1
- symfony/yaml: ^v6.4|^v7.1
- symplify/easy-coding-standard: ^12.0
Conflicts
- api-platform/core: <2.7.13
- api-platform/symfony: <v4.1.0
- babdev/pagerfanta-bundle: <3.6.1
- doctrine/collections: <1.7.0
- doctrine/data-fixtures: <1.5.1
- doctrine/dbal: <2.13.3
- doctrine/doctrine-bundle: <2.8.0
- doctrine/orm: <2.20.0
- friendsofsymfony/rest-bundle: <3.1.0
- jms/serializer-bundle: <4.2.0
- knplabs/knp-menu: <3.3.0
- lexik/jwt-authentication-bundle: <2.12
- masterminds/html5: <2.7.5
- payum/core: <1.7.3
- polishsymfonycommunity/symfony-mocker-container: <1.0.6
- sylius/resource-bundle: <1.13.0
- sylius/sylius: <2.0.8
- symfony/framework-bundle: >=5.4.0 <=5.4.20|>=6.0.0 <=6.0.16|>=6.1.0 <=6.1.8|>=6.2.0 <=6.2.2|6.2.8
- symplify/easy-coding-standard: <10.2.0
- twig/twig: <2.14.7
- webmozart/assert: <1.11.0
- willdurand/negotiation: <3.0
This package is auto-updated.
Last update: 2025-10-10 08:47:43 UTC
README
Sylius Analytics Plugin
Features
- Asynchronously logs visits to all frontend pages (excluding admin)
- Tracks visitor data: channel, full URL, route name, customer, session ID, IP address, user agent, and timestamp
- Displays:
- Most requested pages in the last X days (configurable)
- Request counts on product detail pages
- Full log of requests with filtering capabilities inside the admin panel
- Built on top of Symfony Messenger for asynchronous processing
Installation
-
Run
composer require 3brs/sylius-analytics-plugin
. -
Register plugin in your
config/bundles.php
ThreeBRS\SyliusAnalyticsPlugin\ThreeBRSSyliusAnalyticsPlugin::class => ['all' => true],
-
Import configuration to
config/packages/threebrs_sylius_analytics_plugin.yaml
:imports: - { resource: "@ThreeBRSSyliusAnalyticsPlugin/config/config.yaml" }
-
Import routing to
config/routes.yaml
:threebrs_statistics_plugin_routing_file: resource: "@ThreeBRSSyliusAnalyticsPlugin/config/routes.yaml" prefix: '%sylius_admin.path_name%'
-
Messenger Transport Configuration
This plugin uses Symfony Messenger to log requests.
Default Behavior (Synchronous)
-
By default, the plugin uses synchronous processing via the
sync://
DSN. This means that log messages are processed immediately, without requiring any queue or worker. This is ideal for development and testing environments. -
To enable this mode, set the following in your
.env
:
THREEBRS_MESSENGER_TRANSPORT_LOG_VISIT_DSN=sync://
- For better performance in production or staging environments, you can configure the plugin to log requests asynchronously using a queue (e.g., Doctrine transport)
THREEBRS_MESSENGER_TRANSPORT_LOG_VISIT_DSN=doctrine://default
- After setting this, you must run the Messenger worker to process the queued log messages:
bin/console messenger:consume log_visit -vv
- Only use this mode if your project supports background workers and a transport like Doctrine, Redis, etc.
-
-
Configure how many past days are considered when calculating the "Most Visited Pages" in the admin dashboard by setting the following parameter:
parameters: threebrs_analytics_plugin.request_log_days: 7 # Change as needed
-
Generate and run Doctrine migrations:
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
-
Optional: Enable UTF-8 support in routing for better slug handling (diacritics, etc.):
# config/packages/routing.yaml framework: router: utf8: true
Usage
The plugin will automatically log requests on:
- Homepage
- Product detail pages
- Category pages
- Cart pages
- Other shop pages
You can view the statistics inside the admin panel under the Analytics section.
Log processing is handled via Symfony Messenger, either synchronously (by default) or asynchronously if a queue is configured.
Development
Setup
Initialize the development environment:
make init
This command installs dependencies, sets up the database, and prepares frontend assets (or follow related steps in Makefile).
Usage
- Develop your plugin logic inside
/src
- See
bin/
for useful dev tools
Testing
Run all tests and quality checks:
make ci
Run individual checks:
make phpstan # Static analysis make ecs # Code style check make fix # Fix code style issues make lint # Symfony and Doctrine linting make behat # Behavioral tests
Database Management
make fixtures # Load test fixtures
Development Server
Start the development environment:
make run # Start Docker containers make bash # Access PHP container shell
Other Useful Commands
make static # Run static analysis (PHPStan + ECS + Lint) make cache # Clear application cache make var # Recreate var directory
All commands use the test environment by default. See the Makefile for detailed implementation of each target.
License
This library is under the MIT license.
Credits
Developed by 3BRS