Class: Spree::Admin::AnalyticsController

Inherits:
Admin::BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/analytics_controller.rb

Instance Method Summary collapse

Instance Method Details

#registerObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/spree/admin/analytics_controller.rb', line 4

def register
  redirect_if_registered and return

  begin
    store = Spree::Dash::Jirafe.register(store_hash)
    Spree::Dash::Config.app_id = store[:app_id]
    Spree::Dash::Config.app_token = store[:app_token]
    Spree::Dash::Config.site_id = store[:site_id]
    Spree::Dash::Config.token = store[:site_token]
    redirect_to admin_path
  rescue Spree::Dash::JirafeException => e
    flash[:error] = e.message
    redirect_to root_path
  end
end

#syncObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/spree/admin/analytics_controller.rb', line 20

def sync
  session[:last_jirafe_sync] = DateTime.now
  begin
    store = Spree::Dash::Jirafe.synchronize_resources(store_hash)
    redirect_to admin_path
  rescue Spree::Dash::JirafeException => e
    flash[:error] = e.message
    redirect_to admin_path
  end
end

#updateObject



31
32
33
34
35
36
37
38
# File 'app/controllers/spree/admin/analytics_controller.rb', line 31

def update
  Spree::Dash::Config.app_id = params[:app_id]
  Spree::Dash::Config.app_token = params[:app_token]
  Spree::Dash::Config.site_id = params[:site_id]
  Spree::Dash::Config.token = params[:token]
  flash[:success] = t(:jirafe_settings_updated, :scope => "spree.dash")
  redirect_to admin_analytics_path
end