定制 impactlabs/laravel-error-tracker 二次开发

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

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

impactlabs/laravel-error-tracker

Composer 安装命令:

composer require impactlabs/laravel-error-tracker

包简介

Track errors by their business impact - know which bugs cost you money. Lightweight alternative to Sentry/Flare.

README 文档

README

Latest Version on Packagist Total Downloads GitHub Tests Action Status

A Laravel package that tracks not just errors, but their business impact. Perfect for SaaS, AdTech, and e-commerce platforms where errors have measurable financial consequences.

🎯 What Makes This Different

Unlike traditional error trackers, this package answers:

  • "Which errors are costing us money?"
  • "Which customers are affected?"
  • "Should we fix this NOW or later?"

✨ Features

  • 🎯 Business Impact Tracking - Track revenue loss, affected customers, and business metrics
  • 🔥 Smart Priority Scoring - Automatically prioritize errors by business impact
  • 📊 Context Enrichment - Capture business entities, user context, and system state
  • 🔔 Intelligent Notifications - WhatsApp, Slack, Email with actionable insights
  • 📡 Flexible Forwarding - Send logs to Elasticsearch, Graylog, Sentry, Datadog, etc.
  • Lightweight & Fast - <500KB memory, 3-6ms execution (async mode)
  • 🎨 Simple Usage - One-line trait implementation

📦 Installation

composer require impactlabs/laravel-error-tracker

Publish the config and migrations:

php artisan vendor:publish --tag=error-tracker
php artisan migrate

🚀 Quick Start

Option 1: Using Traits (Recommended)

use ImpactLabs\ErrorTracker\Traits\TracksBusinessErrors;

class Campaign extends Model
{
    use TracksBusinessErrors;
    
    public function process()
    {
        try {
            // Your business logic
        } catch (\Exception $e) {
            // One line - auto-detects context!
            $this->reportError($e);
            throw $e;
        }
    }
}

Option 2: Manual Reporting

use ImpactLabs\ErrorTracker\Facades\ErrorTracker;

ErrorTracker::report($exception)
    ->withAdvertiser($advertiserId)
    ->withCampaign($campaignId)
    ->withRevenueImpact(5000.00)
    ->withUserTier('premium')
    ->send();

Option 3: Global Handler

// In app/Exceptions/Handler.php
public function register()
{
    $this->reportable(function (\Throwable $e) {
        \ImpactLabs\ErrorTracker\Facades\ErrorTracker::report($e)->send();
    });
}

⚙️ Configuration

Configure in .env:

# Enable tracking
ERROR_TRACKER_ENABLED=true
ERROR_TRACKER_ASYNC=true

# Elasticsearch forwarding
ES_ERROR_TRACKER_ENABLED=true
ES_ERROR_TRACKER_HOST=http://localhost:9200

# WhatsApp notifications
WHATSAPP_ERROR_ENABLED=true
WHATSAPP_API_URL=your-whatsapp-api-url
WHATSAPP_ERROR_PHONE=8801234567890
WHATSAPP_ACCESS_TOKEN=your-token

# Slack notifications
SLACK_ERROR_ENABLED=true
SLACK_ERROR_WEBHOOK=your-slack-webhook

📊 View Top Errors

# Show top errors by priority
php artisan error-tracker:top

# Show by revenue impact
php artisan error-tracker:top --by=revenue

# Show for specific advertiser
php artisan error-tracker:top --advertiser=123

🔌 Supported Log Forwarders

Self-hosted

  • ✅ Elasticsearch
  • ✅ Graylog
  • ✅ Grafana Loki

Managed Services

  • ✅ Sentry
  • ✅ Datadog
  • ✅ Logtail (Better Stack)

Custom

  • ✅ Any HTTP endpoint

🧪 Testing

composer test

📝 Changelog

Please see CHANGELOG for more information on what has changed recently.

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email selimppc@gmail.com instead of using the issue tracker.

💖 Credits

📄 License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-29