telegram_bot_crashlytics 1.1.0 copy "telegram_bot_crashlytics: ^1.1.0" to clipboard
telegram_bot_crashlytics: ^1.1.0 copied to clipboard

A new Flutter package which xullas apidan kelgan bad responcelani telegram guruhingizga tashlab beradi

Telegram Bot Crashlytics #

Telegram Bot Crashlytics is a package that works with the Dio library to send application errors directly to Telegram. With this package, you can send errors from your app to your Telegram group or channel in real-time.

Created by JaysonKhan

Features #

  • Automatic error reporting to Telegram.
  • Monitors any HTTP errors via a Dio interceptor.
  • Allows sending additional messages (for example, user notifications or system status updates).
  • Retrieves detailed device information and appends it to error messages for enhanced debugging.
  • Lets you selectively ignore specific HTTP status codes with the ignoreStatusCodes parameter.

Installation #

Add the following line to your pubspec.yaml file:

dependencies:
  telegram_bot_crashlytics: ^1.1.0

Or, install it via the command line:

flutter pub add telegram_bot_crashlytics

Usage #

1. Creating a Bot #

To create a new bot in Telegram, contact BotFather and obtain the bot token.

How to get bot token How to get chat ID

2. Obtaining the Telegram Chat ID #

Identify the Chat ID of the group or channel where you want to receive messages. You can find this by sending a message to yourself or the bot and then accessing it through the API:

https://api.telegram.org/bot<your-bot-token>/getUpdates

3. Verifying the Result from Chat #

After sending a test message, you should see a response similar to the following:

Result from chat

4. Setting up Telegram Bot Crashlytics #

Configure the package in your app as follows:

import 'package:telegram_bot_crashlytics/telegram_bot_crashlytics.dart';

void main() {
  // Set up Telegram Bot Crashlytics
  final telegramCrashlytics = TelegramBotCrashlytics(
    botToken: 'YOUR_BOT_TOKEN',
    chatId: YOUR_CHAT_ID,
    ignoreStatusCodes: [400, 404], // Add ignored status codes here
  );

  // Set up Dio and add the interceptor
  final dio = Dio();
  dio.interceptors.add(telegramCrashlytics.interceptor);
}

5. Monitoring Errors #

When making HTTP requests with Dio, errors are automatically sent to Telegram via the interceptor.

If you want to manually send a message outside of Dio errors:

await telegramCrashlytics.sendErrorToTelegram("Describe the error here.");
await telegramCrashlytics.sendInfoToTelegram("Provide additional information here.");

Additional Settings #

  • Device Information:

    • Automatically adds device details (e.g., Android model, iOS version) to error messages.
    • Each device type is represented with an emoji sticker for quick identification in Telegram.
  • Selective Ignoring of HTTP Status Codes:

    • Use the ignoreStatusCodes parameter to exclude specific status codes from being sent to Telegram.

Example #

// Executing HTTP request with Dio
final response = await dio.get('https://jsonplaceholder.typicode.com/posts');

// If an error occurs, it will be automatically sent to Telegram by the interceptor.

Join Our Channel #

Join our Telegram channel for updates and Flutter tips: @FlutterMarkazi


Support the Project #

If you like this project and want to support me, consider buying me a coffee or donating via USDT TRC20:

  • Buy Me a Coffee: KHAN347
  • USDT TRC20 Wallet: TPXnvYAYcsf1tMrqWfpmDy5swFpiJ737br
12
likes
0
points
387
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter package which xullas apidan kelgan bad responcelani telegram guruhingizga tashlab beradi

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

device_info_plus, dio, flutter, http, logging

More

Packages that depend on telegram_bot_crashlytics