承接 mohammedshuaau/enhanced-analytics 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mohammedshuaau/enhanced-analytics

Composer 安装命令:

composer require mohammedshuaau/enhanced-analytics

包简介

A powerful, efficient analytics solution for Statamic with real-time tracking, caching, and comprehensive dashboard visualization.

README 文档

README

A powerful analytics addon for Statamic that provides detailed insights into your website's traffic and user behavior.

Features

📊 Real-Time Analytics

  • Page view tracking with automatic data processing
  • Unique visitor identification and session management
  • Configurable processing frequency (default: every 15 minutes)
  • Automatic data aggregation for efficient querying

👥 Visitor Insights

  • Total visits and unique visitors
  • New vs returning visitors
  • Session duration and pages per session
  • Bounce rate and exit rate analysis
  • User flow tracking (entry pages, engaged pages, exit pages)

🌍 Geographic Data

  • IP-based geolocation using ip-api.com
  • Country and city-level tracking
  • Built-in rate limiting (45 requests/minute)
  • Automatic caching of geolocation data
  • Configurable cache duration

💻 Technical Insights

  • Device type tracking (desktop, mobile, tablet)
  • Browser and platform detection
  • Referrer URL tracking
  • User agent analysis

⚡ Performance Features

  • Efficient data caching system
  • Support for file caching
  • Automatic cleanup of old data
  • Chunk-based processing to prevent memory issues
  • Lock system to prevent concurrent processing

🎨 Dashboard Features

  • Clean, modern interface with dark mode support
  • Polled data refresh
  • Customizable date ranges (24h, 7d, 30d, custom)
  • Comparative metrics with previous periods
  • Export functionality for detailed analysis
  • Interactive charts and visualizations

🔒 Privacy & Security

  • Built-in consent management system (disabled by default)
  • No external service dependencies
  • Complete data ownership
  • Configurable IP address exclusions
  • Bot filtering
  • Authenticated user tracking options
  • Granular consent controls for visitors
  • Optional geolocation tracking toggle

Installation

  1. Install the package via Composer:
composer require mohammedshuaau/enhanced-analytics
  1. Publish the configuration:
php artisan vendor:publish --tag=enhanced-analytics-config
  1. Run the migrations:
php artisan migrate

Configuration

The addon can be configured via the config/enhanced-analytics.php file:

return [
    'cache' => [
        'driver' => 'file', // Options: 'file', 'redis'
        'file' => [
            'path' => storage_path('app/enhanced-analytics'),
            'permissions' => [
                'file' => 0644,
                'directory' => 0755
            ]
        ]
    ],

    'geolocation' => [
        'cache_duration' => 1440, // 24 hours
        'rate_limit' => 45 // requests per minute
    ],

    'processing' => [
        'frequency' => 15, // minutes
        'chunk_size' => 1000,
        'lock_timeout' => 60
    ],

    'tracking' => [
        'exclude_paths' => [
            'cp/*',
            'api/*'
        ],
        'exclude_ips' => [],
        'exclude_bots' => true,
        'track_authenticated_users' => true,
        'consent' => [
            'enabled' => false, // Set to true to enable consent banner
            'banner' => [
                'title' => 'Privacy Notice',
                'description' => 'We use analytics to understand how you use our website and improve your experience.',
                'accept_button' => 'Accept',
                'decline_button' => 'Decline',
                'settings_button' => 'Customize',
                'position' => 'bottom', // options: bottom, top, center
            ],
        ],
    ]
];

Consent Banner Configuration

The addon includes a privacy-focused consent banner that's disabled by default. Here's how to configure it:

  1. Enable the consent banner by setting tracking.consent.enabled to true in your config file.

  2. Add the consent banner and CSRF token (header meta tag) to your layout:

{{ enhanced_analytics:consent_banner }}
<meta name="csrf-token" content="{{ csrf_token }}">
  1. Customize the banner appearance and text:
'consent' => [
    'enabled' => true,
    'banner' => [
        'title' => 'Your Custom Title',
        'description' => 'Your custom description about tracking.',
        'accept_button' => 'Allow Tracking',
        'decline_button' => 'No Thanks',
        'settings_button' => 'Preferences',
        'position' => 'bottom', // Available options: bottom, top, center
    ],
],

Customizing the Consent Banner Template

You can fully customize the consent banner's appearance by publishing and editing its template:

  1. Publish the consent banner template:
php artisan vendor:publish --tag="enhanced-analytics-views"
  1. Edit the template at:
resources/views/vendor/enhanced-analytics/components/consent-banner.antlers.html

The template uses Alpine.js for interactivity and Tailwind CSS for styling. You can modify the HTML structure, styling, and behavior while maintaining the core functionality through the following data attributes:

  • x-data="consentBanner": The main component
  • x-model="settings.geolocation": Geolocation toggle binding
  • x-on:click="accept": Accept button action
  • x-on:click="decline": Decline button action
  • x-on:click="toggleSettings": Settings toggle action

The consent banner includes:

  • Essential analytics toggle (always enabled)
  • Optional geolocation tracking toggle
  • Persistent settings through session storage
  • Responsive design with dark mode support

When enabled, tracking will only begin after the visitor provides consent. Their preferences are saved and respected across sessions.

Usage

Once installed, the addon will automatically start tracking page visits. Access the analytics dashboard via the Control Panel under Tools > Analytics.

Automatic Processing

The addon automatically processes analytics data via Scheduler. You might want to run the scheduler and the addon will handle the rest. You can always set the minutes the command should execute.

Manual Processing

You can manually process analytics data using the command:

php artisan analytics:process

Data Export

Export detailed analytics data directly from the dashboard in CSV format for further analysis.

Performance Considerations

  • The addon uses efficient caching and processes data in chunks to maintain performance
  • Geolocation data is cached to respect API rate limits
  • Database queries are optimized using aggregates for faster dashboard loading
  • Automatic cleanup of old cache data

Upcoming Features

  • Support for Redis Driver

Contributing

Contributions are always welcome!

Development Guidelines

  • Follow PSR-12 coding standards
  • Add appropriate comments and documentation
  • Update the README.md with details of significant changes
  • Add/update tests as needed
  • Ensure all tests pass before submitting PR

Testing

Run the test suite:

vendor/bin/phpunit

Support

If you discover any security-related issues, please use the issue tracker to report them.

License

The MIT License (MIT). Please see License File for more information.

mohammedshuaau/enhanced-analytics 适用场景与选型建议

mohammedshuaau/enhanced-analytics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.94k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 01 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「performance」 「cache」 「real-time」 「analytics」 「chart」 「dashboard」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mohammedshuaau/enhanced-analytics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mohammedshuaau/enhanced-analytics 我们能提供哪些服务?
定制开发 / 二次开发

基于 mohammedshuaau/enhanced-analytics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-01-12