Skip to content

Commit ff7645d

Browse files
committed
Remove GA code, add back extra_footer_scripts
Let's no longer special case Google Analytics
1 parent e86b01e commit ff7645d

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

binderhub/app.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def _log_level(self):
106106
None,
107107
allow_none=True,
108108
help="""
109+
..deprecated::
110+
111+
No longer supported. If you want to use Google Analytics, use :attr:`extra_footer_scripts`
112+
to load JS from Google Analytics.
113+
109114
The Google Analytics code to use on the main page.
110115
111116
Note that we'll respect Do Not Track settings, despite the fact that GA does not.
@@ -117,6 +122,11 @@ def _log_level(self):
117122
google_analytics_domain = Unicode(
118123
"auto",
119124
help="""
125+
..deprecated::
126+
127+
No longer supported. If you want to use Google Analytics, use :attr:`extra_footer_scripts`
128+
to load JS from Google Analytics.
129+
120130
The Google Analytics domain to use on the main page.
121131
122132
By default this is set to 'auto', which sets it up for current domain and all
@@ -125,6 +135,13 @@ def _log_level(self):
125135
config=True,
126136
)
127137

138+
@observe("google_analytics_domain", "google_analytics_code")
139+
def _google_analytics_deprecation(self, change):
140+
if change.new:
141+
raise ValueError(
142+
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"
143+
)
144+
128145
about_message = Unicode(
129146
"",
130147
help="""
@@ -943,8 +960,6 @@ def initialize(self, *args, **kwargs):
943960
"registry": registry,
944961
"traitlets_config": self.config,
945962
"traitlets_parent": self,
946-
"google_analytics_code": self.google_analytics_code,
947-
"google_analytics_domain": self.google_analytics_domain,
948963
"about_message": self.about_message,
949964
"banner_message": self.banner_message,
950965
"extra_footer_scripts": self.extra_footer_scripts,

binderhub/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ async def get(self):
239239
submit=False,
240240
binder_version=binder_version,
241241
message=self.settings["about_message"],
242-
google_analytics_code=self.settings["google_analytics_code"],
243-
google_analytics_domain=self.settings["google_analytics_domain"],
244242
extra_footer_scripts=self.settings["extra_footer_scripts"],
245243
)
246244

binderhub/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def get(self):
2727
self.render_template(
2828
"page.html",
2929
page_config=page_config,
30+
extra_footer_scripts=self.settings["extra_footer_scripts"],
3031
)
3132

3233

binderhub/templates/page.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@
2525
</body>
2626

2727
<script src="{{static_url("dist/bundle.js")}}"></script>
28+
29+
{% if extra_footer_scripts %}
30+
{% for script in extra_footer_scripts|dictsort %}
31+
<script>
32+
{{ script[1]|safe }}
33+
</script>
34+
{% endfor %}
35+
{% endif %}
36+
2837
</html>

0 commit comments

Comments
 (0)