streply / streply-php
该软件包最新版本(0.0.60)没有可用的许可信息。
Streply PHP SDK
资助软件包维护!
streply.com/pricing
streply.com
0.0.60
2024-04-26 07:21 UTC
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-09-26 08:16:33 UTC
README
安装
composer require streply/streply-php
初始化
在代码开始时初始化 Streply。
Streply\Initialize('https://clientPublicKey@api.streply.com/projectId');
位置
clientPublicKey
你的公开API密钥projectId
你的项目ID
使用参数初始化
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'release' => 'my-project-name@2.3.12', 'environment' => 'production', ] );
捕获
异常
try { if(true) { throw new \Exceptions\SomeException('Exception message here'); } } catch(\Exceptions\ParentException $exception) { Streply\Exception($exception); }
带有参数和捕获级别的异常
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 ); }
日志
Streply\Log('log.name', ['paramName' => 'paramValue']);
活动
Streply\Activity('message', ['paramName' => 'paramValue']);
捕获级别
Level::CRITICAL
Level::HIGH
Level::NORMAL
Level::LOW
性能
创建事务
Streply\Performance::Start('transactionId', 'Product checkout');
添加点
Streply\Performance::Point('transactionId', 'calculate price'); ... Streply\Performance::Point('transactionId', 'cart amount', [ 'amount' => 100.56 ]);
发送事务
Streply\Performance::Finish('transactionId');
添加用户数据
Streply\User('joey@streply.com');
或带有参数和名称
Streply\User('joey@streply.com', 'Joey Tribbiani', [ 'createdAt' => '2022-11-10 15:10:32' ]);
配置
作用域
使用 setScope
助手将为 Streply SDK 捕获的所有事件设置作用域。
\Streply\setScope(function (\Streply\Scope $scope): void { $scope->setChannel('my-chanel'); });
如果您想更改单个事件的作用域,可以使用 withScope
助手。此助手不会保留所做的作用域更改。
\Streply\withScope(function (\Streply\Scope $scope): void { $scope->setChannel('my-chanel'); \Streply\Log('my log with channel'); });
作用域中可用的方法
setChannel
setFlag
setRelease
setEnvironment
在发送之前过滤事件
Streply\Initialize( 'https://clientPublicKey@api.streply.com/projectId', [ 'filterBeforeSend' => function(\Streply\Entity\Event $event): bool { if($event->getMessage() === 'someMessage') { return false; } return true; } ] );
此外,您可以在以后的时间修改所有选择
Streply\Configuration::filterBeforeSend(function(\Streply\Entity\Event $event) { if($event->getMessage() === 'someMessage') { return false; } return true; });
忽略异常
Streply\Configuration::ignoreExceptions([ App\Exception\QueryException::class, App\Exception\InvalidAuthorizationException::class, ]);
显示日志
print_r(Streply\Logs());