From 4b64369ddbc0cdc49857e4b3b42856d307bdc2e3 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sat, 21 Jul 2018 15:09:03 +0100 Subject: [PATCH] Added GA and Matomo toggle in Legal Settings in the global settings in the BO and added GA and Matomo cookies details to the cookies policy page (according to what is configured in the BO) --- .../cookies_policy/cookies_policy.html.haml | 88 +++++++++++++++++++ .../spree/app_configuration_decorator.rb | 2 + .../edit/legal_settings.html.haml.deface | 8 +- config/locales/en.yml | 16 ++++ 4 files changed, 113 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml b/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml index 4599813a62..2e9f5f1cd6 100644 --- a/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml +++ b/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml @@ -27,6 +27,13 @@ {{ instance_hostname }} %td {{ 'legal.cookies_policy.cookie_session_desc' | t}} + %tr + %td + cookies_consent + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_consent_desc' | t}} %tr %td remember_spree_user_token @@ -65,6 +72,87 @@ {{ instance_hostname }} %p {{ 'legal.cookies_policy.essential_cookies_note' | t}} + +- if Spree::Config.cookies_policy_matomo_section || Spree::Config.cookies_policy_ga_section + %h2 + {{ 'legal.cookies_policy.statistics_cookies' | t}} + %p + {{ 'legal.cookies_policy.statistics_cookies_desc' | t}} + + - if Spree::Config.cookies_policy_ga_section + %p + {{ 'legal.cookies_policy.statistics_cookies_analytics_desc' | t}} + - if Spree::Config.cookies_policy_matomo_section + %p + {{ 'legal.cookies_policy.statistics_cookies_matomo_desc' | t}} + + %table{ng: { controller:"CookiesPolicyModalCtrl"}} + %tr + %th + {{ 'legal.cookies_policy.cookie_name' | t}} + %th + {{ 'legal.cookies_policy.cookie_domain' | t}} + %th + {{ 'legal.cookies_policy.cookie_desc' | t}} + - if Spree::Config.cookies_policy_ga_section + %tr + %td + __utma + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_analytics_utma_desc' | t}} + %tr + %td + __utmt + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_analytics_utmt_desc' | t}} + %tr + %td + __utmb + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_analytics_utmb_desc' | t}} + %tr + %td + __utmc + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_analytics_utmc_desc' | t}} + %tr + %td + __utmz + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_analytics_utmz_desc' | t}} + - if Spree::Config.cookies_policy_matomo_section + %tr + %td + _pk_ref, _pk_cvar, _pk_id and _pk_ses + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_matomo_basics_desc' | t}} + %tr + %td + _pk_hsr + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_matomo_heatmap_desc' | t}} + %tr + %td + piwik_ignore + %td + {{ instance_hostname }} + %td + {{ 'legal.cookies_policy.cookie_matomo_ignore_desc' | t}} + %h2 {{ 'legal.cookies_policy.disabling_cookies_header' | t}} %p diff --git a/app/models/spree/app_configuration_decorator.rb b/app/models/spree/app_configuration_decorator.rb index 9f9d051521..992c39abe1 100644 --- a/app/models/spree/app_configuration_decorator.rb +++ b/app/models/spree/app_configuration_decorator.rb @@ -13,6 +13,8 @@ Spree::AppConfiguration.class_eval do preference :enterprises_require_tos, :boolean, default: false preference :privacy_policy_url, :string, default: nil preference :cookies_consent_banner_toggle, :boolean, default: false + preference :cookies_policy_matomo_section, :boolean, default: false + preference :cookies_policy_ga_section, :boolean, default: false # Tax Preferences preference :products_require_tax_category, :boolean, default: false diff --git a/app/overrides/spree/admin/general_settings/edit/legal_settings.html.haml.deface b/app/overrides/spree/admin/general_settings/edit/legal_settings.html.haml.deface index d7368246b9..5cbe3a577f 100644 --- a/app/overrides/spree/admin/general_settings/edit/legal_settings.html.haml.deface +++ b/app/overrides/spree/admin/general_settings/edit/legal_settings.html.haml.deface @@ -3,7 +3,7 @@ %fieldset.legal.no-border-bottom %legend{:align => "center"}= t('.legal_settings') .field - = label_tag(:footer_tos_url, t(:footer_tos_url)) + tag(:br) + = label_tag(:footer_tos_url, t('.footer_tos_url')) + tag(:br) = preference_field_tag(:footer_tos_url, Spree::Config[:footer_tos_url], type: Spree::Config.preference_type(:footer_tos_url)) .field = preference_field_tag(:enterprises_require_tos, Spree::Config[:enterprises_require_tos], :type => Spree::Config.preference_type(:enterprises_require_tos)) @@ -11,6 +11,12 @@ .field = preference_field_tag(:cookies_consent_banner_toggle, Spree::Config[:cookies_consent_banner_toggle], :type => Spree::Config.preference_type(:cookies_consent_banner_toggle)) = label_tag(:cookies_consent_banner_toggle, t('.cookies_consent_banner_toggle')) + tag(:br) + .field + = preference_field_tag(:cookies_policy_matomo_section, Spree::Config[:cookies_policy_matomo_section], :type => Spree::Config.preference_type(:cookies_policy_matomo_section)) + = label_tag(:cookies_policy_matomo_section, t('.cookies_policy_matomo_section')) + tag(:br) + .field + = preference_field_tag(:cookies_policy_ga_section, Spree::Config[:cookies_policy_ga_section], :type => Spree::Config.preference_type(:cookies_policy_ga_section)) + = label_tag(:cookies_policy_ga_section, t('.cookies_policy_ga_section')) + tag(:br) .field = label_tag(:privacy_policy_url, t('.privacy_policy_url')) + tag(:br) = preference_field_tag(:privacy_policy_url, Spree::Config[:privacy_policy_url], type: Spree::Config.preference_type(:privacy_policy_url)) diff --git a/config/locales/en.yml b/config/locales/en.yml index a7a828c45a..e8df84c912 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1277,9 +1277,22 @@ en: cookie_domain: "Set By" cookie_desc: "Description" cookie_session_desc: "Used to allow the website to remember users between page visits, for example, remember items in your cart." + cookie_consent_desc: "Used to maintain status of user consent to store cookies" cookie_remember_me_desc: "Used if the user has requested the website to remember him. This cookie is automatically deleted after 12 days. If as a user you want that cookie to be deleted, you only need to logout. If you don’t want that cookie to be installed on your computer you shouldn’t check the “remember me” checkbox when logging in." cookie_openstreemap_desc: "Used by our friendly open source mapping provider (OpenStreetMap) to ensure that it does not receive too many requests during a given time period, to prevent abuse of their services." cookie_stripe_desc: "Data collected by our payment processor Stripe for fraud detection https://stripe.com/cookies-policy/legal. Not all shops use Stripe as a payment method but it is a good practice to prevent fraud to apply it to all pages. Stripe probably build a picture of which of our pages usually interact with their API and then flag anything unusual. So setting the Stripe cookie has a broader function than simply the provision of a payment method to a user. Removing it could affect the security of the service itself. You can learn more about Stripe and read its privacy policy at https://stripe.com/privacy." + statistics_cookies: "Statistics Cookies" + statistics_cookies_desc: "The following are not Strictly Necessary, but help to provide you with the best user experience by allowing us to analyse user behaviour, identify which features you use most, or don’t use, understand user experience issues, etc." + statistics_cookies_analytics_desc: "We use Google Analytics, as it was the default service connected with Spree (the e-commerce open source software that we built on) but our vision is to switch to Matomo (ex Piwik, open source analytics tool) as soon as we can." + statistics_cookies_matomo_desc: "We use Matomo (ex Piwik), an open source analytics tool." + cookie_analytics_utma_desc: "Used to distinguish users and sessions. The cookie is created when the javascript library executes and no existing __utma cookies exists. The cookie is updated every time data is sent to Google Analytics." + cookie_analytics_utmt_desc: "Used to throttle request rate." + cookie_analytics_utmb_desc: "Used to determine new sessions/visits. The cookie is created when the javascript library executes and no existing __utmb cookies exists. The cookie is updated every time data is sent to Google Analytics." + cookie_analytics_utmc_desc: "Not used in ga.js. Set for interoperability with urchin.js. Historically, this cookie operated in conjunction with the __utmb cookie to determine whether the user was in a new session/visit." + cookie_analytics_utmz_desc: "Stores the traffic source or campaign that explains how the user reached your site. The cookie is created when the javascript library executes and is updated every time data is sent to Google Analytics." + cookie_matomo_basics_desc: "Matomo first party cookies to collect statistics." + cookie_matomo_heatmap_desc: "Matomo Heatmap & Session Recording cookie." + cookie_matomo_ignore_desc: "Cookie used to exclude user from being tracked." disabling_cookies_header: "Warning on disabling cookies" disabling_cookies_desc: "As a user you can always allow, block or delete Open Food Network’s or any other website cookies whenever you want to through your browser’s setting control. Each browser has a different operative. Here are the links:" disabling_cookies_firefox_link: "https://support.mozilla.org/en-US/kb/enable-and-disable-cookies-website-preferences" @@ -2652,6 +2665,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using cookies_consent_banner_toggle: "Display cookies consent banner" privacy_policy_url: "Privacy Policy URL" enterprises_require_tos: "Enterprises must accept Terms of Service" + cookies_policy_matomo_section: "Display Matomo section on cookies policy page" + cookies_policy_ga_section: "Display Google Analytics section on cookies policy page" + footer_tos_url: "Terms of Service URL" checkout: payment: stripe: