Python django.conf.settings.SENTRY_DSN Examples

The following are 10 code examples for showing how to use django.conf.settings.SENTRY_DSN(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: micromasters   Author: mitodl   File: views.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def terms_of_service(request):
    """
    Handles the terms of service page
    """
    return render(
        request,
        "terms_of_service.html",
        context={
            "has_zendesk_widget": True,
            "is_public": True,
            "js_settings_json": json.dumps({
                "release_version": settings.VERSION,
                "environment": settings.ENVIRONMENT,
                "sentry_dsn": settings.SENTRY_DSN,
                "user": serialize_maybe_user(request.user),
            }),
            "ga_tracking_id": "",
        }
    ) 
Example 2
Project: micromasters   Author: mitodl   File: models.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def get_context(self, request, *args, **kwargs):
        js_settings = {
            "gaTrackingID": settings.GA_TRACKING_ID,
            "host": webpack_dev_server_host(request),
            "environment": settings.ENVIRONMENT,
            "sentry_dsn": settings.SENTRY_DSN,
            "release_version": settings.VERSION
        }

        username = get_social_username(request.user)
        context = super().get_context(request)

        context["is_public"] = True
        context["has_zendesk_widget"] = True
        context["google_maps_api"] = False
        context["authenticated"] = not request.user.is_anonymous
        context["is_staff"] = has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID])
        context["username"] = username
        context["js_settings_json"] = json.dumps(js_settings)
        context["title"] = self.title
        context["ga_tracking_id"] = ""

        return context 
Example 3
Project: django-react-boilerplate   Author: vintasoftware   File: context_processors.py    License: MIT License 5 votes vote down vote up
def sentry_dsn(request):
    return {"SENTRY_DSN": settings.SENTRY_DSN} 
Example 4
Project: Wagtail-Pipit   Author: Frojd   File: context_processors.py    License: MIT License 5 votes vote down vote up
def settings_context_processor(request):
    """
    Expose django settings to template engine
    """
    parsed_settings = {"DEBUG": settings.DEBUG, "APP_VERSION": settings.APP_VERSION}

    if hasattr(settings, "SENTRY_DSN"):
        parsed_settings["SENTRY_DSN"] = settings.SENTRY_DSN

    if hasattr(settings, "SENTRY_ENVIRONMENT"):
        parsed_settings["SENTRY_ENVIRONMENT"] = settings.SENTRY_ENVIRONMENT

    return {"SETTINGS": parsed_settings} 
Example 5
Project: Wagtail-Pipit   Author: Frojd   File: context_processors.py    License: MIT License 5 votes vote down vote up
def settings_context_processor(request):
    """
    Expose django settings to template engine
    """
    parsed_settings = {"DEBUG": settings.DEBUG, "APP_VERSION": settings.APP_VERSION}

    if hasattr(settings, "SENTRY_DSN"):
        parsed_settings["SENTRY_DSN"] = settings.SENTRY_DSN

    if hasattr(settings, "SENTRY_ENVIRONMENT"):
        parsed_settings["SENTRY_ENVIRONMENT"] = settings.SENTRY_ENVIRONMENT

    return {"SETTINGS": parsed_settings} 
Example 6
Project: arxiv-vanity   Author: arxiv-vanity   File: utils.py    License: Apache License 2.0 5 votes vote down vote up
def log_exception():
    """
    Log an exception that has been raised to the console and Sentry.
    Must be called within an `except ...:` statement.
    """
    traceback.print_exc()
    if settings.SENTRY_DSN:
        capture_exception() 
Example 7
Project: betterself   Author: jeffshek   File: celery.py    License: MIT License 5 votes vote down vote up
def on_configure(self):
            client = raven.Client(settings.SENTRY_DSN)

            # register a custom filter to filter out duplicate logs
            register_logger_signal(client)

            # hook into the Celery error handler
            register_signal(client) 
Example 8
Project: micromasters   Author: mitodl   File: views.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def standard_error_page(request, status_code, template_filename):
    """
    Returns an error page with a given template filename and provides necessary context variables
    """
    name = request.user.profile.preferred_name if not request.user.is_anonymous else ""
    authenticated = not request.user.is_anonymous
    username = get_social_username(request.user)
    response = render(
        request,
        template_filename,
        context={
            "has_zendesk_widget": True,
            "is_public": True,
            "js_settings_json": json.dumps({
                "release_version": settings.VERSION,
                "environment": settings.ENVIRONMENT,
                "sentry_dsn": settings.SENTRY_DSN,
                "user": serialize_maybe_user(request.user),
            }),
            "authenticated": authenticated,
            "name": name,
            "username": username,
            "is_staff": has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID]),
            "support_email": settings.EMAIL_SUPPORT,
            "sentry_dsn": settings.SENTRY_DSN,
        }
    )
    response.status_code = status_code
    return response 
Example 9
Project: micromasters   Author: mitodl   File: models.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_context(self, request, *args, **kwargs):
        programs = Program.objects.filter(live=True).select_related('programpage').order_by("id")
        benefits_page = BenefitsPage.objects.filter(live=True).first()
        js_settings = {
            "gaTrackingID": settings.GA_TRACKING_ID,
            "host": webpack_dev_server_host(request),
            "environment": settings.ENVIRONMENT,
            "sentry_dsn": settings.SENTRY_DSN,
            "release_version": settings.VERSION
        }

        username = get_social_username(request.user)
        context = super(HomePage, self).get_context(request)

        def get_program_page(program):
            """Return a None if ProgramPage does not exist, to avoid template errors"""
            try:
                return program.programpage
            except ProgramPage.DoesNotExist:
                return None

        program_pairs = [(program, get_program_page(program)) for program in programs]
        context["programs"] = program_pairs
        context["is_public"] = True
        context["has_zendesk_widget"] = True
        context["google_maps_api"] = False
        context["authenticated"] = not request.user.is_anonymous
        context["is_staff"] = has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID])
        context["username"] = username
        context["js_settings_json"] = json.dumps(js_settings)
        context["title"] = self.title
        context["ga_tracking_id"] = ""
        context["coupon_code"] = get_coupon_code(request)
        context["benefits_url"] = benefits_page.get_url() if benefits_page else ""

        return context 
Example 10
Project: micromasters   Author: mitodl   File: views.py    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def get(self, request, *args, **kwargs):
        """
        Handle GET requests to templates using React
        """
        user = request.user
        roles = []
        if not user.is_anonymous:
            roles = [
                {
                    'program': role.program.id,
                    'role': role.role,
                    'permissions': [perm for perm, value in available_perm_status(user).items() if value is True]
                } for role in user.role_set.all()
            ]

        js_settings = {
            "gaTrackingID": settings.GA_TRACKING_ID,
            "reactGaDebug": settings.REACT_GA_DEBUG,
            "host": webpack_dev_server_host(request),
            "edx_base_url": settings.EDXORG_BASE_URL,
            "roles": roles,
            "release_version": settings.VERSION,
            "environment": settings.ENVIRONMENT,
            "sentry_dsn": settings.SENTRY_DSN,
            "search_url": reverse('search_api', kwargs={"elastic_url": ""}),
            "support_email": settings.EMAIL_SUPPORT,
            "user": serialize_maybe_user(request.user),
            "es_page_size": settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE,
            "public_path": public_path(request),
            "EXAMS_SSO_CLIENT_CODE": settings.EXAMS_SSO_CLIENT_CODE,
            "EXAMS_SSO_URL": settings.EXAMS_SSO_URL,
            "FEATURES": {
                "PROGRAM_LEARNERS": settings.FEATURES.get('PROGRAM_LEARNERS_ENABLED', False),
                "DISCUSSIONS_POST_UI": settings.FEATURES.get('OPEN_DISCUSSIONS_POST_UI', False),
                "DISCUSSIONS_CREATE_CHANNEL_UI": settings.FEATURES.get('OPEN_DISCUSSIONS_CREATE_CHANNEL_UI', False),
                "PROGRAM_RECORD_LINK": settings.FEATURES.get('PROGRAM_RECORD_LINK', False),
                "ENABLE_PROGRAM_LETTER": settings.FEATURES.get('ENABLE_PROGRAM_LETTER', False)
            },
            "open_discussions_redirect_url": settings.OPEN_DISCUSSIONS_REDIRECT_URL,
        }

        return render(
            request,
            "dashboard.html",
            context={
                "has_zendesk_widget": True,
                "is_public": False,
                "google_maps_api": False,
                "js_settings_json": json.dumps(js_settings),
                "ga_tracking_id": "",
            }
        )