summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/example.env1
-rw-r--r--python/fatcat_web/templates/base.html10
-rw-r--r--python/fatcat_web/web_config.py5
3 files changed, 16 insertions, 0 deletions
diff --git a/python/example.env b/python/example.env
index 120c9e6e..3a83d5b3 100644
--- a/python/example.env
+++ b/python/example.env
@@ -15,6 +15,7 @@ GITLAB_CLIENT_SECRET=""
IA_XAUTH_CLIENT_ID=""
IA_XAUTH_CLIENT_SECRET=""
SENTRY_DSN=""
+ENABLE_GOATCOUNTER=""
# These auth keys only for workers/importers; locally will fall back to
# FATCAT_API_AUTH_TOKEN
diff --git a/python/fatcat_web/templates/base.html b/python/fatcat_web/templates/base.html
index 73f33d0d..c17f81de 100644
--- a/python/fatcat_web/templates/base.html
+++ b/python/fatcat_web/templates/base.html
@@ -153,6 +153,16 @@
integrity="sha256-9H3HWYnPJ2bEHgkOrw+48KheOqYzTvJd1hbeU9sEDFk="
crossorigin="anonymous">
</script>
+{% if config.ENABLE_GOATCOUNTER -%}
+ <script>
+ window.goatcounter = {
+ /* title leaks search query, so don't report it */
+ title: "",
+ {# to allow localhost connections (dev) to be colected, set: allow_local: true #}
+ };
+ </script>
+ <script data-goatcounter="{{ config.GOATCOUNTER_ENDPOINT }}" async src="{{ config.GOATCOUNTER_SCRIPT_URL }}"></script>
+{%- endif %}
{% block postscript %}{% endblock %}
</body>
diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py
index 5d2da830..25c93114 100644
--- a/python/fatcat_web/web_config.py
+++ b/python/fatcat_web/web_config.py
@@ -52,6 +52,11 @@ class Config(object):
IA_XAUTH_CLIENT_ID = os.environ.get("IA_XAUTH_CLIENT_ID", default=None)
IA_XAUTH_CLIENT_SECRET = os.environ.get("IA_XAUTH_CLIENT_SECRET", default=None)
+ # analytics; used in production
+ ENABLE_GOATCOUNTER = bool(os.environ.get("ENABLE_GOATCOUNTER", default=False))
+ GOATCOUNTER_ENDPOINT = os.environ.get("GOATCOUNTER_ENDPOINT", default="https://goatcounter.fatcat.wiki/count")
+ GOATCOUNTER_SCRIPT_URL = os.environ.get("GOATCOUNTER_SCRIPT_URL", default="https://goatcounter.fatcat.wiki/count.js")
+
# controls granularity of "shadow_only" preservation category
FATCAT_MERGE_SHADOW_PRESERVATION = os.environ.get("FATCAT_MERGE_SHADOW_PRESERVATION", default=False)