PHPackages                             tourze/wechat-mini-program-stats-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/wechat-mini-program-stats-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/wechat-mini-program-stats-bundle
=======================================

微信小程序数据统计和分析bundle，提供用户访问、性能指标、留存分析等统计功能

0.0.1(10mo ago)00MITPHPPHP ^8.1CI failing

Since Jun 22Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/wechat-mini-program-stats-bundle)[ Packagist](https://packagist.org/packages/tourze/wechat-mini-program-stats-bundle)[ RSS](/packages/tourze-wechat-mini-program-stats-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (31)Versions (2)Used By (0)

WeChat Mini Program Stats Bundle
================================

[](#wechat-mini-program-stats-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![PHP Version](https://camo.githubusercontent.com/872bbe13994174d0c3c65e116c16340fb42fc1ca6c6a937a806bf3d251f87533/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f7765636861742d6d696e692d70726f6772616d2d73746174732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-mini-program-stats-bundle)[![Latest Version](https://camo.githubusercontent.com/7746a93a99025ea2b365ce89a4ff6ca079a0de83bba4bbda5143c2c886b055cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f7765636861742d6d696e692d70726f6772616d2d73746174732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-mini-program-stats-bundle)[![License](https://camo.githubusercontent.com/990780cf6f318116f163218a67e94f2292b2cc93e695efc52075af33ec72195c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f7765636861742d6d696e692d70726f6772616d2d73746174732d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-mini-program-stats-bundle)[![Build Status](https://camo.githubusercontent.com/07a93c6c3a828e1e929e2a173231acc84705e6f7a486f6d8d0f4103f204a79d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](#)[![Code Coverage](https://camo.githubusercontent.com/e9118f6cfb6d298b03d6071558a977d100df49e8f0c3217957e362bab3e63370/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39352532352d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](#)

This bundle provides comprehensive statistics collection and analysis for WeChat Mini Programs using the WeChat official API.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Requirements](#requirements)
- [Features](#features)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Available Commands](#available-commands)
- [JSON-RPC Procedures](#json-rpc-procedures)
- [Entity Overview](#entity-overview)
- [Usage Examples](#usage-examples)
- [Advanced Usage](#advanced-usage)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [License](#license)

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

[](#installation)

```
composer require tourze/wechat-mini-program-stats-bundle
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher
- WeChat Mini Program API access

Features
--------

[](#features)

- **Data Collection**: Automated collection of WeChat Mini Program statistics data
- **Visit Analysis**: Daily, weekly, and monthly visit trend analysis
- **Performance Monitoring**: Performance data collection and analysis
- **User Analytics**: User portrait and access behavior analysis
- **Retention Analysis**: User retention tracking and analysis
- **Scheduled Tasks**: Automated data collection via cron jobs

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

[](#configuration)

### 1. Enable the Bundle

[](#1-enable-the-bundle)

Add the bundle to your `config/bundles.php`:

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

### 2. Configure Database

[](#2-configure-database)

Run the migrations to create the required tables:

```
php bin/console doctrine:migrations:migrate
```

### 3. WeChat API Configuration

[](#3-wechat-api-configuration)

Ensure you have configured the WeChat Mini Program API credentials in your main application configuration.

Quick Start
-----------

[](#quick-start)

### Set Up Cron Jobs

[](#set-up-cron-jobs)

The bundle includes automated data collection commands that can be scheduled:

```
# Daily statistics collection
php bin/console wechat-mini-program:get-daily-summary
php bin/console wechat-mini-program:get-daily-visit-trend
php bin/console wechat-mini-program:get-daily-retain

# Weekly and monthly trends
php bin/console wechat-mini-program:get-weekly-visit-trend
php bin/console wechat-mini-program:get-monthly-visit-trend

# Performance monitoring
php bin/console wechat-mini-program:performance-data:get
php bin/console wechat-mini-program:operation-performance:sync
```

Available Commands
------------------

[](#available-commands)

### Data Collection Commands

[](#data-collection-commands)

- `wechat-mini-program:get-daily-summary` - Collect daily summary statistics
- `wechat-mini-program:get-daily-visit-trend` - Collect daily visit trend data
- `wechat-mini-program:get-weekly-visit-trend` - Collect weekly visit trend data
- `wechat-mini-program:get-monthly-visit-trend` - Collect monthly visit trend data
- `wechat-mini-program:get-daily-retain` - Collect daily retention data

### User Analytics Commands

[](#user-analytics-commands)

- `wechat-mini-program:user-portrait:get` - Collect user portrait data
- `wechat-mini-program:user-accesses:week-data:get` - Collect weekly user access data
- `wechat-mini-program:user-accesses:month-data:get` - Collect monthly user access data
- `wechat-mini-program:visit-distribution:get` - Collect visit distribution data

### Performance Commands

[](#performance-commands)

- `wechat-mini-program:performance-data:get` - Collect performance data
- `wechat-mini-program:operation-performance:sync` - Sync operation performance data
- `wechat-mini-program:check-performance` - Check performance metrics

### Page Analytics Commands

[](#page-analytics-commands)

- `wechat-mini-program:get-wechat-user-access-page-data` - Collect page access data
- `wechat-mini-program:count-daily-page-visit-data` - Count daily page visits
- `wechat-mini-program:count-daily-new-user-visit-data` - Count daily new user visits
- `wechat-mini-program:count-wechat-hour-visit-data` - Count hourly visit data

JSON-RPC Procedures
-------------------

[](#json-rpc-procedures)

The bundle provides several JSON-RPC procedures for accessing statistics data:

### Visit Trend Procedures

[](#visit-trend-procedures)

- `GetWechatMiniProgramDailyVisitTrendData` - Get daily visit trend data
- `GetWechatMiniProgramDailyVisitTrendDataByDateRange` - Get daily visit trend data by date range
- `GetWechatMiniProgramDailyVisitTrendDataTotalByDateRange` - Get aggregated daily visit trend data
- `GetWechatMiniProgramVisitTotalUser` - Get total visit users
- `GetWechatMiniProgramVisitUvAverage` - Get average unique visitors

### User Analytics Procedures

[](#user-analytics-procedures)

- `GetWechatMiniProgramUserPortraitAge` - Get user age demographics
- `GetWechatMiniProgramUserPortraitGender` - Get user gender demographics
- `GetWechatMiniProgramUserPortraitGenderByDateRange` - Get user gender demographics by date range
- `GetWechatMiniProgramUserPortraitProvince` - Get user province distribution

### Page &amp; Retention Procedures

[](#page--retention-procedures)

- `GetWechatMiniProgramPageVisitTotalDataByDate` - Get page visit data by specific date
- `GetWechatMiniProgramPageVisitTotalDataByDateRange` - Get page visit data by date range
- `GetWechatMiniProgramRetainUserByDate` - Get user retention data by date
- `GetWechatMiniProgramNewUserVisitByDate` - Get new user visits by date

Entity Overview
---------------

[](#entity-overview)

The bundle provides the following entities for data storage:

- **DailyPageVisitData**: Daily page visit statistics
- **MonthlyVisitTrend**: Monthly visit trend data
- **WeeklyVisitTrend**: Weekly visit trend data
- **Performance**: Performance monitoring data
- **PerformanceAttribute**: Performance attribute details
- **OperationPerformance**: Operation performance metrics

Usage Examples
--------------

[](#usage-examples)

### Collecting Daily Statistics

[](#collecting-daily-statistics)

```
use Symfony\Component\Console\Application;
use WechatMiniProgramStatsBundle\Command\DataCube\GetDailySummaryCommand;

// Run daily summary collection
$application = new Application();
$command = $container->get(GetDailySummaryCommand::class);
$application->addCommand($command);
$application->run();
```

### Accessing Statistics Data

[](#accessing-statistics-data)

```
use WechatMiniProgramStatsBundle\Repository\DailyPageVisitDataRepository;

// Get daily page visit data
$repository = $entityManager->getRepository(DailyPageVisitData::class);
$data = $repository->findBy(['date' => new \DateTime('2024-01-01')]);
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Data Processing

[](#custom-data-processing)

You can extend the bundle's functionality by creating custom commands or services that utilize the existing repositories and entities. The bundle is designed to be flexible and extensible.

### Performance Monitoring

[](#performance-monitoring)

The bundle includes comprehensive performance monitoring capabilities that can help you track and optimize your WeChat Mini Program's performance metrics.

Testing
-------

[](#testing)

This bundle includes comprehensive test coverage with both unit and integration tests.

### Running Tests

[](#running-tests)

```
# Run all tests
./vendor/bin/phpunit packages/wechat-mini-program-stats-bundle/tests

# Run tests with coverage
php -d memory_limit=2G ./vendor/bin/phpunit packages/wechat-mini-program-stats-bundle/tests --coverage-html coverage

# Run PHPStan analysis
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/wechat-mini-program-stats-bundle
```

### Test Structure

[](#test-structure)

- **Unit Tests**: Entity and Enum tests that verify basic functionality
- **Integration Tests**: Repository and Service tests that require database connection
- **Command Tests**: Console command tests for data collection functionality

All tests follow the PSR standards and include comprehensive assertions for both happy path and edge cases.

Security
--------

[](#security)

- **API Security**: All WeChat API communications are secured with proper authentication
- **Data Validation**: Input data is validated before processing and storage
- **SQL Injection Prevention**: All database queries use parameterized statements
- **Access Control**: Commands and services respect application security policies

If you discover any security vulnerabilities, please report them via [GitHub Issues](https://github.com/tourze/php-monorepo/issues).

Contributing
------------

[](#contributing)

We welcome contributions! Here's how you can help:

### Reporting Issues

[](#reporting-issues)

- Use [GitHub Issues](https://github.com/tourze/php-monorepo/issues) to report bugs
- Include PHP version, Symfony version, and detailed error messages
- Provide minimal code examples that reproduce the issue

### Submitting Pull Requests

[](#submitting-pull-requests)

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/new-feature`
3. Make your changes with appropriate tests
4. Ensure all tests pass: `./vendor/bin/phpunit packages/wechat-mini-program-stats-bundle/tests`
5. Run PHPStan analysis: `php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/wechat-mini-program-stats-bundle`
6. Submit a pull request with clear description

### Code Standards

[](#code-standards)

- Follow PSR-12 coding standards
- Write comprehensive tests for new features
- Update documentation for any new functionality
- Use meaningful commit messages

Changelog
---------

[](#changelog)

### Version 0.1.x

[](#version-01x)

- Initial release with core statistics collection functionality
- Support for daily, weekly, and monthly visit trend analysis
- User portrait and behavior analytics
- Performance monitoring capabilities
- Comprehensive JSON-RPC API procedures

License
-------

[](#license)

This bundle is released under the MIT license. See the included LICENSE file for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

322d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-mini-program-stats-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-wechat-mini-program-stats-bundle/health.svg)](https://phpackages.com/packages/tourze-wechat-mini-program-stats-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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