Skip to content

Commit

Permalink
Drop Google Analytics trackers
Browse files Browse the repository at this point in the history
We don't rely on this information, and
likely Google shouldn't have it anyway.
  • Loading branch information
benmwebb committed Jul 1, 2022
1 parent 3c264c4 commit 6308190
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 63 deletions.
4 changes: 0 additions & 4 deletions doc/configfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ urltop
The URL under which the service's web pages live. This is used to construct
URLs containing job results, for example.

google_ua
The Google Analytics UA for tracking traffic. Please ask a sysadmin to
register the service. As default, the ModBase UA is used.

track_hostname
If set to "True" then the hostname or IP address of each web service
user is stored in the database.
Expand Down
4 changes: 1 addition & 3 deletions doc/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ For example, the user 'bob' wants to set up a web service for peptide docking.

#. Once deployment is successful, he asks a sysadmin to set up the web server
on `modbase` so that the URL given in `urltop` in :file:`conf/live.conf`
works, and to register the service with
`Google Analytics <https://salilab.org/internal/wiki/GoogleAnalytics>`_.
The resulting UA number should also get entered into the configuration file.
works.

#. Whenever Bob makes changes to the service in his `pepdock` directory, he
simply runs `scons test` to make sure the changes didn't break anything,
Expand Down
1 change: 0 additions & 1 deletion examples/alternative.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[frontend:modalt]
service_name: ModAlt
urltop: http://modbase.compbio.ucsf.edu/modalt
google_ua: UA-44577804-1
1 change: 0 additions & 1 deletion examples/example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ admin_email: modfoo-admin@salilab.org
socket: /modbase1/home/modfoo/modfoo.socket
service_name: ModFoo
urltop: http://modbase.compbio.ucsf.edu/modfoo
google_ua: UA-44577804-1

[backend]
user: modfoo
Expand Down
29 changes: 2 additions & 27 deletions perl/saliweb/frontend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,6 @@ sub new {
return $self;
}

sub _google_ua {
my $self = shift;
if (defined($self->{config}) && defined($self->{config}->{general})
&& defined($self->{config}->{general}->{google_ua})) {
return $self->{config}->{general}->{google_ua};
} else {
# If the google_ua has not been set in the configuration file
# use the ModBase UA
return ('UA-44577804-1');
}
}

sub _admin_email {
my $self = shift;
if (defined($self->{config}) && defined($self->{config}->{general})
Expand Down Expand Up @@ -740,24 +728,13 @@ for example.
sub get_start_html_parameters {
my ($self, $style) = @_;
my $q = $self->{'CGI'};
my $google_ua = $self->_google_ua;
my $JS_Google_Analytics = "
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '$google_ua', 'ucsf.edu', {'cookieFlags': 'SameSite=None; Secure'});
ga('send', 'pageview'); ";

my %param = (-title => $self->{page_title},
-style => {-src=>[$style,
"/fontawesome6/css/fontawesome.min.css",
"/fontawesome6/css/brands.min.css"]},
-script=>[{-language => 'JavaScript',
-src => "/saliweb/js/salilab.js"},
{-language => 'JavaScript',
-code => $JS_Google_Analytics}]);
-src => "/saliweb/js/salilab.js"}]);
if ($self->{responsive}) {
$param{-meta} = {'viewport' => 'width=device-width, initial-scale=1'};
}
Expand Down Expand Up @@ -1421,7 +1398,6 @@ sub display_download_page {

sub display_help_page {
my $self = shift;
my $google_ua = shift;
try {
my $q = $self->{'CGI'};
my $display_type = $q->param('type') || 'help';
Expand All @@ -1431,7 +1407,7 @@ sub display_help_page {
$self->check_page_access('help');
my $content = $self->get_help_page($display_type);
if ($style eq "helplink") {
print $self->start_html("/saliweb/css/help.css", $google_ua);
print $self->start_html("/saliweb/css/help.css");
print "<div><div>";
_display_content($content);
print $self->end_html;
Expand Down Expand Up @@ -1660,7 +1636,6 @@ sub read_config {
# Overwrite variables with those of the alternative frontend selected
my $sec = "frontend:$frontend";
$contents->{general}->{urltop} = $contents->{$sec}->{urltop};
$contents->{general}->{google_ua} = $contents->{$sec}->{google_ua};
}
my ($vol, $dirs, $file) = File::Spec->splitpath($filename);
my $frontend_file = File::Spec->rel2abs(
Expand Down
13 changes: 0 additions & 13 deletions python/saliweb/frontend/templates/saliweb/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@
{%- block js %}
{%- endblock %}

{%- if config.GOOGLE_UA %}
<script type="text/JavaScript">//<![CDATA[

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ config.GOOGLE_UA }}', 'ucsf.edu', {'cookieFlags': 'SameSite=None; Secure'});
ga('send', 'pageview');
//]]></script>
{%- endif %}

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
Expand Down
14 changes: 0 additions & 14 deletions test/frontend/frontend.pl
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ BEGIN
"check help_link href");
}

# Test _google_ua method
{
my $default = 'UA-44577804-1';
my $self = {};
bless($self, 'saliweb::frontend');
is($self->_google_ua, $default, 'google_ua (default 1)');
$self->{config} = {};
is($self->_google_ua, $default, ' (default 2)');
$self->{config}->{general} = {};
is($self->_google_ua, $default, ' (default 3)');
$self->{config}->{general}->{google_ua} = "test_ua";
is($self->_google_ua, "test_ua", ' (config)');
}

# Test _admin_email method
{
my $default = 'system@salilab.org';
Expand Down

0 comments on commit 6308190

Please sign in to comment.