Merge pull request #5153 from luisramos0/bye_bye_ga

Bye bye Google Analytics
This commit is contained in:
Luis Ramos
2020-04-28 16:09:16 +01:00
committed by GitHub
13 changed files with 35 additions and 91 deletions

View File

@@ -14,7 +14,6 @@ Spree::AppConfiguration.class_eval do
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

View File

@@ -56,4 +56,3 @@
= render "layouts/bugherd_script"
= render "layouts/matomo_tag"
= render 'spree/shared/google_analytics'

View File

@@ -38,9 +38,6 @@
.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))

View File

@@ -20,7 +20,6 @@
= configurations_sidebar_menu_item Spree.t(:shipping_methods), admin_shipping_methods_path
= configurations_sidebar_menu_item Spree.t(:shipping_categories), admin_shipping_categories_path
= configurations_sidebar_menu_item t(:enterprise_fees), main_app.admin_enterprise_fees_path
= configurations_sidebar_menu_item Spree.t(:analytics_trackers), admin_trackers_path
= configurations_sidebar_menu_item t('admin.contents.edit.title'), main_app.edit_admin_contents_path
= configurations_sidebar_menu_item t('admin.invoice_settings.edit.title'), main_app.edit_admin_invoice_settings_path
= configurations_sidebar_menu_item t('admin.matomo_settings.edit.title'), main_app.edit_admin_matomo_settings_path

View File

@@ -3,7 +3,7 @@
= tab :order_cycles, url: main_app.admin_order_cycles_path, icon: 'icon-refresh'
= tab :orders, :subscriptions, :customer_details, :adjustments, :payments, :return_authorizations, url: admin_orders_path('q[s]' => 'completed_at desc'), icon: 'icon-shopping-cart'
= tab :reports, icon: 'icon-file'
= tab :general_settings, :mail_method, :image_settings, :tax_categories, :tax_rates, :tax_settings, :zones, :countries, :states, :payment_methods, :taxonomies, :shipping_methods, :shipping_categories, :enterprise_fees, :trackers, :contents, :invoice_settings, :matomo_settings, :stripe_connect_settings, label: 'configuration', icon: 'icon-wrench', url: edit_admin_general_settings_path
= tab :general_settings, :mail_method, :image_settings, :tax_categories, :tax_rates, :tax_settings, :zones, :countries, :states, :payment_methods, :taxonomies, :shipping_methods, :shipping_categories, :enterprise_fees, :contents, :invoice_settings, :matomo_settings, :stripe_connect_settings, label: 'configuration', icon: 'icon-wrench', url: edit_admin_general_settings_path
= tab :enterprises, :enterprise_relationships, url: main_app.admin_enterprises_path
= tab :customers, url: main_app.admin_customers_path
= tab :enterprise_groups, url: main_app.admin_enterprise_groups_path, label: 'groups'

View File

@@ -70,7 +70,5 @@
%div{"data-hook" => "admin_footer_scripts"}
= render 'spree/shared/google_analytics'
%script
= raw "Spree.api_key = \"#{try_spree_current_user.try(:spree_api_key).to_s}\";"

View File

@@ -1,39 +0,0 @@
<% if tracker = Spree::Tracker.current %>
<%= javascript_tag do %>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<%= tracker.analytics_id %>']);
_gaq.push(['_trackPageview']);
<% if flash[:commerce_tracking] && @order.present? %>
<%# more info: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEcommerce %>
_gaq.push(['_addTrans',
"<%= j @order.number %>",
"",
"<%= @order.total %>",
"<%= @order.adjustments.tax.sum(:amount) %>",
"<%= @order.adjustments.shipping.sum(:amount) %>",
"<%= j @order.bill_address.city %>",
"<%= j @order.bill_address.state_text %>",
"<%= j @order.bill_address.country.name %>"
]);
<% @order.line_items.each do |line_item| %>
_gaq.push(['_addItem',
"<%= j @order.number %>",
"<%= j line_item.variant.sku %>",
"<%= j line_item.variant.product.name %>",
"",
"<%= line_item.price %>",
"<%= line_item.quantity %>"
]);
<% end %>
_gaq.push(['_trackTrans']);
<% end %>
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = '//google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<% end %>
<% end %>

View File

@@ -1404,14 +1404,8 @@ en:
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 dont use, understand user experience issues, etc."
statistics_cookies_analytics_desc_html: "To collect and analyse platform usage data, 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 <a href='https://matomo.org/' target='_blank'>Matomo</a> (ex Piwik, open source analytics tool that is GDPR compliant and protects your privacy) as soon as we can."
statistics_cookies_matomo_desc_html: "To collect and analyse platform usage data, we use <a href='https://matomo.org/' target='_blank'>Matomo</a> (ex Piwik), an open source analytics tool that is GDPR compliant and protects your privacy."
statistics_cookies_matomo_optout: "Do you want to opt-out of Matomo analytics? We dont collect any personal data, and Matomo helps us to improve our service, but we respect your choice :-)"
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."
@@ -3049,13 +3043,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
new_shipping_category: "New Shipping Category"
back_to_shipping_categories: "Back To Shipping Categories"
analytics_trackers: "Analytics Trackers"
no_trackers_found: "No Trackers Found"
new_tracker: "New Tracker"
add_one: "Add One"
google_analytics_id: "Analytics ID"
back_to_trackers_list: "Back to Trackers List"
name: "Name"
description: "Description"
type: "Type"
@@ -3397,7 +3384,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
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:

View File

@@ -136,7 +136,6 @@ Spree::Core::Engine.routes.draw do
end
resource :image_settings
resources :trackers
resources :zones
resources :countries do

View File

@@ -0,0 +1,14 @@
class DropTrackersTable < ActiveRecord::Migration
def up
drop_table :spree_trackers
end
def down
create_table :spree_trackers do |t|
t.string :environment
t.string :analytics_id
t.boolean :active, :default => true
t.timestamps
end
end
end

View File

@@ -0,0 +1,13 @@
class RemoveGaCookiesPreference < ActiveRecord::Migration
class Spree::Preference < ActiveRecord::Base; end
def up
Spree::Preference
.where( key: 'spree/app_configuration/cookies_policy_ga_section')
.destroy_all
end
def down
# If this preference is re-added to the code, the DB entry will be regenerated
end
end

View File

@@ -12,7 +12,6 @@
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20200406085833) do
create_table "adjustment_metadata", :force => true do |t|
t.integer "adjustment_id"
t.integer "enterprise_id"
@@ -1011,14 +1010,6 @@ ActiveRecord::Schema.define(:version => 20200406085833) do
add_index "spree_tokenized_permissions", ["permissable_id", "permissable_type"], :name => "index_tokenized_name_and_type"
create_table "spree_trackers", :force => true do |t|
t.string "environment"
t.string "analytics_id"
t.boolean "active", :default => true
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "spree_users", :force => true do |t|
t.string "encrypted_password"
t.string "password_salt"

View File

@@ -44,32 +44,20 @@
%p
= t 'legal.cookies_policy.essential_cookies_note'
- if Spree::Config.cookies_policy_matomo_section || Spree::Config.cookies_policy_ga_section
- if Spree::Config.cookies_policy_matomo_section
%h2
= t 'legal.cookies_policy.statistics_cookies'
%p
= t 'legal.cookies_policy.statistics_cookies_desc'
- if Spree::Config.cookies_policy_ga_section
%p
= t 'legal.cookies_policy.statistics_cookies_analytics_desc_html'
- if Spree::Config.cookies_policy_matomo_section
%p
= t 'legal.cookies_policy.statistics_cookies_matomo_desc_html'
%p
= t 'legal.cookies_policy.statistics_cookies_matomo_desc_html'
%table{ng: { controller:"CookiesPolicyModalCtrl"}}
- if Spree::Config.cookies_policy_ga_section
= render_cookie_entry( "__utma", t( "legal.cookies_policy.cookie_analytics_utma_desc" ) )
= render_cookie_entry( "__utmt", t( "legal.cookies_policy.cookie_analytics_utmt_desc" ) )
= render_cookie_entry( "__utmb", t( "legal.cookies_policy.cookie_analytics_utmb_desc" ) )
= render_cookie_entry( "__utmc", t( "legal.cookies_policy.cookie_analytics_utmc_desc" ) )
= render_cookie_entry( "__utmz", t( "legal.cookies_policy.cookie_analytics_utmz_desc" ) )
- if Spree::Config.cookies_policy_matomo_section
= render_cookie_entry( "_pk_ref, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_basics_desc" ) )
= render_cookie_entry( "_pk_hsr, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_heatmap_desc" ) )
= render_cookie_entry( "piwik_ignore, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_ignore_desc" ) )
= render_cookie_entry( "_pk_ref, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_basics_desc" ) )
= render_cookie_entry( "_pk_hsr, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_heatmap_desc" ) )
= render_cookie_entry( "piwik_ignore, _pk_cvar, _pk_id and _pk_ses", t( "legal.cookies_policy.cookie_matomo_ignore_desc" ) )
- if Spree::Config.cookies_policy_matomo_section && Spree::Config.matomo_url.present?
- if Spree::Config.matomo_url.present?
%p
= t 'legal.cookies_policy.statistics_cookies_matomo_optout'
%p