PHP code example of farmatholin / segment-io-bundle

1. Go to this page and download the library: Download farmatholin/segment-io-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

farmatholin / segment-io-bundle example snippets


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

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
    }


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
    }