mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #11351 from selten/analytics
This commit is contained in:
@@ -54,7 +54,7 @@ var LibraryRouter = Backbone.Router.extend({
|
||||
},
|
||||
|
||||
/**
|
||||
* Track every route change as a page view in Google Analytics.
|
||||
* Track every route change as a page view in Google Analytics or Plausible
|
||||
*/
|
||||
trackPageview: function () {
|
||||
var url = Backbone.history.getFragment();
|
||||
@@ -65,6 +65,13 @@ var LibraryRouter = Backbone.Router.extend({
|
||||
if (typeof ga !== "undefined") {
|
||||
ga("send", "pageview", `${getAppRoot()}library/list${url}`);
|
||||
}
|
||||
if (typeof window.plausible !== "undefined") {
|
||||
window.plausible(`pageview ${getAppRoot()}library/list${url}`);
|
||||
}
|
||||
if (typeof window._paq !== "undefined") {
|
||||
window._paq.push(["setCustomUrl", `${getAppRoot()}library/list${url}`]);
|
||||
window._paq.push(["trackPageView"]);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -115,6 +122,33 @@ var GalaxyLibrary = Backbone.View.extend({
|
||||
ga("create", Galaxy.config.ga_code, "auto");
|
||||
ga("send", "pageview");
|
||||
}
|
||||
if (Galaxy.config.plausible_server && Galaxy.config.plausible_domain) {
|
||||
document.write(
|
||||
'<script async defer data-domain="' +
|
||||
Galaxy.config.plausible_domain +
|
||||
'" src="' +
|
||||
Galaxy.config.plausible_server +
|
||||
'/js/plausible.js"></script>'
|
||||
);
|
||||
}
|
||||
if (Galaxy.config.matomo_server && Galaxy.config.matomo_site_id) {
|
||||
var _paq = (window._paq = window._paq || []);
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(["trackPageView"]);
|
||||
_paq.push(["enableLinkTracking"]);
|
||||
(function () {
|
||||
var u = Galaxy.config.matomo_server + "/";
|
||||
_paq.push(["setTrackerUrl", u + "matomo.php"]);
|
||||
_paq.push(["setSiteId", Galaxy.config.matomo_site_id]);
|
||||
var d = document;
|
||||
var g = d.createElement("script");
|
||||
var s = d.getElementsByTagName("script")[0];
|
||||
g.type = "text/javascript";
|
||||
g.async = true;
|
||||
g.src = u + "matomo.js";
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
}
|
||||
|
||||
Galaxy.libraries = this;
|
||||
|
||||
|
||||
@@ -1468,6 +1468,51 @@
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
``plausible_server``
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
Please enter the URL for the Plausible server (including https) so
|
||||
this can be used for tracking with Plausible
|
||||
(https://plausible.io/).
|
||||
:Default: ``None``
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
``plausible_domain``
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
Please enter the URL for the Galaxy server so this can be used for
|
||||
tracking with Plausible (https://plausible.io/).
|
||||
:Default: ``None``
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~
|
||||
``matomo_server``
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
Please enter the URL for the Matomo server (including https) so
|
||||
this can be used for tracking with Matomo (https://matomo.org/).
|
||||
:Default: ``None``
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
``matomo_site_id``
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
Please enter the site ID for the Matomo server so this can be used
|
||||
for tracking with Matomo (https://matomo.org/).
|
||||
:Default: ``None``
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
``display_servers``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -817,6 +817,23 @@ galaxy:
|
||||
# your Google Analytics account. Example: UA-XXXXXXXX-Y
|
||||
#ga_code: null
|
||||
|
||||
# Please enter the URL for the Plausible server (including https) so
|
||||
# this can be used for tracking with Plausible
|
||||
# (https://plausible.io/).
|
||||
#plausible_server: null
|
||||
|
||||
# Please enter the URL for the Galaxy server so this can be used for
|
||||
# tracking with Plausible (https://plausible.io/).
|
||||
#plausible_domain: null
|
||||
|
||||
# Please enter the URL for the Matomo server (including https) so this
|
||||
# can be used for tracking with Matomo (https://matomo.org/).
|
||||
#matomo_server: null
|
||||
|
||||
# Please enter the site ID for the Matomo server so this can be used
|
||||
# for tracking with Matomo (https://matomo.org/).
|
||||
#matomo_site_id: null
|
||||
|
||||
# Galaxy can display data at various external browsers. These options
|
||||
# specify which browsers should be available. URLs and builds
|
||||
# available at these browsers are defined in the specified files.
|
||||
|
||||
@@ -179,6 +179,23 @@ tool_shed:
|
||||
# your Google Analytics account. Example: UA-XXXXXXXX-Y
|
||||
#ga_code: null
|
||||
|
||||
# Please enter the URL for the Plausible server (including https) so
|
||||
# this can be used for tracking with Plausible
|
||||
# (https://plausible.io/).
|
||||
#plausible_server: null
|
||||
|
||||
# Please enter the URL for the Galaxy server so this can be used for
|
||||
# tracking with Plausible (https://plausible.io/).
|
||||
#plausible_domain: null
|
||||
|
||||
# Please enter the URL for the Matomo server (including https) so this
|
||||
# can be used for tracking with Matomo (https://matomo.org/).
|
||||
#matomo_server: null
|
||||
|
||||
# Please enter the site ID for the Matomo server so this can be used
|
||||
# for tracking with Matomo (https://matomo.org/).
|
||||
#matomo_site_id: null
|
||||
|
||||
# The Tool Shed encodes various internal values when these values will
|
||||
# be output in some format (for example, in a URL or cookie). You
|
||||
# should set a key to be used by the algorithm that encodes and
|
||||
|
||||
@@ -162,6 +162,10 @@ class ConfigSerializer(base.ModelSerializer):
|
||||
'datatypes_disable_auto': _use_config,
|
||||
'allow_user_dataset_purge': _defaults_to(False), # schema default is True
|
||||
'ga_code': _use_config,
|
||||
'plausible_server': _use_config,
|
||||
'plausible_domain': _use_config,
|
||||
'matomo_server': _use_config,
|
||||
'matomo_site_id': _use_config,
|
||||
'enable_unique_workflow_defaults': _use_config,
|
||||
'enable_beta_markdown_export': _use_config,
|
||||
'simplified_workflow_run_ui_target_history': _use_config,
|
||||
|
||||
@@ -1061,6 +1061,34 @@ mapping:
|
||||
You can enter tracking code here to track visitor's behavior
|
||||
through your Google Analytics account. Example: UA-XXXXXXXX-Y
|
||||
|
||||
plausible_server:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Plausible server (including https) so this can be used for tracking
|
||||
with Plausible (https://plausible.io/).
|
||||
|
||||
plausible_domain:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Galaxy server so this can be used for tracking
|
||||
with Plausible (https://plausible.io/).
|
||||
|
||||
matomo_server:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Matomo server (including https) so this can be used for tracking
|
||||
with Matomo (https://matomo.org/).
|
||||
|
||||
matomo_site_id:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the site ID for the Matomo server so this can be used for tracking
|
||||
with Matomo (https://matomo.org/).
|
||||
|
||||
display_servers:
|
||||
type: str
|
||||
default: hgw1.cse.ucsc.edu,hgw2.cse.ucsc.edu,hgw3.cse.ucsc.edu,hgw4.cse.ucsc.edu,hgw5.cse.ucsc.edu,hgw6.cse.ucsc.edu,hgw7.cse.ucsc.edu,hgw8.cse.ucsc.edu,lowepub.cse.ucsc.edu
|
||||
|
||||
@@ -172,6 +172,34 @@ mapping:
|
||||
You can enter tracking code here to track visitor's behavior
|
||||
through your Google Analytics account. Example: UA-XXXXXXXX-Y
|
||||
|
||||
plausible_server:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Plausible server (including https) so this can be used for tracking
|
||||
with Plausible (https://plausible.io/).
|
||||
|
||||
plausible_domain:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Galaxy server so this can be used for tracking
|
||||
with Plausible (https://plausible.io/).
|
||||
|
||||
matomo_server:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the URL for the Matomo server (including https) so this can be used for tracking
|
||||
with Matomo (https://matomo.org/).
|
||||
|
||||
matomo_site_id:
|
||||
type: str
|
||||
required: false
|
||||
desc: |
|
||||
Please enter the site ID for the Matomo server so this can be used for tracking
|
||||
with Matomo (https://matomo.org/).
|
||||
|
||||
id_secret:
|
||||
type: str
|
||||
default: changethisinproductiontoo
|
||||
|
||||
@@ -68,6 +68,12 @@
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.ga_code:
|
||||
${ galaxy_client.config_google_analytics(self.js_app.config.ga_code) }
|
||||
%endif
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.plausible_server and self.js_app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(self.js_app.config.plausible_server, self.js_app.config.plausible_domain) }
|
||||
%endif
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.matomo_server and self.js_app.config.matomo_site_id:
|
||||
${ galaxy_client.config_matomo_analytics(self.js_app.config.matomo_server, self.js_app.config.matomo_site_id) }
|
||||
%endif
|
||||
|
||||
%if not form_input_auto_focus is UNDEFINED and form_input_auto_focus:
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -70,6 +70,12 @@
|
||||
%if t.webapp.name == 'galaxy' and app.config.ga_code:
|
||||
${galaxy_client.config_google_analytics(app.config.ga_code)}
|
||||
%endif
|
||||
%if t.webapp.name == 'galaxy' and app.config.plausible_server and app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(app.config.plausible_server, app.config.plausible_domain) }
|
||||
%endif
|
||||
%if t.webapp.name == 'galaxy' and app.config.matomo_server and app.config.matomo_site_id:
|
||||
${ galaxy_client.config_matomo_analytics(app.config.matomo_server, app.config.matomo_site_id) }
|
||||
%endif
|
||||
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -70,6 +70,41 @@ ${ h.dumps( dictionary, indent=( 2 if trans.debug else 0 ) ) }
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="config_plausible_analytics(plausible_server, plausible_domain)">
|
||||
%if plausible_server and plausible_domain:
|
||||
<script async defer data-domain="${plausible_domain}" src="${plausible_server}/js/plausible.js"></script>
|
||||
%else:
|
||||
<script>console.warn("Missing plausible server or plausible domain");</script>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="config_matomo_analytics(matomo_server, matomo_site_id)">
|
||||
<script type="text/javascript">
|
||||
console.log("config_matomo_analytics matomo_server:", '${matomo_server}');
|
||||
console.log("config_matomo_analytics matomo_site_id:", '${matomo_site_id}');
|
||||
%if ga_code:
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function () {
|
||||
var u = "${matomo_server}/";
|
||||
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
_paq.push(['setSiteId', '${matomo_site_id}']);
|
||||
var d = document;
|
||||
var g = d.createElement('script');
|
||||
var s = d.getElementsByTagName('script')[0];
|
||||
g.type = 'text/javascript';
|
||||
g.async = true;
|
||||
g.src = u + 'matomo.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
%else:
|
||||
console.warn("Missing matomo server or matomo site id");
|
||||
%endif
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
||||
## ----------------------------------------------------------------------------
|
||||
<%def name="get_user_dict()">
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
%if app.config.ga_code:
|
||||
${ galaxy_client.config_google_analytics(app.config.ga_code)}
|
||||
%endif
|
||||
%if app.config.plausible_server and app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(app.config.plausible_server, app.config.plausible_domain) }
|
||||
%endif
|
||||
%if app.config.matomo_server:
|
||||
${ galaxy_client.config_matomo_analytics(app.config.matomo_server) }
|
||||
%endif
|
||||
|
||||
## start main tag
|
||||
<nav id="masthead" class="navbar navbar-expand fixed-top justify-content-center navbar-dark">
|
||||
|
||||
@@ -64,6 +64,12 @@
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.ga_code:
|
||||
${ galaxy_client.config_google_analytics(self.js_app.config.ga_code) }
|
||||
%endif
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.plausible_server and self.js_app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(self.js_app.config.plausible_server, self.js_app.config.plausible_domain) }
|
||||
%endif
|
||||
%if self.js_app and self.js_app.config and self.js_app.config.matomo_server and self.js_app.config.matomo_site_id:
|
||||
${ galaxy_client.config_matomo_analytics(self.js_app.config.matomo_server, self.js_app.config.matomo_site_id) }
|
||||
%endif
|
||||
|
||||
%if not form_input_auto_focus is UNDEFINED and form_input_auto_focus:
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -69,6 +69,12 @@
|
||||
%if t.webapp.name == 'galaxy' and app.config.ga_code:
|
||||
${galaxy_client.config_google_analytics(app.config.ga_code)}
|
||||
%endif
|
||||
%if t.webapp.name == 'galaxy' and app.config.plausible_server and app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(app.config.plausible_server, app.config.plausible_domain) }
|
||||
%endif
|
||||
%if t.webapp.name == 'galaxy' and app.config.matomo_server and app.config.matomo_site_id:
|
||||
${ galaxy_client.config_matomo_analytics(app.config.matomo_server, app.config.matomo_site_id) }
|
||||
%endif
|
||||
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -71,6 +71,43 @@ ${ h.dumps( dictionary, indent=( 2 if trans.debug else 0 ) ) }
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="config_plausible_analytics(plausible_server, plausible_domain)">
|
||||
%if plausible_server and plausible_domain:
|
||||
<script async defer data-domain="${plausible_domain}" src="${plausible_server}/js/plausible.js"></script>
|
||||
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
|
||||
%else:
|
||||
<script>
|
||||
console.warn("Missing plausible server or plausible domain");
|
||||
</script>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="config_matomo_analytics(matomo_server, matomo_site_id)">
|
||||
<script type="text/javascript">
|
||||
console.log("config_matomo_analytics matomo_server:", '${matomo_server}');
|
||||
console.log("config_matomo_analytics matomo_site_id:", '${matomo_site_id}')
|
||||
%if matomo_server and matomo_site_id:
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function () {
|
||||
var u = "${matomo_server}/";
|
||||
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
_paq.push(['setSiteId', '${matomo_site_id}']);
|
||||
var d = document;
|
||||
var g = d.createElement('script');
|
||||
var s = d.getElementsByTagName('script')[0];
|
||||
g.type = 'text/javascript';
|
||||
g.async = true;
|
||||
g.src = u + 'matomo.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
%else:
|
||||
console.warn("Missing matomo server or matomo site id");
|
||||
%endif
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
||||
## ----------------------------------------------------------------------------
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
'jquery-ui/smoothness/jquery-ui',
|
||||
'bootstrap-tour',
|
||||
)}
|
||||
|
||||
</head>
|
||||
|
||||
<body scroll="no" class="full-content">
|
||||
@@ -76,7 +75,12 @@
|
||||
%if app.config.ga_code:
|
||||
${ galaxy_client.config_google_analytics(app.config.ga_code) }
|
||||
%endif
|
||||
|
||||
%if app.config.plausible_server and app.config.plausible_domain:
|
||||
${ galaxy_client.config_plausible_analytics(app.config.plausible_server, app.config.plausible_domain) }
|
||||
%endif
|
||||
%if app.config.matomo_server and app.config.matomo_site_id:
|
||||
${ galaxy_client.config_matomo_analytics(app.config.matomo_server, app.config.matomo_site_id) }
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="js_disabled_warning()">
|
||||
|
||||
Reference in New Issue
Block a user