network_pulse

pub.dev License: MIT

Universal Flutter HTTP & Dio network monitoring, in-app debug inspector, and automated Telegram error alert dispatcher with zero-leak token security.


🌟 Features

  • 🌐 Universal Networking Support: Works seamlessly with Dio, http, Retrofit, GetConnect, and Chopper.
  • 📱 In-App Floating Inspector Overlay: Non-intrusive debug bubble displaying real-time HTTP calls, status codes, latency, formatted JSON, and 1-tap cURL export.
  • 🚨 Automated Telegram Alerts: Instantly sends markdown error reports to your Telegram Bot/Group on 5xx Server Errors, 4xx Client Errors, or Timeouts.
  • 🔒 Zero Token Leaks (.gitignore Protected): Read secrets via .env files or generated configs without committing sensitive bot tokens to Git version control.

🚀 Quick Start

1. Installation

Add network_pulse to your pubspec.yaml:

dependencies:
  network_pulse: ^0.0.1

2. Initialization

Initialize NetworkPulse in your main.dart:

void main() {
  NetworkPulse.init(
    telegramBotToken: const String.fromEnvironment('TELEGRAM_BOT_TOKEN'),
    telegramChatId: const String.fromEnvironment('TELEGRAM_CHAT_ID'),
    notifyOn5xx: true,
    notifyOnTimeouts: true,
    ignoredPaths: ['/ping', '/health'],
  );

  runApp(
    const NetworkPulseOverlay(
      child: MyApp(),
    ),
  );
}

3. Attach Interceptors

For Dio / Retrofit:

final dio = Dio();
dio.interceptors.add(NetworkPulse.dioInterceptor());

For package:http:

final client = NetworkPulse.httpClient();
final response = await client.get(Uri.parse('https://api.example.com/data'));

🔒 Security Best Practices

To prevent committing sensitive Telegram Bot Tokens and Chat IDs to GitHub:

  1. Store credentials in a .env file or pass via --dart-define:
    flutter run --dart-define=TELEGRAM_BOT_TOKEN="YOUR_BOT_TOKEN" --dart-define=TELEGRAM_CHAT_ID="-1001234567890"
    
  2. Always add .env and .g.dart to your .gitignore:
    # NetworkPulse Secrets
    .env
    *.g.dart
    

📄 License

MIT License. Created & maintained by Ibrohim Qobilov.

Libraries

network_pulse