Skip to content

Commit

Permalink
Remove GA code, add back extra_footer_scripts
Browse files Browse the repository at this point in the history
Let's no longer special case Google Analytics
  • Loading branch information
yuvipanda committed May 23, 2024
1 parent e86b01e commit ff7645d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
19 changes: 17 additions & 2 deletions binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def _log_level(self):
None,
allow_none=True,
help="""
..deprecated::
No longer supported. If you want to use Google Analytics, use :attr:`extra_footer_scripts`
to load JS from Google Analytics.
The Google Analytics code to use on the main page.
Note that we'll respect Do Not Track settings, despite the fact that GA does not.
Expand All @@ -117,6 +122,11 @@ def _log_level(self):
google_analytics_domain = Unicode(
"auto",
help="""
..deprecated::
No longer supported. If you want to use Google Analytics, use :attr:`extra_footer_scripts`
to load JS from Google Analytics.
The Google Analytics domain to use on the main page.
By default this is set to 'auto', which sets it up for current domain and all
Expand All @@ -125,6 +135,13 @@ def _log_level(self):
config=True,
)

@observe("google_analytics_domain", "google_analytics_code")
def _google_analytics_deprecation(self, change):
if change.new:
raise ValueError(
f"Setting {change.owner.__class__.__name__}.{change.name} is no longer supported. Use {change.owner.__class__.__name__}.extra_footer_scripts to load Google Analytics JS directly"
)

about_message = Unicode(
"",
help="""
Expand Down Expand Up @@ -943,8 +960,6 @@ def initialize(self, *args, **kwargs):
"registry": registry,
"traitlets_config": self.config,
"traitlets_parent": self,
"google_analytics_code": self.google_analytics_code,
"google_analytics_domain": self.google_analytics_domain,
"about_message": self.about_message,
"banner_message": self.banner_message,
"extra_footer_scripts": self.extra_footer_scripts,
Expand Down
2 changes: 0 additions & 2 deletions binderhub/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ async def get(self):
submit=False,
binder_version=binder_version,
message=self.settings["about_message"],
google_analytics_code=self.settings["google_analytics_code"],
google_analytics_domain=self.settings["google_analytics_domain"],
extra_footer_scripts=self.settings["extra_footer_scripts"],
)

Expand Down
1 change: 1 addition & 0 deletions binderhub/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def get(self):
self.render_template(
"page.html",
page_config=page_config,
extra_footer_scripts=self.settings["extra_footer_scripts"],
)


Expand Down
9 changes: 9 additions & 0 deletions binderhub/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@
</body>

<script src="{{static_url("dist/bundle.js")}}"></script>

{% if extra_footer_scripts %}
{% for script in extra_footer_scripts|dictsort %}
<script>
{{ script[1]|safe }}
</script>
{% endfor %}
{% endif %}

</html>

0 comments on commit ff7645d

Please sign in to comment.