- vừa được xem lúc

Sentry, User Feedback and Ruby

0 0 17

Người đăng: Sujoy Datta

Theo Viblo Asia

The first time i searched about sentry in the internet was quite a confusing time. Because google was showing some comic character from marvel where i was told that sentry is a great tool for detecting errors and exceptions in an application. Setting aside my interest for this newly found superhero(who can defeat batman ?), I concentrated on the sentry i wanted to know and below is the glimpse of some of my findings.

Sentry

Even an well-coded and well-tested application can have exceptional error scenario that can be hard to debug and ressolve. Sentry comes like a messiah in this situation. So the question may arise, What this actually is? Sentry is an open-source real time error tracking system in all the environments of an application lifecycle. It is an easily configurable system which support many programming languages and their framworks in frontend, backend, mobile and desktop like Java, Python, Ruby, React, c#, PHP and more. Many reknowed companies as well as start-ups have given their faith in their product development and producing smooth and error-free systems for the users.

Installation in Rails

Creating an account in sentry is free for developers(although the error tacking number is limited) with the option of enterprse options with unlimited track. To connect the project with sentry we need to create an account in sentry and collect the DSN string for communicate project with sentry. This DSN value is a secret key assigned for the project. So we should handle it with care. For this we will save the DSN value in environmental variable file as SENTRY_DSN and call it in the project asENV["SENTRY_DSN"] .

Now to ease the integration of sentry has an official gemfile named sentry-ruby . To use this we need to follow 2 steps:

  1. Add
gem "sentry-ruby"

in the gemfile and run bundle install.

  1. In the application.rb simply add the DSN value we created and restart the server.
Sentry.init do |config| config.dsn = ENV["SENTRY_DSN"]
end

voila!!

Testing

After integrating the sentry in the project, next we can create an exception from our console(dont forget to restart the console too). Run this code from the console you will see an entry of exception in your own dashboard.

Sentry.capture_message("hello") begin 1 / 0
rescue ZeroDivisionError => exception Sentry.capture_exception(exception)
end

and in the list: when you enter the error description:

User feeback

User feedback is one of the enriching features of sentry system. It allows an end-user to volunteerily contribute to the source of an error. It is an excellent feature for the developers to recreate the bug scenario and fix them in the path of making a good software. This is particularly advantageous when the application has a error page known as 500 page. Enabling this feature in ruby projects is not so hazzardous but need to follow some steps. I am discussing the steps below:

  1. First we will create a 500 page for our application. It will be shown when an unexceptional error or exception occurs. So our 500.slim page will be:
= image_tag "error_500.png", class: "error-page-image"

which will generate

  1. To collect feedback, we will use the embeddable JavaScript widget, which requests and collects the user's name, email address, and a description of what occurred. When feedback is provided, Sentry pairs the feedback with the original event, giving you additional insights into issues. To integrate the widget, we need to be running version 2.1 or newer of our JavaScript SDK. The widget authenticates with your public DSN, then passes in the Event ID that was generated on your backend. To add this we simply need to include sentry raven js in our 500 page. and call the API to show the user feedback dialogue box. so our 500 page will be
= image_tag "error_500.png", class: "error-page-image" = javascript_include_tag "path/to/sentry_raven.js" javascript: Raven.showReportDialog({ eventId: '#{Raven.last_event_id}', dsn: '#{ENV["SENTRY_DSN"]}' });

Now it will show the feedback form first like this

  1. Next step is to just fill this form up and submit the report. The person responsible to fix this issue can see the feedback in error page of that particular error

Thank you for reading

References: https://www.sitepoint.com/getting-started-with-sentry-io-error-tracking/ https://github.com/getsentry/sentry-ruby

Bình luận

Bài viết tương tự

- vừa được xem lúc

Bài toán tìm đường đi ngắn nhất với giải thuật Dijkstra

Với các bạn sinh viên chuyên ngành công nghệ thông tin, chắc không lạ gì với bài toán tìm đường đi ngắn nhất (Shortest Path Problems) trong đồ thị trọng số nữa. Ở bài viết lần này, mình sẽ làm 3 việc:.

0 0 122

- vừa được xem lúc

Tôi cá là bạn không biết những điều này - Ruby on rails ( Phần 2)

Các bạn có thể theo dõi phần 1 ở đây :. https://viblo.asia/p/toi-ca-la-ban-khong-biet-nhung-dieu-nay-ruby-on-rails-phan-1-WAyK8DDeKxX. 5.

0 0 211

- vừa được xem lúc

Những thay đổi trong ruby 3.0

. 2020 là một năm lớn đối với cộng đồng Ruby. Những người sáng lập Ruby có một món quà thực sự tuyệt vời cho chúng ta vào giáng sinh với việc phát hành Ruby 3.

0 0 31

- vừa được xem lúc

Có gì đặc biệt trong phiên bản Ruby 3x3 ?

Hello guys, chắc hẳn thời gian vừa rồi chúng ta cũng đã nghe qua thông tin Ruby sắp cho ra mắt Ruby version 3, hay còn được gọi là ruby 3x3, vậy liệu Ruby version 3 này có gì mới, và có những update nào đáng phải kể đến, và tại sao mọi người lại gọi nó là ruby version 3x3, thì trong bài ngày hôm nay

0 0 30

- vừa được xem lúc

Cách sử dụng class Time & Date trong Ruby (Phần 1)

Time là một class trong Ruby, nó sẽ giúp chỉnh sửa format, trích xuất thông tin một cách hiệu quả theo ý của bạn. . Topic hôm nay chúng ta có gì nào. .

0 0 83

- vừa được xem lúc

Ruby 3.0 có gì mới

Ruby 3.0.0 đã được ra mới được ra mắt vào tháng 12/2020, mục tiêu của bản 3.0.

0 0 26