cdnsteve/segment-php-sdk

Segment.com PHP SDK

v1.0.0 2015-11-30 15:53 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:36:46 UTC


README

PHP SDK 用于与 Segment.com 分析 API 交互。使用 PHP 命名空间、GuzzleHttp 和 Composer。

Build Status

请注意,此项目正在积极开发中,目前不应在生产环境中使用。

安装

composer require cdnsteve/segment-php-sdk

示例

<?php
require __DIR__ . '/vendor/autoload.php';

use CdnSteve\Segment\Segment;
use CdnSteve\Segment\Analytics;

Segment::config([
  'api_key' => 'YOUR_API_KEY',
  'timeout' => 2.0, // HTTP request in seconds.
  ]);

// Setup unique identity to track.
Analytics::identify([
  'userId'=> '5114'
]);

// Track it!
Analytics::track([
  'userId'=> '5114',
  'event' => 'Purchase item',
  'properties' => [
    'product' => 'Solution 10',
    'premium_frequency' => 'monthly',
    'insurance_coverage' => 250000,
    'premium' => 50.35,
  ]
]);

许可证

MIT 许可证