mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-30 18:00:17 -06:00
SDK: platform-specific notes for PHP, JS
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load static code %}
|
||||
|
||||
{% block title %}Set up your SDK · {{ site_title }}{% endblock %}
|
||||
{% block title %}Connect your application · {{ site_title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -9,49 +9,38 @@
|
||||
<div class="flex items-center justify-center">
|
||||
|
||||
<div class="m-4 max-w-4xl flex-auto">
|
||||
<h1 class="text-4xl font-bold">Set up your SDK</h1>
|
||||
<h1 class="text-4xl font-bold">Connect your application</h1>
|
||||
|
||||
<div class="mt-4">
|
||||
Connect your application to Bugsink to start tracking errors.
|
||||
Bugsink is compatible with the Sentry SDK. A basic setup is the following:
|
||||
Bugsink is compatible with the <a href="https://docs.sentry.io/platforms/">Sentry SDKs</a>.
|
||||
Use the following DSN to connect your application to Bugsink:
|
||||
</div>
|
||||
{% code %}:::text
|
||||
{{ dsn }}
|
||||
{% endcode %}
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 1: Install the SDK</h2>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Language-specific instructions</h2>
|
||||
<div class="mt-4">
|
||||
{{ install_text }}
|
||||
Pick your language to get specific instructions on how to set up the SDK.
|
||||
|
||||
<ul class="list-disc list-inside mt-4">
|
||||
<li><a class="text-cyan-500 font-bold" href="python/">Python</a></li>
|
||||
<li><a class="text-cyan-500 font-bold" href="javascript/">JavaScript</a></li>
|
||||
<li><a class="text-cyan-500 font-bold" href="php/">PHP</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
{{ install }}
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 2: Initialize the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Initialize and configure the SDK with your DSN. Add the following at the start of your application code:
|
||||
</div>
|
||||
|
||||
{{ conf }}
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Step 3: Verify the setup</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
To verify that everything is working, raise an exception on purpose and check that it appears in Bugsink.
|
||||
Put this code somewhere after the configuration:
|
||||
</div>
|
||||
|
||||
{{ verify }}
|
||||
|
||||
<div class="mt-4">
|
||||
Your event should now appear in the <a href="{% url "issue_list_open" project_pk=project.pk %}" class="text-cyan-500 font-bold">list of open issues</a>.
|
||||
Not listed? It will probably work anyway! Just use the DSN above, and let us know if you run into any issues (or not).
|
||||
</div>
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Further reading</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
For more information on how to use the SDK, check the <a href="https://www.bugsink.com/docs/platforms/python/" class="text-cyan-500 font-bold">full documentation</a>.
|
||||
For more information on how to use the SDK, check the <a href="https://www.bugsink.com/docs/sdk-recommendations/" class="text-cyan-500 font-bold">Bugsink-specific SDK recommendations</a>.
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static code %}
|
||||
|
||||
{% block title %}Set up your SDK · {{ site_title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
|
||||
<div class="m-4 max-w-4xl flex-auto">
|
||||
<h1 class="text-4xl font-bold">Set up your SDK</h1>
|
||||
|
||||
<div class="mt-4">
|
||||
Connect your JavaScript application to Bugsink to start tracking errors.
|
||||
Bugsink is compatible with the <a class="text-cyan-500 font-bold" href="https://docs.sentry.io/platforms/javascript/">Sentry SDK</a>.
|
||||
Detailed instructions per framework are in the <a class="text-cyan-500 font-bold" href="https://docs.sentry.io/platforms/javascript/">Sentry SDK Documentation</a>. In the below we provide an overview, zoom in on the differences between Bugsink and Sentry, and provide a snippet with the correct DSN set.
|
||||
</div>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 1: Install the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Install the SDK by including a script tag, or by using a package manager such as npm or yarn. Note that the SDK to use depends on your framework (e.g. React, Angular, Vue, etc.).
|
||||
|
||||
{% code %}:::text
|
||||
npm install @sentry/your-js-flavor --save
|
||||
{% endcode %}
|
||||
</div>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 2: Initialize the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Initialize and configure the SDK with your DSN. Use the configuration snippet that applies to your framework,
|
||||
and replace the Sentry.init call with the call below:
|
||||
</div>
|
||||
|
||||
{% code %}:::javascript
|
||||
// use the correct import statement for your framework, like:
|
||||
|
||||
// import * as Sentry from "@sentry/browser";
|
||||
// const Sentry = require("@sentry/node");
|
||||
// import * as Sentry from "@sentry/angular";
|
||||
|
||||
Sentry.init({
|
||||
dsn: "{{ dsn }}",
|
||||
|
||||
// Alternatively, use `process.env.npm_package_version` for a dynamic release version
|
||||
// if your build tool supports it.
|
||||
release: "my-project-name@...",
|
||||
|
||||
integrations: [],
|
||||
tracesSampleRate: 0,
|
||||
{% comment %} sendDefaultPii: true, // not actually implemented yet, see https://github.com/getsentry/sentry-javascript/issues/5347
|
||||
{% endcomment %}});
|
||||
{% endcode %}
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Step 3: Verify the setup</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
To verify that everything is working, raise an exception on purpose and check that it appears in Bugsink.
|
||||
A good location for this depends on your framework, but a good place is in the main entry point of your application.
|
||||
(Don't use the devtools console, because it will not be caught by the SDK).
|
||||
</div>
|
||||
|
||||
{% code %}:::javascript
|
||||
// Put something like this in the handler of a button click, on a timeout, or similar.
|
||||
throw new Error("Error Thrown on purpose to send it to Bugsink");
|
||||
{% endcode %}
|
||||
|
||||
<div class="mt-4">
|
||||
Your event should now appear in the <a href="{% url "issue_list_open" project_pk=project.pk %}" class="text-cyan-500 font-bold">list of open issues</a>.
|
||||
</div>
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Further reading</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
For more information on how to use the SDK, check the <a href="https://www.bugsink.com/docs/sdk-recommendations/" class="text-cyan-500 font-bold">Bugsink-specific SDK recommendations</a>.
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
81
projects/templates/projects/project_sdk_setup_php.html
Normal file
81
projects/templates/projects/project_sdk_setup_php.html
Normal file
@@ -0,0 +1,81 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static code %}
|
||||
|
||||
{% block title %}Set up your SDK · {{ site_title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
|
||||
<div class="m-4 max-w-4xl flex-auto">
|
||||
<h1 class="text-4xl font-bold">Set up your SDK</h1>
|
||||
|
||||
<div class="mt-4">
|
||||
Connect your PHP application to Bugsink to start tracking errors.
|
||||
Bugsink is compatible with the <a class="text-cyan-500 font-bold" href="https://docs.sentry.io/platforms/php/">Sentry SDK</a>.
|
||||
Note that the instructions for <a class="text-cyan-500 font-bold" href="https://docs.sentry.io/platforms/php/guides/laravel/">Laravel</a> and <a class="text-cyan-500 font-bold" href="https://docs.sentry.io/platforms/php/guides/symfony/">Symfony</a> are quite different from plain PHP.
|
||||
In the below we provide an overview, zoom in on the differences between Bugsink and Sentry, and provide a snippet with the correct DSN set.
|
||||
</div>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 1: Install the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Install the SDK using Composer. Run either of the following commands:
|
||||
|
||||
{% code %}:::text
|
||||
PICK ONE:
|
||||
composer require sentry/sentry
|
||||
composer require sentry/sentry-laravel
|
||||
composer require sentry/sentry-symfony
|
||||
{% endcode %}
|
||||
</div>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 2: Configure the SDK with your DSN</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
The steps for initialization/configuration differ between the different frameworks. Refer to the relevant
|
||||
document.
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
Configure the SDK without tracing and profiling, as Bugsink does not support these features.
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
Initialize and configure the SDK with your DSN:
|
||||
</div>
|
||||
|
||||
{% code %}:::php
|
||||
{{ dsn }}
|
||||
{% endcode %}
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Step 3: Verify the setup</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
To verify that everything is working, raise an exception on purpose and check that it appears in Bugsink.
|
||||
How to do this depends on the framework you are using, as per the documentation. Here's an example for plain PHP:
|
||||
</div>
|
||||
|
||||
{% code %}:::php
|
||||
<?php
|
||||
try {
|
||||
$this->iWantThisToFailSoBugsinkShowsIt();
|
||||
} catch (\Throwable $exception) {
|
||||
\Sentry\captureException($exception);
|
||||
}
|
||||
?>{% endcode %}
|
||||
|
||||
<div class="mt-4">
|
||||
Your event should now appear in the <a href="{% url "issue_list_open" project_pk=project.pk %}" class="text-cyan-500 font-bold">list of open issues</a>.
|
||||
</div>
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Further reading</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
For more information on how to use the SDK, check the <a href="https://www.bugsink.com/docs/sdk-recommendations/" class="text-cyan-500 font-bold">Bugsink-specific SDK recommendations</a>.
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
80
projects/templates/projects/project_sdk_setup_python.html
Normal file
80
projects/templates/projects/project_sdk_setup_python.html
Normal file
@@ -0,0 +1,80 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static code %}
|
||||
|
||||
{% block title %}Connect your Python Application · {{ site_title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
|
||||
<div class="m-4 max-w-4xl flex-auto">
|
||||
<h1 class="text-4xl font-bold">Connect your Python Application</h1>
|
||||
|
||||
<div class="mt-4">
|
||||
Connect your Python application to Bugsink to start tracking errors.
|
||||
Bugsink is compatible with the Sentry SDK. A basic setup is the following:
|
||||
</div>
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 1: Install the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Install the SDK using pip:
|
||||
</div>
|
||||
|
||||
{% code %}:::text
|
||||
pip install sentry-sdk
|
||||
{% endcode %}
|
||||
|
||||
<h2 class="mt-8 text-2xl font-bold">Step 2: Initialize the SDK</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
Initialize and configure the SDK with your DSN. Add the following at the start of your application code:
|
||||
</div>
|
||||
|
||||
{% code %}:::python
|
||||
import sentry_sdk
|
||||
|
||||
sentry_sdk.init(
|
||||
"{{ dsn }}",
|
||||
|
||||
send_default_pii=True,
|
||||
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=...,
|
||||
|
||||
traces_sample_rate=0,
|
||||
)
|
||||
{% endcode %}
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Step 3: Verify the setup</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
To verify that everything is working, raise an exception on purpose and check that it appears in Bugsink.
|
||||
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
Put this code somewhere in your application where it can easily be triggered and then trigger it (don't use an interactive shell since the SDK will ignore exceptions raised in it):
|
||||
</div>
|
||||
|
||||
{% code %}:::python
|
||||
raise Exception("Raised Exception on purpose to send it to Bugsink")
|
||||
{% endcode %}
|
||||
|
||||
<div class="mt-4">
|
||||
Your event should now appear in the <a href="{% url "issue_list_open" project_pk=project.pk %}" class="text-cyan-500 font-bold">list of open issues</a>.
|
||||
</div>
|
||||
|
||||
<h2 class="mt-6 text-2xl font-bold">Further reading</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
For more information on how to use the SDK, check the <a href="https://www.bugsink.com/docs/sdk-recommendations/" class="text-cyan-500 font-bold">Bugsink-specific SDK recommendations</a>.
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -20,4 +20,5 @@ urlpatterns = [
|
||||
path('<int:project_pk>/members/settings/<str:user_pk>/', project_member_settings, name="project_member_settings"),
|
||||
|
||||
path('<int:project_pk>/sdk-setup/', project_sdk_setup, name="project_sdk_setup"),
|
||||
path('<int:project_pk>/sdk-setup/<str:platform>/', project_sdk_setup, name="project_sdk_setup_platform"),
|
||||
]
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from pygments import highlight
|
||||
from pygments.lexers import PythonLexer, TextLexer
|
||||
from pygments.formatters import HtmlFormatter
|
||||
|
||||
from django.template.loader import get_template
|
||||
from django.shortcuts import render
|
||||
from django.db import models
|
||||
from django.shortcuts import redirect
|
||||
@@ -15,7 +10,6 @@ from django.contrib import messages
|
||||
from django.contrib.auth import logout
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from users.models import EmailVerification
|
||||
from teams.models import TeamMembership, Team, TeamRole
|
||||
@@ -385,16 +379,8 @@ def project_members_accept(request, project_pk):
|
||||
return render(request, "projects/project_members_accept.html", {"project": project, "membership": membership})
|
||||
|
||||
|
||||
def _sdk_code(part, context, lexer):
|
||||
template = get_template("sdkconf/python/%s" % part)
|
||||
code = template.render(context)
|
||||
|
||||
return mark_safe(
|
||||
highlight(code, lexer, HtmlFormatter()).replace("highlight", "p-4 mt-4 bg-slate-50 syntax-coloring"))
|
||||
|
||||
|
||||
@atomic_for_request_method
|
||||
def project_sdk_setup(request, project_pk):
|
||||
def project_sdk_setup(request, project_pk, platform=""):
|
||||
project = Project.objects.get(id=project_pk)
|
||||
|
||||
if not request.user.is_superuser and not ProjectMembership.objects.filter(project=project, user=request.user,
|
||||
@@ -404,10 +390,11 @@ def project_sdk_setup(request, project_pk):
|
||||
# NOTE about lexers:: I have bugsink/pyments_extensions; but the platforms mentioned there don't necessarily map to
|
||||
# what I will make selectable here. "We'll see" whether yet another lookup dict will be needed.
|
||||
|
||||
return render(request, "projects/project_sdk_setup.html", {
|
||||
assert platform in ["", "python", "javascript", "php"]
|
||||
|
||||
template_name = "projects/project_sdk_setup%s.html" % ("_" + platform if platform else "")
|
||||
|
||||
return render(request, template_name, {
|
||||
"project": project,
|
||||
"install_text": get_template("sdkconf/python/install_text").render({}),
|
||||
"install": _sdk_code("install", {}, TextLexer()),
|
||||
"conf": _sdk_code("conf", {"dsn": project.dsn}, PythonLexer()),
|
||||
"verify": _sdk_code("verify", {}, PythonLexer()),
|
||||
"dsn": project.dsn,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user