quarterdeck 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +93 -0
  4. data/Rakefile +3 -0
  5. data/app/assets/stylesheets/quarterdeck/application.css +15 -0
  6. data/app/controllers/quarterdeck/application_controller.rb +73 -0
  7. data/app/controllers/quarterdeck/campaigns_controller.rb +52 -0
  8. data/app/controllers/quarterdeck/events_controller.rb +38 -0
  9. data/app/controllers/quarterdeck/geographics_controller.rb +41 -0
  10. data/app/controllers/quarterdeck/live_controller.rb +32 -0
  11. data/app/controllers/quarterdeck/overview_controller.rb +89 -0
  12. data/app/controllers/quarterdeck/visits_controller.rb +46 -0
  13. data/app/helpers/quarterdeck/application_helper.rb +4 -0
  14. data/app/javascript/quarterdeck/application.js +9 -0
  15. data/app/javascript/quarterdeck/controllers/chart_controller.js +99 -0
  16. data/app/javascript/quarterdeck/controllers/date_range_controller.js +18 -0
  17. data/app/javascript/quarterdeck/controllers/live_controller.js +59 -0
  18. data/app/jobs/quarterdeck/application_job.rb +4 -0
  19. data/app/mailers/quarterdeck/application_mailer.rb +6 -0
  20. data/app/models/quarterdeck/application_record.rb +5 -0
  21. data/app/views/layouts/quarterdeck/application.html.erb +36 -0
  22. data/app/views/quarterdeck/campaigns/show.html.erb +35 -0
  23. data/app/views/quarterdeck/events/index.html.erb +89 -0
  24. data/app/views/quarterdeck/geographics/show.html.erb +32 -0
  25. data/app/views/quarterdeck/live/show.html.erb +75 -0
  26. data/app/views/quarterdeck/overview/show.html.erb +38 -0
  27. data/app/views/quarterdeck/shared/_data_table.html.erb +29 -0
  28. data/app/views/quarterdeck/shared/_nav.html.erb +36 -0
  29. data/app/views/quarterdeck/shared/_period_tabs.html.erb +31 -0
  30. data/app/views/quarterdeck/shared/_stat_card.html.erb +22 -0
  31. data/app/views/quarterdeck/visits/index.html.erb +115 -0
  32. data/app/views/quarterdeck/visits/show.html.erb +72 -0
  33. data/config/importmap.rb +5 -0
  34. data/config/routes.rb +8 -0
  35. data/lib/generators/quarterdeck/install_generator.rb +39 -0
  36. data/lib/quarterdeck/engine.rb +19 -0
  37. data/lib/quarterdeck/version.rb +3 -0
  38. data/lib/quarterdeck.rb +19 -0
  39. data/lib/tasks/quarterdeck_tasks.rake +4 -0
  40. metadata +139 -0
@@ -0,0 +1,72 @@
1
+ <div class="space-y-6">
2
+ <div class="flex items-center gap-3">
3
+ <%= link_to quarterdeck.visits_path, class: "text-indigo-600 hover:text-indigo-800 text-sm" do %>
4
+ &larr; Back to Visits
5
+ <% end %>
6
+ </div>
7
+
8
+ <!-- Visit Details -->
9
+ <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
10
+ <h3 class="text-lg font-semibold text-gray-900 mb-4">Visit Details</h3>
11
+ <dl class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
12
+ <% details = {
13
+ "Started" => @visit.started_at&.strftime("%b %d, %Y %H:%M:%S"),
14
+ "Landing Page" => @visit.landing_page,
15
+ "Referring Domain" => @visit.referring_domain,
16
+ "Browser" => @visit.browser,
17
+ "OS" => @visit.os,
18
+ "Device" => @visit.device_type,
19
+ "Country" => @visit.country,
20
+ "Region" => @visit.region,
21
+ "City" => @visit.city,
22
+ "UTM Source" => @visit.utm_source,
23
+ "UTM Medium" => @visit.utm_medium,
24
+ "UTM Campaign" => @visit.utm_campaign,
25
+ "UTM Term" => @visit.utm_term,
26
+ "UTM Content" => @visit.utm_content,
27
+ "IP" => @visit.ip
28
+ } %>
29
+ <% details.each do |label, val| %>
30
+ <div>
31
+ <dt class="text-xs font-medium text-gray-500 uppercase"><%= label %></dt>
32
+ <dd class="mt-1 text-sm text-gray-900"><%= val.presence || "-" %></dd>
33
+ </div>
34
+ <% end %>
35
+ </dl>
36
+ </div>
37
+
38
+ <!-- Events -->
39
+ <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
40
+ <div class="px-6 py-4 border-b border-gray-200">
41
+ <h3 class="text-sm font-semibold text-gray-900">Events (<%= @events.count %>)</h3>
42
+ </div>
43
+ <div class="overflow-x-auto">
44
+ <table class="min-w-full divide-y divide-gray-200">
45
+ <thead class="bg-gray-50">
46
+ <tr>
47
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
48
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
49
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Properties</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody class="bg-white divide-y divide-gray-200">
53
+ <% @events.each do |event| %>
54
+ <tr class="hover:bg-gray-50">
55
+ <td class="px-6 py-3 text-sm text-gray-900 whitespace-nowrap"><%= event.time.strftime("%H:%M:%S") %></td>
56
+ <td class="px-6 py-3 text-sm text-gray-900">
57
+ <span class="inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-indigo-50 text-indigo-700">
58
+ <%= event.name %>
59
+ </span>
60
+ </td>
61
+ <td class="px-6 py-3 text-sm text-gray-600 max-w-md truncate">
62
+ <% if event.properties.present? %>
63
+ <code class="text-xs bg-gray-100 rounded px-1 py-0.5"><%= event.properties.to_json %></code>
64
+ <% end %>
65
+ </td>
66
+ </tr>
67
+ <% end %>
68
+ </tbody>
69
+ </table>
70
+ </div>
71
+ </div>
72
+ </div>
@@ -0,0 +1,5 @@
1
+ pin "chart.js/auto", to: "https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js"
2
+ pin "quarterdeck/application", to: "quarterdeck/application.js"
3
+ pin "quarterdeck/controllers/chart_controller", to: "quarterdeck/controllers/chart_controller.js"
4
+ pin "quarterdeck/controllers/date_range_controller", to: "quarterdeck/controllers/date_range_controller.js"
5
+ pin "quarterdeck/controllers/live_controller", to: "quarterdeck/controllers/live_controller.js"
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Quarterdeck::Engine.routes.draw do
2
+ root to: "overview#show"
3
+ resources :visits, only: [ :index, :show ]
4
+ resources :events, only: [ :index ]
5
+ resource :campaigns, only: [ :show ]
6
+ resource :geographic, only: [ :show ]
7
+ resource :live, only: [ :show ], controller: "live"
8
+ end
@@ -0,0 +1,39 @@
1
+ module Quarterdeck
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ desc "Install Quarterdeck analytics dashboard"
7
+
8
+ def create_initializer
9
+ create_file "config/initializers/quarterdeck.rb", <<~RUBY
10
+ # Quarterdeck configuration
11
+ # See https://github.com/leopolicastro/quarterdeck for documentation
12
+
13
+ # Set the parent controller for Quarterdeck controllers
14
+ # Quarterdeck.parent_controller = "ApplicationController"
15
+
16
+ # Set up authentication (optional)
17
+ # Quarterdeck.authenticate_with do
18
+ # redirect_to main_app.root_path unless current_user&.admin?
19
+ # end
20
+ RUBY
21
+ end
22
+
23
+ def mount_engine
24
+ route 'mount Quarterdeck::Engine => "/analytics"'
25
+ end
26
+
27
+ def show_post_install
28
+ say ""
29
+ say "Quarterdeck has been installed!", :green
30
+ say ""
31
+ say " Dashboard: /analytics"
32
+ say " Config: config/initializers/quarterdeck.rb"
33
+ say ""
34
+ say "Make sure you have ahoy_matey configured in your app."
35
+ say ""
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ module Quarterdeck
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Quarterdeck
4
+
5
+ initializer "quarterdeck.importmap", before: "importmap" do |app|
6
+ if app.config.respond_to?(:importmap)
7
+ app.config.importmap.paths << Engine.root.join("config/importmap.rb")
8
+ app.config.importmap.cache_sweepers << Engine.root.join("app/javascript")
9
+ end
10
+ end
11
+
12
+ initializer "quarterdeck.assets" do |app|
13
+ if app.config.respond_to?(:assets)
14
+ app.config.assets.paths << Engine.root.join("app/javascript")
15
+ app.config.assets.precompile += %w[ quarterdeck/application.css ]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Quarterdeck
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ require "quarterdeck/version"
2
+ require "ahoy_matey"
3
+ require "pagy"
4
+ require "groupdate"
5
+ require "quarterdeck/engine"
6
+
7
+ module Quarterdeck
8
+ mattr_accessor :parent_controller, default: "ApplicationController"
9
+
10
+ class << self
11
+ def authenticate_with(&block)
12
+ @authentication_block = block
13
+ end
14
+
15
+ def authentication_block
16
+ @authentication_block
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :quarterdeck do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quarterdeck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - leopolicastro
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.1.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 8.1.2
26
+ - !ruby/object:Gem::Dependency
27
+ name: pagy
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '6'
40
+ - !ruby/object:Gem::Dependency
41
+ name: groupdate
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '6'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '6'
54
+ - !ruby/object:Gem::Dependency
55
+ name: csv
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ description: A beautiful analytics dashboard UI for Rails apps already using ahoy_matey
69
+ for tracking. Quarterdeck reads your existing Ahoy data and presents it in a modern
70
+ dashboard with charts, tables, and filters.
71
+ email:
72
+ - 43428385+leopolicastro@users.noreply.github.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - MIT-LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - app/assets/stylesheets/quarterdeck/application.css
81
+ - app/controllers/quarterdeck/application_controller.rb
82
+ - app/controllers/quarterdeck/campaigns_controller.rb
83
+ - app/controllers/quarterdeck/events_controller.rb
84
+ - app/controllers/quarterdeck/geographics_controller.rb
85
+ - app/controllers/quarterdeck/live_controller.rb
86
+ - app/controllers/quarterdeck/overview_controller.rb
87
+ - app/controllers/quarterdeck/visits_controller.rb
88
+ - app/helpers/quarterdeck/application_helper.rb
89
+ - app/javascript/quarterdeck/application.js
90
+ - app/javascript/quarterdeck/controllers/chart_controller.js
91
+ - app/javascript/quarterdeck/controllers/date_range_controller.js
92
+ - app/javascript/quarterdeck/controllers/live_controller.js
93
+ - app/jobs/quarterdeck/application_job.rb
94
+ - app/mailers/quarterdeck/application_mailer.rb
95
+ - app/models/quarterdeck/application_record.rb
96
+ - app/views/layouts/quarterdeck/application.html.erb
97
+ - app/views/quarterdeck/campaigns/show.html.erb
98
+ - app/views/quarterdeck/events/index.html.erb
99
+ - app/views/quarterdeck/geographics/show.html.erb
100
+ - app/views/quarterdeck/live/show.html.erb
101
+ - app/views/quarterdeck/overview/show.html.erb
102
+ - app/views/quarterdeck/shared/_data_table.html.erb
103
+ - app/views/quarterdeck/shared/_nav.html.erb
104
+ - app/views/quarterdeck/shared/_period_tabs.html.erb
105
+ - app/views/quarterdeck/shared/_stat_card.html.erb
106
+ - app/views/quarterdeck/visits/index.html.erb
107
+ - app/views/quarterdeck/visits/show.html.erb
108
+ - config/importmap.rb
109
+ - config/routes.rb
110
+ - lib/generators/quarterdeck/install_generator.rb
111
+ - lib/quarterdeck.rb
112
+ - lib/quarterdeck/engine.rb
113
+ - lib/quarterdeck/version.rb
114
+ - lib/tasks/quarterdeck_tasks.rake
115
+ homepage: https://github.com/leopolicastro/quarterdeck
116
+ licenses:
117
+ - MIT
118
+ metadata:
119
+ homepage_uri: https://github.com/leopolicastro/quarterdeck
120
+ source_code_uri: https://github.com/leopolicastro/quarterdeck
121
+ changelog_uri: https://github.com/leopolicastro/quarterdeck/blob/main/CHANGELOG.md
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubygems_version: 4.0.6
137
+ specification_version: 4
138
+ summary: Analytics dashboard engine for Rails apps using Ahoy
139
+ test_files: []