PHPackages                             bahdan/symfony-privacy-analytics-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. bahdan/symfony-privacy-analytics-bundle

ActiveSymfony-bundle

bahdan/symfony-privacy-analytics-bundle
=======================================

Zero-cookie, GDPR-compliant server-side privacy analytics bundle for Symfony

v1.1.1(today)033↑2627.3%MITPHPPHP &gt;=8.3CI passing

Since Aug 24Pushed todayCompare

[ Source](https://github.com/bahdanhal/symfony-privacy-analytics-bundle)[ Packagist](https://packagist.org/packages/bahdan/symfony-privacy-analytics-bundle)[ RSS](/packages/bahdan-symfony-privacy-analytics-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (6)Used By (0)

Symfony Privacy Analytics Bundle
================================

[](#symfony-privacy-analytics-bundle)

A lightweight, zero-cookie, GDPR-compliant server-side web analytics bundle for Symfony applications.

[Packagist](https://packagist.org/packages/bahdan/symfony-privacy-analytics-bundle) · [GitHub](https://github.com/bahdanhal/symfony-privacy-analytics-bundle)

Key Features
------------

[](#key-features)

- **Zero Cookies / No Consent Banner Needed**: Anonymously hashes `IP + User-Agent + secret` with HMAC-SHA256.
- **Bot &amp; Crawler Filtering**: Ignores automated crawlers, spiders, and testing clients automatically.
- **Privacy Header Compliance**: Honors `DNT` (Do Not Track) and `Sec-GPC` (Global Privacy Control) request headers.
- **Referrer Categorization**: Automatically groups incoming traffic into `search`, `social`, `referral`, `internal`, and `direct`.
- **Dual Storage**: Supports Doctrine ORM (PostgreSQL/SQLite/MySQL) and monthly partitioned JSONL storage with streaming retention pruning.
- **SQL Aggregation**: Doctrine summaries aggregate counts, unique visitors, sources, referrers, paths, and daily metrics in the database rather than hydrating raw page views.
- **Cached Summaries**: Dashboard aggregates use the application's PSR-6-compatible Symfony cache for a configurable short TTL.
- **Optional Async Ingestion**: Symfony Messenger can move writes off the request worker for traffic spikes.
- **Extensible Bot Filtering**: Add project-specific user-agent substrings without forking the bundle.

Installation
------------

[](#installation)

```
composer require bahdan/symfony-privacy-analytics-bundle
```

Doctrine is optional. Install it only when selecting the Doctrine storage backend:

```
composer require doctrine/orm doctrine/dbal
```

The JSONL backend does not register or resolve Doctrine services. Existing `page-views.jsonl` files remain readable while new events are written to monthly `page-views-YYYY-MM.jsonl` partitions.

Doctrine entity mappings are registered automatically. Your application still owns schema migrations; generate and review a migration after enabling Doctrine storage.

Configuration
-------------

[](#configuration)

Register the bundle in `config/bundles.php`:

```
return [
    // ...
    Bahdan\PrivacyAnalyticsBundle\PrivacyAnalyticsBundle::class => ['all' => true],
];
```

Configure the storage and privacy secret:

```
# config/packages/privacy_analytics.yaml
privacy_analytics:
  secret: '%kernel.secret%'
  storage: doctrine
  retention_days: 90
  summary_cache_ttl: 60
  custom_bot_patterns:
    - your-internal-monitor
```

High-traffic ingestion with Messenger
-------------------------------------

[](#high-traffic-ingestion-with-messenger)

Install Messenger, enable async ingestion, and route the bundle message to your asynchronous transport:

```
composer require symfony/messenger
```

```
# config/packages/privacy_analytics.yaml
privacy_analytics:
  async: true

# config/packages/messenger.yaml
framework:
  messenger:
    transports:
      analytics: '%env(MESSENGER_TRANSPORT_DSN)%'
    routing:
      Bahdan\PrivacyAnalyticsBundle\Message\RecordPageView: analytics
```

Run a normal Messenger worker for the `analytics` transport. With Doctrine storage, dashboard summaries remain database-side aggregate queries. JSONL summaries stream only partitions that can overlap the requested period; Doctrine is recommended for sustained high traffic.

Dashboard data
--------------

[](#dashboard-data)

Inject `Bahdan\PrivacyAnalyticsBundle\Application\TrafficAnalytics` into a controller and return `summary()` as JSON or render it in Twig. The stable result contains seven-day and thirty-day totals, sources, referring domains, top paths, and a 30-day daily series, so applications can use Chart.js or their existing design system without the bundle imposing frontend dependencies.

```
#[Route('/admin/analytics', methods: ['GET'])]
public function analytics(TrafficAnalytics $analytics): JsonResponse
{
    return $this->json($analytics->summary(new \DateTimeImmutable('now', new \DateTimeZone('UTC'))));
}
```

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3841889?v=4)[bhal](/maintainers/bhal)[@Bhal](https://github.com/Bhal)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bahdan-symfony-privacy-analytics-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bahdan-symfony-privacy-analytics-bundle/health.svg)](https://phpackages.com/packages/bahdan-symfony-privacy-analytics-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M433](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.5k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k190.0M2.6k](/packages/symfony-security-bundle)[shopware/storefront

Storefront for Shopware

674.7M288](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M684](/packages/shopware-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
