The cat said

Sentry is an error collection platform solution, and individual projects are free.

It is now quite mature for Flutter to collect errors from Dart, Flutter, and native side at the same time.

In the enterprise, Brother Cat has built the Sentry service by himself, which can be privatized.

Be sure to retweet brother for more Flutter posts at ~~~~

Ducafecat WeChat group

B stationhttps://space.bilibili.com/40…

The original

https://medium.com/podiihq/er…

code

This way, you will be able to monitor and get error notifications and resolve customer complaints before they start. Because working code = = happy customers.

reference

  • https://sentry.io
  • https://pub.flutter-io.cn/pac…

The body of the

Imagine you’re an independent developer, you build a new feature before you go on vacation, you deploy it into production a few days before the weekend, and when customers start actively using it, user problems and complaints start popping up, you’ve kicked off your vacation mood. As the usual slogan goes, “The customer is always right”, you decide to prioritise customer satisfaction over the holidays and get back in the mood for work. It can be frustrating, right?

Here’s how to report errors to the service to avoid unknown potential errors or problems before the customer, because the working code equals a satisfied customer.

You can report code errors to a number of services. However, in this article, you’ll learn how to monitor your application and potential errors or bugs, and report them using Sentry.

What is Sentry?

Sentry is an application monitoring platform that enables developers to monitor, diagnose, fix, and optimize the performance of their code.

Let’s get started

Create an account using Sentry

If you don’t already have an account on Sentry, create one here:

https://sentry.io/signup

Create a new Sentry Flutter application

Next, log in to the Sentry account you just created to create the Flutter application.

Follow these steps to successfully create the new project.

  • Create a new project

Once logged in, select the Create Project icon to create a new project.

  • Select development platform

There are various development platforms that support Sentry, including Python, Express, Spring Boot, Android, and more, but this article will focus on Flutter. Therefore, select Flutter from the list.

  • Set the default alarm Settings

Next, set the default alarm setting to how often and when to get alerts when any errors occur. In this article, I’ll select the option to get alerts for any new issues, but you can always select any option you want.

  • Finally, give your project a name

In this article, I’ll name it Whistle Test, and then create the project.

  • Get the DSN from Sentry

To report errors to Sentry, you need a DSN (data source name) that will uniquely identify your application with the Sentry service. Therefore, after creating the project on Sentry, we will copy the DSN from the application created in the previous steps.

To get the DSN, in the project you just created from above, navigate to the project Settings and scroll down to the Client Key (DSN), as shown below:

Next, after selecting the client key, the client key TAB will be displayed and from there you will copy the DSN, as shown below:

Create a Flutter application to report errors to Sentry

This step assumes that you already have some practical experience on how to create a new Flutter project. If you are new to Flutter check the official Flutter file. You can also check out my article How to Start with Flutter.

Now let’s create a sample Flutter application that will report errors to the Sentry service.

On the terminal, type $flutter create Command, followed by the name of the application. In this case, we will use the name Flutter Sentry Test.

$ flutter create flutter_sentry_test

Note: You can also create applications on your respective IDE to your liking.

Import the Flutter Sentry package

Install Sentry in your application and add it to the pubspec.yaml file

Configure and initialize the Sentry SDK

In the main.dart file, import the Sentry package.

Next, add a configuration that will catch unhandled exceptions in the application. In this step, replace the DSN URL with the Sentry DSN in the application that you created in Step 2. Get a DSN from the Sentry above.

You can also configure SENTRY \_ DSN via a DART environment variable by passing the — Dart-define flag to the compiler, as shown in the following example:

--dart-define SENTRY_DSN = 'https://your-sentry.io DSN'

validation

Finally, in this step, you verify that the error was sent by adding a conscious error to the code for testing purposes.

This will throw a State Error, which will be sent to the Sentry. IO service

You can verify this by navigating to your Sentry application

In my case, here is the State Error that was sent to my Flutter Sentry application

Here is a demonstration of how the sample application sends an error to Sentry:

See the full code snippet here:

https://github.com/JosephineA…

This way, you will be able to monitor and get error notifications and resolve customer complaints before they start. Because working code = = happy customers.


The elder brother of the © cat

https://ducafecat.tech/

https://github.com/ducafecat

The issue of

Open source

GetX Quick Start

https://github.com/ducafecat/…

News Client

https://github.com/ducafecat/…

Strapi manual translation

https://getstrapi.cn

WeChat discussion group Ducafecat

A series of collections

The translation

https://ducafecat.tech/catego…

The open source project

https://ducafecat.tech/catego…

DART programming language basics

https://space.bilibili.com/40…

Flutter Zero Basics Beginners

https://space.bilibili.com/40…

Flutter combat news client from scratch

https://space.bilibili.com/40…

Flutter component development

https://space.bilibili.com/40…

Flutter Bloc

https://space.bilibili.com/40…

Flutter Getx4

https://space.bilibili.com/40…

Docker Yapi

https://space.bilibili.com/40…