Skip to content

Commit

Permalink
Merge pull request #2 from spree-edge/4-8-stable
Browse files Browse the repository at this point in the history
4 8 stable
  • Loading branch information
rahul-bash authored Dec 16, 2024
2 parents 95ff793 + 030339b commit fe09eb9
Show file tree
Hide file tree
Showing 53 changed files with 576 additions and 330 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

gem 'rails-controller-testing'
gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'rails-controller-testing'

gemspec
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require 'spree/testing_support/extension_rake'
RSpec::Core::RakeTask.new

task :default do
if Dir["spec/dummy"].empty?
if Dir['spec/dummy'].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
Dir.chdir('../../')
end
Rake::Task[:spec].invoke
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ module SpreeAnalyticsTrackers
module StoreControllerDecorator
def self.included(base)
base.include ::Spree::BaseHelper

base.helper 'spree/trackers'
end
end
end

if defined?(Spree::StoreController)
::Spree::StoreController.include(::SpreeAnalyticsTrackers::StoreControllerDecorator)
end
::Spree::StoreController.include(::SpreeAnalyticsTrackers::StoreControllerDecorator) if defined?(Spree::StoreController)
10 changes: 5 additions & 5 deletions app/helpers/spree/trackers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def product_for_segment(product, optional = {})
product_hash = Rails.cache.fetch(cache_key) do
{
product_id: product.id,
sku: product.sku,
sku: product.sku || product.id,
category: product.category&.name,
name: product.name,
brand: product.brand&.name,
Expand All @@ -25,7 +25,7 @@ def product_for_segment(product, optional = {})
hash[:image_url] = default_image_for_product_or_variant(product)
end.merge(optional).to_json.html_safe
end

def product_for_google(product, optional = {})
cache_key = [
'spree-google-product',
Expand All @@ -36,12 +36,12 @@ def product_for_google(product, optional = {})

Rails.cache.fetch(cache_key) do
{
item_id: product.sku,
item_id: product.id,
item_name: product.name,
item_category: product.category&.name,
item_brand: product.brand&.name,
price: product.price_in(current_currency).amount&.to_f,
currency: current_currency,
currency: current_currency
}.merge(optional).to_json.html_safe
end
end
Expand All @@ -60,7 +60,7 @@ def ga_line_item(line_item)
Rails.cache.fetch(cache_key) do
product = line_item.product
{
id: variant.sku,
id: variant.id,
name: variant.name,
category: product.category&.name,
variant: variant.options_text,
Expand Down
8 changes: 5 additions & 3 deletions app/models/spree/tracker.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Spree
class Tracker < Spree::Base
TRACKING_ENGINES = %i(google_analytics segment).freeze
TRACKING_ENGINES = %i[google_analytics segment].freeze
enum engine: TRACKING_ENGINES

after_commit :clear_cache

validates :analytics_id, presence: true, uniqueness: { scope: [:engine, :store_id], case_sensitive: false }
validates :analytics_id, presence: true, uniqueness: { scope: %i[engine store_id], case_sensitive: false }
validates :store, presence: true

scope :active, -> { where(active: true) }
Expand All @@ -19,7 +19,9 @@ def self.current(engine = nil, store = nil)
tracker = Rails.cache.fetch("current_tracker/#{engine}/#{store.id}") do
active.find_by(store: store, engine: engine)
end
tracker.analytics_id.present? ? tracker : nil if tracker
return unless tracker

tracker.analytics_id.present? ? tracker : nil
end

def clear_cache
Expand Down
11 changes: 0 additions & 11 deletions app/overrides/add_cart_viewed_to_orders_edit.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/overrides/add_checkout_step_viewed_to_checkout_edit.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_google_analytics_add_shipping_info_to_payment.rb

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_google_analytics_begin_checkout_to_address.rb

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions app/overrides/add_google_analytics_to_spree_application.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_google_analytics_view_item_list_to_products.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/overrides/add_google_purchase_to_orders_show.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_order_complete_to_orders_show.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_product_list_filtered_to_taxons_show.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_product_list_viewed_to_products_list.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/overrides/add_product_viewed_to_products_show.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_products_searched_to_products_list.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_segment_initializer_to_layout.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/overrides/add_segment_page_viewed_to_layout.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/presenters/spree_analytics_trackers/base_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(resource = {}, options = {})
@options = options
end

def to_json
def to_json(*_args)
serialize_resource(@resource, @options).to_json
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Segment
class OrderPresenter < SpreeAnalyticsTrackers::BasePresenter
private

def serialize_resource(resource, options = {})
def serialize_resource(resource, _options = {})
{
order_id: resource.number.to_s,
total: resource.total&.to_f,
Expand All @@ -16,8 +16,6 @@ def serialize_resource(resource, options = {})
}
end

private

def serialize_line_item(line_item)
{
product_id: line_item.product_id&.to_s,
Expand Down
Loading

0 comments on commit fe09eb9

Please sign in to comment.