uecode/segment-io-php 问题修复 & 功能扩展

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

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

uecode/segment-io-php

Composer 安装命令:

composer require uecode/segment-io-php

包简介

A PHP library for reporting events to the Segment.io API

README 文档

README

Build Status Quality Score Code Coverage Total Downloads

This library provides a Web Service Client for the Segment.io HTTP API using Guzzle v5.

Installation

Installation

Install the latest version with:

$ composer require uecode/segment-io-php ~1.1

Basic Usage

use SegmentIO\Client;

$client = new Client(['write_key' => $writeKey]);

// Identify the user - assuming, below, that you
// have a $user object from your database
$client->identify([
    'userId' => $user->getId(),
    'traits' => [
        'name' => $user->getName(),
        'email' => $user->getEmail()
    ]
]);

// Track an event (userId or anonymousId is required for all events!)
$client->track([
    'userId' => $user->getId(),
    'event'  => 'Some Event Happened',
    'properties' => [
        'foo' => 'bar'
    ]
]);

Configuration Options

The client accepts an array of configuration options:

Setting Property Name Description
API Write Key write_key The Segment.io API Write Key
API Version version The API Version. Used to version the API (default: v1)
Batching batching A method of batching calls to the API to reduce latency of over the wire requests (supports: request or file) - use false to disable
Request Batching: Max Queue Size max_queue_size When using Request Batching, this is the total amount of Events to queue before flushing
Request Batching: Batch Size batch_size When using Request Batching, this is the total amount of Events sent in a single Request
File Batching: Log File log_file When using File Batching, this determines what file to log Events to

Using Batching

By default, this client will attempt to queue all calls to the API and send them out over a single batch request. Because of the blocking nature of PHP, this method reduces the amount of time the Client has to wait for requests to the API.

Batching does not apply to the import() method on the client.

There are two methods of Batching Available:

Request Batching

Note: This is enabled by default.

When making calls to the API, the events will be placed into a queue and will be flushed under one of two cases: when / if the max_queue_size is reached or at the end of the PHP Request.

Changing the Client options for max_queue_size and batch_size will affect how often the Client attempts to flush events.

File Batching

The file batching is a more performant method for making requests to Segment.io.

Each time a track or identify call is made, it will record that call to a log file. The log file is then uploaded “out of band” by running the included parse command.

You can change the location of the log file by using the log_file Client configuration option. If a log_file is not specified, it will default to: /tmp/segment-io.log.

To upload the Events from the log file to Segment.io, run the included parse command:

./parse YOUR_WRITE_KEY --file /tmp/segment-io.log

Tracking HTTP API Documentation

Documentation is available for the Tracking HTTP API at segment.io/docs/tracking-api/.

License

This software is released under the MIT License. See the license file for details.

uecode/segment-io-php 适用场景与选型建议

uecode/segment-io-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.1k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2014 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「analytics」 「segment.io」 「segment」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 uecode/segment-io-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 uecode/segment-io-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 uecode/segment-io-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 5
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-01