diff --git a/client/src/galaxy.library.js b/client/src/galaxy.library.js index 664bff5e592..62090ac6acf 100644 --- a/client/src/galaxy.library.js +++ b/client/src/galaxy.library.js @@ -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( + '' + ); + } + 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; diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index ddc26a4658c..8d1c05cb446 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -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`` ~~~~~~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index a65ad1df8fb..3f90f6c42c3 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -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. diff --git a/lib/galaxy/config/sample/tool_shed.yml.sample b/lib/galaxy/config/sample/tool_shed.yml.sample index d7e8e6c5aac..3ba6eb2948e 100644 --- a/lib/galaxy/config/sample/tool_shed.yml.sample +++ b/lib/galaxy/config/sample/tool_shed.yml.sample @@ -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 diff --git a/lib/galaxy/managers/configuration.py b/lib/galaxy/managers/configuration.py index cbf2bd1be09..0018945f7bf 100644 --- a/lib/galaxy/managers/configuration.py +++ b/lib/galaxy/managers/configuration.py @@ -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, diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index 378e1b9bb4b..87d9be76f7c 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -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 diff --git a/lib/tool_shed/webapp/config_schema.yml b/lib/tool_shed/webapp/config_schema.yml index 1302a11593a..3fadb90539a 100644 --- a/lib/tool_shed/webapp/config_schema.yml +++ b/lib/tool_shed/webapp/config_schema.yml @@ -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 diff --git a/lib/tool_shed/webapp/templates/base.mako b/lib/tool_shed/webapp/templates/base.mako index c72f5687ddf..ea1688d42bf 100644 --- a/lib/tool_shed/webapp/templates/base.mako +++ b/lib/tool_shed/webapp/templates/base.mako @@ -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: +<%def name="config_plausible_analytics(plausible_server, plausible_domain)"> + %if plausible_server and plausible_domain: + + %else: + + %endif + + +<%def name="config_matomo_analytics(matomo_server, matomo_site_id)"> + + + ## ---------------------------------------------------------------------------- <%def name="get_user_dict()"> diff --git a/lib/tool_shed/webapp/templates/webapps/tool_shed/base_panels.mako b/lib/tool_shed/webapp/templates/webapps/tool_shed/base_panels.mako index 95384138be4..e9ceef2c311 100644 --- a/lib/tool_shed/webapp/templates/webapps/tool_shed/base_panels.mako +++ b/lib/tool_shed/webapp/templates/webapps/tool_shed/base_panels.mako @@ -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