ahoy_captain 0.82 → 0.91
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -13
- data/app/assets/javascript/ahoy_captain/controllers/active_links_controller.js +6 -3
- data/app/assets/javascript/ahoy_captain/controllers/filter/item_controller.js +12 -0
- data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +4 -4
- data/app/assets/javascript/ahoy_captain/controllers/toggle_controller.js +17 -0
- data/app/components/ahoy_captain/dropdown_button_component.html.erb +5 -5
- data/app/components/ahoy_captain/dropdown_link_component.html.erb +5 -5
- data/app/components/ahoy_captain/filter/dropdown_component.html.erb +48 -0
- data/app/components/ahoy_captain/filter/dropdown_component.rb +51 -0
- data/app/components/ahoy_captain/filter/modal_component.html.erb +2 -2
- data/app/components/ahoy_captain/filter/select_component.html.erb +3 -3
- data/app/components/ahoy_captain/filter/select_component.rb +22 -8
- data/app/components/ahoy_captain/filter/tag_component.html.erb +8 -4
- data/app/components/ahoy_captain/filter/tag_component.rb +6 -30
- data/app/components/ahoy_captain/filter/tag_container_component.html.erb +2 -3
- data/app/components/ahoy_captain/filter/tag_container_component.rb +1 -8
- data/app/components/ahoy_captain/stats/container_component.html.erb +8 -0
- data/app/components/ahoy_captain/stats/container_component.rb +12 -0
- data/app/components/ahoy_captain/sticky_nav_component.html.erb +7 -19
- data/app/components/ahoy_captain/sticky_nav_component.rb +8 -0
- data/app/components/ahoy_captain/table_component.html.erb +2 -2
- data/app/components/ahoy_captain/table_component.rb +3 -0
- data/app/components/ahoy_captain/tables/headers/goals_header_component.html.erb +1 -1
- data/app/components/ahoy_captain/tables/headers/header_component.html.erb +1 -1
- data/app/components/ahoy_captain/tables/rows/goals_row_component.html.erb +1 -1
- data/app/components/ahoy_captain/tables/rows/goals_row_component.rb +8 -0
- data/app/components/ahoy_captain/tables/rows/row_component.rb +2 -2
- data/app/components/ahoy_captain/tile_component.html.erb +4 -3
- data/app/components/ahoy_captain/tile_component.rb +1 -1
- data/app/components/ahoy_captain/tooltip_component.html.erb +2 -2
- data/app/controllers/ahoy_captain/filters/sources_controller.rb +1 -1
- data/app/controllers/ahoy_captain/stats/base_controller.rb +3 -3
- data/app/helpers/ahoy_captain/application_helper.rb +33 -0
- data/app/models/ahoy_captain/filter_parser.rb +67 -0
- data/app/presenters/ahoy_captain/goals_presenter.rb +3 -2
- data/app/queries/ahoy_captain/stats/average_views_per_visit_query.rb +1 -1
- data/app/queries/ahoy_captain/stats/visit_duration_query.rb +1 -1
- data/app/views/ahoy_captain/funnels/show.html.erb +5 -2
- data/app/views/ahoy_captain/layouts/application.html.erb +3 -3
- data/app/views/ahoy_captain/realtimes/show.html.erb +1 -1
- data/app/views/ahoy_captain/roots/_filters.html.erb +34 -0
- data/app/views/ahoy_captain/roots/show.html.erb +19 -89
- data/app/views/ahoy_captain/stats/base/index.html.erb +4 -3
- data/app/views/ahoy_captain/stats/show.html.erb +7 -52
- data/lib/ahoy_captain/ahoy/event_methods.rb +12 -3
- data/lib/ahoy_captain/ahoy/visit_methods.rb +1 -1
- data/lib/ahoy_captain/configuration.rb +16 -6
- data/lib/ahoy_captain/engine.rb +17 -0
- data/lib/ahoy_captain/filter_configuration/filter.rb +16 -0
- data/lib/ahoy_captain/filter_configuration/filter_collection.rb +48 -0
- data/lib/ahoy_captain/filters_configuration.rb +73 -0
- data/lib/ahoy_captain/goals.rb +1 -1
- data/lib/ahoy_captain/predicate_label.rb +7 -0
- data/lib/ahoy_captain/version.rb +1 -1
- data/lib/ahoy_captain.rb +1 -0
- data/lib/generators/ahoy_captain/templates/config.rb.tt +25 -0
- metadata +14 -2
@@ -1,12 +1,13 @@
|
|
1
|
-
<div class=
|
1
|
+
<div class="card card-compact <%= 'lg:col-span-2' if wide %> col-span-1 p-4 shadow-xl rounded-md p-8 mx-4 lg:mx-0 bg-base-100 ">
|
2
2
|
<div class="flex justify-between">
|
3
|
-
<
|
3
|
+
<h2 class="card-title"><%= title %></h2>
|
4
4
|
<div class="flex self-center gap-3">
|
5
5
|
<%= display_links %>
|
6
6
|
</div>
|
7
7
|
</div>
|
8
|
+
|
8
9
|
<%= statistic_display %>
|
9
10
|
<div class="flex justify-center">
|
10
11
|
<%= details_cta %>
|
11
12
|
</div>
|
12
|
-
</div>
|
13
|
+
</div>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<div class="tooltip" data-tip=<%= amount %>>
|
1
|
+
<div class="tooltip " data-tip=<%= amount %>>
|
2
2
|
<p><%= abbreviate %></p>
|
3
|
-
</div>
|
3
|
+
</div>
|
@@ -4,7 +4,7 @@ module AhoyCaptain
|
|
4
4
|
def index
|
5
5
|
query = visit_query.all
|
6
6
|
|
7
|
-
render json: query.
|
7
|
+
render json: query.select("distinct referring_domain").where.not(referring_domain: nil).group(:referring_domain).order(Arel.sql "count(*) desc").pluck(:referring_domain).map { |city| serialize(city) }
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -32,10 +32,10 @@ module AhoyCaptain
|
|
32
32
|
# assume we're in a realtime
|
33
33
|
return INTERVAL_PERIOD["realtime"][0]
|
34
34
|
end
|
35
|
-
diff = (range[1] - range[0]).seconds
|
36
|
-
if diff
|
35
|
+
diff = (range[1] - range[0]).seconds.in_days.to_i
|
36
|
+
if diff > 30
|
37
37
|
"month"
|
38
|
-
elsif diff
|
38
|
+
elsif diff > 0
|
39
39
|
"day"
|
40
40
|
else
|
41
41
|
"hour"
|
@@ -2,7 +2,9 @@ module AhoyCaptain
|
|
2
2
|
module ApplicationHelper
|
3
3
|
include Pagy::Frontend
|
4
4
|
|
5
|
+
# params that are coerced from the ApplicationController#act_like_an_spa
|
5
6
|
SPECIAL_PARAMS = [:campaigns_type, :devices_type]
|
7
|
+
|
6
8
|
def ahoy_captain_importmap_tags(entry_point = "application", shim: true)
|
7
9
|
safe_join [
|
8
10
|
(javascript_importmap_shim_tag if shim),
|
@@ -21,6 +23,37 @@ module AhoyCaptain
|
|
21
23
|
params.to_unsafe_h.slice(*SPECIAL_PARAMS)
|
22
24
|
end
|
23
25
|
|
26
|
+
# gets put into the form as a hidden field
|
27
|
+
#
|
28
|
+
def non_filter_ransack_params
|
29
|
+
other_params = {}
|
30
|
+
map = [
|
31
|
+
:start_date,
|
32
|
+
:end_date,
|
33
|
+
:period,
|
34
|
+
:interval
|
35
|
+
]
|
36
|
+
|
37
|
+
ransack = [:goal]
|
38
|
+
|
39
|
+
map.each do |key|
|
40
|
+
if params[key]
|
41
|
+
other_params[key] = params[key]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
ransack.each do |key|
|
46
|
+
Ransack.predicates.keys.each do |predicate|
|
47
|
+
if value = params.dig(:q, "#{key}_#{predicate}")
|
48
|
+
other_params[:q] ||= {}
|
49
|
+
other_params[:q]["#{key}_#{predicate}"] = value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
other_params
|
55
|
+
end
|
56
|
+
|
24
57
|
def render_pagination
|
25
58
|
if @pagination
|
26
59
|
pagy_nav(@pagination).html_safe
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module AhoyCaptain
|
2
|
+
class FilterParser
|
3
|
+
FILTER_MENU_MAX_SIZE = 2
|
4
|
+
class Item
|
5
|
+
attr_accessor :name, :column, :description, :values, :predicate, :url, :modal, :label
|
6
|
+
|
7
|
+
def title
|
8
|
+
column.titleize
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.parse(request)
|
13
|
+
new(request).tap do |instance|
|
14
|
+
instance.parse
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
delegate_missing_to :@items
|
19
|
+
|
20
|
+
def initialize(request)
|
21
|
+
@request = request
|
22
|
+
@params = @request.params
|
23
|
+
@filter_params = @request.params[:q] || {}
|
24
|
+
@items = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse
|
28
|
+
@filter_params.each do |key, values|
|
29
|
+
item = Item.new
|
30
|
+
|
31
|
+
item.values = Array(values)
|
32
|
+
item.predicate = Ransack::Predicate.detect_and_strip_from_string!(key.dup)
|
33
|
+
item.column = key.delete_suffix("_#{item.predicate}")
|
34
|
+
modal_name = AhoyCaptain.config.filters.detect { |_, filters| filters.include?(item.column) }[1].modal_name
|
35
|
+
if modal_name
|
36
|
+
item.modal = modal_name
|
37
|
+
end
|
38
|
+
|
39
|
+
label = if item.column == "goal"
|
40
|
+
AhoyCaptain.config.goals[values].title
|
41
|
+
else
|
42
|
+
item.values.to_sentence(last_word_connector: " or ")
|
43
|
+
end
|
44
|
+
item.label = label
|
45
|
+
item.description = "#{item.column.titleize} #{::AhoyCaptain::PredicateLabel[item.predicate]} #{label}"
|
46
|
+
item.url = build_url(key, values)
|
47
|
+
@items[key] = item
|
48
|
+
end
|
49
|
+
|
50
|
+
@items
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def build_url(name, values)
|
56
|
+
search_params = @request.query_parameters.deep_dup
|
57
|
+
if search_params["q"][name].is_a?(Array)
|
58
|
+
search_params["q"][name] = search_params["q"][name] - Array(values)
|
59
|
+
else
|
60
|
+
search_params["q"].delete(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
@request.path + "?" + search_params.to_query
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -16,7 +16,7 @@ module AhoyCaptain
|
|
16
16
|
queries = {
|
17
17
|
totals: @event_query.select("count(distinct(#{AhoyCaptain.event.table_name}.visit_id)) as unique_visits, '_internal_total_visits_' as name, count(distinct #{AhoyCaptain.event.table_name}.id) as total_events, 0 as sort_order")
|
18
18
|
}
|
19
|
-
selects = ["SELECT unique_visits, name, total_events, sort_order, 0 as cr from totals"]
|
19
|
+
selects = ["SELECT unique_visits, name, total_events, sort_order, 0 as cr, '' as goal_id from totals"]
|
20
20
|
last_goal = nil
|
21
21
|
map = {}.with_indifferent_access
|
22
22
|
|
@@ -27,9 +27,10 @@ module AhoyCaptain
|
|
27
27
|
"'#{goal.id}' as name",
|
28
28
|
"count(distinct #{AhoyCaptain.event.table_name}.id) as total_events",
|
29
29
|
"#{index + 1} as sort_order",
|
30
|
+
"'#{goal.id}' as goal_id"
|
30
31
|
]
|
31
32
|
).merge(goal.event_query.call).group("#{AhoyCaptain.event.table_name}.name")
|
32
|
-
selects << ["SELECT unique_visits, name, total_events, sort_order, 0::decimal as cr from #{goal.id}"]
|
33
|
+
selects << ["SELECT unique_visits, name, total_events, sort_order, 0::decimal as cr, '#{goal.id}' as goal_id from #{goal.id}"]
|
33
34
|
map[goal.id] = goal
|
34
35
|
last_goal = goal
|
35
36
|
end
|
@@ -9,7 +9,7 @@ module AhoyCaptain
|
|
9
9
|
::Ahoy::Visit
|
10
10
|
.select("duration as duration, started_at")
|
11
11
|
.from(events, :views_per_visit_table)
|
12
|
-
.joins("inner join #{AhoyCaptain.visit.table_name} on
|
12
|
+
.joins("inner join #{AhoyCaptain.visit.table_name} on #{AhoyCaptain.visit.table_name}.id = views_per_visit_table.visit_id")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<%= turbo_frame_tag :goals do %>
|
2
2
|
<div >
|
3
|
-
|
4
|
-
|
3
|
+
<% if params.dig(:q, :goal_id) %>
|
4
|
+
<p>Funnels are unavailable if filtering by a goal.</p>
|
5
|
+
<% else %>
|
6
|
+
<canvas data-controller="funnel-chart" data-data="<%= @funnel.to_json %>" ></canvas>
|
7
|
+
<% end %>
|
5
8
|
</div>
|
6
9
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html>
|
2
|
+
<html data-theme='<%= AhoyCaptain.config.theme %>'>
|
3
3
|
<head>
|
4
4
|
<title>Ahoy Captain</title>
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
@@ -116,9 +116,9 @@
|
|
116
116
|
</style>
|
117
117
|
</head>
|
118
118
|
|
119
|
-
<body data-
|
119
|
+
<body data-controller='application'>
|
120
120
|
<%= yield %>
|
121
|
-
<div class="flex justify-center
|
121
|
+
<div class="flex justify-center border-t-4 border-base-100 py-4">
|
122
122
|
<div class="flex justify-around space-x-4 my-4">
|
123
123
|
<h5>Powered by <a href='https://github.com/joshmn/ahoy_captain' target=”_blank”>Ahoy Captain v<%= AhoyCaptain::VERSION %></a></h5>
|
124
124
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= turbo_frame_tag :realtime do %>
|
2
2
|
<div>
|
3
|
-
<a class="block ml-1 md:ml-2 mr-auto text-xs md:text-sm font-bold
|
3
|
+
<a class="block ml-1 md:ml-2 mr-auto text-xs md:text-sm font-bold " title="" data-realtime-target="label">
|
4
4
|
<svg class="inline w-2 mr-1 md:mr-2 text-green-500 fill-current animate-pulse" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
5
5
|
<circle cx="8" cy="8" r="8"></circle>
|
6
6
|
</svg><%= @total %> <span class="hidden sm:inline-block">current visitors</span>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%= form_with url: url_for(params.permit!.except(:q)), method: :get, data: { turbo_frame: "_top", controller: "filter-form", action: "reset->filter-form#handleReset" } do |form| %>
|
2
|
+
<% non_filter_ransack_params.each do |k,v| %>
|
3
|
+
<%= form.hidden_field k, value: v %>
|
4
|
+
<% end %>
|
5
|
+
<% AhoyCaptain.config.filters.each do |name, filters| %>
|
6
|
+
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by #{name}", id: "#{filters.modal_name}") do |modal| %>
|
7
|
+
<% modal.with_modal_display do %>
|
8
|
+
<% filters.each do |filter| %>
|
9
|
+
<%= render AhoyCaptain::Filter::SelectComponent.new(label: filter.label, column: filter.column, url: public_send(filter.url), predicates: filter.predicates, multiple: filter.multiple, form: form) %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
|
16
|
+
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Range", id: "customRangeModal") do |modal| %>
|
17
|
+
<% modal.with_modal_display do %>
|
18
|
+
<div class="flex gap-2 w-full">
|
19
|
+
<div class="form-control w-full max-w-xs">
|
20
|
+
<label class="label" for="start_date">
|
21
|
+
<span class="label-text">Start Date</span>
|
22
|
+
</label>
|
23
|
+
<input type="datetime-local" id="start_date" name="start_date" class="input input-bordered w-full" value="<%= params[:start_date] %>" />
|
24
|
+
</div>
|
25
|
+
<div class="form-control w-full max-w-xs">
|
26
|
+
<label class="label" for="end_date">
|
27
|
+
<span class="label-text">End Date</span>
|
28
|
+
</label>
|
29
|
+
<input type="datetime-local" id="end_date" name="end_date" class="input input-bordered w-full" value="<%= params[:end_date] %>" />
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<main class='
|
1
|
+
<main class='min-h-screen pb-4 max-w-6xl mx-auto' data-controller="application">
|
2
2
|
<%= render AhoyCaptain::StickyNavComponent.new do |nav| %>
|
3
3
|
<% nav.with_realtime_update do %>
|
4
4
|
<%= turbo_frame_tag :realtime, src: realtime_path, data: { controller: "realtime" }, loading: :lazy %>
|
@@ -15,11 +15,11 @@
|
|
15
15
|
<%= render AhoyCaptain::TileComponent.new(title: 'Top Sources') do |component| %>
|
16
16
|
<% component.with_display_links do %>
|
17
17
|
<div data-controller="active-links">
|
18
|
-
<a href="<%= sources_path(search_params) %>" data-turbo-frame="sources"
|
18
|
+
<a href="<%= sources_path(search_params) %>" data-turbo-frame="sources" class="" data-active-links-target="link">All</a>
|
19
19
|
<%= render AhoyCaptain::DropdownLinkComponent.new(title: "Campaign") do |dropdown| %>
|
20
20
|
<% %w{utm_source utm_medium utm_term utm_content utm_campaign}.each do |source| %>
|
21
21
|
<% dropdown.with_option do %>
|
22
|
-
<a href="<%= public_send("campaign_#{source}_path".to_sym, **search_params) %>" data-turbo-frame="sources" data-active-links-target="link">
|
22
|
+
<a href="<%= public_send("campaign_#{source}_path".to_sym, **search_params) %>" class="" data-turbo-frame="sources" data-active-links-target="link">
|
23
23
|
<%= source.titleize.gsub("Utm", "UTM") %>
|
24
24
|
</a>
|
25
25
|
<% end %>
|
@@ -31,66 +31,66 @@
|
|
31
31
|
<%= turbo_frame_tag :sources, src: sources_path(search_params), loading: :lazy %>
|
32
32
|
<% end %>
|
33
33
|
<% component.with_details_cta do %>
|
34
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#sources" class="link no-underline">Details</button>
|
34
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#sources" class="link no-underline ">Details</button>
|
35
35
|
<% end %>
|
36
36
|
<% end %>
|
37
37
|
|
38
38
|
<%= render AhoyCaptain::TileComponent.new(title: 'Top Pages') do |component| %>
|
39
39
|
<% component.with_display_links do %>
|
40
40
|
<div data-controller='active-links'>
|
41
|
-
<a href="<%= top_pages_path(search_params) %>" data-turbo-frame="pages"
|
42
|
-
<a href="<%= entry_pages_path(search_params) %>" data-turbo-frame="pages"
|
43
|
-
<a href="<%= exit_pages_path(search_params) %>" data-turbo-frame="pages"
|
41
|
+
<a href="<%= top_pages_path(search_params) %>" data-turbo-frame="pages" class=" text-sm" data-active-links-target="link">Top Pages</a>
|
42
|
+
<a href="<%= entry_pages_path(search_params) %>" data-turbo-frame="pages" class=" text-sm" data-active-links-target="link">Entry Pages</a>
|
43
|
+
<a href="<%= exit_pages_path(search_params) %>" data-turbo-frame="pages" class=" text-sm" data-active-links-target="link">Exit Pages</a>
|
44
44
|
</div>
|
45
45
|
<% end %>
|
46
46
|
<% component.with_statistic_display do %>
|
47
47
|
<%= turbo_frame_tag :pages, src: top_pages_path(search_params), loading: :lazy %>
|
48
48
|
<% end %>
|
49
49
|
<% component.with_details_cta do %>
|
50
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal"
|
50
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#pages" class="link no-underline ">Details</button>
|
51
51
|
<% end %>
|
52
52
|
<% end %>
|
53
53
|
|
54
54
|
<%= render AhoyCaptain::TileComponent.new(title: 'Countries') do |component| %>
|
55
55
|
<% component.with_display_links do %>
|
56
56
|
<div data-controller="active-links">
|
57
|
-
<a href="<%= countries_path(search_params) %>" data-turbo-frame="geography" data-active-links-target="link">Countries</a>
|
58
|
-
<a href="<%= regions_path(search_params) %>" data-turbo-frame="geography" data-active-links-target="link">Regions</a>
|
59
|
-
<a href="<%= cities_path(search_params) %>" data-turbo-frame="geography" data-active-links-target="link">Cities</a>
|
57
|
+
<a href="<%= countries_path(search_params) %>" data-turbo-frame="geography" class=" text-sm" data-active-links-target="link">Countries</a>
|
58
|
+
<a href="<%= regions_path(search_params) %>" data-turbo-frame="geography" class=" text-sm" data-active-links-target="link">Regions</a>
|
59
|
+
<a href="<%= cities_path(search_params) %>" data-turbo-frame="geography" class=" text-sm" data-active-links-target="link">Cities</a>
|
60
60
|
</div>
|
61
61
|
<% end %>
|
62
62
|
<% component.with_statistic_display do %>
|
63
63
|
<%= turbo_frame_tag :geography, src: countries_path(search_params), loading: :lazy %>
|
64
64
|
<% end %>
|
65
65
|
<% component.with_details_cta do %>
|
66
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal"
|
66
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#geography" class="link no-underline ">Details</button>
|
67
67
|
<% end %>
|
68
68
|
<% end %>
|
69
69
|
|
70
70
|
<%= render AhoyCaptain::TileComponent.new(title: 'Devices') do |component| %>
|
71
71
|
<% component.with_display_links do %>
|
72
72
|
<div data-controller="active-links">
|
73
|
-
<a href="<%= devices_browsers_path(search_params) %>" data-turbo-frame="devices"
|
74
|
-
<a href="<%= devices_operating_systems_path(search_params) %>" data-turbo-frame="devices" data-active-links-target="link">OS</a>
|
75
|
-
<a href="<%= devices_device_types_path(search_params) %>" data-turbo-frame="devices"
|
73
|
+
<a href="<%= devices_browsers_path(search_params) %>" data-turbo-frame="devices" class=" text-sm" data-active-links-target="link">Browser</a>
|
74
|
+
<a href="<%= devices_operating_systems_path(search_params) %>" data-turbo-frame="devices" class=" text-sm" data-active-links-target="link">OS</a>
|
75
|
+
<a href="<%= devices_device_types_path(search_params) %>" data-turbo-frame="devices" class=" text-sm" data-active-links-target="link">Size</a>
|
76
76
|
</div>
|
77
77
|
<% end %>
|
78
78
|
<% component.with_statistic_display do %>
|
79
79
|
<%= turbo_frame_tag :devices, src: devices_browsers_path(search_params), loading: :lazy %>
|
80
80
|
<% end %>
|
81
81
|
<% component.with_details_cta do %>
|
82
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#devices" class="link no-underline">Details</button>
|
82
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#devices" class="link no-underline ">Details</button>
|
83
83
|
<% end %>
|
84
84
|
<% end %>
|
85
85
|
<%= render AhoyCaptain::TileComponent.new(wide: true) do |component| %>
|
86
86
|
<% component.with_display_links do %>
|
87
|
-
<a href="<%= goals_path(search_params) %>" data-turbo-frame="goals" class="link
|
87
|
+
<a href="<%= goals_path(search_params) %>" data-turbo-frame="goals" class="link ">
|
88
88
|
Goals
|
89
89
|
</a>
|
90
90
|
<%= render AhoyCaptain::DropdownLinkComponent.new(title: "Funnels") do |dropdown| %>
|
91
91
|
<% AhoyCaptain.config.funnels.each do |id, funnel| %>
|
92
92
|
<% dropdown.with_option do %>
|
93
|
-
<a href="<%= funnel_path(id, search_params) %>" data-turbo-frame="goals" class="link
|
93
|
+
<a href="<%= funnel_path(id, search_params) %>" data-turbo-frame="goals" class="link ">
|
94
94
|
<%= funnel.title %>
|
95
95
|
</a>
|
96
96
|
<% end %>
|
@@ -105,77 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
</main>
|
107
107
|
|
108
|
-
<%=
|
109
|
-
<%= form.hidden_field :period, value: params[:period] %>
|
110
|
-
<%= form.hidden_field :start_date, value: params[:start_date] %>
|
111
|
-
<%= form.hidden_field :end_date, value: params[:end_date] %>
|
112
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Page", id: "pageModal") do |modal| %>
|
113
|
-
<% modal.with_modal_display do %>
|
114
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Action", column: :route, url: filters_actions_path, predicates: [:in, :not_in], form: form) %>
|
115
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Entry page", column: :entry_page, url: filters_entry_pages_path, predicates: [:in, :not_in], form: form) %>
|
116
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Exit page", column: :exit_page, url: filters_exit_pages_path, predicates: [:in, :not_in], form: form) %>
|
117
|
-
<% end %>
|
118
|
-
<% end %>
|
119
|
-
|
120
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Country", id: "countryModal") do |modal| %>
|
121
|
-
<% modal.with_modal_display do %>
|
122
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Country", column: :country, url: filters_locations_countries_path, predicates: [:in, :not_in], form: form) %>
|
123
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Region", column: :region, url: filters_locations_regions_path, predicates: [:in, :not_in], form: form) %>
|
124
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "City", column: :city, url: filters_locations_cities_path, predicates: [:in, :not_in], form: form) %>
|
125
|
-
<% end %>
|
126
|
-
<% end %>
|
127
|
-
|
128
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Source", id: "sourceModal") do |modal| %>
|
129
|
-
<% modal.with_modal_display do %>
|
130
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Source", column: :referring_domain, url: filters_sources_path, predicates: [:in, :not_in], form: form) %>
|
131
|
-
<% end %>
|
132
|
-
<% end %>
|
133
|
-
|
134
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Screen size", id: "screenModal") do |modal| %>
|
135
|
-
<% modal.with_modal_display do %>
|
136
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Screen size", column: :device_type, url: filters_screens_path, predicates: [:in, :not_in], form: form) %>
|
137
|
-
<% end %>
|
138
|
-
<% end %>
|
139
|
-
|
140
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Browser", id: "osModal") do |modal| %>
|
141
|
-
<% modal.with_modal_display do %>
|
142
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System", column: :os, url: filters_names_path, predicates: [:in, :not_in], form: form) %>
|
143
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System Version", column: :os_version, url: filters_versions_path, predicates: [:in, :not_in], form: form) %>
|
144
|
-
<% end %>
|
145
|
-
<% end %>
|
146
|
-
|
147
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Campaign", id: "utmModal") do |modal| %>
|
148
|
-
<% modal.with_modal_display do %>
|
149
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Medium", column: :utm_medium, url: filters_utm_mediums_path, predicates: [:in, :not_in], form: form) %>
|
150
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Source", column: :utm_source, url: filters_utm_sources_path, predicates: [:in, :not_in], form: form) %>
|
151
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Campaign", column: :utm_campaign, url: filters_utm_campaigns_path, predicates: [:in, :not_in], form: form) %>
|
152
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Term", column: :utm_term, url: filters_utm_terms_path, predicates: [:in, :not_in], form: form) %>
|
153
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Content", column: :utm_content, url: filters_utm_contents_path, predicates: [:in, :not_in], form: form) %>
|
154
|
-
<% end %>
|
155
|
-
<% end %>
|
156
|
-
|
157
|
-
|
158
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Range", id: "customRangeModal") do |modal| %>
|
159
|
-
<% modal.with_modal_display do %>
|
160
|
-
<div class="flex gap-2 w-full">
|
161
|
-
<div class="form-control w-full max-w-xs">
|
162
|
-
<label class="label" for="start_date">
|
163
|
-
<span class="label-text">Start Date</span>
|
164
|
-
</label>
|
165
|
-
<input type="datetime-local" id="start_date" name="start_date" class="input input-bordered w-full" value="<%= params[:start_date] %>" />
|
166
|
-
</div>
|
167
|
-
<div class="form-control w-full max-w-xs">
|
168
|
-
<label class="label" for="end_date">
|
169
|
-
<span class="label-text">End Date</span>
|
170
|
-
</label>
|
171
|
-
<input type="datetime-local" id="end_date" name="end_date" class="input input-bordered w-full" value="<%= params[:end_date] %>" />
|
172
|
-
</div>
|
173
|
-
</div>
|
174
|
-
<% end %>
|
175
|
-
<% end %>
|
176
|
-
|
177
|
-
|
178
|
-
<% end %>
|
108
|
+
<%= render 'filters' %>
|
179
109
|
|
180
110
|
<dialog id="detailsModal" class="modal">
|
181
111
|
<div class="modal-box w-11/12 max-w-5xl">
|
@@ -1,10 +1,11 @@
|
|
1
1
|
<%= turbo_frame_tag :chart do %>
|
2
|
-
<div class="flex justify-end
|
2
|
+
<div class="flex justify-end gap-3 items-center">
|
3
|
+
<a href="<%= export_path(request.query_parameters) %>" class="link text-sm" target="_blank" data-turbo-frame="false">Download</a>
|
3
4
|
<%= form_with url: url_for(params.permit!), method: :get, data: { controller: "interval" } do %>
|
4
|
-
<%= select_tag :interval, options_for_select(available_intervals.collect { |interval| [interval.titleize, interval] }, selected: selected_interval), class: "select
|
5
|
+
<%= select_tag :interval, options_for_select(available_intervals.collect { |interval| [interval.titleize, interval] }, selected: selected_interval), class: "select text-primary select-sm w-full max-w-sm", 'data-action': "change->interval#handleChange" %>
|
5
6
|
<% end %>
|
6
7
|
</div>
|
7
8
|
<div>
|
8
|
-
<canvas data-controller="line-chart" data-line-chart-
|
9
|
+
<canvas style="height:300px;width:100%;" data-controller="line-chart" data-line-chart-label-value="<%= @label %>" data-line-chart-data-value="<%= @stats.to_json %>"></canvas>
|
9
10
|
</div>
|
10
11
|
<% end %>
|
@@ -1,56 +1,11 @@
|
|
1
1
|
<%= turbo_frame_tag :stats do %>
|
2
|
-
<dl class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0 -mt-4 mb-4">
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
</dd>
|
10
|
-
</a>
|
11
|
-
<a href="<%= stats_total_visits_path(search_params) %>" data-turbo-frame="chart">
|
12
|
-
<dt class="text-base font-normal text-base-content">Total Visits</dt>
|
13
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
14
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
15
|
-
<%= number_with_delimiter @presenter.total_visits %>
|
16
|
-
</div>
|
17
|
-
</dd>
|
18
|
-
</a>
|
19
|
-
<a href="<%= stats_total_pageviews_path(search_params) %>" data-turbo-frame="chart">
|
20
|
-
<dt class="text-base font-normal text-base-content">Total Pageviews</dt>
|
21
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
22
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
23
|
-
<%= number_with_delimiter @presenter.total_pageviews %>
|
24
|
-
</div>
|
25
|
-
</dd>
|
26
|
-
</a>
|
27
|
-
<a href="<%= stats_views_per_visits_path(search_params) %>" data-turbo-frame="chart">
|
28
|
-
|
29
|
-
<dt class="text-base font-normal text-base-content">Views per visit</dt>
|
30
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
31
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
32
|
-
<%= number_with_delimiter @presenter.views_per_visit %>
|
33
|
-
</div>
|
34
|
-
</dd>
|
35
|
-
</a>
|
36
|
-
<a href="<%= stats_bounce_rates_path(search_params) %>" data-turbo-frame="chart">
|
37
|
-
|
38
|
-
<dt class="text-base font-normal text-base-content">Bounce rate</dt>
|
39
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
40
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
41
|
-
<%= number_with_delimiter @presenter.bounce_rate %>%
|
42
|
-
</div>
|
43
|
-
</dd>
|
44
|
-
</a>
|
45
|
-
<a href="<%= stats_visit_durations_path(search_params) %>" data-turbo-frame="chart">
|
46
|
-
|
47
|
-
<dt class="text-base font-normal text-base-content">Visit duration</dt>
|
48
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
49
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
50
|
-
<%= @presenter.visit_duration %>
|
51
|
-
</div>
|
52
|
-
</dd>
|
53
|
-
</a>
|
2
|
+
<dl class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0 -mt-4 mb-4" data-controller="active-links" data-active-links-classes-value='["text-primary"]'>
|
3
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_unique_visitors_url(search_params), "Unique Visits", number_with_delimiter(@presenter.unique_visitors), true) %>
|
4
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_total_visits_path(search_params), "Total Visits", number_with_delimiter(@presenter.total_visits)) %>
|
5
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_total_pageviews_path(search_params), "Total Pageviews", number_with_delimiter(@presenter.total_pageviews)) %>
|
6
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_views_per_visits_path(search_params), "Views per Visit", number_with_delimiter(@presenter.views_per_visit)) %>
|
7
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_bounce_rates_path(search_params), "Bounce Rate", "#{number_with_delimiter(@presenter.bounce_rate)}%") %>
|
8
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_visit_durations_url(search_params), "Visit Duration", @presenter.visit_duration) %>
|
54
9
|
</dl>
|
55
10
|
<%= turbo_frame_tag :chart, src: stats_unique_visitors_path(search_params) do %>
|
56
11
|
<% end %>
|
@@ -17,10 +17,10 @@ module AhoyCaptain
|
|
17
17
|
end
|
18
18
|
|
19
19
|
scope :with_entry_pages, -> {
|
20
|
-
with(entry_pages: self.select("MIN(
|
20
|
+
with(entry_pages: self.select("MIN(#{table_name}.id) as min_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}").where(name: AhoyCaptain.config.event[:view_name]).group("#{table_name}.properties")).joins("INNER JOIN entry_pages ON entry_pages.min_id = #{table_name}.id")
|
21
21
|
}
|
22
22
|
scope :with_exit_pages, -> {
|
23
|
-
with(exit_pages: self.select("MAX(
|
23
|
+
with(exit_pages: self.select("MAX(#{table_name}.id) as max_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}").where(name: AhoyCaptain.config.event[:view_name]).group("#{table_name}.properties")).joins("INNER JOIN exit_pages ON exit_pages.max_id = #{table_name}.id")
|
24
24
|
}
|
25
25
|
|
26
26
|
scope :with_routes, -> { where(AhoyCaptain.config.event[:url_exists]) }
|
@@ -44,11 +44,20 @@ module AhoyCaptain
|
|
44
44
|
scope :properties_not_eq, ->(value) do
|
45
45
|
where.not("properties::jsonb @> ?", value)
|
46
46
|
end
|
47
|
+
|
48
|
+
ransacker :goal,
|
49
|
+
formatter: ->(value) {
|
50
|
+
::Arel::Nodes::SqlLiteral.new(
|
51
|
+
::AhoyCaptain.config.goals[value].event_query.call.select(:id).to_sql
|
52
|
+
)
|
53
|
+
} do |parent|
|
54
|
+
parent.table[:id]
|
55
|
+
end
|
47
56
|
end
|
48
57
|
|
49
58
|
class_methods do
|
50
59
|
def ransackable_attributes(auth_object = nil)
|
51
|
-
super + ["action", "controller", "id", "id_property", "name", "page", "properties", "time", "url", "user_id", "visit_id", "property_name"] + self._ransackers.keys
|
60
|
+
super + ["action", "controller", "id", "id_property", "name", "page", "properties", "time", "url", "user_id", "visit_id", "property_name", "goal"] + self._ransackers.keys
|
52
61
|
end
|
53
62
|
|
54
63
|
def ransackable_scopes(auth_object = nil)
|