def get_sentry_integrations() -> list: """ Determine which Sentry SDK integrations to enable. """ default = [ django.DjangoIntegration(), # redis.RedisIntegration(), ] extra = [] try: from sentry_sdk.integrations import celery except DidNotEnable: # happens if the celery import fails by the integration pass else: extra.append(celery.CeleryIntegration()) return [*default, *extra]
) # Django-Hijack HIJACK_LOGIN_REDIRECT_URL = "/" HIJACK_LOGOUT_REDIRECT_URL = reverse_lazy("admin:accounts_user_changelist") # The Admin mixin is used because we use a custom User-model. HIJACK_REGISTER_ADMIN = False # This is a CSRF-security risk. # See: http://django-hijack.readthedocs.io/en/latest/configuration/#allowing-get-method-for-hijack-views HIJACK_ALLOW_GET_REQUESTS = True # Sentry SDK SENTRY_DSN = os.getenv("SENTRY_DSN") SENTRY_SDK_INTEGRATIONS = [ django.DjangoIntegration(), redis.RedisIntegration(), ] if celery is not None: SENTRY_SDK_INTEGRATIONS.append(celery.CeleryIntegration()) if SENTRY_DSN: import sentry_sdk SENTRY_CONFIG = { "dsn": SENTRY_DSN, "release": os.getenv("VERSION_TAG", "VERSION_TAG not set"), } sentry_sdk.init( **SENTRY_CONFIG, integrations=SENTRY_SDK_INTEGRATIONS, send_default_pii=True
'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] # I18N & L10N ----------------------------------------------------------------- LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # ERROR REPORTING ------------------------------------------------------------- SENTRY_DSN = env('SENTRY_DSN', default=None) if SENTRY_DSN: sentry_sdk.init( dsn=SENTRY_DSN, integrations=[django.DjangoIntegration()], environment=ENVIRONMENT, ) # API GATEWAY ---------------------------------------------------------------- STOCK_MANAGER_URL = env('STOCK_MANAGER_URL', default=None)
DEBUG_TOOLBAR_CONFIG = {"SHOW_COLLAPSED": True} # Sentry # https://docs.sentry.io/platforms/python/guides/django SENTRY_DSN = os.environ.get("SENTRY_DSN") SENTRY_ENVIRONMENT = os.environ.get("SENTRY_ENVIRONMENT", os.environ.get("HEROKU_APP_NAME")) SENTRY_RELEASE = os.environ.get("SENTRY_RELEASE", os.environ.get("HEROKU_SLUG_COMMIT")) sentry_sdk.init( integrations=[ sentry_celery.CeleryIntegration(), sentry_django.DjangoIntegration(), sentry_logging.LoggingIntegration(level=logging.INFO, event_level=logging.WARNING), ], environment=SENTRY_ENVIRONMENT, release=SENTRY_RELEASE, traces_sample_rate=float(os.environ.get("SENTRY_TRACES_SAMPLE_RATE", 0.25)), ) # Security # https://docs.djangoproject.com/en/stable/topics/security/ SECURE_HSTS_SECONDS = 0 if DEBUG else 2592000 # 30 days (60 * 60 * 24 * 30) SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = not DEBUG