Configuration
Configuration of the library is very simple, check out the options.
Initialisation
Initialisation of Strepla is performed using the Initialize
, method, which should be placed at the very beginning of the code (e.g. in the index.php file). The method receives the (string) DSN
as the first parameter.
Streply\Initialize('https://clientPublicKey@api.streply.com/projectId');
The second, optional parameter of the Initialize
method is the (array) $options
in which optional settings can be defined.
Available options:
(string) release
- Project version(string) environment
- Application environment(function) filterBeforeSend
- Filtering of events before sending
Example of the option's usage:
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'release' => 'my-project-name@2.3.12', 'environment' => 'production', ] );
Or you can set it in your project:
Streply\Configuration::setEnvironment('local'); Streply\Configuration::setRelease('1.2.0');
Filtering requests before sending
To avoid sending unnecessary requests, you can use the filterBeforeSend
option to impose conditions on events that do not need to be sent to Streply.
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'filterBeforeSend' => function(Streply\Entity\Event $event): bool { if($event->getMessage() === 'someMessage') { return false; } return true; } ] );
Or you can set it in your project:
Streply\Configuration::filterBeforeSend(function(\Streply\Entity\Event $event) { if($event->getMessage() === 'someMessage') { return false; } return true; });
Flag events as a command
You can mark an event as a command. For example, if this event is executed in crontab.
Commands events you can analyze in the "Cron" module.
use Streply\Enum\EventFlag; Streply\Log('some log here')->flag(EventFlag::COMMAND);
Sending event immediately
By default Streply client store all events and send them when method Flush is called.
If you need to send an event immediately you need to use the sendImmediately
method.
Streply\Log('some log here')->sendImmediately();
Remember: The log method will return NULL
if the Streply client was not initialized.
Package
streply/streply-php
Repository
https://github.com/streply/streply-php