If you're setting up Plio for staging or production, you may also wish to capture errors faced by users in real-time. For that purpose, Plio uses Sentry.io for real-time error monitoring and reporting.
- Create an account at Sentry.
- Set up your organization.
- Create a new Django project. Name it
plio-backend.
- Set up env variable for
SENTRY_DSN. You can get the value of DSN for your projects fromProject Settings > SDK Setup > Client Keys (DSN) - Make sure your
APP_ENVis either 'staging' or 'production'. - Test your set up by triggering an error - add the following line in your
urls.pyfile:from django.urls import path def trigger_error(request): division_by_zero = 1 / 0 urlpatterns = [ path('trigger-error/', trigger_error), # other paths ]
- You should now see the error at your Sentry dashboard as well from the
Issuestab.
By default, Sentry sends error reports to your inbox. However, you may prefer other channels to receive error notifications.
At Plio, we use Discord to receive real-time alerts using Sentry Webhooks. If you're also using Discord, or a different tool that supports webhooks, follow the steps below to start receiving alerts:
- Create a new channel at Discord where you want to receive the alerts. Then, enable the webhook and copy the webhook url.
Channel settings > Integrations > Webhook - Create a SentryDiscord webhook.
- Visit this page at SentryDiscord.dev.
- Paste the Discord webhook that you copied in the first step.
- Click on create.
- You will receive a new webhook. Copy and store it somewhere. We'll use it later.
- Go to
Integrationsfor your organization fromSettings > Integrations - Search for
Webhooksand click onAdd to project. - Select your project.
- Enter the SentryDiscord webhook url from step 2 inside the
Callback URLstextbox. - Click
Save changes. - Click
Enable Plugin. - Next, go to
Alerts. By default you may see an alert namedSend a notification for new issues. If yes, you can skip the create alert step below and got to edit existing alert. - Create a new Alert
- Click on
Create Alert Rule. - In the select alert section, select
Issuesinside theErrorsheading. - Click on
Set Conditions. Environmentto be "All Environments".- Set the Alert name to "Send a notification for new issues"
- Move to Set Conditions section.
- For
WHEN, select "A new issue is created". - For
IF, leave it as default (no filters). - For
THEN, add two options.Send a notificationand selectIssue Owners.Send a notification via an integrationand selectWebHooks.
- Set action interval as per your needs.
- Click on
- Edit existing alert - use this if you want to edit existing alert
- Move to Set Conditions section.
- For
THEN, make sure you have theSend a notification via an integrationoption configured withWebHooks.
- All set. Trigger an error in your app and you should see the error coming to your Discord channel!