streply / streply-php
There is no license information available for the latest version (0.0.44) of this package.
A Streply PHP SDK
0.0.44
2023-10-25 05:33 UTC
Requires
- php: ^7.4|^8.0
Requires (Dev)
- phpstan/phpstan: ^1.9
- dev-main
- 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: 2023-11-25 05:43:44 UTC
README
Install
composer require streply/streply-php
Initialization
Initialize Streply on beginning your code and close the connection after your code.
Both functions are mandatory for correctly working.
<?php Streply\Initialize('https://clientPublicKey@api.streply.com/projectId'); // Your code here Streply\Flush();
Where:
clientPublicKey
your public API keyprojectId
your project ID
Initialization with parameters
<?php Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'release' => 'my-project-name@2.3.12', 'environment' => 'production', ] );
Filter events before send
<?php Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'filterBeforeSend' => function(Event $event): bool { if($event->getMessage() === 'someMessage') { return false; } return true; } ] );
Turn off Streply internal requests
<?php Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'internalRequests' => false ] );
Capture
Exception
<?php try { if(true) { throw new \Exceptions\SomeException('Exception message here'); } } catch(\Exceptions\ParentException $exception) { Streply\Exception($exception); }
Exception with params and capture level
<?php 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 ); }
Activity
<?php Streply\Activity( 'message', [ 'paramName' => 'paramValue' ], '#optionalChannel' );
Log
<?php Streply\Log( 'log.name', [ 'paramName' => 'paramValue' ], '#optionalChannel', Level::CRITICAL );
Capture levels
Level::CRITICAL
Level::HIGH
Level::NORMAL
Level::LOW
Breadcrumbs
<?php use Streply\Enum\BreadcrumbType; Streply\Activity('someActivity'); Streply\Breadcrumb(BreadcrumbType::INFO, 'firstBreadcrumb for someActivity'); Streply\Breadcrumb(BreadcrumbType::DEBUG, 'secondBreadcrumb for someActivity', [ 'parameterName' => 'parameterValue' ]);
Available types: BreadcrumbType::INFO
, BreadcrumbType::DEBUG
, BreadcrumbType::ERROR
and BreadcrumbType::QUERY
.
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' ]);
Display logs
<?php print_r(Streply\Logs());