ahoy_captain 0.11.1 → 0.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -25
- data/Rakefile +2 -23
- data/app/assets/javascript/ahoy_captain/application.js +4 -4
- data/app/assets/javascript/ahoy_captain/controllers/application.js +5 -5
- data/app/assets/javascript/ahoy_captain/controllers/application_controller.js +8 -27
- 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_controller.js +145 -0
- data/app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js +17 -0
- data/app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js +127 -113
- data/app/assets/javascript/ahoy_captain/controllers/index.js +3 -4
- data/app/assets/javascript/ahoy_captain/controllers/link_controller.js +43 -0
- data/app/assets/javascript/ahoy_captain/controllers/navigation_controller.js +25 -0
- data/app/assets/javascript/ahoy_captain/controllers/realtime_controller.js +9 -12
- data/app/components/ahoy_captain/dropdown_button_component.html.erb +5 -5
- data/app/components/ahoy_captain/dropdown_link_component.html.erb +7 -5
- data/app/components/ahoy_captain/dropdown_link_component.rb +0 -4
- data/app/components/ahoy_captain/filter/modal_component.html.erb +9 -12
- data/app/components/ahoy_captain/filter/select_component.html.erb +19 -23
- data/app/components/ahoy_captain/filter/select_component.rb +9 -41
- data/app/components/ahoy_captain/filter/tag_component.html.erb +4 -8
- data/app/components/ahoy_captain/filter/tag_component.rb +30 -6
- data/app/components/ahoy_captain/filter/tag_container_component.html.erb +3 -2
- data/app/components/ahoy_captain/filter/tag_container_component.rb +8 -1
- data/app/components/ahoy_captain/sticky_nav_component.html.erb +33 -28
- data/app/components/ahoy_captain/sticky_nav_component.rb +0 -19
- data/app/components/ahoy_captain/table_component.html.erb +37 -4
- data/app/components/ahoy_captain/table_component.rb +5 -25
- data/app/components/ahoy_captain/tile_component.html.erb +10 -21
- data/app/components/ahoy_captain/tile_component.rb +2 -10
- data/app/components/ahoy_captain/tooltip_component.html.erb +2 -2
- data/app/controllers/ahoy_captain/application_controller.rb +30 -23
- data/app/controllers/ahoy_captain/campaigns_controller.rb +10 -2
- data/app/controllers/ahoy_captain/cities_controller.rb +24 -0
- data/app/controllers/ahoy_captain/countries_controller.rb +24 -0
- data/app/controllers/ahoy_captain/devices_controller.rb +6 -3
- data/app/controllers/ahoy_captain/entry_pages_controller.rb +4 -2
- data/app/controllers/ahoy_captain/exit_pages_controller.rb +4 -3
- data/app/controllers/ahoy_captain/filters/base_controller.rb +3 -1
- data/app/controllers/ahoy_captain/filters/pages/actions_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb +3 -3
- data/app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb +3 -2
- data/app/controllers/ahoy_captain/filters/sources_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/utms_controller.rb +1 -1
- data/app/controllers/ahoy_captain/realtimes_controller.rb +1 -1
- data/app/controllers/ahoy_captain/regions_controller.rb +24 -0
- data/app/controllers/ahoy_captain/sources_controller.rb +5 -2
- data/app/controllers/ahoy_captain/stats/base_controller.rb +0 -142
- data/app/controllers/ahoy_captain/stats/bounce_rates_controller.rb +2 -4
- data/app/controllers/ahoy_captain/stats/total_pageviews_controller.rb +1 -2
- data/app/controllers/ahoy_captain/stats/total_visits_controller.rb +1 -2
- data/app/controllers/ahoy_captain/stats/unique_visitors_controller.rb +1 -3
- data/app/controllers/ahoy_captain/stats/views_per_visits_controller.rb +8 -3
- data/app/controllers/ahoy_captain/stats/visit_durations_controller.rb +1 -2
- data/app/controllers/ahoy_captain/top_pages_controller.rb +8 -2
- data/app/decorators/ahoy_captain/application_decorator.rb +3 -27
- data/app/decorators/ahoy_captain/campaign_decorator.rb +0 -8
- data/app/decorators/ahoy_captain/city_decorator.rb +0 -12
- data/app/decorators/ahoy_captain/country_decorator.rb +0 -10
- data/app/decorators/ahoy_captain/device_decorator.rb +2 -13
- data/app/decorators/ahoy_captain/page_decorator.rb +0 -11
- data/app/decorators/ahoy_captain/region_decorator.rb +0 -16
- data/app/decorators/ahoy_captain/source_decorator.rb +0 -7
- data/app/helpers/ahoy_captain/application_helper.rb +3 -60
- data/app/models/ahoy_captain/current.rb +9 -0
- data/app/models/ahoy_captain/rangeable.rb +3 -0
- data/app/models/ahoy_captain/url_helpers.rb +6 -0
- data/app/models/concerns/ahoy_captain/range_options.rb +14 -1
- data/app/presenters/ahoy_captain/dashboard_presenter.rb +46 -18
- data/app/presenters/ahoy_captain/funnel_presenter.rb +29 -32
- data/app/presenters/ahoy_captain/goals_presenter.rb +23 -33
- data/app/queries/ahoy_captain/application_query.rb +13 -81
- data/app/queries/ahoy_captain/entry_pages_query.rb +2 -3
- data/app/queries/ahoy_captain/event_query.rb +8 -30
- data/app/queries/ahoy_captain/exit_pages_query.rb +4 -6
- data/app/queries/ahoy_captain/stats/average_views_per_visit_query.rb +4 -11
- data/app/queries/ahoy_captain/stats/average_visit_duration_query.rb +7 -15
- data/app/queries/ahoy_captain/stats/bounce_rates_query.rb +7 -24
- data/app/queries/ahoy_captain/stats/total_pageviews_query.rb +2 -2
- data/app/queries/ahoy_captain/stats/total_visitors_query.rb +2 -2
- data/app/queries/ahoy_captain/stats/unique_visitors_query.rb +2 -2
- data/app/queries/ahoy_captain/stats/views_per_visit_query.rb +3 -3
- data/app/queries/ahoy_captain/stats/visit_duration_query.rb +5 -5
- data/app/queries/ahoy_captain/visit_query.rb +13 -12
- 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 +2 -5
- data/app/views/ahoy_captain/goals/index.html.erb +37 -2
- data/app/views/ahoy_captain/layouts/application.html.erb +4 -3
- data/app/views/ahoy_captain/realtimes/show.html.erb +1 -1
- data/app/views/ahoy_captain/roots/show.html.erb +118 -117
- data/app/views/ahoy_captain/stats/base/index.html.erb +1 -38
- data/app/views/ahoy_captain/stats/show.html.erb +56 -14
- data/config/routes.rb +3 -16
- data/lib/ahoy_captain/ahoy/event_methods.rb +75 -36
- data/lib/ahoy_captain/ahoy/visit_methods.rb +1 -1
- data/lib/ahoy_captain/configuration.rb +7 -18
- data/lib/ahoy_captain/engine.rb +0 -22
- data/lib/ahoy_captain/goals.rb +4 -16
- data/lib/ahoy_captain/period_collection.rb +1 -1
- data/lib/ahoy_captain/version.rb +1 -1
- data/lib/ahoy_captain.rb +1 -8
- data/lib/generators/ahoy_captain/templates/config.rb.tt +3 -50
- metadata +17 -185
- data/app/assets/javascript/ahoy_captain/controllers/combobox_controller.js +0 -371
- data/app/assets/javascript/ahoy_captain/controllers/filter/item_controller.js +0 -12
- data/app/assets/javascript/ahoy_captain/controllers/filter_form_controller.js +0 -13
- data/app/assets/javascript/ahoy_captain/controllers/filter_modal_controller.js +0 -45
- data/app/assets/javascript/ahoy_captain/controllers/frame_link_controller.js +0 -20
- data/app/assets/javascript/ahoy_captain/controllers/interval_controller.js +0 -15
- data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +0 -251
- data/app/assets/javascript/ahoy_captain/controllers/map_controller.js +0 -47
- data/app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js +0 -10
- data/app/assets/javascript/ahoy_captain/controllers/properties_controller.js +0 -8
- data/app/assets/javascript/ahoy_captain/controllers/property_filter_controller.js +0 -45
- data/app/assets/javascript/ahoy_captain/controllers/tile_controller.js +0 -33
- data/app/assets/javascript/ahoy_captain/controllers/toggle_controller.js +0 -17
- data/app/assets/javascript/ahoy_captain/helpers/chart_utils.js +0 -156
- data/app/assets/javascript/ahoy_captain/helpers/countries.js +0 -2261
- data/app/assets/javascript/ahoy_captain/helpers/number_formatters.js +0 -55
- data/app/components/ahoy_captain/combobox_component.html.erb +0 -33
- data/app/components/ahoy_captain/combobox_component.rb +0 -13
- data/app/components/ahoy_captain/comparison_link_component.html.erb +0 -17
- data/app/components/ahoy_captain/comparison_link_component.rb +0 -44
- data/app/components/ahoy_captain/filter/dropdown_component.html.erb +0 -50
- data/app/components/ahoy_captain/filter/dropdown_component.rb +0 -51
- data/app/components/ahoy_captain/previous_next_component.html.erb +0 -8
- data/app/components/ahoy_captain/previous_next_component.rb +0 -11
- data/app/components/ahoy_captain/stats/comparable_container_component.html.erb +0 -25
- data/app/components/ahoy_captain/stats/comparable_container_component.rb +0 -86
- data/app/components/ahoy_captain/stats/container_component.html.erb +0 -15
- data/app/components/ahoy_captain/stats/container_component.rb +0 -26
- data/app/components/ahoy_captain/tables/devices_table_component.rb +0 -11
- data/app/components/ahoy_captain/tables/dynamic_table.rb +0 -13
- data/app/components/ahoy_captain/tables/dynamic_table_component.rb +0 -204
- data/app/components/ahoy_captain/tables/goals_table_component.rb +0 -17
- data/app/components/ahoy_captain/tables/header_component.html.erb +0 -5
- data/app/components/ahoy_captain/tables/header_component.rb +0 -18
- data/app/components/ahoy_captain/tables/headers/header_component.html.erb +0 -5
- data/app/components/ahoy_captain/tables/headers/header_component.rb +0 -16
- data/app/components/ahoy_captain/tables/properties_table_component.rb +0 -27
- data/app/components/ahoy_captain/tables/row_component.html.erb +0 -4
- data/app/components/ahoy_captain/tables/rows/row_component.html.erb +0 -6
- data/app/components/ahoy_captain/tables/rows/row_component.rb +0 -40
- data/app/controllers/ahoy_captain/exports_controller.rb +0 -14
- data/app/controllers/ahoy_captain/filters/goals_controller.rb +0 -9
- data/app/controllers/ahoy_captain/filters/properties/names_controller.rb +0 -11
- data/app/controllers/ahoy_captain/filters/properties/values_controller.rb +0 -15
- data/app/controllers/ahoy_captain/locations/cities_controller.rb +0 -22
- data/app/controllers/ahoy_captain/locations/countries_controller.rb +0 -22
- data/app/controllers/ahoy_captain/locations/maps_controller.rb +0 -24
- data/app/controllers/ahoy_captain/locations/regions_controller.rb +0 -22
- data/app/controllers/ahoy_captain/properties_controller.rb +0 -41
- data/app/models/ahoy_captain/comparison_mode.rb +0 -72
- data/app/models/ahoy_captain/export.rb +0 -48
- data/app/models/ahoy_captain/filter_parser.rb +0 -82
- data/app/models/ahoy_captain/range_from_params.rb +0 -78
- data/app/models/concerns/ahoy_captain/compare_mode.rb +0 -19
- data/app/models/concerns/ahoy_captain/limitable.rb +0 -17
- data/app/queries/ahoy_captain/campaign_query.rb +0 -14
- data/app/queries/ahoy_captain/city_query.rb +0 -11
- data/app/queries/ahoy_captain/country_query.rb +0 -10
- data/app/queries/ahoy_captain/device_query.rb +0 -10
- data/app/queries/ahoy_captain/region_query.rb +0 -11
- data/app/queries/ahoy_captain/source_query.rb +0 -10
- data/app/queries/ahoy_captain/stats/base_query.rb +0 -18
- data/app/queries/ahoy_captain/top_page_query.rb +0 -13
- data/app/queries/concerns/ahoy_captain/comparable_queries.rb +0 -25
- data/app/queries/concerns/ahoy_captain/comparable_query.rb +0 -138
- data/app/queries/concerns/ahoy_captain/lazy_comparable_query.rb +0 -42
- data/app/views/ahoy_captain/devices/_table.html.erb +0 -2
- data/app/views/ahoy_captain/layouts/shared/_tile_loader.html.erb +0 -12
- data/app/views/ahoy_captain/locations/maps/show.html.erb +0 -3
- data/app/views/ahoy_captain/properties/_form.html.erb +0 -6
- data/app/views/ahoy_captain/properties/index.html.erb +0 -3
- data/app/views/ahoy_captain/properties/show.html.erb +0 -6
- data/app/views/ahoy_captain/roots/_filters.html.erb +0 -80
- data/lib/ahoy_captain/filter_configuration/filter.rb +0 -16
- data/lib/ahoy_captain/filter_configuration/filter_collection.rb +0 -48
- data/lib/ahoy_captain/filters_configuration.rb +0 -77
- data/lib/ahoy_captain/predicate_label.rb +0 -7
- data/lib/generators/ahoy_captain/migration_generator.rb +0 -21
- data/lib/generators/ahoy_captain/templates/migration.rb.tt +0 -7
- /data/app/views/ahoy_captain/{locations/cities → cities}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{locations/cities → cities}/index.html.erb +0 -0
- /data/app/views/ahoy_captain/{locations/countries → countries}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{locations/countries → countries}/index.html.erb +0 -0
- /data/app/views/ahoy_captain/{locations/regions → regions}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{locations/regions → regions}/index.html.erb +0 -0
@@ -1,22 +1,10 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class CityDecorator < CountryDecorator
|
3
|
-
def self.csv_map(params = {})
|
4
|
-
{
|
5
|
-
"Country" => :country,
|
6
|
-
"City" => :city,
|
7
|
-
"Total" => :unit_amount
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
3
|
def display_name
|
12
4
|
search = search_query(country_eq: object.country, city_eq: object.city)
|
13
5
|
frame_link("#{country_emoji(object.country)} #{object.city}", search)
|
14
6
|
end
|
15
7
|
|
16
|
-
def country
|
17
|
-
"#{country_emoji(object.country)} #{object.country}"
|
18
|
-
end
|
19
|
-
|
20
8
|
def unit_amount
|
21
9
|
object.count
|
22
10
|
end
|
@@ -1,16 +1,6 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class CountryDecorator < ApplicationDecorator
|
3
3
|
EMOJI_MAP = { "AD": "🇦🇩", "AE": "🇦🇪", "AF": "🇦🇫", "AG": "🇦🇬", "AI": "🇦🇮", "AL": "🇦🇱", "AM": "🇦🇲", "AO": "🇦🇴", "AQ": "🇦🇶", "AR": "🇦🇷", "AS": "🇦🇸", "AT": "🇦🇹", "AU": "🇦🇺", "AW": "🇦🇼", "AX": "🇦🇽", "AZ": "🇦🇿", "BA": "🇧🇦", "BB": "🇧🇧", "BD": "🇧🇩", "BE": "🇧🇪", "BF": "🇧🇫", "BG": "🇧🇬", "BH": "🇧🇭", "BI": "🇧🇮", "BJ": "🇧🇯", "BL": "🇧🇱", "BM": "🇧🇲", "BN": "🇧🇳", "BO": "🇧🇴", "BQ": "🇧🇶", "BR": "🇧🇷", "BS": "🇧🇸", "BT": "🇧🇹", "BV": "🇧🇻", "BW": "🇧🇼", "BY": "🇧🇾", "BZ": "🇧🇿", "CA": "🇨🇦", "CC": "🇨🇨", "CD": "🇨🇩", "CF": "🇨🇫", "CG": "🇨🇬", "CH": "🇨🇭", "CI": "🇨🇮", "CK": "🇨🇰", "CL": "🇨🇱", "CM": "🇨🇲", "CN": "🇨🇳", "CO": "🇨🇴", "CR": "🇨🇷", "CU": "🇨🇺", "CV": "🇨🇻", "CW": "🇨🇼", "CX": "🇨🇽", "CY": "🇨🇾", "CZ": "🇨🇿", "DE": "🇩🇪", "DJ": "🇩🇯", "DK": "🇩🇰", "DM": "🇩🇲", "DO": "🇩🇴", "DZ": "🇩🇿", "EC": "🇪🇨", "EE": "🇪🇪", "EG": "🇪🇬", "EH": "🇪🇭", "ER": "🇪🇷", "ES": "🇪🇸", "ET": "🇪🇹", "FI": "🇫🇮", "FJ": "🇫🇯", "FK": "🇫🇰", "FM": "🇫🇲", "FO": "🇫🇴", "FR": "🇫🇷", "GA": "🇬🇦", "GB": "🇬🇧", "GD": "🇬🇩", "GE": "🇬🇪", "GF": "🇬🇫", "GG": "🇬🇬", "GH": "🇬🇭", "GI": "🇬🇮", "GL": "🇬🇱", "GM": "🇬🇲", "GN": "🇬🇳", "GP": "🇬🇵", "GQ": "🇬🇶", "GR": "🇬🇷", "GS": "🇬🇸", "GT": "🇬🇹", "GU": "🇬🇺", "GW": "🇬🇼", "GY": "🇬🇾", "HK": "🇭🇰", "HM": "🇭🇲", "HN": "🇭🇳", "HR": "🇭🇷", "HT": "🇭🇹", "HU": "🇭🇺", "ID": "🇮🇩", "IE": "🇮🇪", "IL": "🇮🇱", "IM": "🇮🇲", "IN": "🇮🇳", "IO": "🇮🇴", "IQ": "🇮🇶", "IR": "🇮🇷", "IS": "🇮🇸", "IT": "🇮🇹", "JE": "🇯🇪", "JM": "🇯🇲", "JO": "🇯🇴", "JP": "🇯🇵", "KE": "🇰🇪", "KG": "🇰🇬", "KH": "🇰🇭", "KI": "🇰🇮", "KM": "🇰🇲", "KN": "🇰🇳", "KP": "🇰🇵", "KR": "🇰🇷", "KW": "🇰🇼", "KY": "🇰🇾", "KZ": "🇰🇿", "LA": "🇱🇦", "LB": "🇱🇧", "LC": "🇱🇨", "LI": "🇱🇮", "LK": "🇱🇰", "LR": "🇱🇷", "LS": "🇱🇸", "LT": "🇱🇹", "LU": "🇱🇺", "LV": "🇱🇻", "LY": "🇱🇾", "MA": "🇲🇦", "MC": "🇲🇨", "MD": "🇲🇩", "ME": "🇲🇪", "MF": "🇲🇫", "MG": "🇲🇬", "MH": "🇲🇭", "MK": "🇲🇰", "ML": "🇲🇱", "MM": "🇲🇲", "MN": "🇲🇳", "MO": "🇲🇴", "MP": "🇲🇵", "MQ": "🇲🇶", "MR": "🇲🇷", "MS": "🇲🇸", "MT": "🇲🇹", "MU": "🇲🇺", "MV": "🇲🇻", "MW": "🇲🇼", "MX": "🇲🇽", "MY": "🇲🇾", "MZ": "🇲🇿", "NA": "🇳🇦", "NC": "🇳🇨", "NE": "🇳🇪", "NF": "🇳🇫", "NG": "🇳🇬", "NI": "🇳🇮", "NL": "🇳🇱", "NO": "🇳🇴", "NP": "🇳🇵", "NR": "🇳🇷", "NU": "🇳🇺", "NZ": "🇳🇿", "OM": "🇴🇲", "PA": "🇵🇦", "PE": "🇵🇪", "PF": "🇵🇫", "PG": "🇵🇬", "PH": "🇵🇭", "PK": "🇵🇰", "PL": "🇵🇱", "PM": "🇵🇲", "PN": "🇵🇳", "PR": "🇵🇷", "PS": "🇵🇸", "PT": "🇵🇹", "PW": "🇵🇼", "PY": "🇵🇾", "QA": "🇶🇦", "RE": "🇷🇪", "RO": "🇷🇴", "RS": "🇷🇸", "RU": "🇷🇺", "RW": "🇷🇼", "SA": "🇸🇦", "SB": "🇸🇧", "SC": "🇸🇨", "SD": "🇸🇩", "SE": "🇸🇪", "SG": "🇸🇬", "SH": "🇸🇭", "SI": "🇸🇮", "SJ": "🇸🇯", "SK": "🇸🇰", "SL": "🇸🇱", "SM": "🇸🇲", "SN": "🇸🇳", "SO": "🇸🇴", "SR": "🇸🇷", "SS": "🇸🇸", "ST": "🇸🇹", "SV": "🇸🇻", "SX": "🇸🇽", "SY": "🇸🇾", "SZ": "🇸🇿", "TC": "🇹🇨", "TD": "🇹🇩", "TF": "🇹🇫", "TG": "🇹🇬", "TH": "🇹🇭", "TJ": "🇹🇯", "TK": "🇹🇰", "TL": "🇹🇱", "TM": "🇹🇲", "TN": "🇹🇳", "TO": "🇹🇴", "TR": "🇹🇷", "TT": "🇹🇹", "TV": "🇹🇻", "TW": "🇹🇼", "TZ": "🇹🇿", "UA": "🇺🇦", "UG": "🇺🇬", "UM": "🇺🇲", "US": "🇺🇸", "UY": "🇺🇾", "UZ": "🇺🇿", "VA": "🇻🇦", "VC": "🇻🇨", "VE": "🇻🇪", "VG": "🇻🇬", "VI": "🇻🇮", "VN": "🇻🇳", "VU": "🇻🇺", "WF": "🇼🇫", "WS": "🇼🇸", "YE": "🇾🇪", "YT": "🇾🇹", "ZA": "🇿🇦", "ZM": "🇿🇲", "ZW": "🇿🇼" }
|
4
|
-
def self.csv_map(params = {})
|
5
|
-
{
|
6
|
-
"Country" => :label,
|
7
|
-
"Total" => :unit_amount
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
def label
|
12
|
-
"#{country_emoji(country)} #{country}"
|
13
|
-
end
|
14
4
|
|
15
5
|
def display_name
|
16
6
|
search = search_query(country_eq: object.label)
|
@@ -1,19 +1,8 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class DeviceDecorator < ApplicationDecorator
|
3
|
-
def self.csv_map(params = {})
|
4
|
-
{
|
5
|
-
"#{params[:devices_type]}" => :label,
|
6
|
-
"Total" => :unit_amount
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
3
|
def display_name
|
11
|
-
search = search_query("#{params[:devices_type]}_eq" => label)
|
12
|
-
frame_link(label, search)
|
13
|
-
end
|
14
|
-
|
15
|
-
def label
|
16
|
-
object.label
|
4
|
+
search = search_query("#{params[:devices_type]}_eq" => object.label)
|
5
|
+
frame_link(object.label, search)
|
17
6
|
end
|
18
7
|
|
19
8
|
def unit_amount
|
@@ -1,16 +1,5 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class PageDecorator < ApplicationDecorator
|
3
|
-
def self.csv_map(params = {})
|
4
|
-
{
|
5
|
-
"URL" => :label,
|
6
|
-
"Total" => :unit_amount
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
|
-
def label
|
11
|
-
object.url
|
12
|
-
end
|
13
|
-
|
14
3
|
def display_name
|
15
4
|
search = search_query(type => object.url)
|
16
5
|
frame_link(object.url, search)
|
@@ -1,26 +1,10 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class RegionDecorator < CountryDecorator
|
3
|
-
def self.csv_map(params = {})
|
4
|
-
{
|
5
|
-
"Country" => :country,
|
6
|
-
"Region" => :region,
|
7
|
-
"Total" => :unit_amount
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
3
|
def display_name
|
12
4
|
search = search_query(region_eq: object.region, country_eq: object.country)
|
13
5
|
frame_link("#{country_emoji(object.country)} #{object.region}", search)
|
14
6
|
end
|
15
7
|
|
16
|
-
def country
|
17
|
-
"#{country_emoji(object.country)} #{object.country}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def region
|
21
|
-
object.region
|
22
|
-
end
|
23
|
-
|
24
8
|
def unit_amount
|
25
9
|
object.count
|
26
10
|
end
|
@@ -1,12 +1,5 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class SourceDecorator < ApplicationDecorator
|
3
|
-
def self.csv_map(params = {})
|
4
|
-
{
|
5
|
-
"Domain" => :referring_domain,
|
6
|
-
"Total" => :unit_amount
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
3
|
def display_name
|
11
4
|
display = %Q(
|
12
5
|
<div class='flex justify-start space-x-8 col-span-1 items-center'>
|
@@ -2,36 +2,7 @@ module AhoyCaptain
|
|
2
2
|
module ApplicationHelper
|
3
3
|
include Pagy::Frontend
|
4
4
|
|
5
|
-
|
6
|
-
return nil unless params[:q]
|
7
|
-
|
8
|
-
prop = params[:q].to_unsafe_h.detect { |key, _| key.starts_with?("properties.") }
|
9
|
-
if prop
|
10
|
-
key = prop[0].dup
|
11
|
-
Ransack::Predicate.detect_and_strip_from_string!(key)
|
12
|
-
{ key: key, value: prop[1] }
|
13
|
-
|
14
|
-
else
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def stats_container(value, url, label, formatter, selected = false)
|
20
|
-
if value.is_a?(AhoyCaptain::ComparableQuery::Comparison)
|
21
|
-
::AhoyCaptain::Stats::ComparableContainerComponent.new(url, label, value, formatter, selected, compare_mode?)
|
22
|
-
else
|
23
|
-
::AhoyCaptain::Stats::ContainerComponent.new(url, label, value, formatter, selected)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def number_to_duration(duration)
|
28
|
-
if duration
|
29
|
-
"#{duration.in_minutes.to_i}M #{duration.parts[:seconds].to_i}S"
|
30
|
-
else
|
31
|
-
"0M 0S"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
5
|
+
SPECIAL_PARAMS = [:campaigns_type, :devices_type]
|
35
6
|
def ahoy_captain_importmap_tags(entry_point = "application", shim: true)
|
36
7
|
safe_join [
|
37
8
|
(javascript_importmap_shim_tag if shim),
|
@@ -46,36 +17,8 @@ module AhoyCaptain
|
|
46
17
|
request.query_parameters
|
47
18
|
end
|
48
19
|
|
49
|
-
|
50
|
-
|
51
|
-
def non_filter_ransack_params
|
52
|
-
other_params = {}
|
53
|
-
map = [
|
54
|
-
:start_date,
|
55
|
-
:end_date,
|
56
|
-
:period,
|
57
|
-
:interval,
|
58
|
-
:comparison,
|
59
|
-
]
|
60
|
-
|
61
|
-
# properties stuff falls into current_property_filter
|
62
|
-
ransack = [:goal]
|
63
|
-
|
64
|
-
map.each do |key|
|
65
|
-
if params[key]
|
66
|
-
other_params[key] = params[key]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
ransack.each do |key|
|
71
|
-
Ransack.predicates.keys.each do |predicate|
|
72
|
-
if value = params.dig(:q, "#{key}_#{predicate}")
|
73
|
-
other_params["q[#{key}_#{predicate}]"] = value
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
other_params
|
20
|
+
def special_params
|
21
|
+
params.to_unsafe_h.slice(*SPECIAL_PARAMS)
|
79
22
|
end
|
80
23
|
|
81
24
|
def render_pagination
|
@@ -1,8 +1,21 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
module RangeOptions
|
3
3
|
|
4
|
+
def period
|
5
|
+
raise NotImplementedError
|
6
|
+
end
|
7
|
+
|
4
8
|
private def range
|
5
|
-
|
9
|
+
if params[:start_date].present? && params[:end_date].present?
|
10
|
+
custom = [params[:start_date].to_datetime, params[:end_date].to_datetime].sort
|
11
|
+
duration = (custom[1].to_date - custom[0].to_date)
|
12
|
+
|
13
|
+
if AhoyCaptain.config.ranges.max && (duration.days <= AhoyCaptain.config.ranges.max)
|
14
|
+
return custom
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
AhoyCaptain.config.ranges.for(period)
|
6
19
|
end
|
7
20
|
end
|
8
21
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module AhoyCaptain
|
2
2
|
class DashboardPresenter
|
3
|
-
include Rangeable
|
4
3
|
include RangeOptions
|
5
|
-
include CompareMode
|
6
4
|
|
7
5
|
attr_reader :params
|
8
6
|
|
@@ -11,43 +9,73 @@ module AhoyCaptain
|
|
11
9
|
end
|
12
10
|
|
13
11
|
def unique_visitors
|
14
|
-
|
12
|
+
cached(:unique_visitors) do
|
13
|
+
Stats::UniqueVisitorsQuery.call(params).count(:ip)
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def total_visits
|
18
|
-
|
18
|
+
cached(:total_visits) do
|
19
|
+
Stats::TotalVisitorsQuery.call(params).count
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def total_pageviews
|
22
|
-
|
24
|
+
cached(:total_pageviews) do
|
25
|
+
Stats::TotalPageviewsQuery.call(params).count
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def views_per_visit
|
26
|
-
|
30
|
+
cached(:views_per_visit) do
|
31
|
+
begin
|
32
|
+
result = Stats::AverageViewsPerVisitQuery.call(params).count
|
33
|
+
(result.values.sum.to_f / result.size).round(2)
|
34
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
35
|
+
if e.message.include?("PG::DivisionByZero")
|
36
|
+
return "0"
|
37
|
+
else
|
38
|
+
raise e
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
27
43
|
end
|
28
44
|
|
29
45
|
def bounce_rate
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
cached(:bounce_rate) do
|
47
|
+
begin
|
48
|
+
result = Stats::BounceRatesQuery.call(params)
|
49
|
+
result[0].bounce_rate.round(2)
|
50
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
51
|
+
if e.message.include?("PG::DivisionByZero")
|
52
|
+
return "0"
|
53
|
+
else
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
35
58
|
end
|
36
59
|
end
|
37
60
|
|
38
61
|
def visit_duration
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
62
|
+
cached(:visit_duration) do
|
63
|
+
result = Stats::AverageVisitDurationQuery.call(params)
|
64
|
+
duration = result[0].average_visit_duration
|
65
|
+
if duration
|
66
|
+
"#{duration.parts[:minutes]}M #{duration.parts[:seconds].round}S"
|
67
|
+
else
|
68
|
+
"0M 0S"
|
69
|
+
end
|
44
70
|
end
|
45
71
|
end
|
46
72
|
|
47
73
|
private
|
48
74
|
|
49
|
-
def
|
50
|
-
params
|
75
|
+
def cached(*names)
|
76
|
+
AhoyCaptain.cache.fetch("ahoy_captain:#{names.join(":")}:#{params.permit!.except("controller", "action").to_unsafe_h.map { |k,v| "#{k}-#{v}" }.join(":")}", expire_in: AhoyCaptain.config.cache.ttl) do
|
77
|
+
yield
|
78
|
+
end
|
51
79
|
end
|
52
80
|
end
|
53
81
|
end
|
@@ -9,47 +9,44 @@ module AhoyCaptain
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def build
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
queries = {}
|
13
|
+
prev_goal = nil
|
14
|
+
prev_table = nil
|
15
|
+
selects = []
|
16
|
+
@funnel.goals.each do |goal|
|
17
|
+
if prev_goal
|
18
|
+
query = ::Ahoy::Event
|
19
|
+
.select("distinct ahoy_events.visit_id")
|
20
|
+
.from(prev_table.to_s)
|
21
|
+
.joins("inner join ahoy_events on ahoy_events.visit_id = #{prev_table}.id")
|
22
|
+
.where("ahoy_events.name = ?", goal.event_name.to_s).to_sql
|
23
|
+
prev_table = "#{goal.id}"
|
24
|
+
selects << ["SELECT '#{prev_goal.title} > #{goal.title}' as step, count(*) from #{prev_table}"]
|
25
|
+
queries[prev_table] = query
|
26
|
+
else
|
27
|
+
prev_table = :visitors
|
28
|
+
prev_goal = goal
|
16
29
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
map = {}.with_indifferent_access
|
30
|
+
query = @event_query
|
31
|
+
.select("distinct(visit_id) as id, min(time) as min_time")
|
32
|
+
.where(name: goal.event_name.to_s)
|
33
|
+
.group("1").to_sql
|
34
|
+
selects << ["'#{goal.title}' as step, count(*) from #{prev_table}"]
|
23
35
|
|
24
|
-
|
25
|
-
|
26
|
-
selects << ["SELECT unique_visits, name, total_events, sort_order from #{goal.id}"]
|
27
|
-
map[goal.id] = goal
|
28
|
-
last_goal = goal
|
36
|
+
queries[prev_table] = query
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
|
-
|
32
|
-
select = selects.join(" UNION ").delete_suffix(" from #{last_goal.id}")
|
33
|
-
select = select.delete_prefix("SELECT ")
|
34
|
-
steps = ::Ahoy::Event.with(
|
35
|
-
queries,
|
36
|
-
).select(select).from("#{last_goal.id}").order("sort_order asc")
|
37
|
-
|
38
|
-
items = ::Ahoy::Event.with(steps: steps).select("total_events, unique_visits, name, round((total_events::numeric/lag(total_events, 1) over ()),2) as drop_off").from("steps").order("sort_order asc").index_by(&:name)
|
39
|
-
items.delete("_internal_total_visits_")
|
40
|
-
@steps = []
|
40
|
+
select = selects.join(" UNION ").delete_suffix(" from #{prev_table}")
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
42
|
+
steps = ::Ahoy::Event.with(
|
43
|
+
queries
|
44
|
+
).select(select).from(prev_table).order("count desc")
|
47
45
|
|
48
|
-
@steps =
|
46
|
+
@steps = ::Ahoy::Event.with(steps: steps).select("step, count, lag(count, 1) over () as lag, abs(count::numeric - lag(count, 1) over ())::integer as drop_off, round((1.0 - count::numeric/GREATEST(lag(count, 1) over (), 1)),2) as conversion_rate").from("steps")
|
49
47
|
self
|
50
48
|
end
|
51
49
|
|
52
|
-
|
53
50
|
def total
|
54
51
|
@event_query.distinct(:visitor_token).count
|
55
52
|
end
|
@@ -6,54 +6,44 @@ module AhoyCaptain
|
|
6
6
|
@goals = nil
|
7
7
|
end
|
8
8
|
|
9
|
-
# this is a dumpster fire
|
10
9
|
def build
|
11
10
|
if AhoyCaptain.config.goals.none?
|
12
11
|
@goals = []
|
13
12
|
return self
|
14
13
|
end
|
15
|
-
|
16
|
-
|
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
|
-
}
|
19
|
-
selects = ["SELECT unique_visits, name, total_events, sort_order, 0 as cr, '' as goal_id from totals"]
|
14
|
+
queries = {}
|
15
|
+
selects = []
|
20
16
|
last_goal = nil
|
21
|
-
map = {}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
"count(distinct(#{AhoyCaptain.event.table_name}.visit_id)) as unique_visits" ,
|
27
|
-
"'#{goal.id}' as name",
|
28
|
-
"count(distinct #{AhoyCaptain.event.table_name}.id) as total_events",
|
29
|
-
"#{index + 1} as sort_order",
|
30
|
-
"'#{goal.id}' as goal_id"
|
31
|
-
]
|
32
|
-
).merge(goal.event_query.call).group("#{AhoyCaptain.event.table_name}.name")
|
33
|
-
selects << ["SELECT unique_visits, name, total_events, sort_order, 0::decimal as cr, '#{goal.id}' as goal_id from #{goal.id}"]
|
34
|
-
map[goal.id] = goal
|
17
|
+
map = {}
|
18
|
+
AhoyCaptain.config.goals.each do |goal|
|
19
|
+
queries[goal.id] = @event_query.select("count(distinct(visit_id)) as uniques, count(name) as total, name").where(name: goal.event_name).group("name")
|
20
|
+
selects << ["SELECT total, uniques, name from #{goal.id}"]
|
21
|
+
map[goal.event_name] = goal
|
35
22
|
last_goal = goal
|
36
23
|
end
|
37
|
-
|
38
|
-
# activerecord quirk / with bug
|
39
24
|
select = selects.join(" UNION ").delete_suffix(" from #{last_goal.id}")
|
40
25
|
select = select.delete_prefix("SELECT ")
|
41
26
|
steps = ::Ahoy::Event.with(
|
42
|
-
queries
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@goals =
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
27
|
+
queries
|
28
|
+
).select(select).from("#{last_goal.id}")
|
29
|
+
|
30
|
+
items = ::Ahoy::Event.with(steps: steps).select("total, uniques, name, 0 as conversion_rate").from("steps").index_by(&:name)
|
31
|
+
@goals = []
|
32
|
+
map.each do |name, _|
|
33
|
+
if items[name]
|
34
|
+
items[name].name = map[name].title
|
35
|
+
items[name].conversion_rate = ((items[name].total / total.to_d) * 100).round(2) * 100
|
36
|
+
@goals << items[name]
|
37
|
+
else
|
38
|
+
@goals << OpenStruct.new(name: map[name].title, uniques: 0, total: 0, conversion_rate: 0)
|
39
|
+
end
|
51
40
|
end
|
41
|
+
|
52
42
|
self
|
53
43
|
end
|
54
44
|
|
55
|
-
def
|
56
|
-
@
|
45
|
+
def total
|
46
|
+
@total ||= @event_query.distinct(:visitor_token).count
|
57
47
|
end
|
58
48
|
|
59
49
|
def as_json
|