2017 © Pedro Peláez
 

library log-tracker

Tracking companion to APIx Log

image

apix/log-tracker

Tracking companion to APIx Log

  • Wednesday, June 14, 2017
  • by frqnck
  • Repository
  • 1 Watchers
  • 2 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Log-Tracker, the tracking companion to Apix-Log

Latest Stable Version Build Status Code Quality Code Coverage License, (*1)

An extension for the Apix-Log PSR-3 logger which adds log tracking to: * GoogleAnalytics, * Dashbot., (*2)

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, and the Composer package is on packagist., (*3)

Feel free to comment, send pull requests and patches..., (*4)

Installation

Install the latest version via composer:, (*5)

$ composer require apix/log-tracker

You require at least PHP 5.3., (*6)

Basic usage, Google Analytics.

use Apix\Log;

$options = [
    'tid' => '<UA-XX-XX>',   // Tracking/Property ID (required). 
    //'cid' => '<UUID-v4>',  // 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 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., (*7)

Basic usage, Dashbot.

use Apix\Log;

$dashbot_logger = new Dashbot('<API-Key');
//$dashbot_logger->setPlatform('facebook'); // 'generic' (default), 'slack', 'kik'.
//$dashbot_logger->setGlobalTag('myTag');   // Useful to combined metrics.

$messages_received = ["text" => "Hi, bot", "userId" => "..."];
$dataToTrack = $dashbot_logger->incoming($messages_received);
//$dataToTrack = $dashbot_logger->incoming($messages_received, "localTag"); // Override the global tag

$messages_sent = ["text" => "Hello, user", "userId" => "..."];
$dataToTrack = $logger->outgoing($messages_sent);

$dashbot_logger->info('Dashbot Tracking', $dataToTrack);

Notes: * The log level and message are not forwarded to Dashbot (TBD). * A local tag (which override the main global tag) can be passed to the incoming and outgoing methods as a second argument., (*8)

Advanced usage.

Please for now just follow Apix Log Examples., (*9)

The Versions

14/06 2017

dev-master

9999999-dev

Tracking companion to APIx Log

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Franck Cassedanne

13/10 2016

1.1.1

1.1.1.0

Tracking companion to APIx Log

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Franck Cassedanne

11/10 2016

1.1.0

1.1.0.0

Tracking companion to APIx Log

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Franck Cassedanne

10/10 2016

1.0.0

1.0.0.0

Tracking companion to APIx Log

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Franck Cassedanne