From 0ee2e116d557f5db38f9ece94cccfa892652da6e Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Tue, 18 Feb 2020 11:19:11 -0500 Subject: [PATCH] lp1517298_matomo_support Signed-off-by: Rogan Hamby --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 36 ++++++++++++++++- .../sql/Pg/upgrade/xxxx.data.support_matomo.sql | 47 ++++++++++++++++++++++ Open-ILS/src/templates/opac/parts/base.tt2 | 7 ++++ .../src/templates/opac/parts/matomo_analytics.tt2 | 19 +++++++++ .../Administration/lp1517298_matomo.adoc | 28 +++++++++++++ 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql create mode 100644 Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index a49cf02de8..fd8ce4918d 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1933,7 +1933,14 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 618, 'CREATE_PRECAT', oils_i18n_gettext(618, 'Allows a user to create a pre-catalogued copy', 'ppl', 'description')), ( 619, 'EDIT_SELF_IN_CLIENT', oils_i18n_gettext(619, - 'Allow a user to edit their own account in the staff client', 'ppl', 'description')) + 'Allow a user to edit their own account in the staff client', 'ppl', 'description')), + ( 620, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.use_matomo', oils_i18n_gettext(620, + 'Set OPAC to use Matomo tracking', 'ppl', 'description')), + ( 621, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_id', oils_i18n_gettext(621, + 'Set Matomo ID', 'ppl', 'description')), + ( 622, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_url', oils_i18n_gettext(622, + 'Set Matomo URL', 'ppl', 'description')) + ; @@ -20308,3 +20315,30 @@ VALUES ( ) ); +INSERT into config.org_unit_setting_type + ( name, grp, label, description, datatype, update_perm ) VALUES + ( 'opac.analytics.use_matomo', 'opac', + oils_i18n_gettext('opac.analytics.use_matomo', + 'Flag to turn Matomo use on and off', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.use_matomo', + 'Flag to turn Matomo use on and off', + 'coust', 'description'), + 'bool', 620), + ( 'opac.analytics.matomo_id', 'opac', + oils_i18n_gettext('opac.analytics.matomo_id', + 'Requires the Matomo ID', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_id', + 'Requires the Matomo ID', + 'coust', 'description'), + 'string', 621), + ( 'opac.analytics.matomo_url', 'opac', + oils_i18n_gettext('opac.analytics.matomo_url', + 'Requires the url to the Matomo software', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_url', + 'Requires the url to the Matomo software', + 'coust', 'description'), + 'string', 622) +; diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql new file mode 100644 index 0000000000..a416561e11 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql @@ -0,0 +1,47 @@ + BEGIN; + + SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); + + INSERT into config.org_unit_setting_type + ( name, grp, label, description, datatype, fm_class ) VALUES + ( 'opac.analytics.use_matomo', 'opac', + oils_i18n_gettext('opac.analytics.use_matomo', + 'Flag to turn Matomo use on and off', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.use_matomo', + 'Flag to turn Matomo use on and off', + 'coust', 'description'), + 'bool', NULL), + ( 'opac.analytics.matomo_id', 'opac', + oils_i18n_gettext('opac.analytics.matomo_id', + 'Requires the Matomo ID', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_id', + 'Requires the Matomo ID', + 'coust', 'description'), + 'string', NULL), + ( 'opac.analytics.matomo_url', 'opac', + oils_i18n_gettext('opac.analytics.matomo_url', + 'Requires the url to the Matomo software', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_url', + 'Requires the url to the Matomo software', + 'coust', 'description'), + 'string', NULL) + ; + + INSERT INTO permission.perm_list ( id, code, description ) VALUES + ( 620, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.use_matomo', oils_i18n_gettext(620, + 'Set OPAC to use Matomo tracking', 'ppl', 'description')), + ( 621, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_id', oils_i18n_gettext(621, + 'Set Matomo ID', 'ppl', 'description')), + ( 622, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_url', oils_i18n_gettext(622, + 'Set Matomo URL', 'ppl', 'description')) + ; + + UPDATE config.org_unit_setting_type SET update_perm = 620 WHERE name = 'opac.analytics.use_matomo'; + UPDATE config.org_unit_setting_type SET update_perm = 621 WHERE name = 'opac.analytics.matomo_id'; + UPDATE config.org_unit_setting_type SET update_perm = 622 WHERE name = 'opac.analytics.matomo_url'; + + COMMIT; + diff --git a/Open-ILS/src/templates/opac/parts/base.tt2 b/Open-ILS/src/templates/opac/parts/base.tt2 index b6c2876a8a..735269d469 100644 --- a/Open-ILS/src/templates/opac/parts/base.tt2 +++ b/Open-ILS/src/templates/opac/parts/base.tt2 @@ -22,6 +22,13 @@ [% '' %] [% END %] + [% IF ctx.get_org_setting(ctx.search_ou, 'opac.analytics.use_matomo') == 1 %] + [% matomo_enabled = 1; %] + [% matomo_id = ctx.get_org_setting(ctx.search_ou, 'opac.analytics.matomo_id'); %] + [% matomo_url = ctx.get_org_setting(ctx.search_ou, 'opac.analytics.matomo_url'); %] + [% INCLUDE 'opac/parts/matomo_analytics.tt2' %] + [% END %] + [%- libname = ctx.get_aou(ctx.search_ou).name; libname = libname | html; libsname = ctx.get_aou(ctx.search_ou).shortname; %] diff --git a/Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 b/Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 new file mode 100644 index 0000000000..48c7c6769a --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/matomo_analytics.tt2 @@ -0,0 +1,19 @@ +[%- PROCESS "opac/parts/header.tt2"; + IF matomo_enabled == 1 %] + + + + +[%- END %] diff --git a/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc b/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc new file mode 100644 index 0000000000..79f977e928 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc @@ -0,0 +1,28 @@ +Matomo Support +^^^^^^^^^^^^^^ +Support for the open source web analytics platform Matomo is now +native to Evergreen. Support is on an org unit level so different +libraries can have separate or no analytics. Once you setup +a Matomo service you will need the URL and site ID. Typically +Matomo will give you a block of javascript you can insert into +web sites. One line will look like : + +var u="http://mylibrary.lib/matomo/"; + +The full URL in the double quotes will be your URL. Another line +will look like: + +_paq.push(['setSiteId', '1']); + +In this case the number 1 will be your site ID. + +These are set by YOAUSes opac.analytics.matomo_url and +opac.analytics.matomo_id respectively. There is also a boolean +setting called opac.analytics.use_matomo which determines if +it is used at all. Three new permsisions control access to +these: + +UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_id +UPDATE_ORG_UNIT_SETTING.opac.analytics.matomo_url +UPDATE_ORG_UNIT_SETTING.opac.analytics.use_matomo + -- 2.11.0