{% extends "base.html" %} {% load static %} {% block title %}Set up your SDK ยท {{ site_title }}{% endblock %} {% block content %}

Set up your SDK

Add an SDK to your application to start tracking errors. {% comment %} Bugsink tracks errors in your running applications. To get the errors from your application into Bugsink, you need to set up an SDK. An SDK is a library that you include in your application that sends the errors to Bugsink. Follow the instructions below to set up your SDK. {% endcomment %}
Note: currently, we only support the Python SDK. Other SDKs might actually work, but have not been tested.
Bugsink is compatible with the Sentry SDK. A basic setup is the following:

Step 1: Install the SDK

Install the SDK using pip:
pip install sentry-sdk

Step 2: Initialize the SDK

Initialize the SDK with your DSN:
{% comment %} add hoc construction of highlighted code: from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter lexer = PythonLexer() code = """import sentry_sdk sentry_sdk.init( "REPLACEME", # The SDK's default is to not send PII; for a SaaS solution this is probably # the right choice, but when you're using Bugsink (i.e. self-hosted), it's # more likely that you want to send everything (and e.g. be able to see # which user was affected by a certain event). Uncomment the following line # to send PII. # send_default_pii=True, # The SDK's default is to be quite conservative with the nr of local # variables it sends per frame (the default is is 10). If you want to see # more, you may either proceed with the monkey patching described in the # issue below, or set max_request_body_size to "always" (which will send # everything). Note that this may lead to very large messages, which may be # dropped by the server (but the server is under your control, so you can # change that). see https://github.com/getsentry/sentry-python/issues/377 # max_request_body_size="always", # Setting up the release is highly recommended. The SDK will try to infer # it, but explicitly setting it is more reliable. # release=..., # Bugsink intentionally does not support traces. No need to send them then traces_sample_rate=0, )""" print(highlight(code, lexer, HtmlFormatter()).replace("highlight", "p-4 mt-4 bg-slate-50 syntax-coloring").replace("REPLACEME", "{{ project.dsn }}")) {% endcomment %}
import sentry_sdk
sentry_sdk.init(
    "{{ project.dsn }}",

    # The SDK's default is to not send PII; for a SaaS solution this is probably
    # the right choice, but when you're using Bugsink (i.e. self-hosted), it's
    # more likely that you want to send everything (and e.g. be able to see
    # which user was affected by a certain event). Uncomment the following line
    # to send PII.
    # send_default_pii=True,

    # The SDK's default is to be quite conservative with the nr of local
    # variables it sends per frame (the default is is 10). If you want to see
    # more, you may either proceed with the monkey patching described in the
    # issue below, or set max_request_body_size to "always" (which will send
    # everything). Note that this may lead to very large messages, which may be
    # dropped by the server (but the server is under your control, so you can
    # change that). see https://github.com/getsentry/sentry-python/issues/377
    # max_request_body_size="always",

    # Setting up the release is highly recommended. The SDK will try to infer
    # it, but explicitly setting it is more reliable.
    # release=...,

    # Bugsink intentionally does not support traces. No need to send them then.
    traces_sample_rate=0,  
)
For integration-specific (Django, Flask, etc) notes, see the Sentry documentation.

Step 3: Verify the setup

Verify the setup by sending an event:
import sentry_sdk
division_by_zero = 1 / 0
Your event should now appear in the list of open issues.
Alternatively, manage the Project Members or Project settings.
{% endblock %}