PHPackages                             dosomething/mb-stat-tracker - 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. dosomething/mb-stat-tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dosomething/mb-stat-tracker
===========================

This library offers an interface for DoSomething.org message broker producers and consumers to report stats.

v0.0.3(11y ago)0922MITPHPPHP &gt;=5.3.0

Since Apr 18Pushed 11y ago11 watchersCompare

[ Source](https://github.com/DoSomething/mb-stat-tracker)[ Packagist](https://packagist.org/packages/dosomething/mb-stat-tracker)[ Docs](https://github.com/DoSomething/mb-stat-tracker)[ RSS](/packages/dosomething-mb-stat-tracker/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

This library offers an interface to interact with the various stat tracking tools that we will be using with the message broker.

Add via Composer
----------------

[](#add-via-composer)

Add to a project through Composer in the composer.json:

```
{
  "require": {
    "dosomething/mb-stat-tracker": "v0.0.2"
  }
}

```

StatHat - Usage
---------------

[](#stathat---usage)

StatHat basic value tracking that can either be incremented as a counter or averaged over time.

#### Create the StatHat Object

[](#create-the-stathat-object)

- The `$stathat_ez_key` is the EZ key linked to your StatHat account.
- The second parameter of the constructor (in this case `'stat-name-base:'`)is the base name of the stat. If no subset stat is defined, then stats will just get reported to this stat name alone.
- The ':' at the end of the stat's base name is not required. But it is a convention we're going with on the message broker.

```
use DoSomething\MBStatTracker\StatHat;

$statHat = new StatHat($stathat_ez_key, 'stat-name-base:');

```

#### Enable for Production

[](#enable-for-production)

Maybe this is a bad design decision, but by default, stats won't get reported to the StatHat servers. This was done so dev stats don't mix with production stats. Again, maybe a bad design decision. But for now, you'll have to explicitly enable it if you want stats reported.

```
$statHat->setIsProduction(TRUE);

```

#### Add Additional Stats

[](#add-additional-stats)

(optional) If necessary, secondary stat names can be reported to and will be grouped separately in the StatHat reports. The following would create 3 separate stat names `stat-name-base: stat name 1`, `stat-name-base: stat name 2`, and `stat-name-base: stat name 3`:

```
$statHat->addStatName('stat name 1');
$statHat->addStatName('stat name 2');
$statHat->addStatName('stat name 3');

```

#### Report the Stats

[](#report-the-stats)

Only one of the following should be used for each stat name:

- Add `$count` to the value of a stat name:

```
$statHat->reportCount($count);

```

- Add `$value` to a stat name. StatHat will calculate the average:

```
$statHat->reportValue($value);

```

#### Report Different Stats

[](#report-different-stats)

To report different stats to different stat names, create different instances of the StatHat object.

```
$sh1A = new StatHat($ez_key, 'stat-base-1');
$sh1A->addStatName('name A');
$sh1A->reportCount(1);

$sh1B = new StatHat($ez_key, 'stat-base-1');
$sh1B->addStatName('name B');
$sh1B->reportCount(2);

$sh2 = new StatHat($ez_key, 'stat-base-2');
$sh2->addStatName('name name name');
$sh2->reportValue(1);

```

StatHat - Checking Reports
--------------------------

[](#stathat---checking-reports)

After logging into the StatHat account, reported stats can be viewed here:

[![Bitdeli Badge](https://camo.githubusercontent.com/42d853180949864c4fce65370a23e1b0a2ca275a67eaa2ca854eb057be339f3a/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f446f536f6d657468696e672f6d622d737461742d747261636b65722f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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 ~15 days

Total

3

Last Release

4377d ago

### Community

Maintainers

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

---

Top Contributors

[![jonuy](https://avatars.githubusercontent.com/u/696595?v=4)](https://github.com/jonuy "jonuy (16 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

### Embed Badge

![Health badge](/badges/dosomething-mb-stat-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/dosomething-mb-stat-tracker/health.svg)](https://phpackages.com/packages/dosomething-mb-stat-tracker)
```

PHPackages © 2026

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