Monitoring 101 for React Developers

    Rate this content
    Bookmark

    If finding errors in your frontend project is like searching for a needle in a code haystack, then Sentry error monitoring can be your metal detector. Learn the basics of error monitoring with Sentry. Whether you are running a React, Angular, Vue, or just “vanilla” JavaScript, see how Sentry can help you find the who, what, when and where behind errors in your frontend project.

    This workshop has been presented at React Advanced 2023, check out the latest edition of this React Conference.

    FAQ

    Sentry is an application monitoring tool that helps developers detect issues in their applications quickly. It provides functionalities such as error tracking, performance monitoring, and issue resolution insights, enabling developers to pinpoint and fix problems efficiently.

    Sentry can be integrated into Next.js applications by setting up a Sentry project and configuring it to monitor the application. This includes installing necessary SDKs, setting up source maps for better error tracking, and configuring alerting and issue assignments for operational efficiency.

    Key features of Sentry's monitoring tools include error tracking, performance monitoring, distributed tracing, and session replay. These features help developers understand the health of their applications, diagnose issues, and improve user experience.

    Sentry's session replay feature captures user interactions with an application, allowing developers to see exactly what users experienced leading up to an issue. This helps in diagnosing problems that may not be directly apparent from error logs or performance metrics alone.

    Distributed tracing in Sentry provides a detailed view of requests as they travel through different services and infrastructure layers. It helps developers identify performance bottlenecks and understand the behavior of complex systems, leading to more effective troubleshooting and optimization.

    Yes, Sentry integrates seamlessly with existing development workflows through its support for various programming languages, frameworks, and integration with other tools like GitHub, Slack, and JIRA. This flexibility allows teams to adopt Sentry without disrupting their current processes.

    Setting up Sentry for a Next.js application involves creating a Sentry account, installing the Sentry SDK, configuring your project in Sentry to capture errors and performance data, and optionally setting up source maps for better error diagnostics.

    Lazar Nikolov
    Lazar Nikolov
    Sarah Guthals
    Sarah Guthals
    112 min
    16 Oct, 2023

    Comments

    Sign in or register to post your comment.
    • Sergio Vinicius de Sa Lucena
      Sergio Vinicius de Sa Lucena
      Nord Security
      Did you guys record the workshop? If so, Is there a link we could use to watch it?
    • Maria Eugenia Trapani
      Maria Eugenia Trapani
      Eleven labs
      Hello, could you please share the meeting passcode? Zoom is asking it to join the call. Thanks
    Video Summary and Transcription
    In this workshop, we will discuss monitoring and debugging with Sentry, focusing on Next.js. We'll cover setting up a Sentry project, configuring source maps, adding event context and custom tags, and resolving errors. Sentry helps developers quickly identify and resolve issues in their code, providing valuable context like stack traces, breadcrumbs, and session replay. Integrations with services like GitHub and Slack enhance error management, and alerts can be customized based on specific metrics. Distributed tracing allows for tracking performance issues, and session replay provides valuable context for debugging errors.

    1. Introduction to Monitoring and Sentry

    Short description:

    In this workshop, we will discuss monitoring in general, specifically for React apps, with a focus on Next.js. We'll cover setting up a Sentry project, configuring source maps, adding event context and custom tags, and more. After a short break, Lazar will talk about alerts, performance errors, distributed tracing, and session replay. We will share links and slides, and there will be time for Q&A. Monitoring helps detect and resolve issues that cause poor user experiences, such as slow page loads or unresponsive buttons. Sentry provides developers with timely information and context to fix these issues quickly. The goal is to resolve issues before users become frustrated and abandon the app. Sentry aims to detect and resolve issues as quickly as possible, ensuring most users never even know there was an issue. Some users in the chat expressed interest in using performance monitoring but find it challenging to understand what's happening.

    Alright, so let's go ahead and get started. My name is Sarah Goethals and I lead DevRel at Sentry. Sentry is an application monitoring tool company. We are – hello from Germany. We are here to tell you a little bit about monitoring in general, specifically for React apps. Specifically, the example we're going to use is a Next.js app. As I was mentioning, this app is open source. It's publicly available from Portugal. Welcome. So you're welcome to check it out. We'll have links at the end for you, and we'll share these slides with you as well. You're not necessarily intended to follow along specifically, but if you want to, you're welcome to open up a Next.js app or React app in your favorite editor. I'm going to be using VS Code today, and you're welcome to try things out. I do recommend you sign up for maybe a free Suntry account to get started, but you don't necessarily have to follow along. The intention is that we'll share these slides with you afterwards, and we'll give you very actionable steps for how to do this later if you so choose. Again, just a quick reminder, this is recorded. Feel free to add questions throughout the workshop in the chat. At about an hour, we will take a short break. So yeah, let's go ahead and get started.

    So this is what we're going to be talking to you about. Oh, sorry, I totally blanked. Lazar, please introduce yourself. Hey everyone, I'm Lazar. I'm with everyone here at Suntry. I'm originally from Macedonia too, just like our Archilka, but I'm right now in Toronto, Canada. Yeah, I'm excited to be here. I think this is going to be a really good workshop. I love doing workshops, especially with alongside with Sarah. So yeah. Awesome. Let's make this happen. All right, let's go ahead and get started. So today we're going to talk to you a little bit about getting up and running with your Next.js and React app with Suntry. So I'll go over a brief introduction to what monitoring is. I'll show you how to actually set up a Suntry project, configure source maps so that you can find the exact kind of code that is causing your performance or errors, performance issues or errors, And also walk you through adding event context and custom tags to make things a little bit easier and more actionable to resolve quickly. And then we'll take a short break and I'll pass it off over to Lazar who will talk a little bit about alerts, performance errors. So setting up alerts and issue assignments, a little into distributed tracing, and session replay. We'll give you a quick summary. We'll share links with you, we'll share this slide deck with you, and we'll go ahead and get started. Again, just quick reminder, feel free to ask questions there in the chat. And we will have time for Q&A at the end, or we should have time for Q&A at the end. So if you want to save questions for them, that's fine as well, but feel free to ask them throughout. All right, perfect. So I'm kind of curious if you use a monitoring tool, maybe just in the chat, share what tool you use or if you use it, you don't necessarily have to say what it is, it's okay if you don't use Sentry and you use something else. Just generally curious what folks' experiences with application monitoring. And if you want, feel free to also talk about what the biggest benefit to using it has been for you. As you do this, lots of Sentry, that's exciting.

    A little bit about what monitoring is. This is a pretty hard question to answer in just a couple of slides and we really wanted to focus this workshop on something actionable. We expect that you all are developers or SREs or folks who will actually be using these tools and trying to resolve issues as quickly as possible, capturing possible errors and misbehaviors, yes. So I wanted to give just a quick, quick overview of what monitoring is. Essentially, there's some kind of poor user experience. Maybe this is a slow page load or something on the page is taking too long to render or a button is being unresponsive. There could be an actual error. It could just be a slow API call. Something that is causing a poor user experience. Some folks in the chat are also adding some other things that it can be useful for. For example, customer support team needing to understand the issues people are facing. Again, some kind of poor user experience. The user becomes frustrated. That typically leads to them immediately just abandoning their cart or switching over to a different app or getting distracted by something else because it's taking too long. Oftentimes, by the time developers realize something is an issue, maybe they're going through customer support. As I've mentioned in the chat, developers are too late for at least those folks that ran into that issue. Sometimes that can be a big problem. Sometimes you don't even know until people are complaining on some social media app or just tagging people, spamming the customer support, spamming the help buttons, etc. We might have all experienced this, I know I have. What Sentry tries to offer instead is an opportunity for Sentry to detect issues that users are facing as quickly as possible. Give those detected issues, whether they're performance issues or errors to developers as quickly as possible with as much context and information as possible so that developers can fix the issue quickly. Ideally, what happens is, yes, maybe some users will still experience the issue, but most users never even know that the issue was a thing because the issue was resolved as quickly as possible. Someone mentioned in the chat wanting to use performance monitoring more, but finding it complicated to understand what's happening.

    2. Introduction to Sentry Setup

    Short description:

    Sentry focuses on enabling developers to quickly identify and resolve problems in their code. In this workshop, we will explore a flashcard app built with Next.js and deployed with Percel. We will guide you through setting up a new React project with Sentry, configuring source maps, and adding event context and custom tags. Follow along with the provided demo repo or use your own application. Let's get started by creating a new project in Sentry and choosing Next.js as the platform. We will walk you through the necessary steps and explain the benefits of uploading source maps. Join us in the chat if you have any questions.

    Hopefully, we'll talk a little bit about that as well today. Specifically, what Sentry likes to focus on is the ability for developers to take action. I said this a couple of times already, as quickly as possible, know what the problem is, know where the problem is, know who on your development team can resolve the problem, alert that person in the appropriate way to alert them, depending on how your team or company operate, and enable them to fix and redeploy as quickly as possible. Whether it's broken lines of code, crashes, busted API calls, we try to focus on being developer first to give you answers, not just clues. We want to demonstrate a little bit about that today. If anyone has a question on that, please feel free to ask in the chat.

    Otherwise, we're going to start exploring some of this in the actual app. We're going to do a demo for you. This is a live demo with actual code and an actual Sentry project, so knock on wood that things don't go too haywire. But of course it probably will because that's how demos work. I hope the demo guys are with us today. Hopefully, it's getting a little windy here. I'm here in Washington state and it's not raining yet, but it is a little windy, and I'm using a Starlink for my Internet. Sometimes when it's a little windy, it blows my Internet away. That's how Internet works, right? We're going to be walking you through a flash card app. This was built with Next.js, and it's deployed with Percel. You can see the GitHub link here, and I'll paste this in the chat for you if you want to check it out, and you don't want to copy all of that down. Again, if you want to follow along either with this demo repo, you will need a Planetscale account or other kind of database. I think this one specifically, is currently set up for Planetscale database, but you'll need a Sentry account with an auth token, and then the read me is pretty detailed for you. You can also use your own demo or your own application, if you want, and what we're going to do, is we're going to set up a new React project with Sentry, specifically an XJS project. We're going to configure source maps, and we're going to add event context and custom tags. I'm going to be unsharing and sharing my screen in a lot of different ways, just to kind of walk you through all of this.

    The first thing that we're going to do is I'm going to show you the repo, just so you can see, generally, what it is we're working with. All right. So here is our flashcard repository. Again, we've got a pretty detailed readme in here. Pretty simple to get started. There's even an exampleenv file, if that's useful for you. Pretty straightforward. Now, I'm going to share my VS code. All right. So, we've got. These darn Zoom things are always in my way. There we go. I have cloned this project in VS code. Specifically, if you are wanting to follow along and do things on your own local machine, and you have a Sentry account, specifically, I'm on the no-Sentry branch, the main branch does have Sentry already set up, or rather the files and has a lot of Sentry, so feel free to either just follow along on the main repo or you can follow along on this no-Sentry repo instead if you want. I did already set my dot env with my PlanetScale DB and all that, that has already been done, but other than that, we are going to be walking you through all of the steps ideally. This isn't quite annoying, I should've set up a third monitor here. I will do that next time. Now we're going to jump into Sentry, and I'm going to create a new project even though we already have one project here, two projects here for testing. I am going to create a new project just so that you can see this project starting from the beginning. When you create a new project in Sentry, you're offered a particular platform to choose from. We're using Next.js, that's what we've written it in, but you can see that we've got a ton of support. We support over 100 languages and frameworks. You can check those out there, but we're going to use Next.js. I'm going to just leave my alerts as alert for every new issue. Lazar will walk through different alerts that we can do later. We'll name this React Advanced London. We'll keep it in that team there. You click on ''Create project'' and it'll bring this essentially docs page. I am going to take advantage of this wizard. But we do have links to the docs that use this wizard. That would be here. Also again, all of these links are in the deck that I will share with you. But you can see that you can either set it up with the wizard or you can do it custom if you'd like. There's a setup the SDK manually here as well. In addition to that, we do have a couple of things that automatically happen when you are using the wizard. One of those things is this wizard for Next.js does automatically upload your source maps. I'm actually going to be removing that at the next step just so that you can see what uploading your source maps can look like and the benefits of it. But this will do it for you. We'll talk about why having your source maps is useful in just a moment. We're going to run this wizard here. I'm just going to copy this and then I'm going to pop on over to VS Code and throw this in the terminal. While I'm doing that, I will double-check on me. I can find the chat. It's going to ask me a couple of questions. Where did you go terminal? There you are. Let me make this little bigger for you. It's asking if we're using Sentry SaaS or self-hosted. We are using SaaS for this one.

    Watch more workshops on topic

    How to Solve Real-World Problems with Remix
    Remix Conf Europe 2022Remix Conf Europe 2022
    195 min
    How to Solve Real-World Problems with Remix
    Featured Workshop
    Michael Carter
    Michael Carter
    - Errors? How to render and log your server and client errorsa - When to return errors vs throwb - Setup logging service like Sentry, LogRocket, and Bugsnag- Forms? How to validate and handle multi-page formsa - Use zod to validate form data in your actionb - Step through multi-page forms without losing data- Stuck? How to patch bugs or missing features in Remix so you can move ona - Use patch-package to quickly fix your Remix installb - Show tool for managing multiple patches and cherry-pick open PRs- Users? How to handle multi-tenant apps with Prismaa - Determine tenant by host or by userb - Multiple database or single database/multiple schemasc - Ensures tenant data always separate from others
    Live Coding Workshop to Setup Rollbar Error Monitoring
    TypeScript Congress 2023TypeScript Congress 2023
    48 min
    Live Coding Workshop to Setup Rollbar Error Monitoring
    WorkshopFree
    Nico Krüger
    Nico Krüger
    During this session you will learn how to create a new Rollbar account and integrate the Rollbar SDK with your application to monitor errors in real-time and respond and fix those errors. We will also cover how to customize payload data sent to Rollbar to extend your monitoring capabilities.

    Agenda:- Create a Rollbar Account (Free Account)- Integrate your application with the Rollbar SDK- Send handled and unhandled errors to Rollbar- Add Custom payload data to your configuration.
    Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
    JSNation 2023JSNation 2023
    44 min
    Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
    WorkshopFree
    Ryan Albrecht
    Ryan Albrecht
    You know that annoying bug? The one that doesn’t show up locally? And no matter how many times you try to recreate the environment you can’t reproduce it? You’ve gone through the breadcrumbs, read through the stack trace, and are now playing detective to piece together support tickets to make sure it’s real.
    Join Sentry developer Ryan Albrecht in this talk to learn how developers can use Session Replay - a tool that provides video-like reproductions of user interactions - to identify, reproduce, and resolve errors and performance issues faster (without rolling your head on your keyboard).
    Building a Sentry: 7 years of open-source React
    React Advanced 2021React Advanced 2021
    69 min
    Building a Sentry: 7 years of open-source React
    Workshop
    Evan Purkhiser
    David Wang
    2 authors
    Join Sentry’s Evan Purkhiser and David Wang as they walk through Sentry’s 230k LoC Typescript/React codebase. They’ll tell war stories of the good, the bad, and the ugly. Gaze in wonder at their modern usage of Typescript, react hooks, and styled components. Recoil in disgust at their legacy Reflux usage and perplexing Webpack configuration. Step away from the workshop with a working knowledge of techniques to keep a large-scale frontend codebase modern and maintainable.

    Check out more articles and videos

    We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

    Mastering Error Handling Node.js
    Node Congress 2022Node Congress 2022
    21 min
    Mastering Error Handling Node.js
    Top Content
    This Talk explores error handling in Node.js, including types of errors, handling techniques, and debugging. It discusses the use of exceptions, callbacks, and promises for error handling. The importance of proper error handling and the benefits of using error classes, expressive error messages, and automated testing are emphasized. The speaker also addresses the use of TypeScript and test-driven development for error prevention. Overall, the Talk provides valuable insights and techniques for mastering error handling in Node.js.
    How Grafana Uses React to Power the World of Observability
    React Summit 2023React Summit 2023
    7 min
    How Grafana Uses React to Power the World of Observability
    Watch video: How Grafana Uses React to Power the World of Observability
    Grafana uses React to power its open source platform, leveraging its vast ecosystem, improved performance, and community contributions. The choice of state management tool depends on the team's problem space. React Hooks have posed challenges but have also been a powerful tool for developers. The new Scenes library simplifies development and reduces the learning curve. Despite challenges, React remains a powerful tool for complex frontends, and Grafana will continue to use it.
    Track Slowdowns and Crashes in your React apps
    React Advanced 2021React Advanced 2021
    8 min
    Track Slowdowns and Crashes in your React apps
    Sentry is a tool for code observability that supports multiple languages and frameworks. It allows monitoring of errors and performance in applications, such as React apps in an ecommerce site. With Sentry, developers can easily investigate errors using developer tools and get a summary of the error. It also provides human-readable stack traces that highlight the exact line of the error.
    Monitoring Errors and Slowdowns with a JS Frontend and Node Backend
    Node Congress 2022Node Congress 2022
    8 min
    Monitoring Errors and Slowdowns with a JS Frontend and Node Backend
    Watch video: Monitoring Errors and Slowdowns with a JS Frontend and Node Backend
    Sentry is code monitoring for developers, specifically designed for the application layer. It helps identify error details, frequency, release, user information, and stack trace. Source maps can be uploaded to see the original source code and suspect commits can be identified. Performance monitoring helps identify slowdowns and determine the cause. Automating alerts and investigating errors helps gain instant context and trace errors across different projects.
    Identify Issues and Prevent Slowdowns in your Vue.JS Apps
    Vue.js London Live 2021Vue.js London Live 2021
    8 min
    Identify Issues and Prevent Slowdowns in your Vue.JS Apps
    Hi, I'm Simon, a solutions engineer at Sentry. We focus on code observability, supporting all major languages and frameworks. With the Sentry SDK, you can monitor errors and performance. Get started with an easy installation process. Sentry provides detailed error information, including the stack trace and contextual information. It also supports source control management systems and integrates with issue tracking tools. The distributed trace feature allows you to see relationships between errors on the front end and back end. We can optimize queries to improve user experience and reduce user misery.
    Monitoring Errors and Slowdowns Across JS Applications
    DevOps.js Conf 2022DevOps.js Conf 2022
    8 min
    Monitoring Errors and Slowdowns Across JS Applications
    Sentry is an error monitoring platform that helps developers optimize the customer experience by alerting them of errors and slowdowns. It supports all major languages and frameworks, with a focus on error monitoring, performance monitoring, and release health. The Talk explores how Sentry organizes and represents error data, analyzes error details and tags, and investigates backend issues, performance problems, and release health. Collaboration with backend teams is emphasized to resolve issues and optimize transaction time. The Talk also highlights the importance of analyzing graphs, issues, and regressions to identify areas for improvement in release health.