ahoy_captain 0.77 → 0.82

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascript/ahoy_captain/application.js +4 -4
  3. data/app/assets/javascript/ahoy_captain/controllers/active_links_controller.js +15 -0
  4. data/app/assets/javascript/ahoy_captain/controllers/application.js +5 -5
  5. data/app/assets/javascript/ahoy_captain/controllers/application_controller.js +9 -10
  6. data/app/assets/javascript/ahoy_captain/controllers/details_modal_controller.js +5 -5
  7. data/app/assets/javascript/ahoy_captain/controllers/dropdown_label_controller.js +2 -2
  8. data/app/assets/javascript/ahoy_captain/controllers/filter_form_controller.js +13 -0
  9. data/app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js +11 -8
  10. data/app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js +77 -133
  11. data/app/assets/javascript/ahoy_captain/controllers/index.js +4 -3
  12. data/app/assets/javascript/ahoy_captain/controllers/interval_controller.js +10 -0
  13. data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +37 -0
  14. data/app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js +10 -0
  15. data/app/assets/javascript/ahoy_captain/controllers/realtime_controller.js +9 -8
  16. data/app/assets/javascript/ahoy_captain/controllers/search_select_controller.js +65 -0
  17. data/app/components/ahoy_captain/filter/modal_component.html.erb +6 -5
  18. data/app/components/ahoy_captain/filter/select_component.html.erb +13 -11
  19. data/app/components/ahoy_captain/filter/select_component.rb +21 -4
  20. data/app/components/ahoy_captain/table_component.html.erb +2 -35
  21. data/app/components/ahoy_captain/table_component.rb +13 -5
  22. data/app/components/ahoy_captain/tables/headers/devices_header_component.html.erb +3 -0
  23. data/app/components/ahoy_captain/tables/headers/devices_header_component.rb +9 -0
  24. data/app/components/ahoy_captain/tables/headers/goals_header_component.html.erb +6 -0
  25. data/app/components/ahoy_captain/tables/headers/goals_header_component.rb +9 -0
  26. data/app/components/ahoy_captain/tables/headers/header_component.html.erb +5 -0
  27. data/app/components/ahoy_captain/tables/headers/header_component.rb +12 -0
  28. data/app/components/ahoy_captain/tables/rows/devices_row_component.html.erb +5 -0
  29. data/app/components/ahoy_captain/tables/rows/devices_row_component.rb +12 -0
  30. data/app/components/ahoy_captain/tables/rows/goals_row_component.html.erb +11 -0
  31. data/app/components/ahoy_captain/tables/rows/goals_row_component.rb +12 -0
  32. data/app/components/ahoy_captain/tables/rows/row_component.html.erb +6 -0
  33. data/app/components/ahoy_captain/tables/rows/row_component.rb +41 -0
  34. data/app/controllers/ahoy_captain/application_controller.rb +17 -15
  35. data/app/controllers/ahoy_captain/campaigns_controller.rb +2 -10
  36. data/app/controllers/ahoy_captain/cities_controller.rb +2 -6
  37. data/app/controllers/ahoy_captain/countries_controller.rb +2 -6
  38. data/app/controllers/ahoy_captain/devices_controller.rb +3 -6
  39. data/app/controllers/ahoy_captain/entry_pages_controller.rb +2 -4
  40. data/app/controllers/ahoy_captain/exit_pages_controller.rb +3 -4
  41. data/app/controllers/ahoy_captain/exports_controller.rb +15 -0
  42. data/app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb +2 -2
  43. data/app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb +1 -2
  44. data/app/controllers/ahoy_captain/filters/properties/names_controller.rb +11 -0
  45. data/app/controllers/ahoy_captain/filters/properties/values_controller.rb +15 -0
  46. data/app/controllers/ahoy_captain/realtimes_controller.rb +1 -1
  47. data/app/controllers/ahoy_captain/regions_controller.rb +3 -7
  48. data/app/controllers/ahoy_captain/sources_controller.rb +2 -5
  49. data/app/controllers/ahoy_captain/stats/base_controller.rb +61 -0
  50. data/app/controllers/ahoy_captain/stats/bounce_rates_controller.rb +4 -2
  51. data/app/controllers/ahoy_captain/stats/total_pageviews_controller.rb +2 -1
  52. data/app/controllers/ahoy_captain/stats/total_visits_controller.rb +2 -1
  53. data/app/controllers/ahoy_captain/stats/unique_visitors_controller.rb +2 -1
  54. data/app/controllers/ahoy_captain/stats/views_per_visits_controller.rb +10 -6
  55. data/app/controllers/ahoy_captain/stats/visit_durations_controller.rb +2 -1
  56. data/app/controllers/ahoy_captain/top_pages_controller.rb +2 -8
  57. data/app/decorators/ahoy_captain/application_decorator.rb +27 -3
  58. data/app/decorators/ahoy_captain/campaign_decorator.rb +8 -0
  59. data/app/decorators/ahoy_captain/city_decorator.rb +12 -0
  60. data/app/decorators/ahoy_captain/country_decorator.rb +10 -0
  61. data/app/decorators/ahoy_captain/device_decorator.rb +13 -2
  62. data/app/decorators/ahoy_captain/page_decorator.rb +11 -0
  63. data/app/decorators/ahoy_captain/region_decorator.rb +16 -0
  64. data/app/decorators/ahoy_captain/source_decorator.rb +7 -0
  65. data/app/models/ahoy_captain/export.rb +48 -0
  66. data/app/presenters/ahoy_captain/dashboard_presenter.rb +24 -16
  67. data/app/presenters/ahoy_captain/funnel_presenter.rb +32 -29
  68. data/app/presenters/ahoy_captain/goals_presenter.rb +32 -23
  69. data/app/queries/ahoy_captain/application_query.rb +9 -5
  70. data/app/queries/ahoy_captain/campaign_query.rb +14 -0
  71. data/app/queries/ahoy_captain/city_query.rb +11 -0
  72. data/app/queries/ahoy_captain/country_query.rb +10 -0
  73. data/app/queries/ahoy_captain/device_query.rb +10 -0
  74. data/app/queries/ahoy_captain/entry_pages_query.rb +3 -2
  75. data/app/queries/ahoy_captain/event_query.rb +26 -9
  76. data/app/queries/ahoy_captain/exit_pages_query.rb +6 -4
  77. data/app/queries/ahoy_captain/region_query.rb +11 -0
  78. data/app/queries/ahoy_captain/source_query.rb +10 -0
  79. data/app/queries/ahoy_captain/stats/average_visit_duration_query.rb +3 -7
  80. data/app/queries/ahoy_captain/stats/bounce_rates_query.rb +9 -6
  81. data/app/queries/ahoy_captain/stats/total_visitors_query.rb +1 -1
  82. data/app/queries/ahoy_captain/stats/unique_visitors_query.rb +1 -1
  83. data/app/queries/ahoy_captain/stats/views_per_visit_query.rb +2 -2
  84. data/app/queries/ahoy_captain/stats/visit_duration_query.rb +4 -4
  85. data/app/queries/ahoy_captain/top_page_query.rb +13 -0
  86. data/app/queries/ahoy_captain/visit_query.rb +12 -12
  87. data/app/views/ahoy_captain/devices/_table.html.erb +5 -0
  88. data/app/views/ahoy_captain/devices/index.html+details.erb +1 -1
  89. data/app/views/ahoy_captain/devices/index.html.erb +2 -2
  90. data/app/views/ahoy_captain/goals/index.html.erb +3 -35
  91. data/app/views/ahoy_captain/layouts/application.html.erb +1 -1
  92. data/app/views/ahoy_captain/roots/show.html.erb +81 -73
  93. data/app/views/ahoy_captain/stats/base/index.html.erb +8 -1
  94. data/app/views/ahoy_captain/stats/show.html.erb +1 -1
  95. data/config/routes.rb +7 -0
  96. data/lib/ahoy_captain/ahoy/event_methods.rb +29 -75
  97. data/lib/ahoy_captain/configuration.rb +2 -2
  98. data/lib/ahoy_captain/engine.rb +1 -0
  99. data/lib/ahoy_captain/goals.rb +15 -3
  100. data/lib/ahoy_captain/period_collection.rb +1 -1
  101. data/lib/ahoy_captain/version.rb +1 -1
  102. data/lib/generators/ahoy_captain/migration_generator.rb +21 -0
  103. data/lib/generators/ahoy_captain/templates/config.rb.tt +18 -3
  104. data/lib/generators/ahoy_captain/templates/migration.rb.tt +7 -0
  105. metadata +48 -7
  106. data/app/assets/javascript/ahoy_captain/controllers/filter_controller.js +0 -145
  107. data/app/assets/javascript/ahoy_captain/controllers/link_controller.js +0 -43
  108. data/app/assets/javascript/ahoy_captain/controllers/navigation_controller.js +0 -25
  109. data/app/models/ahoy_captain/current.rb +0 -9
  110. data/app/models/ahoy_captain/url_helpers.rb +0 -6
@@ -4,104 +4,58 @@ module AhoyCaptain
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- ransacker :route do |parent|
8
- Arel.sql(AhoyCaptain.config.event[:url_column].gsub("properties", "ahoy_events.properties"))
7
+ ransacker :route do |_parent|
8
+ Arel.sql(AhoyCaptain.config.event[:url_column])
9
9
  end
10
10
 
11
- scope :with_routes, -> { where(AhoyCaptain.config.event[:url_exists]) }
12
-
13
- scope :with_url, -> {
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
- }
43
-
44
- scope :route_in, ->(*args) {
45
- url_in(*args)
46
- }
11
+ ransacker :entry_page do |parent|
12
+ Arel.sql("entry_pages.url")
13
+ end
47
14
 
48
- scope :route_not_in, ->(*args) {
49
- url_not_in(*args)
50
- }
15
+ ransacker :exit_page do |parent|
16
+ Arel.sql("exit_pages.url")
17
+ end
51
18
 
52
- scope :route_i_cont, ->(arg) {
53
- url_i_cont(arg)
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")
54
21
  }
55
-
56
- scope :entry_page_in, ->(*args) {
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")
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")
61
24
  }
62
25
 
63
- scope :entry_page_not_in, ->(*args) {
64
- table_alias = "first_events_#{SecureRandom.hex.first(6)}"
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")
67
- }
26
+ scope :with_routes, -> { where(AhoyCaptain.config.event[:url_exists]) }
68
27
 
69
- scope :entry_page_i_cont, ->(arg) {
70
- table_alias = "first_events_#{SecureRandom.hex.first(6)}"
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")
28
+ scope :with_url, -> {
29
+ select(Arel.sql("#{AhoyCaptain.config.event.url_column} AS url"))
73
30
  }
74
31
 
75
- scope :exit_page_in, ->(*args) {
76
- table_alias = "last_events_#{SecureRandom.hex.first(6)}"
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")
32
+ scope :distinct_url, -> {
33
+ distinct(Arel.sql("#{AhoyCaptain.config.event.url_column}"))
80
34
  }
81
35
 
82
- scope :exit_page_not_in, ->(*args) {
83
- table_alias = "last_events_#{SecureRandom.hex.first(6)}"
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")
36
+ scope :property_name_eq, ->(value) {
37
+ where("properties ? :key", key: value)
87
38
  }
88
39
 
89
- scope :exit_page_i_cont, ->(arg) {
90
- table_alias = "last_events_#{SecureRandom.hex.first(6)}"
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")
40
+ scope :properties_eq, ->(value) {
41
+ where("properties @> ?", value)
94
42
  }
95
43
 
44
+ scope :properties_not_eq, ->(value) do
45
+ where.not("properties::jsonb @> ?", value)
46
+ end
96
47
  end
97
48
 
98
49
  class_methods do
99
50
  def ransackable_attributes(auth_object = nil)
100
- super + ["action", "controller", "id", "id_property", "name", "name_property", "page", "properties", "time", "url", "user_id", "visit_id"] + self._ransackers.keys
51
+ super + ["action", "controller", "id", "id_property", "name", "page", "properties", "time", "url", "user_id", "visit_id", "property_name"] + self._ransackers.keys
101
52
  end
102
53
 
103
54
  def ransackable_scopes(auth_object = nil)
104
- super + [:entry_page_in, :entry_page_not_in, :exit_page_in, :entry_page_not_in, :route_in, :route_not_in, :route_i_cont, :entry_page_i_cont, :exit_page_i_cont]
55
+ super + [
56
+ :properties_eq,
57
+ :properties_not_eq
58
+ ]
105
59
  end
106
60
 
107
61
  def ransackable_associations(auth_object = nil)
@@ -16,8 +16,8 @@ module AhoyCaptain
16
16
  end
17
17
  @event = ActiveSupport::OrderedOptions.new.tap do |option|
18
18
  option.view_name = "$view"
19
- option.url_column = "CONCAT(properties->>'controller', '#', properties->>'action')"
20
- option.url_exists = "JSONB_EXISTS(properties, 'controller') AND JSONB_EXISTS(properties, 'action')"
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')"
21
21
  end
22
22
  @models = ActiveSupport::OrderedOptions.new.tap do |option|
23
23
  option.event = "::Ahoy::Event"
@@ -6,6 +6,7 @@ require 'view_component'
6
6
  require 'chartkick'
7
7
  require 'groupdate'
8
8
  require 'pagy'
9
+ require 'zip'
9
10
 
10
11
  module AhoyCaptain
11
12
  class Engine < Rails::Engine
@@ -1,19 +1,31 @@
1
1
  module AhoyCaptain
2
2
  class Goal
3
3
  attr_accessor :id
4
- attr_reader :title, :event_name
4
+ attr_reader :title, :event_query
5
5
  def initialize
6
6
  @id = nil
7
7
  @title = nil
8
- @event_name = nil
8
+ @event_query = nil
9
9
  end
10
10
 
11
11
  def label(value)
12
12
  @title = value
13
13
  end
14
14
 
15
+ def name(value)
16
+ @event_query = -> { ::AhoyCaptain.event.where(name: value) }
17
+ end
18
+
15
19
  def event(value)
16
- @event_name = value
20
+ ActiveSupport::Deprecation.warn(
21
+ "event is deprecated. " \
22
+ "Use name instead."
23
+ )
24
+ name(value)
25
+ end
26
+
27
+ def query(&block)
28
+ @event_query = block
17
29
  end
18
30
  end
19
31
 
@@ -51,7 +51,7 @@ module AhoyCaptain
51
51
  }.each do |param, options|
52
52
  instance.add(param, options[:label], options[:range])
53
53
  end
54
- instance.default = :mtd
54
+ instance.default = :'30d'
55
55
  instance
56
56
  end
57
57
 
@@ -1,3 +1,3 @@
1
1
  module AhoyCaptain
2
- VERSION = "0.77"
2
+ VERSION = "0.82"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require "rails/generators"
2
+ require "rails/generators/active_record"
3
+
4
+ module AhoyCaptain
5
+ module Generators
6
+ class MigrationGenerator < Rails::Generators::Base
7
+ include ActiveRecord::Generators::Migration
8
+ source_root File.join(__dir__, "templates")
9
+
10
+ def copy_templates
11
+ migration_template "migration.rb", "db/migrate/create_ahoy_captain_indexes.rb", migration_version: migration_version
12
+ end
13
+
14
+ private
15
+
16
+ def migration_version
17
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
- AhoyCaptain.configure do
1
+ AhoyCaptain.configure do |config|
2
2
  # ==> Event tracking
3
3
  #
4
4
  # View name
@@ -74,6 +74,12 @@ AhoyCaptain.configure do
74
74
  #
75
75
  # And handle the default range, which will be used if no range is given:
76
76
  # config.ranges.default = '3d'
77
+ #
78
+ # The max range if a custom range is sent
79
+ # config.ranges.max = 180.days
80
+ #
81
+ # Set to false to disable custom ranges
82
+ # config.ranges.custom = true
77
83
 
78
84
  # ==> Caching
79
85
  # config.cache.enabled = false
@@ -91,14 +97,23 @@ AhoyCaptain.configure do
91
97
  #
92
98
  # config.goal :unique_id do
93
99
  # label "Some label here"
94
- # event "The event name you're tracking in your Ahoy::Event table"
100
+ # name "The event name you're tracking in your Ahoy::Event table"
95
101
  # end
96
102
  #
97
103
  # Real-world example:
98
104
  #
99
105
  # config.goal :appointment_paid do
100
106
  # label "Appointment Paid"
101
- # event "$appointment.paid"
107
+ # name "$appointment.paid"
108
+ # end
109
+ #
110
+ # You can also use queries:
111
+ #
112
+ # config.goal :appointment_paid do
113
+ # label "Appointment Paid"
114
+ # query do
115
+ # ::Ahoy::Event.where(...)
116
+ # end
102
117
  # end
103
118
 
104
119
  # ==> Funnels
@@ -0,0 +1,7 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ add_index :<%= ::AhoyCaptain.visit.table_name %>, :started_at unless index_exists?(:<%= ::AhoyCaptain.visit.table_name %>, :started_at)
4
+ add_index :<%= ::AhoyCaptain.event.table_name %>, :visit_id unless index_exists?(:<%= ::AhoyCaptain.event.table_name %>, :visit_id)
5
+ add_index :<%= ::AhoyCaptain.event.table_name %>, :time unless index_exists?(:<%= ::AhoyCaptain.event.table_name %>, :time)
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_captain
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.77'
4
+ version: '0.82'
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshmn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-30 00:00:00.000000000 Z
11
+ date: 2023-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubyzip
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: rails
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -264,17 +278,20 @@ files:
264
278
  - app/assets/images/ahoy_captain/logo.png
265
279
  - app/assets/images/ahoy_captain/safari-pinned-tab.svg
266
280
  - app/assets/javascript/ahoy_captain/application.js
281
+ - app/assets/javascript/ahoy_captain/controllers/active_links_controller.js
267
282
  - app/assets/javascript/ahoy_captain/controllers/application.js
268
283
  - app/assets/javascript/ahoy_captain/controllers/application_controller.js
269
284
  - app/assets/javascript/ahoy_captain/controllers/details_modal_controller.js
270
285
  - app/assets/javascript/ahoy_captain/controllers/dropdown_label_controller.js
271
- - app/assets/javascript/ahoy_captain/controllers/filter_controller.js
286
+ - app/assets/javascript/ahoy_captain/controllers/filter_form_controller.js
272
287
  - app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js
273
288
  - app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js
274
289
  - app/assets/javascript/ahoy_captain/controllers/index.js
275
- - app/assets/javascript/ahoy_captain/controllers/link_controller.js
276
- - app/assets/javascript/ahoy_captain/controllers/navigation_controller.js
290
+ - app/assets/javascript/ahoy_captain/controllers/interval_controller.js
291
+ - app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js
292
+ - app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js
277
293
  - app/assets/javascript/ahoy_captain/controllers/realtime_controller.js
294
+ - app/assets/javascript/ahoy_captain/controllers/search_select_controller.js
278
295
  - app/assets/manifest/ahoy_captain/manifest.js
279
296
  - app/components/ahoy_captain/dropdown_button_component.html.erb
280
297
  - app/components/ahoy_captain/dropdown_button_component.rb
@@ -292,6 +309,18 @@ files:
292
309
  - app/components/ahoy_captain/sticky_nav_component.rb
293
310
  - app/components/ahoy_captain/table_component.html.erb
294
311
  - app/components/ahoy_captain/table_component.rb
312
+ - app/components/ahoy_captain/tables/headers/devices_header_component.html.erb
313
+ - app/components/ahoy_captain/tables/headers/devices_header_component.rb
314
+ - app/components/ahoy_captain/tables/headers/goals_header_component.html.erb
315
+ - app/components/ahoy_captain/tables/headers/goals_header_component.rb
316
+ - app/components/ahoy_captain/tables/headers/header_component.html.erb
317
+ - app/components/ahoy_captain/tables/headers/header_component.rb
318
+ - app/components/ahoy_captain/tables/rows/devices_row_component.html.erb
319
+ - app/components/ahoy_captain/tables/rows/devices_row_component.rb
320
+ - app/components/ahoy_captain/tables/rows/goals_row_component.html.erb
321
+ - app/components/ahoy_captain/tables/rows/goals_row_component.rb
322
+ - app/components/ahoy_captain/tables/rows/row_component.html.erb
323
+ - app/components/ahoy_captain/tables/rows/row_component.rb
295
324
  - app/components/ahoy_captain/tile_component.html.erb
296
325
  - app/components/ahoy_captain/tile_component.rb
297
326
  - app/components/ahoy_captain/tooltip_component.html.erb
@@ -303,6 +332,7 @@ files:
303
332
  - app/controllers/ahoy_captain/devices_controller.rb
304
333
  - app/controllers/ahoy_captain/entry_pages_controller.rb
305
334
  - app/controllers/ahoy_captain/exit_pages_controller.rb
335
+ - app/controllers/ahoy_captain/exports_controller.rb
306
336
  - app/controllers/ahoy_captain/filters/base_controller.rb
307
337
  - app/controllers/ahoy_captain/filters/locations_controller.rb
308
338
  - app/controllers/ahoy_captain/filters/operating_systems/names_controller.rb
@@ -310,6 +340,8 @@ files:
310
340
  - app/controllers/ahoy_captain/filters/pages/actions_controller.rb
311
341
  - app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb
312
342
  - app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb
343
+ - app/controllers/ahoy_captain/filters/properties/names_controller.rb
344
+ - app/controllers/ahoy_captain/filters/properties/values_controller.rb
313
345
  - app/controllers/ahoy_captain/filters/screens_controller.rb
314
346
  - app/controllers/ahoy_captain/filters/sources_controller.rb
315
347
  - app/controllers/ahoy_captain/filters/utms_controller.rb
@@ -340,18 +372,23 @@ files:
340
372
  - app/decorators/ahoy_captain/source_decorator.rb
341
373
  - app/decorators/ahoy_captain/top_page_decorator.rb
342
374
  - app/helpers/ahoy_captain/application_helper.rb
343
- - app/models/ahoy_captain/current.rb
375
+ - app/models/ahoy_captain/export.rb
344
376
  - app/models/ahoy_captain/rangeable.rb
345
- - app/models/ahoy_captain/url_helpers.rb
346
377
  - app/models/ahoy_captain/widget.rb
347
378
  - app/models/concerns/ahoy_captain/range_options.rb
348
379
  - app/presenters/ahoy_captain/dashboard_presenter.rb
349
380
  - app/presenters/ahoy_captain/funnel_presenter.rb
350
381
  - app/presenters/ahoy_captain/goals_presenter.rb
351
382
  - app/queries/ahoy_captain/application_query.rb
383
+ - app/queries/ahoy_captain/campaign_query.rb
384
+ - app/queries/ahoy_captain/city_query.rb
385
+ - app/queries/ahoy_captain/country_query.rb
386
+ - app/queries/ahoy_captain/device_query.rb
352
387
  - app/queries/ahoy_captain/entry_pages_query.rb
353
388
  - app/queries/ahoy_captain/event_query.rb
354
389
  - app/queries/ahoy_captain/exit_pages_query.rb
390
+ - app/queries/ahoy_captain/region_query.rb
391
+ - app/queries/ahoy_captain/source_query.rb
355
392
  - app/queries/ahoy_captain/stats/average_views_per_visit_query.rb
356
393
  - app/queries/ahoy_captain/stats/average_visit_duration_query.rb
357
394
  - app/queries/ahoy_captain/stats/bounce_rates_query.rb
@@ -360,6 +397,7 @@ files:
360
397
  - app/queries/ahoy_captain/stats/unique_visitors_query.rb
361
398
  - app/queries/ahoy_captain/stats/views_per_visit_query.rb
362
399
  - app/queries/ahoy_captain/stats/visit_duration_query.rb
400
+ - app/queries/ahoy_captain/top_page_query.rb
363
401
  - app/queries/ahoy_captain/visit_query.rb
364
402
  - app/views/ahoy_captain/campaigns/index.html+details.erb
365
403
  - app/views/ahoy_captain/campaigns/index.html.erb
@@ -367,6 +405,7 @@ files:
367
405
  - app/views/ahoy_captain/cities/index.html.erb
368
406
  - app/views/ahoy_captain/countries/index.html+details.erb
369
407
  - app/views/ahoy_captain/countries/index.html.erb
408
+ - app/views/ahoy_captain/devices/_table.html.erb
370
409
  - app/views/ahoy_captain/devices/index.html+details.erb
371
410
  - app/views/ahoy_captain/devices/index.html.erb
372
411
  - app/views/ahoy_captain/entry_pages/index.html+details.erb
@@ -400,7 +439,9 @@ files:
400
439
  - lib/ahoy_captain/railtie.rb
401
440
  - lib/ahoy_captain/version.rb
402
441
  - lib/generators/ahoy_captain/install_generator.rb
442
+ - lib/generators/ahoy_captain/migration_generator.rb
403
443
  - lib/generators/ahoy_captain/templates/config.rb.tt
444
+ - lib/generators/ahoy_captain/templates/migration.rb.tt
404
445
  homepage:
405
446
  licenses:
406
447
  - MIT
@@ -1,145 +0,0 @@
1
- import {Controller} from "@hotwired/stimulus"
2
- import SlimSelect from 'slim-select'
3
-
4
- export default class extends Controller {
5
- static values = {
6
- url: String,
7
- column: String,
8
- };
9
- static targets = ["select", 'predicate'];
10
- connect() {
11
- this.selectTargets.forEach(async (target) => {
12
- const url = target.dataset.filterUrlValue;
13
- const optionsSearch = this.fetchOptions(url, target);
14
- const select = await new SlimSelect({
15
- select: target,
16
- data: [],
17
- settings: {
18
- contentPosition: 'relative',
19
- contentLocation: target.closest('fieldset'),
20
- searchText: 'Sorry, no results found',
21
- searchPlaceholder: 'Type to populate results',
22
- placeholderText: `Search for ${target.dataset.filterColumnValue}`,
23
- searchHighlight: true
24
- },
25
- events: {
26
- beforeOpen: async () => {
27
- if (!this.#hasData(target) & !this.#hasSelections(target) ) {
28
- const data = await optionsSearch();
29
- target.slim.setData(data);
30
- }
31
- },
32
- search: async (search, currentData) => {
33
- const data = await optionsSearch(search);
34
- const filteredData = data.filter(item => !currentData.some((selectedItem) => selectedItem.text == item.text ))
35
- return filteredData;
36
- },
37
- beforeChange: this.#beforeChange(target, url),
38
- }
39
- });
40
- const json = JSON.parse(target.dataset.filterSelected)
41
- if(json.length) {
42
- select.setData(json.map(item => ({ "text": item, "value": item })))
43
- select.setSelected(json)
44
- }
45
- })
46
- }
47
-
48
- fetchOptions(url, target) {
49
- return async (search) => {
50
- const query = this.#buildQueryFilters(search, target);
51
- const response = await fetch(`${url}?${query.toString()}`);
52
- const data = await response.json();
53
- return data;
54
- }
55
- }
56
-
57
- #buildQueryFilters(search, target) {
58
- const query = new URLSearchParams(window.location.search);
59
- const otherFilters = this.selectTargets.filter(filter => filter != target);
60
- otherFilters.forEach(function(filter) {
61
- filter.slim.getSelected().forEach(val => {
62
- const filterName = `${filter.name}[]`
63
- if(query.has(filterName)) {
64
- console.log("has the filter")
65
- if(!query.get(`${filter.name}[]`).includes(val)) {
66
- query.append(filterName, value)
67
- }
68
- } else {
69
- query.append(filterName, value)
70
- }
71
- })
72
- });
73
- query.set(`q[${target.dataset.filterColumnValue}_i_cont]`, search || "");
74
- return query;
75
- }
76
-
77
- #beforeChange(target, url) {
78
- return () => {
79
- const otherFilters = this.selectTargets.filter(filter => filter != target);
80
- otherFilters.forEach(async target => {
81
- if (this.#hasData(target)) {
82
- const selected = target.slim.getSelected()
83
- target.slim.setData(selected.map(text => ({ text })))
84
- // setting data triggers a slim render, so need to also set selected again
85
- target.slim.setSelected(selected)
86
- }
87
- })
88
- return true;
89
- }
90
- }
91
-
92
- #hasData(target) {
93
- return target.slim.getData().length !== 0;
94
- }
95
-
96
- #hasSelections(target) {
97
- return target.slim.getSelected().length !== 0;
98
- }
99
-
100
- #filtersForQuery() {
101
- const predicates = this.predicateTargets.map(el => ({name: el.name, column_predicate: el.value}));
102
- const filterValues = this.selectTargets.map(el => ({name: el.name, selections: el.slim.getSelected()}));
103
- const mergedData = predicates.map(predicate => {
104
- const matchingFilter = filterValues.find(filter => filter.name === predicate.name);
105
- if (matchingFilter.selections.length > 0) {
106
- return {...predicate, ...matchingFilter}
107
- }
108
- }).filter(el => el !== undefined);
109
- return mergedData;
110
- }
111
-
112
- resetFilters(event) {
113
- this.selectTargets.forEach(el => {
114
- el.slim.setSelected([])
115
- })
116
- this.applyFilters(event)
117
- }
118
-
119
- applyFilters(e) {
120
- e.preventDefault();
121
- const searchParams = new URLSearchParams(window.location.search);
122
- const filters = this.#filtersForQuery();
123
- filters.forEach(filter => {
124
- const name = `q[${filter.column_predicate}][]`
125
- const selectedValues = searchParams.getAll(name)
126
- filter.selections.forEach(selection => {
127
- if(selectedValues) {
128
- if(!selectedValues.includes(selection)) {
129
- searchParams.append(name, selection)
130
- }
131
- } else {
132
- searchParams.append(name, selection)
133
- }
134
- })
135
- });
136
- ['input[name="start_date"]', 'input[name="end_date"]'].forEach(selector => {
137
- const el = document.querySelector(selector)
138
- if(el.value.length) {
139
- searchParams.delete("period")
140
- }
141
- searchParams.set(el.name, el.value);
142
- });
143
- Turbo.visit(window.location.pathname.replace(/\/$/, "") + `?${searchParams.toString()}`)
144
- }
145
- }
@@ -1,43 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- static targets = ["countriesLink", "top_pagesLink", "devicesLink", "top_sourcesLink"]
5
- static classes = ["countries", "top_pages", "devices", "top_sources"]
6
-
7
- changeCountries(event) {
8
- console.log(...this.countriesClasses)
9
- event.currentTarget.classList.add(...this.countriesClasses)
10
- this.countriesLinkTargets.forEach((target) => {
11
- if (target != event.currentTarget) {
12
- target.classList.remove(...this.countriesClasses)
13
- }
14
- })
15
- }
16
-
17
- changeTopSources(event) {
18
- event.currentTarget.classList.add(...this.top_sourcesClasses)
19
- this.top_sourcesLinkTargets.forEach((target) => {
20
- if (target != event.currentTarget) {
21
- target.classList.remove(...this.top_sourcesClasses)
22
- }
23
- })
24
- }
25
-
26
- changeTopPages(event) {
27
- event.currentTarget.classList.add(...this.top_pagesClasses)
28
- this.top_pagesLinkTargets.forEach((target) => {
29
- if (target != event.currentTarget) {
30
- target.classList.remove(...this.top_pagesClasses)
31
- }
32
- })
33
- }
34
-
35
- changeDevices(event) {
36
- event.currentTarget.classList.add(...this.devicesClasses)
37
- this.devicesLinkTargets.forEach((target) => {
38
- if (target != event.currentTarget) {
39
- target.classList.remove(...this.devicesClasses)
40
- }
41
- })
42
- }
43
- }
@@ -1,25 +0,0 @@
1
- import {Controller} from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- connect() {
5
- this.queryString = new URLSearchParams(window.location.search);
6
- this.baseURL = window.location.pathname.replace(/\/$/, "");
7
- }
8
-
9
- navigate() {
10
- const url = `${this.baseURL}?${this.queryString.toString()}`;
11
- Turbo.visit(url, { action: "replace"})
12
- }
13
-
14
- addQueryParam({ detail: { paramKey, paramValue } }) {
15
- this.queryString.append(paramKey, paramValue)
16
- }
17
-
18
- removeQueryParam({ detail: { paramKey, paramValue } }) {
19
- if (!this.queryString.has(paramKey)) {
20
- paramKey += "[]"
21
- }
22
- this.queryString.delete(paramKey,paramValue)
23
- this.navigate()
24
- }
25
- }
@@ -1,9 +0,0 @@
1
- module AhoyCaptain
2
- class Current < ActiveSupport::CurrentAttributes
3
- attribute :request
4
-
5
- after_reset do
6
- self.request = nil
7
- end
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- module AhoyCaptain
2
- class UrlHelpers
3
- include AhoyCaptain::Engine.routes.url_helpers
4
- include Singleton
5
- end
6
- end