streply / streply-php
A Streply PHP SDK
Fund package maintenance!
streply.com/pricing
streply.com
Installs: 1 349
Dependents: 4
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
Requires (Dev)
- phpstan/phpstan: ^1.9
- symplify/easy-coding-standard: ^12.1
- dev-main
- 0.0.60
- 0.0.59
- 0.0.58
- 0.0.57
- 0.0.56
- 0.0.55
- 0.0.54
- 0.0.53
- 0.0.52
- 0.0.51
- 0.0.50
- 0.0.49
- 0.0.48
- 0.0.47
- 0.0.46
- 0.0.45
- 0.0.44
- 0.0.43
- 0.0.42
- 0.0.41
- 0.0.40
- 0.0.39
- 0.0.38
- 0.0.37
- 0.0.36
- 0.0.35
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This package is auto-updated.
Last update: 2024-11-26 08:43:46 UTC
README
Install
composer require streply/streply-php
Initialization
Initialize Streply on beginning your code.
Streply\Initialize('https://clientPublicKey@api.streply.com/projectId');
Where:
clientPublicKey
your public API keyprojectId
your project ID
Initialization with parameters
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'release' => 'my-project-name@2.3.12', 'environment' => 'production', ] );
Capture
Exception
try { if(true) { throw new \Exceptions\SomeException('Exception message here'); } } catch(\Exceptions\ParentException $exception) { Streply\Exception($exception); }
Exception with params and capture level
use Streply\Enum\Level; try { if(true) { throw new \Exceptions\SomeException('Exception message here'); } } catch(\Exceptions\ParentException $exception) { Streply\Exception( $exception, [ 'paramName' => 'paramValue' ], Level::CRITICAL ); }
Log
Streply\Log('log.name', ['paramName' => 'paramValue']);
Activity
Streply\Activity('message', ['paramName' => 'paramValue']);
Capture levels
Level::CRITICAL
Level::HIGH
Level::NORMAL
Level::LOW
Performance
Creating transaction
Streply\Performance::Start('transactionId', 'Product checkout');
Adding point
Streply\Performance::Point('transactionId', 'calculate price'); ... Streply\Performance::Point('transactionId', 'cart amount', [ 'amount' => 100.56 ]);
Sending transaction
Streply\Performance::Finish('transactionId');
Adding user data
Streply\User('joey@streply.com');
or with parameters and name
Streply\User('joey@streply.com', 'Joey Tribbiani', [ 'createdAt' => '2022-11-10 15:10:32' ]);
Configuration
Scopes
The setScope
helper will set up the scope for all events captured by the Streply SDK.
\Streply\setScope(function (\Streply\Scope $scope): void { $scope->setChannel('my-chanel'); });
If you want to change the scope for a single event, you can use the withScope
helper instead. This helper does not retain the scope changes made.
\Streply\withScope(function (\Streply\Scope $scope): void { $scope->setChannel('my-chanel'); \Streply\Log('my log with channel'); });
Available methods in scope:
setChannel
setFlag
setRelease
setEnvironment
Filter events before send
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'filterBeforeSend' => function(\Streply\Entity\Event $event): bool { if($event->getMessage() === 'someMessage') { return false; } return true; } ] );
Additionally, you have the flexibility to modify all choices at a later time:
Streply\Configuration::filterBeforeSend(function(\Streply\Entity\Event $event) { if($event->getMessage() === 'someMessage') { return false; } return true; });
Ignore Exceptions
Streply\Configuration::ignoreExceptions([ App\Exception\QueryException::class, App\Exception\InvalidAuthorizationException::class, ]);
Display logs
print_r(Streply\Logs());