- 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
-
Run
composer require 3brs/sylius-analytics-plugin. -
Register plugin in your
config/bundles.phpThreeBRS\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%'
-
This plugin uses Symfony Messenger to log requests.
-
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
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.
Initialize the development environment:
make initThis command installs dependencies, sets up the database, and prepares frontend assets (or follow related steps in Makefile).
- Develop your plugin logic inside
/src - See
bin/for useful dev tools
Run all tests and quality checks:
make ciRun 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 testsmake fixtures # Load test fixturesStart the development environment:
make run # Start Docker containers
make bash # Access PHP container shellmake static # Run static analysis (PHPStan + ECS + Lint)
make cache # Clear application cache
make var # Recreate var directoryAll commands use the test environment by default. See the Makefile for detailed implementation of each target.
This library is under the MIT license.
Developed by 3BRS
