iugosds / sherlaravel
Sherlock Score integration for Laravel projects
Requires
- illuminate/support: ~5|~6
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3|~4
- phpunit/phpunit: ^8.0
- sempro/phpunit-pretty-print: ^1.0
This package is auto-updated.
Last update: 2024-08-27 04:19:24 UTC
README
Sherlock Score integration for Laravel.
Track your users, trials, and paid accounts with Sherlock’s Product Engagement Scoring engine.
Installation
Via Composer
$ composer require iugosds/sherlaravel
Usage
First of all, add a SHERLOCK_SCORE_API_KEY key to your .env file:
SHERLOCK_SCORE_API_KEY=a12b34c56...
You can also disable this package by adding a SHERLOCK_SCORE_ENABLED key set to false (true by default).
In case you don't want to wait for the API to respond, you can run all interactions with Sherlock Scores as asynchronous calls (jobs will be dispatched to the "default" queue of your laravel application). To enable this feature, set the SHERLOCK_ASYNC_CALLS variable to true in your .env file.
To start interacting with Sherlock Score, use the following methods:
use SherLaravel;
SherLaravel::identifyAccount("groupIdHere");
With Sherlock you can keep track of Accounts (or groups of users). To identfy a new account, add the line above to your controller.
SherLaravel::identifyUser("userIdHere");
The identifyUser method is used to identify a new User. It will be tipically added to the register method on your login controller, or to the "created" event of your User Model in case you are using Observers.
SherLaravel::trackEvent("userID", "event-name");
In your controllers, use the trackEvent method every time you want to track an interaction with a user.
SherLaravel::identifyAccount(String $group_id, ?Array $traits= [], ?int $timestamp = null) SherLaravel::identifyUser(String $user_id, ?String $group_id = null, ?Array $traits= [], ?int $timestamp = null) SherLaravel::trackEvent(String $user_id, String $event, ?int $timestamp = null)
##Sample:
SherLaravel::identifyUser("1234", "Customer44", [ 'name' => 'John Doe', 'email' => 'johndoe@example.com'], '1553647710707');
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Credits
License
MIT. Please see the license file for more information.