コード例 #1
0
ファイル: js_sdk_loader.py プロジェクト: Kayle009/sentry
    def _get_context(self, key):
        """Sets context information needed to render the loader"""
        if not key:
            return ({}, None, None)

        sdk_version = get_browser_sdk_version(key)
        try:
            if '%s' in settings.JS_SDK_LOADER_DEFAULT_SDK_URL:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL % (sdk_version, )
            else:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL
        except TypeError:
            sdk_url = ''  # It fails if it cannot inject the version in the string

        return ({
            'config': config.get_project_key_config(key),
            'jsSdkUrl': sdk_url,
            'publicKey': key.public_key
        }, sdk_version, sdk_url)
コード例 #2
0
    def _get_context(self, key):
        """Sets context information needed to render the loader"""
        if not key:
            return ({}, None, None)

        sdk_version = get_browser_sdk_version(key)
        try:
            if '%s' in settings.JS_SDK_LOADER_DEFAULT_SDK_URL:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL % (
                    sdk_version, )
            else:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL
        except TypeError:
            sdk_url = ''  # It fails if it cannot inject the version in the string

        return ({
            'config': config.get_project_key_config(key),
            'jsSdkUrl': sdk_url,
            'publicKey': key.public_key
        }, sdk_version, sdk_url)
コード例 #3
0
ファイル: js_sdk_loader.py プロジェクト: yodi-n/sentry
    def get(self, request, public_key, minified):
        """Returns a js file that can be integrated into a website"""
        try:
            key = ProjectKey.objects.get(public_key=public_key)
        except ProjectKey.DoesNotExist:
            raise Http404

        sdk_version = get_browser_sdk_version(key)
        try:
            if '%s' in settings.JS_SDK_LOADER_DEFAULT_SDK_URL:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL % (
                    sdk_version, )
            else:
                sdk_url = settings.JS_SDK_LOADER_DEFAULT_SDK_URL
        except TypeError:
            sdk_url = ''  # It fails if it cannot inject the version in the string

        if not sdk_url:
            tmpl = 'sentry/js-sdk-loader-noop.js.tmpl'
        elif minified is not None:
            tmpl = 'sentry/js-sdk-loader.min.js.tmpl'
        else:
            tmpl = 'sentry/js-sdk-loader.js.tmpl'

        context = {
            'config': config.get_project_key_config(key),
            'jsSdkUrl': sdk_url,
            'publicKey': public_key
        }

        response = render_to_response(tmpl,
                                      context,
                                      content_type="text/javascript")

        response['Cache-Control'] = CACHE_CONTROL
        response['Surrogate-Key'] = 'project/%s sdk/%s sdk-loader' % (
            key.project_id, sdk_version)

        return response