定制 meemalabs/analytics-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

meemalabs/analytics-laravel

最新稳定版本:v0.1.0

Composer 安装命令:

composer require meemalabs/analytics-laravel

包简介

Laravel log driver for ts-analytics error collection

README 文档

README

A Laravel log driver that sends errors and log entries to your ts-analytics server. Works like Flare or Bugsnag — configure it once and Laravel's exception handler automatically reports errors through the logging pipeline.

Installation

composer require meemalabs/analytics-laravel

The service provider is auto-discovered by Laravel.

Configuration

Publish the config file:

php artisan vendor:publish --tag=analytics-config

Add these to your .env:

ANALYTICS_TOKEN=ak_your_api_key
ANALYTICS_SITE_ID=my-site

Add the analytics channel to your config/logging.php:

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['daily', 'analytics'],
    ],

    'analytics' => [
        'driver' => 'analytics',
        'level' => 'error',
    ],
],

That's it. Exceptions and error-level log entries are now sent to your analytics server automatically.

Config Reference

All options in config/analytics.php:

Key Env Var Default Description
token ANALYTICS_TOKEN '' API key (must start with ak_)
site_id ANALYTICS_SITE_ID '' Site identifier
environment ANALYTICS_ENVIRONMENT APP_ENV Environment name in reports
enabled ANALYTICS_ENABLED true Kill switch to disable reporting
level ANALYTICS_LOG_LEVEL error Minimum log level to report

How It Works

  1. The package registers an analytics Monolog log driver via Log::extend()
  2. When Laravel logs an error (or an exception is thrown), the log record reaches the AnalyticsLogHandler
  3. If the log context contains a Throwable, a full error report is built with class name, message, stack trace, file, and line
  4. Otherwise, a message-level report is built from the log message
  5. The report is sent via HTTP POST to the analytics endpoint (/errors/collect) with the X-Analytics-Token header
  6. The HTTP call uses a 5-second timeout and silently catches failures — logging never crashes the app

Requirements

  • PHP 8.2+
  • Laravel 11+

License

MIT

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固