承接 farmatholin/segment-io-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

farmatholin/segment-io-bundle

Composer 安装命令:

composer require farmatholin/segment-io-bundle

包简介

Segment.io php lib

README 文档

README

Bundle include segment.io library for analytics

include segmentio/analytics-php

Documentation

The bulk of the documentation is stored in the Resources/doc folder in this bundle

Installation

Installing the bundle via packagist is the quickest and simplest method of installing the bundle. Here are the steps:

Step 1: Composer require

$ php composer.phar require "farmatholin/segment-io-bundle":"^1.3"

Step 2: Enable the bundle in the kernel (Symfony < 3.4)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Farmatholin\SegmentIoBundle\SegmentIoBundle(),
        // ...
    );
}

That's it! You are ready to use Segment.io with symfony2.

Configuration

Required segment write key:

Symfony 4.X || 5.X || 6.X :

# config/packages/segment_io.yaml

segment_io:
    write_key: "%env(SEGMENTIO_KEY)%"  # add your key
    guest_id: "guest" # default guest. Guest id for annotation Track and Page
    env: prod #default prod. Can be prod (sending to segment) and dev (not sending)
    data_residency: Oregon #default Oregon. Can be Oregon, Dublin, Signapore or Sydney. Overwritten by host option
    options:
        consumer: socket #default
        debug: false #default
        ssl: false #default
        max_queue_size: 10000 #default
        flush_at: 100 #default
        timeout: 0.5 #default
        filename: null #default
        host:  #default not set - uses segment default api

Symfony 2.X || 3.X

# app/config/config.yml

    segment_io:
        write_key: "%your_key%" #add your key
        guest_id: "guest" # default guest. Guest id for annotation Track and Page
        env: prod #default prod. Can be prod (sending to segment) and dev (not sending)
        data_residency: Oregon #default Oregon. Can be Oregon, Dublin, Signapore or Sydney. Overwritten by host option
        options:
            consumer: socket #default
            debug: false #default
            ssl: false #default
            max_queue_size: 10000 #default
            flush_at: 100 #default
            timeout: 0.5 #default
            filename: null #default
            host: #default not set - uses segment default api.

Data Residency

Segment allows the usage of regional infrastructure. If your Segment plan supports this, you can set the data_residency option to either Oregon, Dublin, Singapore or Sydney. If you set the option.host value, the data_residency setting is ignored and the host option is used.

Usage

Get segment_io.analytics service from the service container and start using it:

$analytics = $this->get('segment_io.analytics');
$analytics->page([]);

Or using Annotations (Page and Track)

User for annotations is getting from TokenStorage. If user doesn't exit, id set to guest or from configuration 'guest_id'

use Farmatholin\SegmentIoBundle\Configuration\Page;
use Farmatholin\SegmentIoBundle\Configuration\Track;

/**
     * @Route("/", name="homepage")
     *
     * @Page(
     *     name="index",
     *     category="page",
     *     properties={"foo":"bar"}
     * )
     * @Track(
     *     event="visit homepage",
     *     properties={"bar":"foo"},
     *     useTimestamp=true,
     *     context={"aa":"bb"}
     * )
     */
    public function indexAction(Request $request)
    {
        // your code
    }

Or using dependency injection:

use Farmatholin\SegmentIoBundle\Util\SegmentIoProvider;
    
    /**
     * @Route("/", name="homepage", methods={"GET"})
     *
     * @param SegmentIoProvider $segmentIoProvider
     */
    public function index(SegmentIoProvider $segmentIoProvider) {
        $segmentIoProvider->track([
            'userId' => 123, // or 'guest' if not available
            'event' => 'visit homepage',
            'properties' => [
                'foo' => 'bar'
            ] 
        ]);
        $segmentIoProvider->flush();
        
        // your code
    }

Refer to Segment.io analytics-php library.

farmatholin/segment-io-bundle 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 259.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-11