PHPackages                             nyco/wp-stat-collector - 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. [Database &amp; ORM](/categories/database)
4. /
5. nyco/wp-stat-collector

ActiveWordpress-muplugin[Database &amp; ORM](/categories/database)

nyco/wp-stat-collector
======================

A developer plugin for WordPress that adds hooks to enable the logging of data from the site to a specified MySQL database.

0.0.9(4y ago)21151[2 PRs](https://github.com/CityOfNewYork/nyco-wp-stat-collector/pulls)GPL-3.0+PHP

Since Feb 10Pushed 3y ago15 watchersCompare

[ Source](https://github.com/CityOfNewYork/nyco-wp-stat-collector)[ Packagist](https://packagist.org/packages/nyco/wp-stat-collector)[ Docs](https://github.com/cityofnewyork/nyco-wp-stat-collector)[ RSS](/packages/nyco-wp-stat-collector/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (12)Used By (0)

NYCO Stat Collector for WordPress
=================================

[](#nyco-stat-collector-for-wordpress)

A developer plugin for WordPress that adds [hooks](https://developer.wordpress.org/plugins/hooks/) to enable the logging of data from the site to a specified MySQL database.

Installation using [Composer](https://getcomposer.org/)
-------------------------------------------------------

[](#installation-using-composer)

**$1** This package uses [Composer Installers](https://github.com/composer/installers) to install the package in the **Must Use** plugins directory (*/wp-content/mu-plugins*):

```
composer require nyco/wp-stat-collector

```

*Not using Composer?* Download an archive of the code and drop it into the mu-plugins directory.

**$2** [Create a proxy PHP loader file](https://wordpress.org/support/article/must-use-plugins/#caveats) inside the mu-plugins directory, or [use the one included with the plugin](https://github.com/CityOfNewYork/nyco-wp-stat-collector/blob/master/autoloader-sample.php):

```
mv wp-content/mu-plugins/wp-stat-collector/autoloader-sample.php wp-content/mu-plugins/wp-stat-collector.php

```

Initialization
--------------

[](#initialization)

The [sample autoloader](https://github.com/CityOfNewYork/nyco-wp-stat-collector/blob/master/autoloader-sample.php) contains the basic code required to initialize the plugin. It will...

- Add the [`statc_register`](#statc_register) with a sample to get started with creating a trigger to write information to your database.
- Add the [`statc_bootstrap`](#statc_bootstrap) with a sample query to create tables in your database for the data to be stored in.
- Require all files containing classes.
- Initialize the [`StatCollector\StatCollector`](https://github.com/CityOfNewYork/nyco-wp-stat-collector/blob/master/Class.php).
- Create an admin settings page under *Settings &gt; Stat Collector* for [configuration](#configuration).

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

[](#configuration)

- Host (including port)
- Name
- Username
- Password
- Send Notifications - Wether or not to email the administrator if there is a connection error.

### Notices

[](#notices)

- Tables Created - A notice that database tables have been created using the [`statc_bootstrap`](#statc_bootstrap) hook.
- Certificate Authority - A notice that a certificate authority has been found.
- Connection - A notice that a connection can be made using the credetials above.

SSL
---

[](#ssl)

Stat Collector uses the [Amazon Web Services RDS certificate bundle](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html) for making MySQL connections over SSL.

Actions
-------

[](#actions)

### statc\_register

[](#statc_register)

Hook for internal actions that collect information to write to the DB.

**...args**

- `Class StatCollector` - An instance of [StatCollector](https://github.com/CityOfNewYork/nyco-wp-stat-collector/blob/master/Class.php).

#### Example

[](#example)

```
add_action('statc_register', function($statc) {
  add_action('my_action', function($data) use ($statc) {
    if (gettype($data) === 'string') {
      $statc->collect('my_table', [
        'my_data' => $data,
      ]);
    }
  }, $statc->settings->priority, 2);

  return true;
});

```

### statc\_init

[](#statc_init)

Hook for plugin post-instantiation.

**...args**

- `Class StatCollector` - An instance of [StatCollector](https://github.com/CityOfNewYork/nyco-wp-stat-collector/blob/master/Class.php).

### statc\_bootstrap

[](#statc_bootstrap)

Hook for bootstrapping the database.

**...args**

- `Class wpdb` - An instance of [wpdb](https://developer.wordpress.org/reference/classes/wpdb/) with a connection to your database.

#### Example

[](#example-1)

```
add_action('statc_bootstrap', function($db) {
  $db->query(
    'CREATE TABLE IF NOT EXISTS my_table (
      id INT(11) NOT NULL AUTO_INCREMENT,
      my_data TEXT DEFAULT NULL,
      PRIMARY KEY(id)
    ) ENGINE=InnoDB'
  );

  return true;
});

```

---

[![The Mayor's Office for Economic Opportunity](NYCMOEO_SecondaryBlue256px.png)](NYCMOEO_SecondaryBlue256px.png)

[The Mayor's Office for Economic Opportunity](http://nyc.gov/opportunity) (NYC Opportunity) is committed to sharing open source software that we use in our products. Feel free to ask questions and share feedback. **Interested in contributing?** See our open positions on [buildwithnyc.github.io](http://buildwithnyc.github.io/). Follow our team on [Github](https://github.com/orgs/CityOfNewYork/teams/nycopportunity) (if you are part of the [@cityofnewyork](https://github.com/CityOfNewYork/) organization) or [browse our work on Github](https://github.com/search?q=nycopportunity).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Every ~93 days

Recently: every ~187 days

Total

9

Last Release

1531d ago

### Community

Maintainers

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

---

Top Contributors

[![devowhippit](https://avatars.githubusercontent.com/u/3826974?v=4)](https://github.com/devowhippit "devowhippit (14 commits)")

---

Tags

databaseloggingmysqlnycopportunitypluginsslwordpresswpdbwordpressdatadatabasemysqlintegrationsnycopportunity

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nyco-wp-stat-collector/health.svg)

```
[![Health](https://phpackages.com/badges/nyco-wp-stat-collector/health.svg)](https://phpackages.com/packages/nyco-wp-stat-collector)
```

###  Alternatives

[olliejones/index-wp-mysql-for-speed

Speed up your WordPress site by adding high-performance keys (database indexes) to your MySQL database tables.

1481.8k](/packages/olliejones-index-wp-mysql-for-speed)[bradmkjr/monolog-wordpress

A handler for Monolog that sends messages to MySQL via WordPress Functions

2817.1k](/packages/bradmkjr-monolog-wordpress)[codesvault/howdy-qb

Mysql Query Builder for WordPress

371.2k1](/packages/codesvault-howdy-qb)[devgeniem/better-wp-db-error

Better WordPress database error handling.

1161.3k](/packages/devgeniem-better-wp-db-error)[pixelstudio/wp-sync-db

WordPress plugin to sync database between different installs

472.5k1](/packages/pixelstudio-wp-sync-db)[smrtr/mysql-version-control

A crude version control system for mysql written in php

221.4k](/packages/smrtr-mysql-version-control)

PHPackages © 2026

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