Skip to content

Commit

Permalink
Integrate sentry into the django project (qgis#408)
Browse files Browse the repository at this point in the history
* Integrate sentry into the django project

* Init sentry when the dsn is specified

* Fix test in GH actions

* Update the url in  valid_metadata_link
  • Loading branch information
Xpirix authored May 23, 2024
1 parent a44599d commit 8ac0822
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 7 deletions.
3 changes: 3 additions & 0 deletions dockerize/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ QGISPLUGINS_ENV=debug
# Ldap
ENABLE_LDAP=False

# SENTRY
SENTRY_DSN=''

# Download stats URL
METABASE_DOWNLOAD_STATS_URL='https://plugins.qgis.org/metabase/public/dashboard/<dashboard_id>'
2 changes: 1 addition & 1 deletion dockerize/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:
- EMAIL_HOST_USER=${EMAIL_HOST_USER:-automation}
- EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
- DEFAULT_PLUGINS_SITE=${DEFAULT_PLUGINS_SITE:-https://plugins.qgis.org/}

- SENTRY_DSN=${SENTRY_DSN}
volumes:
- ../qgis-app:/home/web/django_project
- ./docker/uwsgi.conf:/uwsgi.conf
Expand Down
2 changes: 2 additions & 0 deletions dockerize/docker/REQUIREMENTS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ geoip2==4.5.0
django-matomo==0.1.6
uwsgi~=2.0
freezegun~=1.4

sentry-sdk~=2.2
16 changes: 12 additions & 4 deletions qgis-app/plugins/tests/test_plugin_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ def test_plugin_new_version(self):
self.assertEqual(self.plugin.tracker, "https://github.com/")
self.assertEqual(self.plugin.repository, "https://github.com/")

self.assertEqual(
self.assertIn(
'[email protected]',
mail.outbox[0].recipients(),
['[email protected]', '[email protected]']
)
self.assertIn(
'[email protected]',
mail.outbox[0].recipients()
)

# Should use the new email
Expand Down Expand Up @@ -145,9 +149,13 @@ def test_plugin_version_update(self):
self.assertEqual(self.plugin.tracker, "https://github.com/")
self.assertEqual(self.plugin.repository, "https://github.com/")

self.assertEqual(
self.assertIn(
'[email protected]',
mail.outbox[0].recipients(),
['[email protected]', '[email protected]']
)
self.assertIn(
'[email protected]',
mail.outbox[0].recipients()
)

# Should use the new email
Expand Down
8 changes: 6 additions & 2 deletions qgis-app/plugins/tests/test_plugin_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ def test_plugin_upload_form(self):
3)
self.assertTrue(PluginVersion.objects.filter(plugin__name='Test Plugin', version='0.0.1').exists())

self.assertEqual(
self.assertIn(
'[email protected]',
mail.outbox[0].recipients(),
['[email protected]', '[email protected]']
)
self.assertIn(
'[email protected]',
mail.outbox[0].recipients()
)

# Should use the new email
Expand Down
Binary file modified qgis-app/plugins/tests/testfiles/valid_metadata_link.zip
Binary file not shown.
14 changes: 14 additions & 0 deletions qgis-app/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,17 @@

# Default primary key type
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'


# Sentry
SENTRY_DSN = os.environ.get("SENTRY_DSN", "")

if SENTRY_DSN and SENTRY_DSN != "":
import sentry_sdk

sentry_sdk.init(
dsn=SENTRY_DSN,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
)

0 comments on commit 8ac0822

Please sign in to comment.