spree_analytics_trackers 2.0.0.rc1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/README.md +1 -1
- data/app/assets/javascripts/spree/frontend/add_to_cart_analytics.js +11 -7
- data/app/controllers/spree/admin/trackers_controller.rb +8 -0
- data/app/models/spree/tracker.rb +11 -5
- data/app/overrides/add_google_analytics_page_view_to_spree_application.rb +2 -10
- data/app/overrides/add_google_analytics_to_spree_application.rb +2 -10
- data/app/overrides/add_segment_initializer_to_layout.rb +2 -10
- data/app/overrides/add_segment_page_viewed_to_layout.rb +2 -10
- data/app/views/spree/admin/trackers/_form.html.erb +7 -1
- data/app/views/spree/admin/trackers/index.html.erb +2 -0
- data/app/views/spree/shared/trackers/google_analytics/_checkout_step_viewed.js.erb +3 -6
- data/app/views/spree/shared/trackers/google_analytics/_initializer.js.erb +15 -1
- data/app/views/spree/shared/trackers/google_analytics/_page_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/google_analytics/_purchase.js.erb +2 -1
- data/app/views/spree/shared/trackers/segment/_cart_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_checkout_step_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_initializer.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_order_complete.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_page_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_product_list_filtered.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_product_list_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_product_viewed.js.erb +1 -1
- data/app/views/spree/shared/trackers/segment/_products_searched.js.erb +1 -1
- data/db/migrate/20200721163729_add_store_id_to_spree_trackers.rb +14 -0
- data/lib/spree_analytics_trackers/factories.rb +1 -0
- data/lib/spree_analytics_trackers/version.rb +1 -2
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +15 -6
- data/spec/models/spree/tracker_spec.rb +15 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0b6411079e555367f446b09fa1a87c6d65ae92a91492864063597fda033d168
|
4
|
+
data.tar.gz: 817b4c0ad4564596b3e38813557d58f3eb68359d9fb388a8e4f65c6f9c6a4f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb572bed798cf004072d91cd33892302fec6a622fabaa03b0b30bbed97af66215450abfd9f99bb41147ad499656611070e9aa475961f931c5fa16dad00782b4
|
7
|
+
data.tar.gz: b8366a5461585d8f75ff2e6256b9f1b1ea6d5e2f22ae7940aafb9a3d147d63958ecbd8332e8f5ab1728840558d6eb4b2b16f829cf7e93c50f4749047234cc98e
|
data/.bundle/config
ADDED
data/README.md
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
//= require spree/frontend
|
2
2
|
|
3
3
|
function gaAddToCart(variant, quantity) {
|
4
|
+
clearGAplugins();
|
5
|
+
var price = typeof variant.price === 'object' ? variant.price.amount : variant.price
|
4
6
|
gtag(
|
5
7
|
'event',
|
6
8
|
'add_to_cart',
|
7
9
|
{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
items: [{
|
11
|
+
id: variant.sku,
|
12
|
+
name: variant.name,
|
13
|
+
category: variant.category,
|
14
|
+
variant: variant.options_text,
|
15
|
+
brand: variant.brand,
|
16
|
+
price: price,
|
17
|
+
quantity: quantity
|
18
|
+
}]
|
15
19
|
}
|
16
20
|
);
|
17
21
|
}
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class TrackersController < ResourceController
|
4
|
+
before_action :load_data
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def load_data
|
9
|
+
@engines = Spree::Tracker.engines.keys.sort.map { |k| [k.humanize, k] }
|
10
|
+
@stores = Spree::Store.all
|
11
|
+
end
|
4
12
|
end
|
5
13
|
end
|
6
14
|
end
|
data/app/models/spree/tracker.rb
CHANGED
@@ -5,20 +5,26 @@ module Spree
|
|
5
5
|
|
6
6
|
after_commit :clear_cache
|
7
7
|
|
8
|
-
validates :analytics_id, presence: true, uniqueness: { scope: :engine, case_sensitive: false }
|
8
|
+
validates :analytics_id, presence: true, uniqueness: { scope: [:engine, :store_id], case_sensitive: false }
|
9
|
+
validates :store, presence: true
|
9
10
|
|
10
11
|
scope :active, -> { where(active: true) }
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
belongs_to :store
|
14
|
+
|
15
|
+
def self.current(engine = nil, store = nil)
|
16
|
+
engine ||= TRACKING_ENGINES.first
|
17
|
+
store ||= Spree::Store.default
|
18
|
+
|
19
|
+
tracker = Rails.cache.fetch("current_tracker/#{engine}/#{store.id}") do
|
20
|
+
active.find_by(store: store, engine: engine)
|
15
21
|
end
|
16
22
|
tracker.analytics_id.present? ? tracker : nil if tracker
|
17
23
|
end
|
18
24
|
|
19
25
|
def clear_cache
|
20
26
|
TRACKING_ENGINES.each do |engine|
|
21
|
-
Rails.cache.delete("current_tracker/#{engine}")
|
27
|
+
Rails.cache.delete("current_tracker/#{engine}/#{store_id}")
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -1,17 +1,9 @@
|
|
1
1
|
spree_version = Gem.loaded_specs['spree_core'].version
|
2
2
|
unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha')
|
3
3
|
Deface::Override.new(
|
4
|
-
virtual_path: 'spree/
|
4
|
+
virtual_path: 'spree/shared/_head',
|
5
5
|
name: 'add_google_analytics_page_viewed_to_spree_application',
|
6
|
-
|
7
|
-
partial: 'spree/shared/trackers/google_analytics/page_viewed.js',
|
8
|
-
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
9
|
-
)
|
10
|
-
|
11
|
-
Deface::Override.new(
|
12
|
-
virtual_path: 'spree/layouts/checkout',
|
13
|
-
name: 'add_google_analytics_page_viewed_to_spree_checkout',
|
14
|
-
insert_bottom: "[data-hook='body']",
|
6
|
+
insert_before: 'meta',
|
15
7
|
partial: 'spree/shared/trackers/google_analytics/page_viewed.js',
|
16
8
|
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
17
9
|
)
|
@@ -1,17 +1,9 @@
|
|
1
1
|
if Gem.loaded_specs['spree_core'].version >= Gem::Version.create('3.5.0.alpha')
|
2
2
|
Deface::Override.new(
|
3
|
-
virtual_path: 'spree/
|
3
|
+
virtual_path: 'spree/shared/_head',
|
4
4
|
name: 'add_google_analytics_initializer_to_spree_application',
|
5
|
-
|
5
|
+
insert_before: 'meta',
|
6
6
|
partial: 'spree/shared/trackers/google_analytics/initializer.js',
|
7
7
|
original: 'cfa30a2831d9a41394c03229cd28b3c7eee69585'
|
8
8
|
)
|
9
|
-
|
10
|
-
Deface::Override.new(
|
11
|
-
virtual_path: 'spree/layouts/checkout',
|
12
|
-
name: 'add_google_analytics_initializer_to_spree_checkout',
|
13
|
-
insert_top: '[data-hook="inside_head"]',
|
14
|
-
partial: 'spree/shared/trackers/google_analytics/initializer.js',
|
15
|
-
original: 'ca3d46a134b93856baf937cf2e473da66d9d8efc'
|
16
|
-
)
|
17
9
|
end
|
@@ -1,17 +1,9 @@
|
|
1
1
|
spree_version = Gem.loaded_specs['spree_core'].version
|
2
2
|
unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha')
|
3
3
|
Deface::Override.new(
|
4
|
-
virtual_path: 'spree/
|
4
|
+
virtual_path: 'spree/shared/_head',
|
5
5
|
name: 'add_segment_initializer_to_layout',
|
6
|
-
|
7
|
-
partial: 'spree/shared/trackers/segment/initializer.js',
|
8
|
-
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
9
|
-
)
|
10
|
-
|
11
|
-
Deface::Override.new(
|
12
|
-
virtual_path: 'spree/layouts/checkout',
|
13
|
-
name: 'add_segment_initializer_to_spree_checkout',
|
14
|
-
insert_bottom: '[data-hook="inside_head"]',
|
6
|
+
insert_before: 'meta',
|
15
7
|
partial: 'spree/shared/trackers/segment/initializer.js',
|
16
8
|
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
17
9
|
)
|
@@ -1,17 +1,9 @@
|
|
1
1
|
spree_version = Gem.loaded_specs['spree_core'].version
|
2
2
|
unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha')
|
3
3
|
Deface::Override.new(
|
4
|
-
virtual_path: 'spree/
|
4
|
+
virtual_path: 'spree/shared/_head',
|
5
5
|
name: 'add_segment_page_tracker_to_body',
|
6
|
-
|
7
|
-
partial: 'spree/shared/trackers/segment/page_viewed.js',
|
8
|
-
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
9
|
-
)
|
10
|
-
|
11
|
-
Deface::Override.new(
|
12
|
-
virtual_path: 'spree/layouts/checkout',
|
13
|
-
name: 'add_segment_page_tracker_to_spree_checkout',
|
14
|
-
insert_bottom: "[data-hook='body']",
|
6
|
+
insert_before: 'meta',
|
15
7
|
partial: 'spree/shared/trackers/segment/page_viewed.js',
|
16
8
|
original: '6841b819babbe4df1f03d0bc8e05dc81bf0d45ad'
|
17
9
|
)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="col-12 col-lg-6" data-hook="analytics_engine">
|
3
3
|
<%= f.field_container :engine, class: ["form-group"], "data-hook" => "analytics_engine" do %>
|
4
4
|
<%= f.label :engine, Spree.t(:analytics_engine) %>
|
5
|
-
<%= f.select :engine,
|
5
|
+
<%= f.select :engine, @engines, {}, { class: 'select2' } %>
|
6
6
|
<%= f.error_message_on :engine %>
|
7
7
|
<% end %>
|
8
8
|
</div>
|
@@ -30,6 +30,12 @@
|
|
30
30
|
<%= f.error_message_on :analytics_id %>
|
31
31
|
<% end %>
|
32
32
|
</div>
|
33
|
+
<div class="col-12 col-lg-6">
|
34
|
+
<div data-hook="store" class="form-group">
|
35
|
+
<%= label_tag :tracker_store, Spree.t(:store) %>
|
36
|
+
<%= collection_select(:tracker, :store_id, @stores, :id, :name, { include_blank: true }, {id: 'store_id', class: 'select2'}) %>
|
37
|
+
</div>
|
38
|
+
</div>
|
33
39
|
<div class="col-12 col-lg-6" data-hook="additional_tracker_fields"></div>
|
34
40
|
</div>
|
35
41
|
|
@@ -12,6 +12,7 @@
|
|
12
12
|
<tr data-hook="admin_trackers_index_headers">
|
13
13
|
<th><%= Spree.t(:google_analytics_id) %></th>
|
14
14
|
<th><%= Spree.t(:analytics_engine) %></th>
|
15
|
+
<th><%= Spree.t(:store) %></th>
|
15
16
|
<th class="text-center"><%= Spree.t(:active) %></th>
|
16
17
|
<th class="actions"></th>
|
17
18
|
</tr>
|
@@ -21,6 +22,7 @@
|
|
21
22
|
<tr id="<%= spree_dom_id tracker %>" data-hook="admin_trackers_index_rows">
|
22
23
|
<td><%= tracker.analytics_id %></td>
|
23
24
|
<td><%= tracker.engine.humanize %></td>
|
25
|
+
<td><%= tracker.store&.name %></td>
|
24
26
|
<td class="text-center">
|
25
27
|
<%= tracker.active ? Spree.t(:say_yes) : Spree.t(:say_no) %>
|
26
28
|
</td>
|
@@ -1,6 +1,7 @@
|
|
1
|
-
<% if @order.present? && !@order.completed? && Spree::Tracker.current(:google_analytics) %>
|
1
|
+
<% if @order.present? && !@order.completed? && Spree::Tracker.current(:google_analytics, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof gtag !== 'undefined') {
|
4
|
+
clearGAplugins();
|
4
5
|
gtag('event', 'checkout_progress', {
|
5
6
|
checkout_step: '<%= (@order.checkout_steps.index(@order.state) + 1) %>',
|
6
7
|
items: [
|
@@ -10,11 +11,7 @@
|
|
10
11
|
],
|
11
12
|
|
12
13
|
coupon: '<%= @order.promo_code %>',
|
13
|
-
|
14
|
-
|
15
|
-
gtag('event', 'set_checkout_option', {
|
16
|
-
'checkout_step': '<%= (@order.checkout_steps.index(@order.state) + 1) %>',
|
17
|
-
'checkout_option': '<%= @order.state %>'
|
14
|
+
checkout_option: '<%= @order.state %>'
|
18
15
|
});
|
19
16
|
};
|
20
17
|
</script>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if tracker = Spree::Tracker.current(:google_analytics) %>
|
1
|
+
<% if tracker = Spree::Tracker.current(:google_analytics, current_store) %>
|
2
2
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
3
3
|
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= tracker.analytics_id %>"></script>
|
4
4
|
<script>
|
@@ -7,5 +7,19 @@
|
|
7
7
|
gtag('js', new Date());
|
8
8
|
|
9
9
|
gtag('config', '<%= tracker.analytics_id %>', { 'send_page_view': false });
|
10
|
+
gtag('set', 'allow_google_signals', true )
|
11
|
+
gtag('set', 'allow_ad_personalization_signals', true );
|
12
|
+
|
13
|
+
function clearGAplugins() {
|
14
|
+
if (typeof ga !== "undefined" && typeof ga.getAll === "function") {
|
15
|
+
var trackingDom = ga.getAll()[0].get('trackingId');
|
16
|
+
if (trackingDom !== undefined) {
|
17
|
+
var trackingId = trackingDom.split('-').join('_')
|
18
|
+
if (trackingId !== undefined && ga.o !== undefined && ga.o["gtag_" + trackingId] !== undefined) {
|
19
|
+
delete ga.o["gtag_" + trackingId].plugins_
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
10
24
|
</script>
|
11
25
|
<% end %>
|
@@ -1,6 +1,7 @@
|
|
1
|
-
<% if @order.present? && order_just_completed?(@order) && Spree::Tracker.current(:google_analytics) %>
|
1
|
+
<% if @order.present? && order_just_completed?(@order) && Spree::Tracker.current(:google_analytics, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof gtag !== 'undefined') {
|
4
|
+
clearGAplugins();
|
4
5
|
gtag('event', 'purchase', {
|
5
6
|
transaction_id: '<%= @order.number %>',
|
6
7
|
value: <%= @order.total&.to_f %>,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if @order.present? && !@order.completed? && Spree::Tracker.current(:segment) %>
|
1
|
+
<% if @order.present? && !@order.completed? && Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof analytics !== 'undefined') {
|
4
4
|
analytics.track('Checkout Step Viewed', {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if tracker = Spree::Tracker.current(:segment) %>
|
1
|
+
<% if tracker = Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<script>
|
3
3
|
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";
|
4
4
|
analytics.load('<%=tracker.analytics_id%>'.replace(/^\s+|\s+$/g, ''));
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if @order.present? && order_just_completed?(@order) && Spree::Tracker.current(:segment) %>
|
1
|
+
<% if @order.present? && order_just_completed?(@order) && Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<% order_json = SpreeAnalyticsTrackers::Segment::OrderPresenter.new(@order).to_json %>
|
3
3
|
<script>
|
4
4
|
if (typeof analytics !== 'undefined') {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if defined?(products) && products.present? && Spree::Tracker.current(:segment) %>
|
1
|
+
<% if defined?(products) && products.present? && Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof analytics !== 'undefined') {
|
4
4
|
var segmentProductListViewedJson = {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if @product.present? && Spree::Tracker.current(:segment) %>
|
1
|
+
<% if @product.present? && Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof analytics !== 'undefined') {
|
4
4
|
var segmentProductViewed = <%= product_for_segment(@product, image: default_image_for_product_or_variant(@product)) %>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if params.key?(:keywords) && params[:keywords].present? && Spree::Tracker.current(:segment) %>
|
1
|
+
<% if params.key?(:keywords) && params[:keywords].present? && Spree::Tracker.current(:segment, current_store) %>
|
2
2
|
<script>
|
3
3
|
if (typeof analytics !== 'undefined') {
|
4
4
|
analytics.track('Products Searched', {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddStoreIdToSpreeTrackers < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
add_column :spree_trackers, :store_id, :integer
|
4
|
+
add_index :spree_trackers, :store_id
|
5
|
+
|
6
|
+
Spree::Tracker.reset_column_information
|
7
|
+
|
8
|
+
default_store = Spree::Store.default
|
9
|
+
Spree::Tracker.all.each do |tracker|
|
10
|
+
tracker.store = default_store
|
11
|
+
tracker.save
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,10 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe 'Analytics Tracker', type: :feature do
|
4
4
|
stub_authorization!
|
5
5
|
|
6
|
+
let!(:default_store) { Spree::Store.default }
|
7
|
+
let!(:another_store) { create(:store, name: 'Eurozone') }
|
8
|
+
|
6
9
|
context 'index' do
|
7
10
|
before(:each) do
|
8
|
-
create(:tracker)
|
9
|
-
create(:tracker, analytics_id: 'A200')
|
11
|
+
create(:tracker, store: default_store)
|
12
|
+
create(:tracker, analytics_id: 'A200', store: another_store)
|
10
13
|
visit spree.admin_trackers_path
|
11
14
|
end
|
12
15
|
|
@@ -18,13 +21,15 @@ describe 'Analytics Tracker', type: :feature do
|
|
18
21
|
within_row(1) do
|
19
22
|
expect(column_text(1)).to eq('A100')
|
20
23
|
expect(column_text(2)).to eq('Google analytics')
|
21
|
-
expect(column_text(3)).to eq(
|
24
|
+
expect(column_text(3)).to eq(default_store.name)
|
25
|
+
expect(column_text(4)).to eq('Yes')
|
22
26
|
end
|
23
27
|
|
24
28
|
within_row(2) do
|
25
29
|
expect(column_text(1)).to eq('A200')
|
26
30
|
expect(column_text(2)).to eq('Google analytics')
|
27
|
-
expect(column_text(3)).to eq('
|
31
|
+
expect(column_text(3)).to eq('Eurozone')
|
32
|
+
expect(column_text(4)).to eq('Yes')
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
@@ -34,18 +39,22 @@ describe 'Analytics Tracker', type: :feature do
|
|
34
39
|
visit spree.admin_trackers_path
|
35
40
|
end
|
36
41
|
|
37
|
-
it 'should be able to create a new analytics tracker' do
|
42
|
+
it 'should be able to create a new analytics tracker', js: true do
|
38
43
|
within('.content-header') do
|
39
44
|
click_link 'admin_new_tracker_link'
|
40
45
|
end
|
41
46
|
fill_in 'tracker_analytics_id', with: 'A100'
|
47
|
+
|
48
|
+
select2 default_store.name, from: 'Store'
|
49
|
+
|
42
50
|
click_button 'Create'
|
43
51
|
|
44
52
|
expect(page).to have_content('successfully created!')
|
45
53
|
within_row(1) do
|
46
54
|
expect(column_text(1)).to eq('A100')
|
47
55
|
expect(column_text(2)).to eq('Google analytics')
|
48
|
-
expect(column_text(3)).to eq(
|
56
|
+
expect(column_text(3)).to eq(default_store.name)
|
57
|
+
expect(column_text(4)).to eq('Yes')
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
@@ -13,5 +13,20 @@ describe Spree::Tracker, type: :model do
|
|
13
13
|
tracker.clear_cache
|
14
14
|
expect(Spree::Tracker.current).to be_nil
|
15
15
|
end
|
16
|
+
|
17
|
+
context 'multi-store' do
|
18
|
+
let(:default_store) { Spree::Store.default }
|
19
|
+
let(:euro_store) { create(:store, code: :eu, name: 'eurozone') }
|
20
|
+
let!(:default_tracker) { create(:tracker, store: default_store, engine: :google_analytics) }
|
21
|
+
let!(:euro_tracker) { create(:tracker, store: euro_store, engine: :google_analytics) }
|
22
|
+
|
23
|
+
it 'returns default tracker from default store' do
|
24
|
+
expect(Spree::Tracker.current).to eq(default_tracker)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns tracker from a specified store' do
|
28
|
+
expect(Spree::Tracker.current(:google_analytics, euro_store)).to eq(euro_tracker)
|
29
|
+
end
|
30
|
+
end
|
16
31
|
end
|
17
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_analytics_trackers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spark Solutions
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -98,6 +98,7 @@ executables: []
|
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
|
+
- ".bundle/config"
|
101
102
|
- ".gitignore"
|
102
103
|
- ".rspec"
|
103
104
|
- ".rubocop.yml"
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- config/locales/zh-TW.yml
|
153
154
|
- config/routes.rb
|
154
155
|
- db/migrate/20171013160337_create_spree_trackers.rb
|
156
|
+
- db/migrate/20200721163729_add_store_id_to_spree_trackers.rb
|
155
157
|
- gemfiles/.bundle/config
|
156
158
|
- gemfiles/spree_4_1.gemfile
|
157
159
|
- gemfiles/spree_master.gemfile
|
@@ -172,7 +174,7 @@ homepage: https://github.com/spree-contrib/spree_analytics_trackers
|
|
172
174
|
licenses:
|
173
175
|
- BSD-3-Clause
|
174
176
|
metadata: {}
|
175
|
-
post_install_message:
|
177
|
+
post_install_message:
|
176
178
|
rdoc_options: []
|
177
179
|
require_paths:
|
178
180
|
- lib
|
@@ -183,13 +185,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
185
|
version: 2.5.0
|
184
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
187
|
requirements:
|
186
|
-
- - "
|
188
|
+
- - ">="
|
187
189
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
190
|
+
version: '0'
|
189
191
|
requirements:
|
190
192
|
- none
|
191
193
|
rubygems_version: 3.1.2
|
192
|
-
signing_key:
|
194
|
+
signing_key:
|
193
195
|
specification_version: 4
|
194
196
|
summary: Adds analytics trackers functionality to Spree
|
195
197
|
test_files:
|