mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-15 09:40:23 -06:00
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
import uuid
|
|
|
|
from django.db import models
|
|
|
|
|
|
class Project(models.Model):
|
|
# id is implied which makes it an Integer; we would prefer a uuid but the sentry clients have int baked into the DSN
|
|
# parser (we could also introduce a special field for that purpose but that's ugly too)
|
|
|
|
name = models.CharField(max_length=255, blank=False, null=False)
|
|
|
|
# sentry_key mirrors the "public" part of the sentry DSN. As of late 2023 Sentry's docs say the this about DSNs:
|
|
#
|
|
# > DSNs are safe to keep public because they only allow submission of new events and related event data; they do
|
|
# > not allow read access to any information.
|
|
#
|
|
# The "because" in that sentence is dubious at least; however, I get why they say it, because they want to do JS and
|
|
# native apps too, and there's really no way to do those without exposing (some) endpoint. Anyway, I don't think the
|
|
# "public" key is public, and if you can help it it's always better to keep it private.
|
|
sentry_key = models.UUIDField(editable=False, default=uuid.uuid4)
|
|
|
|
# We don't implement private_key because as of late 2023 the Sentry documentation says the following:
|
|
# > The secret part of the DSN is optional and effectively deprecated. While clients will still honor it, if
|
|
# > supplied, future versions of Sentry will entirely ignore it.
|
|
# private_key = ...
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def get_dsn(self):
|
|
# TODO, because the server needs to know its own address
|
|
return get_dsn()
|
|
|
|
"""
|
|
# TODO is this even more efficient?
|
|
indexes = [
|
|
models.Index(fields=["id", "sentry_key"]),
|
|
]
|
|
"""
|