Getting Started with Sentry.io Error Tracking

This article was created in partnership with Sentry. Thank you for supporting the partners who make SitePoint possible.

Writing code can be fun. Testing it is another matter. Of course, SitePoint readers always produce bug-free applications but errors can still slip into the best production code. How can you detect those issues?…

Tests

Writing software to test software is one option. Unit and integration testing can be adopted to verify functions and interfaces accordingly. Unfortunately:

  1. It can be difficult to write tests when product requirements are evolving.
  2. Are you sure your tests cover every option and pathway?
  3. Who’s testing your tests?
--ADVERTISEMENT--

Tests help, but the industry still releases software with bugs because it’s impossible to cover every eventually. Does a bug occur in a certain browser, on a particular OS, at a specific time of day?

In addition, browser testing is notoriously complicated owing to:

  • Multiple devices and applications. There’s a long tail of old, new, and obscure browsers across desktop PCs, tablets, smartphones, TVs, games consoles, smart watches, IoT devices, and more. It’s impossible to test everything.
  • User control. Any user can choose whether to download, block or modify any part of your application. For example, Firefox will block Google Analytics when tracking is disabled; recording an Analytics event could cause the whole application to fail.
  • Network failures. Even if the user permits every file you throw at them, there’s no guarantee they’ll receive all images, CSS, JavaScript and other assets. Travelling or using flaky hotel wi-fi exacerbates the problem.

User Feedback

Have you ever watched someone using your software? They always do something you never expected. I wince every time I see someone enter a URL into the Google.com search box.

Humans are adept at finding their own methods to complete tasks based on previous experience. Those processes may or may not be efficient, but they’ll rarely match your expectations because your experiences are different. A bug may occur because a sequence of tasks is tackled in a manner that seems illogical to you.

Additionally, the majority of users will never report a bug. They won’t know whether the fault occurred in your app, the browser, or the OS. Many may blame themselves, will not know who to contact, or simply switch to a competing product.

Users who do report issues will rarely be able to describe the problem unless they have software engineering expertise. It’s frustrating to be faced with dozens of “ProductX doesn’t work” issue tickets.

Ultimately, should we rely on customers to report problems?

Logging

Logging errors is a possibility but:

  1. How do you log errors that are completely unexpected?
  2. Will the logging code still run if your application fails?
  3. How do you log errors in environments outside your control, such as a browser?
  4. A single error could be logged tens of thousands of times after deployment. Identifying critical flaws amongst known problems can be difficult.

Fortunately, Sentry.io provides a logging-on-steroids solution which can capture the most obscure problems.

Sentry.io Quickstart

Sentry.io is an open-source full-stack error tracking system which supports a wide range of server, browser, desktop and native mobile languages and frameworks including PHP, Node.js, Python, Ruby, C#, Java, Go, React, Angular, Vue, JavaScript and more. The system is used by Dropbox, AirBnB, PayPal, Uber, reddit, Mozilla, MailChimp, and Microsoft to monitor thousands of applications.

Sentry.io developer accounts are free with commercial options for larger teams generating thousands of events across multiple projects. You can sign-up quickly using a GitHub, Azure DevOps, or Sentry.io account.

On log-in, you’ll be prompted to start a new project by entering its name and choosing a technology:

Sentry.io project settings

You will then be issued with code to insert into your application. A typical example for client-side JavaScript requires a couple of new lines:

Sentry.io integration settings

You may need to set-up multiple monitors to detect issues in your application’s browser UI, mobile app, and back-end server at the same time.

The whole process takes a few minutes. Once your application is deployed, any errors encountered by users – whether they are aware of them or not – are automatically captured and tracked in real time on the Sentry.io issue stream:

Sentry.io issue stream

Identical problems are presented as a single entry which reports how many times it was triggered and how many users were affected. Further details can be examined to determine the product version, issue severity, OS, browser, IP address, dates, call stack, etc:

enter image description here

Sentry.io features beyond the basics include:

  • configuration settings to define release versions, code repositories, server names, URLs, etc.
  • user information, messages, tagging, and custom events
  • user feedback widgets to record further information
  • inbound message filtering rules
  • issue assigning to team members
  • bookmarking, resolving, ignoring, sharing and deleting issues
  • activity and issue reports
  • a command-line executable to report OS or build issues
  • a full API to submit, retrieve, update, delete and manage event data
  • on-premise installations
  • robust security with optional two-factor authentication
  • chat integration with Slack, HipChat and others
  • commercial and community support options.

Sentry.io is logging more than 20 billion errors per month (mostly from my code!) Developer accounts are free and include 5,000 errors per month. Employ Sentry.io as the newest member of your Q&A team today!