asci/track 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asci/track

Composer 安装命令:

composer require asci/track

包简介

track is event based tracking system with multiple database backend support.

README 文档

README

Build Status Latest Stable Version Total Downloads SensioLabsInsight

track is an event based tracking system that helps you to collect and query statistical data based on the actions from your customers, users or visitors.

With track you can;

  • collect page views, clicks, conversions or any kind of user actions for your website, API or mobile app.
  • query collected data with complex filters. (currently only with native queries)
  • create funnels (in progress)

Features

  • Collect data with unlimited custom parameters.
new Event(
    'Purchase',
    array(
        'Affiliate'     => 'Amazon.de',
        'Category'      => 'Smartphones',
        'Product Name'  => 'iPhone 5s Black 64GB',
        'Price'         => 549.99,
        //...
    )
);
  • Query on collected data and create analytics.
  • Create funnels (in progress)
  • Duplicate/Unique filtering. (in progress)
  • Multiple database backend options. (currently only mongodb and postgresql with hstore)
  • Easily extendable architecture.
  • Full test coverage with phpspec.

Events

An event basically defines the same thing as in its name. Any kind of action made by your customers, users or applications can be described as an event. For instance; 'Page View', 'Button Click', 'Purchase', 'API Request', 'Exception', etc.

Track defines events within the special Event objects. An Event object can carry many special information with it among the custom ones. For instance an Event object can have;

  • IP address,
  • a unique key to distinguish your users,
  • the time of the event,
  • requested URL,
  • product category,
  • pruduct name,
  • customer source,
  • and many other defined by you.

Track comes with bunch of built-in events specicialized for different purposes. All the built-in event can be found under the Track\Event namespace. You can also define your own customized events for your needs.

Built-in Events

Track comes with bunch of built-in events specicialized for different purposes. All the built-in event can be found under the Track\Event namespace.

1. Track\Event

This is the base event of Track and provides very basic expectations from an event. All the other events has to be extending to it, this means that every event has to/will have at least a name, a timestamp and a unique id. If you don't give these values while initializing your event object they will get automatically generated by Track.

$event = new Track\Event(
    'Page View',                // Event name
    array(
        'utm_source' => 'partner_x',
        'utml_medium' => 'affiliate',
    )
);

print_r($event->toArray());

/*
will give you like the following 

array(
    'timestamp' => 'timestamp',
    'id' => 'random_string',
    'utm_source' => 'partner_x',
    'utml_medium' => 'affiliate'
)
*/

Examples

Store an event

use Track\Client;
use Track\Storage\MongoDBStorage;
use Track\Event\Event;

// Configure your mongodb connection
$mongoClient = new \MongoClient();
$mongoDB = $mongoClient->selectDB('stats');

// Initialize the storage
$storage = new MongoDBStorage($mongoDB);

$client = new Client($storage);

// Create an event for your needs
$event = new Event(
    'Purchase',
    array(
        'Affiliate' => 'Amazon.de',
        'Category'  => 'Smartphones',
        'Product Name'  => 'iPhone 5s Black',
        'Price' => 549.99,
    )
);

// Store the event
$client->track($event);

Query events

use Track\Query;
use Track\Storage\MongoDBStorage;

// Configure your mongodb connection
$mongoClient = new \MongoClient();
$mongoDB = $mongoClient->selectDB('stats');

// Initialize the storage
$storage = new MongoDBStorage($mongoDB);

$query = new Query($storage);
$results = $query->native(array('name' => 'Purchase'));

/*
will return

array(
    array(
        'Affiliate' => 'Amazon.de',
        'Category'  => 'Smartphones',
        'Product Name'  => 'iPhone 5s Black',
        'Price' => 549.99,
        ...
    ),
    ...
)
*/

PostgreSQL hstore Setup

CREATE EXTENSION IF NOT EXISTS hstore;

CREATE TABLE IF NOT EXISTS events (
  id serial PRIMARY KEY,
  data hstore
);

-- Some hstore raw query examples

SELECT data
FROM events
WHERE (data->'timestamp')::int > 12345678;

SELECT data
FROM events
WHERE data->'name'= 'Purchase';

统计信息

  • 总下载量: 24.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固