The cat said

Sentry is a bug collection platform solution, and individual projects are free.

It is now mature enough to collect Dart, Flutter, and native errors at the same time.

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

The original

Medium.com/podiihq/err…

code

This way, you will be able to monitor and get error notifications and resolve them early before customers start complaining. Because working code = = happy customers.

reference

  • sentry.io
  • Pub. Flutter – IO. Cn/packages/se…

The body of the

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

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

You can report code errors to many services. However, in this article, you’ll learn how to monitor applications and potential errors or bugs and report them using Sentry.

What is a 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:

sentry.io/signup

Create a new Sentry Flutter application

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

Follow these steps to successfully create a new project.

  • Creating a new project

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

  • Choose a development platform

A variety of development platforms support Sentry, including Python, Express, Spring Boot, Android, and more, but this article focuses only on Flutter. Therefore, select Flutter from the list.

  • Set default alert Settings

Next, set the default alert Settings to when and how often to get alerts if any errors occur. In this article, I’ll choose the alert option to get any new issues, but you can always choose any option you want.

  • Finally, give your project a name

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

  • Get DSN from Sentry

To report errors to Sentry, you need a DSN (data source name) that uniquely identifies 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 follows:

Next, after selecting the client key, the client key TAB will display and from there you will copy the DSN as follows:

Create a Flutter application to report errors to Sentry

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

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

On the terminal, enter $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
Copy the code

Note: You can also create applications on your own 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 the configuration that will catch unhandled exceptions in your application. In this step, replace the DSN URL with the Sentry DSN in the application you created in Step 2. Get a DSN from the Sentry above.

You can also configure sentr_ DSN with the 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'
Copy the code

validation

Finally, in this step, verify that an 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 confirm this by navigating to your Sentry application

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

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

Click here to see the full code snippet:

Github.com/JosephineAk…

This way, you will be able to monitor and get error notifications and resolve them early before customers start complaining. Because working code = = happy customers.


The elder brother of the © cat

ducafecat.tech/

github.com/ducafecat

space.bilibili.com/404904528

The issue of

Open source

GetX Quick Start

Github.com/ducafecat/g…

News client

Github.com/ducafecat/f…

Strapi manual translation

getstrapi.cn

Wechat discussion group Ducafecat

A series of collections

The translation

Ducafecat. Tech/categories /…

The open source project

Ducafecat. Tech/categories /…

Dart programming language basics

Space.bilibili.com/404904528/c…

Start Flutter with zero basics

Space.bilibili.com/404904528/c…

Flutter combat news client from scratch

Space.bilibili.com/404904528/c…

Flutter component development

Space.bilibili.com/404904528/c…

Flutter Bloc

Space.bilibili.com/404904528/c…

Flutter Getx4

Space.bilibili.com/404904528/c…

Docker Yapi

Space.bilibili.com/404904528/c…