Getting Started with Sentry.io Error Tracking

    Craig Buckler
    Craig Buckler
    Share

    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?

    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!

    Frequently Asked Questions (FAQs) about Sentry.io Error Tracking

    What is Sentry.io and how does it work?

    Sentry.io is an open-source error tracking tool that helps developers monitor and fix crashes in real time. It works by integrating with your application, capturing errors and exceptions as they occur, and providing detailed insights into the issues. This includes information like stack traces, user information, and more. Sentry.io supports multiple programming languages and platforms, making it a versatile tool for diverse development environments.

    How do I integrate Sentry.io into my application?

    Integrating Sentry.io into your application involves installing the Sentry SDK (Software Development Kit) that corresponds to your programming language or platform. Once installed, you’ll need to configure it with your DSN (Data Source Name) from Sentry.io. This allows the SDK to send error data to your Sentry.io account. The exact steps can vary depending on your specific language or platform.

    Can Sentry.io be removed from the server?

    Yes, Sentry.io can be removed from your server if you no longer wish to use it. The process involves uninstalling the Sentry SDK from your application and removing any related configuration settings. However, it’s important to note that removing Sentry.io will stop the error tracking and you won’t receive any insights into the issues occurring in your application.

    What programming languages and platforms does Sentry.io support?

    Sentry.io supports a wide range of programming languages and platforms. This includes popular languages like JavaScript, Python, Ruby, Java, and PHP, as well as platforms like Node.js, Android, iOS, and more. This makes it a versatile tool that can be used in diverse development environments.

    How does Sentry.io help in improving application performance?

    Sentry.io provides detailed insights into the errors and exceptions occurring in your application. This includes information like stack traces, user information, and more. By analyzing this data, developers can identify the root cause of issues and fix them quickly. This helps in improving the overall performance and reliability of the application.

    Is Sentry.io a free tool?

    Sentry.io offers both free and paid plans. The free plan includes basic features and is suitable for small projects or individual developers. The paid plans offer more advanced features and are designed for larger teams and projects.

    How does Sentry.io handle user data?

    Sentry.io takes user data privacy very seriously. It provides features like data scrubbing and anonymization to help protect sensitive user information. Additionally, Sentry.io complies with major data protection regulations like GDPR and CCPA.

    Can I use Sentry.io for mobile application error tracking?

    Yes, Sentry.io supports error tracking for both Android and iOS mobile applications. It provides detailed insights into the issues occurring in your mobile apps, helping you improve their performance and reliability.

    How does Sentry.io compare to other error tracking tools?

    Sentry.io stands out for its real-time error tracking capabilities, wide range of supported languages and platforms, and detailed error insights. It also offers a user-friendly interface and flexible pricing plans, making it a popular choice among developers.

    What kind of support does Sentry.io offer?

    Sentry.io offers comprehensive support to its users. This includes detailed documentation, community forums, and direct support for paid users. This ensures that users can get the help they need when using Sentry.io.