/laravel-segment

A Laravel wrapper for the Segment API and events tracking.

Primary LanguagePHPMIT LicenseMIT

A Laravel wrapper for the Segment API and events tracking.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

You can install the package via composer:

composer require binarcode/laravel-segment

You can publish and run the migrations with:

php artisan vendor:publish --tag="segment-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="segment-config"

This is the contents of the published config file:

return [
    /**
     * The queue name where the segment events will be dispatched.
     */
    'queue' => env('SEGMENT_QUEUE', env('QUEUE_CONNECTION', 'sync')),

    /**
     * Segment API key [see: https://segment.com/docs/connections/sources/catalog/libraries/server/php/#identify].
     */
    'key' => env('SEGMENT_KEY', ''),
];

Usage

Track event

BinarCode\LaravelSegment\Facades\LaravelSegment::track('click')->properties([...])

Alias anonymous id to a real user id

BinarCode\LaravelSegment\Facades\LaravelSegment::alias($previous, $userId);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.