sentry: Set environment to staging on staging hosts.

Splitting exceptions out between staging and production provides
useful filtering.
This commit is contained in:
Alex Vandiver
2021-07-08 17:38:46 -07:00
committed by Tim Abbott
parent 16691110a6
commit a985284b5d
2 changed files with 10 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ from sentry_sdk.utils import capture_internal_exceptions
from version import ZULIP_VERSION
from .config import PRODUCTION
from .config import PRODUCTION, STAGING
if TYPE_CHECKING:
from sentry_sdk._types import Event, Hint
@@ -60,9 +60,16 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
def setup_sentry(dsn: Optional[str], *integrations: Integration) -> None:
if not dsn:
return
if PRODUCTION:
if STAGING:
environment = "staging"
else:
environment = "production"
else:
environment = "development"
sentry_sdk.init(
dsn=dsn,
environment="production" if PRODUCTION else "development",
environment=environment,
release=ZULIP_VERSION,
integrations=[
DjangoIntegration(),