PHPackages                             apix/log-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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. apix/log-tracker

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

apix/log-tracker
================

Tracking companion to APIx Log

1.1.1(9y ago)226BSD-3-ClausePHPPHP &gt;=5.3CI failing

Since Oct 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/apix/log-tracker)[ Packagist](https://packagist.org/packages/apix/log-tracker)[ RSS](/packages/apix-log-tracker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Log-Tracker, the tracking companion to [Apix-Log](//github.com/apix/log)
========================================================================

[](#log-tracker-the-tracking-companion-to-apix-log)

[![Latest Stable Version](https://camo.githubusercontent.com/dc3fe121c2132f6c8712f0c0cfc9e5755f4ba9e1f883a35f9c6c5b001f906d89/68747470733a2f2f706f7365722e707567782e6f72672f617069782f6c6f672d747261636b65722f762f737461626c652e737667)](https://packagist.org/packages/apix/log-tracker) [![Build Status](https://camo.githubusercontent.com/10ec6ee681a2e9a553243979ba2cdb6ba88ea38273a1eb45c4b723ce89e4bd3a/68747470733a2f2f7472617669732d63692e6f72672f617069782f6c6f672d747261636b65722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/apix/log-tracker) [![Code Quality](https://camo.githubusercontent.com/d3edb161cf32d9d8d2231c01d2a9b93c86ff8583e4d89efd96cc922648a8ee41/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f617069782f6c6f672d747261636b65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/apix/log-tracker/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a6bcc1addd6bb458354b7042885f15f739dddf70274022f6defd2f8a484898cf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f617069782f6c6f672d747261636b65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/apix/log-tracker/?branch=master) [![License](https://camo.githubusercontent.com/8865fcee65f0f4738388d9fb22602a3fb09a920dc91a4cf9c928747ec84bbf06/68747470733a2f2f706f7365722e707567782e6f72672f617069782f6c6f672d747261636b65722f6c6963656e73652e737667)](https://packagist.org/packages/apix/log-tracker)

An extension for the [Apix-Log](//github.com/apix/log) PSR-3 logger which adds log tracking to:

- [GoogleAnalytics](src/GoogleAnalytics.php),
- [Dashbot](src/Dashbot.php).

Features:

- Send tracking data asynchnonously (non-blocking).
- Handles batched/deferred mode.
- 100% Unit tested and compliant with PSR0, PSR1 and PSR2.
- Continuously integrated against all modern PHP versions (**5.3 all the way through 7.3**, including HHVM).
- Home repo is on [on github](//github.com/apix/log-tracker), and the Composer package is [on packagist](//packagist.org/packages/apix/log-tracker).

Feel free to comment, send pull requests and patches...

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

[](#installation)

Install the latest version via composer:

```
$ composer require apix/log-tracker

```

You require at least PHP 5.3.

Basic usage, Google Analytics.
------------------------------

[](#basic-usage-google-analytics)

```
use Apix\Log;

$options = [
    'tid' => '',   // Tracking/Property ID (required).
    //'cid' => '',  // Anonymous Client ID UUIDv4 (if not provided, auto-generated one).
    //...                    // Any numbers of Google Analytics Parameters (see notes).
];

$ga_logger = new GoogleAnalytics($options);
$ga_logger->setDeferred(true); // Enable batched mode (recommneded).

$dataToTrack = $ga_logger->getPage('http://foo.tld/...', 'Welcome page');
//$dataToTrack = $ga_logger->getEvent('category', 'action', 'label', 'value');
//$dataToTrack = $ga_logger->getSocial('action', 'network', 'target');
//$dataToTrack = $ga_logger->getException('description');
//$dataToTrack = $ga_logger->getApp('name', 'version', 'id');

$ga_logger->notice('GA Tracking', $dataToTrack);
```

Notes:

- The log level and message are not forwarded to Google Analytics (TBD).
- If required, you can add some additional [Google Analytics Parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters) to the `options` array such as `uip` (user IP), `ua` (user agent), etc... If not provided, these will be generated and/or guessed from the current context.

Basic usage, Dashbot.
---------------------

[](#basic-usage-dashbot)

```
use Apix\Log;

$dashbot_logger = new Dashbot('
