simplestats-io/laravel-client

v2.0.8 2024-09-16 14:52 UTC

This package is auto-updated.

Last update: 2024-09-16 16:40:35 UTC


README

Latest Version on Packagist Tests Check & fix styling License

这是官方的 Laravel 客户端,用于将跟踪数据发送到 https://simplestats.io

简介

SimpleStats 是一款针对 Laravel 应用程序优化的精简统计工具,超越了仅仅查看访问量和浏览量的局限。它提供了对用户来源和行为的 精确洞察。通过默认的通过 UTM 代码进行跟踪和过滤,您可以获得对 营销 活动的详细分析,确定哪些努力可以带来 收入。轻松评估活动 ROI,发现成本效益高的用户获取渠道,并确定最有效的性能渠道。 SimpleStats 确保完全符合 GDPR 规定,并具有简单直观的安装过程。

screenshot

安装

您可以通过 composer 安装客户端包

composer require simplestats-io/laravel-client

您应该使用以下命令发布配置文件

php artisan vendor:publish --tag="simplestats-client-config"

这是配置文件的默认内容,根据您的需要调整

use App\Models\User;
use Illuminate\Auth\Events\Login;

return [

    /*
     |--------------------------------------------------------------------------
     | SimpleStats Settings
     |--------------------------------------------------------------------------
     |
     | SimpleStats is enabled by default. Be aware that if you turn disable it,
     | you may lose important tracking data. In most cases, leave it enabled!
     |
     | You can provide an array of URI's that must be ignored (eg. 'api/*')
     */

    'enabled' => env('SIMPLESTATS_ENABLED', true),
    
    'except' => [
        'telescope*',
        'horizon*',
        'admin*',
        'api*',
    ],

    /*
     |--------------------------------------------------------------------------
     | SimpleStats API Credentials
     |--------------------------------------------------------------------------
     |
     | Define your API credentials here. If you are not told to change the API URL,
     | just keep the default. It's important to set an API token! You'll receive
     | one, after creating an Instance for a Project on https://simplestats.io
     |
     */

    'api_url' => env('SIMPLESTATS_API_URL', 'https://simplestats.io/api/v1/'),

    'api_token' => env('SIMPLESTATS_API_TOKEN'),

    /*
     |--------------------------------------------------------------------------
     | SimpleStats Queue
     |--------------------------------------------------------------------------
     |
     | To avoid the tracking API calls block the whole request and for fault tolerance,
     | we highly recommend to use Laravel's built-in queue-system. Here you can define
     | to which queue the tracking API calls should be dispatched and handled by.
     |
     */

    'queue' => env('SIMPLESTATS_QUEUE', 'default'),

    /*
     |--------------------------------------------------------------------------
     | SimpleStats Tracking Codes
     |--------------------------------------------------------------------------
     |
     | Below you can set your tracking code URL param names. We already set some
     | classical defaults for you, but you're free to change them as you like.
     | Note that only the params which are listed here are getting tracked!
     |
     */

    'tracking_codes' => [
        'source' => ['utm_source', 'ref', 'referer', 'referrer'],
        'medium' => ['utm_medium', 'adGroup', 'adGroupId'],
        'campaign' => ['utm_campaign'],
        'term' => ['utm_term'],
        'content' => ['utm_content'],
    ],

    /*
     |--------------------------------------------------------------------------
     | SimpleStats Tracking Types
     |--------------------------------------------------------------------------
     |
     | Here you can set three different tracking types. The first is the login
     | event. If this event gets dispatched, we track a login. The second is
     | the user model. If such a model is created, we track a registration.
     |
     | As the payment model is named very individually, we did not set any default here.
     | Give it the name of the model which holds your payments or transactions data.
     |
     | See: https://simplestats.io/docs
     |
     */

    'tracking_types' => [
        'login' => [
            'event' => Login::class,
        ],

        // Make sure this model implements the TrackableUser or
        // the TrackableUserWithCondition contract
        'user' => [
            'model' => User::class,
        ],

        // Make sure this model implements the TrackablePayment or
        // the TrackablePaymentWithCondition contract
        'payment' => [
            'model' => null,
        ],
    ],
];

文档

请在此处查看完整文档: Official SimpleStats.io Documentation

测试

composer test

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全漏洞

请查看 我们的安全政策 了解如何报告安全漏洞。

致谢

许可证

GNU 通用公共许可证 v3.0 或更高版本。请参阅 许可证文件 了解更多信息。