ahoy_captain 0.8 → 0.9
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/application.js +4 -4
- data/app/assets/javascript/ahoy_captain/controllers/active_links_controller.js +14 -0
- data/app/assets/javascript/ahoy_captain/controllers/application.js +5 -5
- data/app/assets/javascript/ahoy_captain/controllers/application_controller.js +9 -10
- data/app/assets/javascript/ahoy_captain/controllers/details_modal_controller.js +5 -5
- data/app/assets/javascript/ahoy_captain/controllers/dropdown_label_controller.js +2 -2
- data/app/assets/javascript/ahoy_captain/controllers/filter/item_controller.js +12 -0
- data/app/assets/javascript/ahoy_captain/controllers/filter_form_controller.js +13 -0
- data/app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js +11 -8
- data/app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js +77 -107
- data/app/assets/javascript/ahoy_captain/controllers/index.js +4 -3
- data/app/assets/javascript/ahoy_captain/controllers/interval_controller.js +3 -3
- data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +37 -0
- data/app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js +10 -0
- data/app/assets/javascript/ahoy_captain/controllers/realtime_controller.js +9 -8
- data/app/assets/javascript/ahoy_captain/controllers/search_select_controller.js +65 -0
- 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 +8 -7
- data/app/components/ahoy_captain/filter/select_component.html.erb +14 -12
- data/app/components/ahoy_captain/filter/select_component.rb +40 -9
- 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 +11 -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 +4 -37
- data/app/components/ahoy_captain/table_component.rb +15 -4
- data/app/components/ahoy_captain/tables/headers/devices_header_component.html.erb +3 -0
- data/app/components/ahoy_captain/tables/headers/devices_header_component.rb +9 -0
- data/app/components/ahoy_captain/tables/headers/goals_header_component.html.erb +6 -0
- data/app/components/ahoy_captain/tables/headers/goals_header_component.rb +9 -0
- data/app/components/ahoy_captain/tables/headers/header_component.html.erb +5 -0
- data/app/components/ahoy_captain/tables/headers/header_component.rb +12 -0
- data/app/components/ahoy_captain/tables/rows/devices_row_component.html.erb +5 -0
- data/app/components/ahoy_captain/tables/rows/devices_row_component.rb +12 -0
- data/app/components/ahoy_captain/tables/rows/goals_row_component.html.erb +11 -0
- data/app/components/ahoy_captain/tables/rows/goals_row_component.rb +20 -0
- data/app/components/ahoy_captain/tables/rows/row_component.html.erb +6 -0
- data/app/components/ahoy_captain/tables/rows/row_component.rb +41 -0
- 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/application_controller.rb +13 -14
- data/app/controllers/ahoy_captain/campaigns_controller.rb +2 -10
- data/app/controllers/ahoy_captain/cities_controller.rb +2 -6
- data/app/controllers/ahoy_captain/countries_controller.rb +2 -6
- data/app/controllers/ahoy_captain/devices_controller.rb +3 -6
- data/app/controllers/ahoy_captain/entry_pages_controller.rb +2 -4
- data/app/controllers/ahoy_captain/exit_pages_controller.rb +3 -4
- data/app/controllers/ahoy_captain/exports_controller.rb +15 -0
- data/app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb +2 -2
- data/app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb +1 -2
- data/app/controllers/ahoy_captain/filters/properties/names_controller.rb +11 -0
- data/app/controllers/ahoy_captain/filters/properties/values_controller.rb +15 -0
- data/app/controllers/ahoy_captain/filters/sources_controller.rb +1 -1
- data/app/controllers/ahoy_captain/regions_controller.rb +3 -7
- data/app/controllers/ahoy_captain/sources_controller.rb +2 -5
- data/app/controllers/ahoy_captain/stats/base_controller.rb +3 -3
- data/app/controllers/ahoy_captain/stats/bounce_rates_controller.rb +1 -0
- data/app/controllers/ahoy_captain/stats/total_pageviews_controller.rb +1 -0
- data/app/controllers/ahoy_captain/stats/total_visits_controller.rb +1 -0
- data/app/controllers/ahoy_captain/stats/unique_visitors_controller.rb +1 -0
- data/app/controllers/ahoy_captain/stats/views_per_visits_controller.rb +3 -2
- data/app/controllers/ahoy_captain/stats/visit_durations_controller.rb +1 -0
- data/app/controllers/ahoy_captain/top_pages_controller.rb +2 -8
- data/app/decorators/ahoy_captain/application_decorator.rb +27 -3
- data/app/decorators/ahoy_captain/campaign_decorator.rb +8 -0
- data/app/decorators/ahoy_captain/city_decorator.rb +12 -0
- data/app/decorators/ahoy_captain/country_decorator.rb +10 -0
- data/app/decorators/ahoy_captain/device_decorator.rb +13 -2
- data/app/decorators/ahoy_captain/page_decorator.rb +11 -0
- data/app/decorators/ahoy_captain/region_decorator.rb +16 -0
- data/app/decorators/ahoy_captain/source_decorator.rb +7 -0
- data/app/helpers/ahoy_captain/application_helper.rb +33 -0
- data/app/models/ahoy_captain/export.rb +48 -0
- data/app/models/ahoy_captain/filter_parser.rb +67 -0
- data/app/presenters/ahoy_captain/dashboard_presenter.rb +6 -1
- data/app/presenters/ahoy_captain/goals_presenter.rb +3 -2
- data/app/queries/ahoy_captain/application_query.rb +4 -3
- data/app/queries/ahoy_captain/campaign_query.rb +14 -0
- data/app/queries/ahoy_captain/city_query.rb +11 -0
- data/app/queries/ahoy_captain/country_query.rb +10 -0
- data/app/queries/ahoy_captain/device_query.rb +10 -0
- data/app/queries/ahoy_captain/entry_pages_query.rb +3 -2
- data/app/queries/ahoy_captain/event_query.rb +17 -15
- data/app/queries/ahoy_captain/exit_pages_query.rb +6 -4
- data/app/queries/ahoy_captain/region_query.rb +11 -0
- data/app/queries/ahoy_captain/source_query.rb +10 -0
- data/app/queries/ahoy_captain/top_page_query.rb +13 -0
- data/app/queries/ahoy_captain/visit_query.rb +1 -1
- data/app/views/ahoy_captain/devices/_table.html.erb +5 -0
- data/app/views/ahoy_captain/devices/index.html+details.erb +1 -1
- data/app/views/ahoy_captain/devices/index.html.erb +2 -2
- data/app/views/ahoy_captain/funnels/show.html.erb +5 -2
- data/app/views/ahoy_captain/goals/index.html.erb +3 -35
- 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 +33 -95
- data/app/views/ahoy_captain/stats/base/index.html.erb +4 -7
- data/app/views/ahoy_captain/stats/show.html.erb +6 -51
- data/config/routes.rb +7 -0
- data/lib/ahoy_captain/ahoy/event_methods.rb +36 -73
- data/lib/ahoy_captain/ahoy/visit_methods.rb +1 -1
- data/lib/ahoy_captain/configuration.rb +13 -3
- data/lib/ahoy_captain/engine.rb +18 -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 +10 -2
- data/lib/ahoy_captain/period_collection.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 +56 -20
- data/app/assets/javascript/ahoy_captain/controllers/filter_controller.js +0 -145
- data/app/assets/javascript/ahoy_captain/controllers/link_controller.js +0 -43
- data/app/assets/javascript/ahoy_captain/controllers/navigation_controller.js +0 -25
- data/app/models/ahoy_captain/current.rb +0 -9
- data/app/models/ahoy_captain/url_helpers.rb +0 -6
@@ -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 %>
|
@@ -14,83 +14,83 @@
|
|
14
14
|
|
15
15
|
<%= render AhoyCaptain::TileComponent.new(title: 'Top Sources') do |component| %>
|
16
16
|
<% component.with_display_links do %>
|
17
|
-
<div data-controller=
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
<div data-controller="active-links">
|
18
|
+
<a href="<%= sources_path(search_params) %>" data-turbo-frame="sources" class="" data-active-links-target="link">All</a>
|
19
|
+
<%= render AhoyCaptain::DropdownLinkComponent.new(title: "Campaign") do |dropdown| %>
|
20
|
+
<% %w{utm_source utm_medium utm_term utm_content utm_campaign}.each do |source| %>
|
21
|
+
<% dropdown.with_option do %>
|
22
|
+
<a href="<%= public_send("campaign_#{source}_path".to_sym, **search_params) %>" class="" data-turbo-frame="sources" data-active-links-target="link">
|
23
|
+
<%= source.titleize.gsub("Utm", "UTM") %>
|
24
|
+
</a>
|
25
|
+
<% end %>
|
25
26
|
<% end %>
|
26
27
|
<% end %>
|
27
|
-
<% end %>
|
28
28
|
</div>
|
29
29
|
<% end %>
|
30
30
|
<% component.with_statistic_display do %>
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
<div data-controller='active-links'>
|
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
|
+
</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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
<div data-controller="active-links">
|
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
|
+
</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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
<div data-controller="active-links">
|
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
|
+
</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 %>
|
@@ -98,76 +98,14 @@
|
|
98
98
|
<% end %>
|
99
99
|
|
100
100
|
<% end %>
|
101
|
-
|
101
|
+
<% component.with_statistic_display do %>
|
102
102
|
<%= turbo_frame_tag :goals, src: goals_path(search_params), loading: :lazy %>
|
103
103
|
<% end %>
|
104
104
|
<% end %>
|
105
105
|
</div>
|
106
106
|
</main>
|
107
107
|
|
108
|
-
<%= render
|
109
|
-
<% modal.with_modal_display do %>
|
110
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Action", column: :route, url: filters_actions_path, predicates: [:in, :not_in]) %>
|
111
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Entry page", column: :entry_page, url: filters_entry_pages_path, predicates: [:in, :not_in]) %>
|
112
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Exit page", column: :exit_page, url: filters_exit_pages_path, predicates: [:in, :not_in]) %>
|
113
|
-
<% end %>
|
114
|
-
<% end %>
|
115
|
-
|
116
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Country", id: "countryModal") do |modal| %>
|
117
|
-
<% modal.with_modal_display do %>
|
118
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Country", column: :country, url: filters_locations_countries_path, predicates: [:in, :not_in]) %>
|
119
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Region", column: :region, url: filters_locations_regions_path, predicates: [:in, :not_in]) %>
|
120
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "City", column: :city, url: filters_locations_cities_path, predicates: [:in, :not_in]) %>
|
121
|
-
<% end %>
|
122
|
-
<% end %>
|
123
|
-
|
124
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Source", id: "sourceModal") do |modal| %>
|
125
|
-
<% modal.with_modal_display do %>
|
126
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Source", column: :referring_domain, url: filters_sources_path, predicates: [:in, :not_in]) %>
|
127
|
-
<% end %>
|
128
|
-
<% end %>
|
129
|
-
|
130
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Screen size", id: "screenModal") do |modal| %>
|
131
|
-
<% modal.with_modal_display do %>
|
132
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Screen size", column: :device_type, url: filters_screens_path, predicates: [:in, :not_in]) %>
|
133
|
-
<% end %>
|
134
|
-
<% end %>
|
135
|
-
|
136
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Browser", id: "osModal") do |modal| %>
|
137
|
-
<% modal.with_modal_display do %>
|
138
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System", column: :os, url: filters_names_path, predicates: [:in, :not_in]) %>
|
139
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System Version", column: :os_version, url: filters_versions_path, predicates: [:in, :not_in]) %>
|
140
|
-
<% end %>
|
141
|
-
<% end %>
|
142
|
-
|
143
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Campaign", id: "utmModal") do |modal| %>
|
144
|
-
<% modal.with_modal_display do %>
|
145
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Medium", column: :utm_medium, url: filters_utm_mediums_path, predicates: [:in, :not_in]) %>
|
146
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Source", column: :utm_source, url: filters_utm_sources_path, predicates: [:in, :not_in]) %>
|
147
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Campaign", column: :utm_campaign, url: filters_utm_campaigns_path, predicates: [:in, :not_in]) %>
|
148
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Term", column: :utm_term, url: filters_utm_terms_path, predicates: [:in, :not_in]) %>
|
149
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Content", column: :utm_content, url: filters_utm_contents_path, predicates: [:in, :not_in]) %>
|
150
|
-
<% end %>
|
151
|
-
<% end %>
|
152
|
-
|
153
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Range", id: "customRangeModal") do |modal| %>
|
154
|
-
<% modal.with_modal_display do %>
|
155
|
-
<div class="flex gap-2 w-full">
|
156
|
-
<div class="form-control w-full max-w-xs">
|
157
|
-
<label class="label">
|
158
|
-
<span class="label-text">Start Date</span>
|
159
|
-
</label>
|
160
|
-
<input type="datetime-local" name="start_date" class="input input-bordered w-full" value="<%= params[:start_date] %>" />
|
161
|
-
</div>
|
162
|
-
<div class="form-control w-full max-w-xs">
|
163
|
-
<label class="label">
|
164
|
-
<span class="label-text">End Date</span>
|
165
|
-
</label>
|
166
|
-
<input type="datetime-local" name="end_date" class="input input-bordered w-full" value="<%= params[:end_date] %>" />
|
167
|
-
</div>
|
168
|
-
</div>
|
169
|
-
<% end %>
|
170
|
-
<% end %>
|
108
|
+
<%= render 'filters' %>
|
171
109
|
|
172
110
|
<dialog id="detailsModal" class="modal">
|
173
111
|
<div class="modal-box w-11/12 max-w-5xl">
|
@@ -1,14 +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
7
|
</div>
|
8
|
-
|
9
8
|
<div>
|
10
|
-
|
11
|
-
|
12
|
-
<%= line_chart @stats %>
|
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>
|
13
10
|
</div>
|
14
11
|
<% end %>
|
@@ -1,56 +1,11 @@
|
|
1
1
|
<%= turbo_frame_tag :stats do %>
|
2
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>
|
3
|
+
<%= render ::AhoyCaptain::Stats::ContainerComponent.new(stats_unique_visitors_url(search_params), "Unique Visits", number_with_delimiter(@presenter.unique_visitors)) %>
|
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 %>
|
data/config/routes.rb
CHANGED
@@ -12,6 +12,7 @@ AhoyCaptain::Engine.routes.draw do
|
|
12
12
|
get "/devices/#{k}" => 'devices#index', defaults: { devices_type: v }, as: "devices_#{k}"
|
13
13
|
end
|
14
14
|
|
15
|
+
resource :export, only: [:show]
|
15
16
|
resource :realtime, only: [:show]
|
16
17
|
resources :funnels, only: [:show]
|
17
18
|
resources :goals, only: [:index]
|
@@ -41,6 +42,12 @@ AhoyCaptain::Engine.routes.draw do
|
|
41
42
|
%w{country region city}.each do |type|
|
42
43
|
get "locations/#{type.pluralize}" => "locations#index", defaults: { type: type }
|
43
44
|
end
|
45
|
+
|
46
|
+
namespace :properties do
|
47
|
+
resources :names, only: [:index]
|
48
|
+
resources :values, only: [:index]
|
49
|
+
end
|
50
|
+
|
44
51
|
resources :sources, only: [:index]
|
45
52
|
resources :screens, only: [:index]
|
46
53
|
scope :operating_systems, module: :operating_systems do
|
@@ -4,104 +4,67 @@ module AhoyCaptain
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
ransacker :route do |
|
7
|
+
ransacker :route do |_parent|
|
8
8
|
Arel.sql(AhoyCaptain.config.event[:url_column])
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
select(Arel.sql("#{AhoyCaptain.config.event.url_column} AS url"))
|
15
|
-
}
|
16
|
-
|
17
|
-
scope :distinct_url, -> {
|
18
|
-
distinct(Arel.sql("#{AhoyCaptain.config.event.url_column}"))
|
19
|
-
}
|
20
|
-
|
21
|
-
scope :url_in, ->(*args) {
|
22
|
-
where("#{AhoyCaptain.config.event.url_column} IN (?)", args)
|
23
|
-
}
|
24
|
-
|
25
|
-
scope :url_eq, ->(arg) {
|
26
|
-
if arg.is_a?(Array)
|
27
|
-
arg = arg[0]
|
28
|
-
end
|
29
|
-
where("#{AhoyCaptain.config.event.url_column} = ?", arg)
|
30
|
-
}
|
31
|
-
|
32
|
-
scope :url_not_in, ->(*args) {
|
33
|
-
where("#{AhoyCaptain.config.event.url_column} NOT IN (?)", args)
|
34
|
-
}
|
35
|
-
|
36
|
-
scope :url_i_cont, ->(arg) {
|
37
|
-
where("#{AhoyCaptain.config.event.url_column} ILIKE ?", "%#{arg}%")
|
38
|
-
}
|
39
|
-
|
40
|
-
scope :route_eq, ->(arg) {
|
41
|
-
url_eq(arg)
|
42
|
-
}
|
11
|
+
ransacker :entry_page do |parent|
|
12
|
+
Arel.sql("entry_pages.url")
|
13
|
+
end
|
43
14
|
|
44
|
-
|
45
|
-
|
46
|
-
|
15
|
+
ransacker :exit_page do |parent|
|
16
|
+
Arel.sql("exit_pages.url")
|
17
|
+
end
|
47
18
|
|
48
|
-
scope :
|
49
|
-
|
19
|
+
scope :with_entry_pages, -> {
|
20
|
+
with(entry_pages: self.select("MIN(ahoy_events.id) as min_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}").where(name: AhoyCaptain.config.event[:view_name]).group("ahoy_events.properties")).joins("INNER JOIN entry_pages ON entry_pages.min_id = ahoy_events.id")
|
50
21
|
}
|
51
|
-
|
52
|
-
|
53
|
-
url_i_cont(arg)
|
22
|
+
scope :with_exit_pages, -> {
|
23
|
+
with(exit_pages: self.select("MAX(ahoy_events.id) as max_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}").where(name: AhoyCaptain.config.event[:view_name]).group("ahoy_events.properties")).joins("INNER JOIN exit_pages ON exit_pages.max_id = ahoy_events.id")
|
54
24
|
}
|
55
25
|
|
56
|
-
scope :
|
57
|
-
table_alias = "first_events_#{SecureRandom.hex.first(6)}"
|
58
|
-
|
59
|
-
subquery = self.select("MIN(id) as min_id").where(name: AhoyCaptain.config.event[:view_name]).route_in(*args).group(:visit_id)
|
60
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.min_id")
|
61
|
-
}
|
26
|
+
scope :with_routes, -> { where(AhoyCaptain.config.event[:url_exists]) }
|
62
27
|
|
63
|
-
scope :
|
64
|
-
|
65
|
-
subquery = self.select("MIN(id) as min_id").where(name: AhoyCaptain.config.event[:view_name]).route_not_in(*args).group(:visit_id)
|
66
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.min_id")
|
28
|
+
scope :with_url, -> {
|
29
|
+
select(Arel.sql("#{AhoyCaptain.config.event.url_column} AS url"))
|
67
30
|
}
|
68
31
|
|
69
|
-
scope :
|
70
|
-
|
71
|
-
subquery = self.select("MIN(id) as min_id").where(name: AhoyCaptain.config.event[:view_name]).route_i_cont(arg).group(:visit_id)
|
72
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.min_id")
|
32
|
+
scope :distinct_url, -> {
|
33
|
+
distinct(Arel.sql("#{AhoyCaptain.config.event.url_column}"))
|
73
34
|
}
|
74
35
|
|
75
|
-
scope :
|
76
|
-
|
77
|
-
|
78
|
-
subquery = self.select("MAX(id) as max_id").where(name: AhoyCaptain.config.event[:view_name]).route_in(*args).group(:visit_id)
|
79
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.max_id")
|
36
|
+
scope :property_name_eq, ->(value) {
|
37
|
+
where("properties ? :key", key: value)
|
80
38
|
}
|
81
39
|
|
82
|
-
scope :
|
83
|
-
|
84
|
-
|
85
|
-
subquery = self.select("MAX(id) as max_id").where(name: AhoyCaptain.config.event[:view_name]).route_not_in(*args).group(:visit_id)
|
86
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.max_id")
|
40
|
+
scope :properties_eq, ->(value) {
|
41
|
+
where("properties @> ?", value)
|
87
42
|
}
|
88
43
|
|
89
|
-
scope :
|
90
|
-
|
91
|
-
|
92
|
-
subquery = self.select("MAX(id) as max_id").where(name: AhoyCaptain.config.event[:view_name]).route_i_cont(*arg).group(:visit_id)
|
93
|
-
joins("INNER JOIN (#{subquery.to_sql}) #{table_alias} ON #{::AhoyCaptain.event.table_name}.id = #{table_alias}.max_id")
|
94
|
-
}
|
44
|
+
scope :properties_not_eq, ->(value) do
|
45
|
+
where.not("properties::jsonb @> ?", value)
|
46
|
+
end
|
95
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
|
96
56
|
end
|
97
57
|
|
98
58
|
class_methods do
|
99
59
|
def ransackable_attributes(auth_object = nil)
|
100
|
-
super + ["action", "controller", "id", "id_property", "name", "
|
60
|
+
super + ["action", "controller", "id", "id_property", "name", "page", "properties", "time", "url", "user_id", "visit_id", "property_name", "goal"] + self._ransackers.keys
|
101
61
|
end
|
102
62
|
|
103
63
|
def ransackable_scopes(auth_object = nil)
|
104
|
-
super + [
|
64
|
+
super + [
|
65
|
+
:properties_eq,
|
66
|
+
:properties_not_eq
|
67
|
+
]
|
105
68
|
end
|
106
69
|
|
107
70
|
def ransackable_associations(auth_object = nil)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'ahoy_captain/period_collection'
|
2
|
+
require 'ahoy_captain/filters_configuration'
|
2
3
|
|
3
4
|
module AhoyCaptain
|
4
5
|
class Configuration
|
5
6
|
attr_accessor :view_name, :theme
|
6
|
-
attr_reader :goals, :funnels, :cache, :ranges, :disabled_widgets, :event, :models
|
7
|
+
attr_reader :goals, :funnels, :cache, :ranges, :disabled_widgets, :event, :models, :filters, :predicate_labels
|
7
8
|
def initialize
|
8
9
|
@goals = GoalCollection.new
|
9
10
|
@funnels = FunnelCollection.new
|
@@ -16,13 +17,22 @@ module AhoyCaptain
|
|
16
17
|
end
|
17
18
|
@event = ActiveSupport::OrderedOptions.new.tap do |option|
|
18
19
|
option.view_name = "$view"
|
19
|
-
option.url_column = "CONCAT(ahoy_events.properties->>'controller', '#', ahoy_events.properties->>'action')"
|
20
|
-
option.url_exists = "JSONB_EXISTS(ahoy_events.properties, 'controller') AND JSONB_EXISTS(ahoy_events.properties, 'action')"
|
20
|
+
option.url_column = "COALESCE(ahoy_events.properties->>'url', CONCAT(ahoy_events.properties->>'controller', '#', ahoy_events.properties->>'action'))"
|
21
|
+
option.url_exists = "(JSONB_EXISTS(ahoy_events.properties, 'controller') AND JSONB_EXISTS(ahoy_events.properties, 'action')) OR (JSONB_EXISTS(ahoy_events.properties, 'url'))"
|
21
22
|
end
|
22
23
|
@models = ActiveSupport::OrderedOptions.new.tap do |option|
|
23
24
|
option.event = "::Ahoy::Event"
|
24
25
|
option.visit = "::Ahoy::Visit"
|
25
26
|
end
|
27
|
+
@filters = FiltersConfiguration.load_default
|
28
|
+
@predicate_labels = {
|
29
|
+
eq: 'equals',
|
30
|
+
not_eq: 'not equals',
|
31
|
+
cont: 'contains',
|
32
|
+
in: 'in',
|
33
|
+
not_in: 'not in',
|
34
|
+
}
|
35
|
+
|
26
36
|
@disabled_widgets = []
|
27
37
|
end
|
28
38
|
|
data/lib/ahoy_captain/engine.rb
CHANGED
@@ -6,6 +6,24 @@ require 'view_component'
|
|
6
6
|
require 'chartkick'
|
7
7
|
require 'groupdate'
|
8
8
|
require 'pagy'
|
9
|
+
require 'zip'
|
10
|
+
|
11
|
+
module Ransack
|
12
|
+
module Nodes
|
13
|
+
class Condition
|
14
|
+
|
15
|
+
# allows for sql from a formatter
|
16
|
+
# see https://github.com/activerecord-hackery/ransack/issues/702
|
17
|
+
def casted_array?(predicate)
|
18
|
+
return unless predicate.is_a?(Arel::Nodes::Casted)
|
19
|
+
|
20
|
+
predicate.value.is_a?(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
9
27
|
|
10
28
|
module AhoyCaptain
|
11
29
|
class Engine < Rails::Engine
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module AhoyCaptain
|
2
|
+
class FilterConfiguration
|
3
|
+
class Filter
|
4
|
+
attr_reader :column, :label, :url, :predicates, :multiple, :position
|
5
|
+
|
6
|
+
def initialize(label:, column:, url:, predicates: [:in, :not_in], multiple: true, position: nil)
|
7
|
+
@column = column
|
8
|
+
@label = label
|
9
|
+
@url = url
|
10
|
+
@predicates = predicates
|
11
|
+
@multiple = multiple
|
12
|
+
@position = position
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module AhoyCaptain
|
2
|
+
class FilterConfiguration
|
3
|
+
class FilterCollection
|
4
|
+
def initialize(label)
|
5
|
+
@label = label
|
6
|
+
@registry = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def filter(label:, column:, url:, predicates: [:in, :not_in], multiple: true, position: nil)
|
10
|
+
position ||= @registry.size
|
11
|
+
if item = find(column)
|
12
|
+
@registry.delete(item)
|
13
|
+
end
|
14
|
+
|
15
|
+
@registry << FilterConfiguration::Filter.new(label: label, column: column, url: url, predicates: predicates, multiple: multiple, position: position)
|
16
|
+
@registry = @registry.sort_by { |filter| filter.position }
|
17
|
+
end
|
18
|
+
|
19
|
+
def each(&block)
|
20
|
+
@registry.each(&block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def modal_name
|
24
|
+
"#{@label.parameterize.underscore}Modal"
|
25
|
+
end
|
26
|
+
|
27
|
+
def find(column)
|
28
|
+
@registry.find { |filter| filter.column == column.to_sym }
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(name)
|
32
|
+
@registry.delete_if { |filter| filter.column == name }
|
33
|
+
end
|
34
|
+
|
35
|
+
def filters
|
36
|
+
@registry
|
37
|
+
end
|
38
|
+
|
39
|
+
def [](name)
|
40
|
+
find(name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def include?(name)
|
44
|
+
find(name).present?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|