Module: Moonshot::MoonshotHelper

Defined in:
app/helpers/moonshot/moonshot_helper.rb

Instance Method Summary collapse

Instance Method Details

#crisp_chat(user: nil, enabled: true, wrapper: :div, api_key:) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/moonshot/moonshot_helper.rb', line 37

def crisp_chat user: nil, enabled: true, wrapper: :div, api_key:
  return unless enabled

  options = {
    controller: 'crisp',
    crisp_website_id_value: api_key
  }

  if user
    options.merge!({
      crisp_identification_value: {
        name: user.tracker_name,
        email: user.tracker_email
      }
    })
  end

  tag.send(wrapper, data: options) do
    yield if block_given?
  end
end

#post_hog_tracker(user: nil, enabled: true, api_key:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/moonshot/moonshot_helper.rb', line 15

def post_hog_tracker user: nil, enabled: true, api_key:
  return unless enabled

  options = {
    controller: 'post-hog',
    post_hog_api_key_value: api_key
  }

  if user
    id_options = {
      id: user.id,
      name: user.tracker_name,
      email: user.tracker_email
    }
    options.merge!({
      post_hog_identification_value: id_options
    })
  end

  tag.div(data: options)
end

#shepherd_tour(tour:, context: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'app/helpers/moonshot/moonshot_helper.rb', line 5

def shepherd_tour tour:, context: {}
  tag.div nil, data: {
    controller: 'shepherd',
    'shepherd-tour-name-value' => tour,
    'shepherd-endpoint-value' => shepherd_rails.tour_statuses_path,
    'shepherd-config-value' => I18n.t(tour, scope: 'shepherd_rails'),
    'shepherd-context-value' => context
  }
end