hosmelq/laravel-logsnag
Composer 安装命令:
composer require hosmelq/laravel-logsnag
包简介
Integrate the power of LogSnag's real-time event tracking into your Laravel application.
README 文档
README
This is an unofficial package for LogSnag.
Laravel LogSnag
Easily integrate LogSnag's event tracking into your Laravel app. Monitor user activity, get realtime analytics, and receive instant insights.
Requirements
This package requires PHP 8.1 or higher and Laravel 10.0 or higher.
Installation
You can install the package via composer:
composer require hosmelq/laravel-logsnag
Configuration
You can publish the config file with:
php artisan vendor:publish --tag="logsnag-config"
Alternatively, you may utilize the install command.
php artisan logsnag:install
Next, you should configure your LogSnag API token and project name in your application’s .env file:
LOGSNAG_API_TOKEN=your-api-token LOGSNAG_PROJECT=your-project-name
We determine the project to send events to using LOGSNAG_PROJECT. Alternatively, you can specify
the project name when creating an event or insight.
Usage
Publish Event
You can use the LogSnag facade to publish events, and insights.
use HosmelQ\LogSnag\Laravel\Facades\LogSnag; LogSnag::log()->publish([ 'channel' => 'waitlist', 'event' => 'User Joined Waitlist', 'icon' => '🎉', ]);
This method returns a Log instance that provides access to the response from the LogSnag API. For more information and a list of available parameters, refer to the LogSnag documentation for Log.
Publish Insight
use HosmelQ\LogSnag\Laravel\Facades\LogSnag; LogSnag::insight()->publish([ 'icon' => '🎉', 'title' => 'Registered Users on Waitlist', 'value' => 8, ]);
This method returns an Insight instance that provides access to the response from the LogSnag API. For more information and a list of available parameters, refer to the LogSnag documentation for Insight.
User Properties
use HosmelQ\LogSnag\Laravel\Facades\LogSnag; LogSnag::identify()->publish([ 'properties' => [ 'email' => 'john@doe.com', 'name' => 'John Doe', 'plan' => 'premium', ], 'user_id' => '123', ]);
This method returns an Identify instance that provides access to the response from the LogSnag API. For more information and a list of available parameters, refer to the LogSnag documentation for Identify.
Apart from the facade, you can utilize the logsnag helper function.
logsnag()->log()->publish([ 'channel' => 'waitlist', 'event' => 'User Joined Waitlist', 'icon' => '🎉', ]);
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 8.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-13