From 2843ab82347a697406a43969545f9781b6b209ef Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Wed, 19 Aug 2020 08:07:51 -0700 Subject: [PATCH] LP1517298: Simplifying and cleaning up matomo implementation Signed-off-by: Jane Sandberg Signed-off-by: Rogan Hamby Signed-off-by: Jason Boyer --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 44 ++++++++-------- .../sql/Pg/upgrade/xxxx.data.support_matomo.sql | 60 +++++++++++----------- Open-ILS/src/templates/opac/parts/base.tt2 | 7 ++- .../Administration/lp1517298_matomo.adoc | 29 +++++------ .../pages/designing_your_catalog.adoc | 14 +++++ 5 files changed, 83 insertions(+), 71 deletions(-) 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 27099e33f6..e203f288d4 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1939,8 +1939,8 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES 'View booking resource types', 'ppl', 'description')), ( 622, 'VIEW_BOOKING_RESOURCE', oils_i18n_gettext(622, 'View booking resources', 'ppl', 'description')), - ( 623, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.use_matomo', oils_i18n_gettext(623, - 'Set OPAC to use Matomo tracking', 'ppl', 'description')) + ( 623, 'UPDATE_ORG_UNIT_SETTING.opac.matomo', oils_i18n_gettext(623, + 'Allows a user to configure Matomo Analytics org unit settings', 'ppl', 'description')) ; @@ -20760,22 +20760,24 @@ VALUES ( ); INSERT into config.org_unit_setting_type - ( name, grp, label, description, datatype, update_perm ) VALUES - ( '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', 623), - ( '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', 623) -; - + ( name, grp, label, description, datatype, update_perm ) +VALUES ( + 'opac.analytics.matomo_id', 'opac', + oils_i18n_gettext( + 'opac.analytics.matomo_id', + 'Matomo Site ID', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_id', + 'The Site ID for your Evergreen catalog. You can find the Site ID in the tracking code you got from Matomo.', + 'coust', 'description'), + 'string', 623 +), ( + 'opac.analytics.matomo_url', 'opac', + oils_i18n_gettext('opac.analytics.matomo_url', + 'Matomo URL', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_url', + 'The URL for your the Matomo software. Be sure to include the trailing slash, e.g. https://my-evergreen.matomo.cloud/', + 'coust', 'description'), + 'string', 623 +); 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 index a90e83b530..e75ad448f1 100644 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.support_matomo.sql @@ -1,34 +1,36 @@ - BEGIN; +BEGIN; - SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); +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.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 ( + 623, 'UPDATE_ORG_UNIT_SETTING.opac.matomo', oils_i18n_gettext(623, + 'Allows a user to configure Matomo Analytics org unit settings', 'ppl', 'description') +); - INSERT INTO permission.perm_list ( id, code, description ) VALUES - ( 623, 'UPDATE_ORG_UNIT_SETTING.opac.analytics.use_matomo', oils_i18n_gettext(623, - 'Set OPAC to use Matomo tracking', 'ppl', 'description')), - ; +INSERT into config.org_unit_setting_type + ( name, grp, label, description, datatype, update_perm ) +VALUES ( + 'opac.analytics.matomo_id', 'opac', + oils_i18n_gettext( + 'opac.analytics.matomo_id', + 'Matomo Site ID', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_id', + 'The Site ID for your Evergreen catalog. You can find the Site ID in the tracking code you got from Matomo.', + 'coust', 'description'), + 'string', 623 +), ( + 'opac.analytics.matomo_url', 'opac', + oils_i18n_gettext('opac.analytics.matomo_url', + 'Matomo URL', + 'coust', 'label'), + oils_i18n_gettext('opac.analytics.matomo_url', + 'The URL for your the Matomo software. Be sure to include the trailing slash, e.g. https://my-evergreen.matomo.cloud/', + 'coust', 'description'), + 'string', 623 +); - UPDATE config.org_unit_setting_type SET update_perm = 623 WHERE name = 'opac.analytics.matomo_id'; - UPDATE config.org_unit_setting_type SET update_perm = 623 WHERE name = 'opac.analytics.matomo_url'; - - COMMIT; +COMMIT; diff --git a/Open-ILS/src/templates/opac/parts/base.tt2 b/Open-ILS/src/templates/opac/parts/base.tt2 index ea47a60afd..190cf99a51 100644 --- a/Open-ILS/src/templates/opac/parts/base.tt2 +++ b/Open-ILS/src/templates/opac/parts/base.tt2 @@ -22,11 +22,10 @@ [% '' %] [% END %] - [% IF ctx.get_org_setting(ctx.search_ou, 'opac.analytics.use_matomo') == 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'); %] + [% IF matomo_id && matomo_url %] [% 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; diff --git a/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc b/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc index 79f977e928..2f947dbce4 100644 --- a/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc +++ b/docs/RELEASE_NOTES_NEXT/Administration/lp1517298_matomo.adoc @@ -1,28 +1,23 @@ 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 + +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: +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. +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: +These are set by YOAUSes opac.analytics.matomo_url and +opac.analytics.matomo_id respectively. A new permsision, +MATOMO_UPDATE_SETTINGS, controls 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 - diff --git a/docs/modules/admin_initial_setup/pages/designing_your_catalog.adoc b/docs/modules/admin_initial_setup/pages/designing_your_catalog.adoc index 128f6afd6d..4da4ae37d8 100644 --- a/docs/modules/admin_initial_setup/pages/designing_your_catalog.adoc +++ b/docs/modules/admin_initial_setup/pages/designing_your_catalog.adoc @@ -553,6 +553,20 @@ information. To use Matomo Analytics you need to: . Set up a hosted instance of Matomo . Add your Evergreen catalogue as a site +. Use the Library Settings Editor to add a Matomo URL and Site ID for your library. + +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. + === NoveList === -- 2.11.0