matey 0.1.3 → 0.1.5

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +1 -1
  3. data/COLOR_SCHEMES.md +24 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +136 -114
  6. data/README.md +8 -3
  7. data/app/components/matey/active_users_component.html.erb +1 -1
  8. data/app/components/matey/active_users_component.rb +5 -3
  9. data/app/components/{application_component.rb → matey/application_component.rb} +3 -1
  10. data/app/components/matey/bounce_rate_component.html.erb +2 -2
  11. data/app/components/matey/bounce_rate_component.rb +5 -3
  12. data/app/components/matey/browser_os_breakdown_component.html.erb +38 -0
  13. data/app/components/matey/browser_os_breakdown_component.rb +11 -0
  14. data/app/components/matey/daily_active_users_component.html.erb +15 -0
  15. data/app/components/matey/daily_active_users_component.rb +11 -0
  16. data/app/components/matey/new_activity_component.html.erb +1 -1
  17. data/app/components/matey/new_activity_component.rb +5 -3
  18. data/app/components/matey/new_users_component.html.erb +1 -1
  19. data/app/components/matey/new_users_component.rb +5 -3
  20. data/app/components/matey/top_events_component.html.erb +2 -2
  21. data/app/components/matey/top_events_component.rb +4 -2
  22. data/app/components/matey/top_visited_pages_table_component.html.erb +2 -2
  23. data/app/components/matey/top_visited_pages_table_component.rb +4 -2
  24. data/app/components/matey/user_engagement_component.html.erb +2 -2
  25. data/app/components/matey/user_engagement_component.rb +4 -2
  26. data/app/components/matey/visits_by_day_of_week_component.html.erb +26 -0
  27. data/app/components/matey/visits_by_day_of_week_component.rb +17 -0
  28. data/images/colorSchemeBlue.png +0 -0
  29. data/images/colorSchemeNeutral.png +0 -0
  30. data/lib/helpers.rb +12 -0
  31. data/lib/matey/version.rb +1 -1
  32. data/lib/matey.rb +4 -1
  33. data/matey.gemspec +2 -1
  34. metadata +30 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5991529e6b95d161fa55e0b72a16fb4d22afd2f1d3fd3e657e6c834b5baca48f
4
- data.tar.gz: 7764c92bd83d7d7796b7e8737af3c8a6c5007b444238d4307f82790413da249c
3
+ metadata.gz: 81ed3e6b62f68768a94051796aa20b432002bc811d841b546e7632952816437e
4
+ data.tar.gz: 99e0970e24a51e1d6b438a8111591dc4c836d336a17e35089b98fba789c7687e
5
5
  SHA512:
6
- metadata.gz: 2cdb414b9eef61de45dc70babff6c441ff54cceebe2c3b6f515c79c52c8b3f4678f8e65bd41d3ca03f00317f21d634c5780263e9004eedcb607ecbdc7260cb65
7
- data.tar.gz: 91e809d70fead673bfa1d308db1edefb5872da969f322f2ac813569de19d18d08657beb21cd31789fbb6e41f04466dad9b054ceecd36cf785b33c3bdb051f243
6
+ metadata.gz: 84b86437df09f3ffa853dbda7da8f21adb36de0c68695855ca1b24330d61ec156002d1295aed604f4fcbb9fee131bcc9cee1d0a168622d92cfc8a5ed1e8853ab
7
+ data.tar.gz: 4739f02fea2fe779525a2ff14c0ed83cfde865e4f4d91a4f7757100eaeddf5764d145ec5e9ce1922aa26409128e2f284ce647f07057fd9bac560d7ef93e6d7d7
@@ -8,7 +8,7 @@
8
8
  // Update 'VARIANT' to pick a Ruby version: 3, 3.1, 3.0, 2, 2.7, 2.6
9
9
  // Append -bullseye or -buster to pin to an OS version.
10
10
  // Use -bullseye variants on local on arm64/Apple Silicon.
11
- "VARIANT": "3.1",
11
+ "VARIANT": "3.2",
12
12
  // Options
13
13
  "NODE_VERSION": "lts/*"
14
14
  }
data/COLOR_SCHEMES.md ADDED
@@ -0,0 +1,24 @@
1
+ # Color Schemes
2
+
3
+ ## Available Colors
4
+
5
+ - [Neutral](#neutral) _(default)_
6
+ - [Blue](#blue)
7
+
8
+ ### Neutral _(default)_
9
+
10
+ ![Neutral Color Scheme](./images/colorSchemeNeutral.png)
11
+
12
+ ```ruby
13
+ <%= render Matey::[ComponentType].new(..., color_scheme: "neutral") %>
14
+ ```
15
+
16
+ Note: If `color_scheme` argument is omitted, color scheme value defaults to `neutral`
17
+
18
+ ### Blue
19
+
20
+ ![Blue Color Scheme](./images/colorSchemeBlue.png)
21
+
22
+ ```ruby
23
+ <%= render Matey::[ComponentType].new(..., color_scheme: 'blue') %>
24
+ ```
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  rails_version = (ENV["RAILS_VERSION"] || "~> 7").to_s
7
- gem "rails", rails_version == "main" ? {git: "https://github.com/rails/rails", ref: "main"} : rails_version
7
+ gem "rails", (rails_version == "main") ? {git: "https://github.com/rails/rails", ref: "main"} : rails_version
8
8
 
9
9
  gem "debug", platforms: %i[mri mingw x64_mingw]
10
10
 
data/Gemfile.lock CHANGED
@@ -1,173 +1,186 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- matey (0.1.3)
4
+ matey (0.1.5)
5
5
  ahoy_matey (~> 4.0)
6
- view_component (~> 2.74.1)
6
+ groupdate (~> 6.4.0)
7
+ view_component (~> 2.74)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- actioncable (7.0.4)
12
- actionpack (= 7.0.4)
13
- activesupport (= 7.0.4)
12
+ actioncable (7.0.5)
13
+ actionpack (= 7.0.5)
14
+ activesupport (= 7.0.5)
14
15
  nio4r (~> 2.0)
15
16
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.4)
17
- actionpack (= 7.0.4)
18
- activejob (= 7.0.4)
19
- activerecord (= 7.0.4)
20
- activestorage (= 7.0.4)
21
- activesupport (= 7.0.4)
17
+ actionmailbox (7.0.5)
18
+ actionpack (= 7.0.5)
19
+ activejob (= 7.0.5)
20
+ activerecord (= 7.0.5)
21
+ activestorage (= 7.0.5)
22
+ activesupport (= 7.0.5)
22
23
  mail (>= 2.7.1)
23
24
  net-imap
24
25
  net-pop
25
26
  net-smtp
26
- actionmailer (7.0.4)
27
- actionpack (= 7.0.4)
28
- actionview (= 7.0.4)
29
- activejob (= 7.0.4)
30
- activesupport (= 7.0.4)
27
+ actionmailer (7.0.5)
28
+ actionpack (= 7.0.5)
29
+ actionview (= 7.0.5)
30
+ activejob (= 7.0.5)
31
+ activesupport (= 7.0.5)
31
32
  mail (~> 2.5, >= 2.5.4)
32
33
  net-imap
33
34
  net-pop
34
35
  net-smtp
35
36
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.4)
37
- actionview (= 7.0.4)
38
- activesupport (= 7.0.4)
39
- rack (~> 2.0, >= 2.2.0)
37
+ actionpack (7.0.5)
38
+ actionview (= 7.0.5)
39
+ activesupport (= 7.0.5)
40
+ rack (~> 2.0, >= 2.2.4)
40
41
  rack-test (>= 0.6.3)
41
42
  rails-dom-testing (~> 2.0)
42
43
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.4)
44
- actionpack (= 7.0.4)
45
- activerecord (= 7.0.4)
46
- activestorage (= 7.0.4)
47
- activesupport (= 7.0.4)
44
+ actiontext (7.0.5)
45
+ actionpack (= 7.0.5)
46
+ activerecord (= 7.0.5)
47
+ activestorage (= 7.0.5)
48
+ activesupport (= 7.0.5)
48
49
  globalid (>= 0.6.0)
49
50
  nokogiri (>= 1.8.5)
50
- actionview (7.0.4)
51
- activesupport (= 7.0.4)
51
+ actionview (7.0.5)
52
+ activesupport (= 7.0.5)
52
53
  builder (~> 3.1)
53
54
  erubi (~> 1.4)
54
55
  rails-dom-testing (~> 2.0)
55
56
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.4)
57
- activesupport (= 7.0.4)
57
+ activejob (7.0.5)
58
+ activesupport (= 7.0.5)
58
59
  globalid (>= 0.3.6)
59
- activemodel (7.0.4)
60
- activesupport (= 7.0.4)
61
- activerecord (7.0.4)
62
- activemodel (= 7.0.4)
63
- activesupport (= 7.0.4)
64
- activestorage (7.0.4)
65
- actionpack (= 7.0.4)
66
- activejob (= 7.0.4)
67
- activerecord (= 7.0.4)
68
- activesupport (= 7.0.4)
60
+ activemodel (7.0.5)
61
+ activesupport (= 7.0.5)
62
+ activerecord (7.0.5)
63
+ activemodel (= 7.0.5)
64
+ activesupport (= 7.0.5)
65
+ activestorage (7.0.5)
66
+ actionpack (= 7.0.5)
67
+ activejob (= 7.0.5)
68
+ activerecord (= 7.0.5)
69
+ activesupport (= 7.0.5)
69
70
  marcel (~> 1.0)
70
71
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.4)
72
+ activesupport (7.0.5)
72
73
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
74
  i18n (>= 1.6, < 2)
74
75
  minitest (>= 5.1)
75
76
  tzinfo (~> 2.0)
76
- ahoy_matey (4.1.0)
77
+ ahoy_matey (4.2.1)
77
78
  activesupport (>= 5.2)
78
79
  device_detector
79
80
  safely_block (>= 0.2.1)
80
81
  ast (2.4.2)
81
82
  builder (3.2.4)
82
- concurrent-ruby (1.1.10)
83
+ concurrent-ruby (1.2.2)
83
84
  crass (1.0.6)
84
- debug (1.6.3)
85
- irb (>= 1.3.6)
85
+ date (3.3.3)
86
+ debug (1.8.0)
87
+ irb (>= 1.5.0)
86
88
  reline (>= 0.3.1)
87
- device_detector (1.0.7)
89
+ device_detector (1.1.0)
88
90
  diff-lcs (1.5.0)
89
- errbase (0.2.2)
90
- erubi (1.11.0)
91
+ erubi (1.12.0)
91
92
  factory_bot (6.2.1)
92
93
  activesupport (>= 5.0.0)
93
94
  factory_bot_rails (6.2.0)
94
95
  factory_bot (~> 6.2.0)
95
96
  railties (>= 5.0.0)
96
- globalid (1.0.0)
97
+ globalid (1.1.0)
97
98
  activesupport (>= 5.0)
98
- i18n (1.12.0)
99
+ groupdate (6.4.0)
100
+ activesupport (>= 6.1)
101
+ i18n (1.14.1)
99
102
  concurrent-ruby (~> 1.0)
100
- io-console (0.5.11)
101
- irb (1.4.2)
103
+ io-console (0.6.0)
104
+ irb (1.7.0)
102
105
  reline (>= 0.3.0)
103
- json (2.6.2)
104
- loofah (2.19.0)
106
+ json (2.6.3)
107
+ language_server-protocol (3.17.0.3)
108
+ lint_roller (1.0.0)
109
+ loofah (2.21.3)
105
110
  crass (~> 1.0.2)
106
- nokogiri (>= 1.5.9)
107
- mail (2.7.1)
111
+ nokogiri (>= 1.12.0)
112
+ mail (2.8.1)
108
113
  mini_mime (>= 0.1.1)
114
+ net-imap
115
+ net-pop
116
+ net-smtp
109
117
  marcel (1.0.2)
110
118
  method_source (1.0.0)
111
119
  mini_mime (1.1.2)
112
- minitest (5.16.3)
113
- net-imap (0.3.1)
120
+ minitest (5.18.1)
121
+ net-imap (0.3.6)
122
+ date
114
123
  net-protocol
115
124
  net-pop (0.1.2)
116
125
  net-protocol
117
- net-protocol (0.1.3)
126
+ net-protocol (0.2.1)
118
127
  timeout
119
128
  net-smtp (0.3.3)
120
129
  net-protocol
121
- nio4r (2.5.8)
122
- nokogiri (1.13.9-x86_64-darwin)
130
+ nio4r (2.5.9)
131
+ nokogiri (1.15.2-aarch64-linux)
132
+ racc (~> 1.4)
133
+ nokogiri (1.15.2-x86_64-darwin)
123
134
  racc (~> 1.4)
124
- nokogiri (1.13.9-x86_64-linux)
135
+ nokogiri (1.15.2-x86_64-linux)
125
136
  racc (~> 1.4)
126
- parallel (1.22.1)
127
- parser (3.1.2.1)
137
+ parallel (1.23.0)
138
+ parser (3.2.2.3)
128
139
  ast (~> 2.4.1)
129
- racc (1.6.0)
130
- rack (2.2.4)
131
- rack-test (2.0.2)
140
+ racc
141
+ racc (1.7.1)
142
+ rack (2.2.7)
143
+ rack-test (2.1.0)
132
144
  rack (>= 1.3)
133
- rails (7.0.4)
134
- actioncable (= 7.0.4)
135
- actionmailbox (= 7.0.4)
136
- actionmailer (= 7.0.4)
137
- actionpack (= 7.0.4)
138
- actiontext (= 7.0.4)
139
- actionview (= 7.0.4)
140
- activejob (= 7.0.4)
141
- activemodel (= 7.0.4)
142
- activerecord (= 7.0.4)
143
- activestorage (= 7.0.4)
144
- activesupport (= 7.0.4)
145
+ rails (7.0.5)
146
+ actioncable (= 7.0.5)
147
+ actionmailbox (= 7.0.5)
148
+ actionmailer (= 7.0.5)
149
+ actionpack (= 7.0.5)
150
+ actiontext (= 7.0.5)
151
+ actionview (= 7.0.5)
152
+ activejob (= 7.0.5)
153
+ activemodel (= 7.0.5)
154
+ activerecord (= 7.0.5)
155
+ activestorage (= 7.0.5)
156
+ activesupport (= 7.0.5)
145
157
  bundler (>= 1.15.0)
146
- railties (= 7.0.4)
158
+ railties (= 7.0.5)
147
159
  rails-dom-testing (2.0.3)
148
160
  activesupport (>= 4.2.0)
149
161
  nokogiri (>= 1.6)
150
- rails-html-sanitizer (1.4.3)
151
- loofah (~> 2.3)
152
- railties (7.0.4)
153
- actionpack (= 7.0.4)
154
- activesupport (= 7.0.4)
162
+ rails-html-sanitizer (1.6.0)
163
+ loofah (~> 2.21)
164
+ nokogiri (~> 1.14)
165
+ railties (7.0.5)
166
+ actionpack (= 7.0.5)
167
+ activesupport (= 7.0.5)
155
168
  method_source
156
169
  rake (>= 12.2)
157
170
  thor (~> 1.0)
158
171
  zeitwerk (~> 2.5)
159
172
  rainbow (3.1.1)
160
173
  rake (13.0.6)
161
- regexp_parser (2.6.0)
162
- reline (0.3.1)
174
+ regexp_parser (2.8.1)
175
+ reline (0.3.5)
163
176
  io-console (~> 0.5)
164
177
  rexml (3.2.5)
165
- rspec-core (3.12.0)
178
+ rspec-core (3.12.2)
166
179
  rspec-support (~> 3.12.0)
167
- rspec-expectations (3.12.0)
180
+ rspec-expectations (3.12.3)
168
181
  diff-lcs (>= 1.2.0, < 2.0)
169
182
  rspec-support (~> 3.12.0)
170
- rspec-mocks (3.12.0)
183
+ rspec-mocks (3.12.5)
171
184
  diff-lcs (>= 1.2.0, < 2.0)
172
185
  rspec-support (~> 3.12.0)
173
186
  rspec-rails (5.1.2)
@@ -179,51 +192,60 @@ GEM
179
192
  rspec-mocks (~> 3.10)
180
193
  rspec-support (~> 3.10)
181
194
  rspec-support (3.12.0)
182
- rubocop (1.35.1)
195
+ rubocop (1.52.1)
183
196
  json (~> 2.3)
184
197
  parallel (~> 1.10)
185
- parser (>= 3.1.2.1)
198
+ parser (>= 3.2.2.3)
186
199
  rainbow (>= 2.2.2, < 4.0)
187
200
  regexp_parser (>= 1.8, < 3.0)
188
201
  rexml (>= 3.2.5, < 4.0)
189
- rubocop-ast (>= 1.20.1, < 2.0)
202
+ rubocop-ast (>= 1.28.0, < 2.0)
190
203
  ruby-progressbar (~> 1.7)
191
- unicode-display_width (>= 1.4.0, < 3.0)
192
- rubocop-ast (1.23.0)
193
- parser (>= 3.1.1.0)
194
- rubocop-performance (1.14.3)
204
+ unicode-display_width (>= 2.4.0, < 3.0)
205
+ rubocop-ast (1.29.0)
206
+ parser (>= 3.2.1.0)
207
+ rubocop-performance (1.18.0)
195
208
  rubocop (>= 1.7.0, < 2.0)
196
209
  rubocop-ast (>= 0.4.0)
197
- ruby-progressbar (1.11.0)
198
- safely_block (0.3.0)
199
- errbase (>= 0.1.1)
200
- sprockets (4.1.1)
210
+ ruby-progressbar (1.13.0)
211
+ safely_block (0.4.0)
212
+ sprockets (4.2.0)
201
213
  concurrent-ruby (~> 1.0)
202
- rack (> 1, < 3)
214
+ rack (>= 2.2.4, < 4)
203
215
  sprockets-rails (3.2.2)
204
216
  actionpack (>= 4.0)
205
217
  activesupport (>= 4.0)
206
218
  sprockets (>= 3.0.0)
207
- sqlite3 (1.5.3-x86_64-darwin)
208
- sqlite3 (1.5.3-x86_64-linux)
209
- standard (1.16.1)
210
- rubocop (= 1.35.1)
211
- rubocop-performance (= 1.14.3)
212
- thor (1.2.1)
213
- timeout (0.3.0)
214
- tzinfo (2.0.5)
219
+ sqlite3 (1.6.3-aarch64-linux)
220
+ sqlite3 (1.6.3-x86_64-darwin)
221
+ sqlite3 (1.6.3-x86_64-linux)
222
+ standard (1.29.0)
223
+ language_server-protocol (~> 3.17.0.2)
224
+ lint_roller (~> 1.0)
225
+ rubocop (~> 1.52.0)
226
+ standard-custom (~> 1.0.0)
227
+ standard-performance (~> 1.1.0)
228
+ standard-custom (1.0.1)
229
+ lint_roller (~> 1.0)
230
+ standard-performance (1.1.0)
231
+ lint_roller (~> 1.0)
232
+ rubocop-performance (~> 1.18.0)
233
+ thor (1.2.2)
234
+ timeout (0.3.2)
235
+ tzinfo (2.0.6)
215
236
  concurrent-ruby (~> 1.0)
216
- unicode-display_width (2.3.0)
217
- view_component (2.74.1)
218
- activesupport (>= 5.0.0, < 8.0)
237
+ unicode-display_width (2.4.2)
238
+ view_component (2.82.0)
239
+ activesupport (>= 5.2.0, < 8.0)
219
240
  concurrent-ruby (~> 1.0)
220
241
  method_source (~> 1.0)
221
242
  websocket-driver (0.7.5)
222
243
  websocket-extensions (>= 0.1.0)
223
244
  websocket-extensions (0.1.5)
224
- zeitwerk (2.6.4)
245
+ zeitwerk (2.6.8)
225
246
 
226
247
  PLATFORMS
248
+ aarch64-linux
227
249
  x86_64-darwin-21
228
250
  x86_64-linux
229
251
 
@@ -242,4 +264,4 @@ DEPENDENCIES
242
264
  standard (~> 1.3)
243
265
 
244
266
  BUNDLED WITH
245
- 2.3.7
267
+ 2.4.10
data/README.md CHANGED
@@ -45,6 +45,8 @@ the `time_window`, which is the period to report on.
45
45
 
46
46
  It is that simple! There should now be a card displaying the number of active users within the past week.
47
47
 
48
+ View the available component color schemes [here](COLOR_SCHEMES.md).
49
+
48
50
  View the list of available components [here](COMPONENTS.md).
49
51
 
50
52
  **Note**: The more data, the more interesting the components will be. A common and helpful pattern is to capture events on all controller actions. Details on doing this can be found [here](https://github.com/ankane/ahoy#ruby).
@@ -55,10 +57,13 @@ After checking out the repository, run the following commands to get started:
55
57
 
56
58
  ```bash
57
59
  # install required packages
58
- bin/setup
60
+ bin/setup
61
+
62
+ # install spec/sample packages
63
+ bundle install --gemfile spec/sample/Gemfile
59
64
 
60
65
  # run test cases and ensure everything is passing
61
- rake spec
66
+ rake spec
62
67
 
63
68
  # an interactive prompt that will allow you to experiment with matey (currently broken!)
64
69
  bin/console
@@ -74,7 +79,7 @@ To use the sample application:
74
79
 
75
80
  1. `cd spec/sample`
76
81
  2. `bundle`
77
- 3. `rails s`
82
+ 3. `bundle exec rails s`
78
83
  4. Open a browser to `localhost:3000`
79
84
 
80
85
  ## Testing
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <div class="row">
4
4
  <div class="col">
@@ -1,7 +1,7 @@
1
1
  require "ahoy_matey"
2
2
 
3
- class Matey::ActiveUsersComponent < ApplicationComponent
4
- def initialize(events:, time_window: 1.week)
3
+ class Matey::ActiveUsersComponent < Matey::ApplicationComponent
4
+ def initialize(events:, time_window: 1.week, color_scheme: "neutral")
5
5
  raise ArgumentError unless events.is_a?(ActiveRecord::Relation)
6
6
  raise ArgumentError unless time_window.is_a?(Integer)
7
7
 
@@ -9,8 +9,10 @@ class Matey::ActiveUsersComponent < ApplicationComponent
9
9
  previous_period = events.where(time: (2 * time_window).ago..time_window.ago).pluck(:user_id).uniq.count
10
10
 
11
11
  @change_active_number = @current_period - previous_period
12
- @change_active_percent = ((@change_active_number.to_f / (previous_period == 0 ? 1 : previous_period)) * 100).truncate(2)
12
+ @change_active_percent = ((@change_active_number.to_f / ((previous_period == 0) ? 1 : previous_period)) * 100).truncate(2)
13
13
 
14
14
  @time_window = time_window
15
+
16
+ @color_scheme = color_scheme(scheme: color_scheme)
15
17
  end
16
18
  end
@@ -1,8 +1,10 @@
1
1
  require "view_component"
2
2
  require "ahoy_matey"
3
+ require_relative "../../../lib/helpers"
3
4
 
4
- class ApplicationComponent < ViewComponent::Base
5
+ class Matey::ApplicationComponent < ViewComponent::Base
5
6
  include ActiveModel::Validations
7
+ include ColorSchemeHelper
6
8
 
7
9
  def before_render
8
10
  validate!
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <h5 class = "text-center"><strong>The Bounce Rate of your Application is: <u><%= @percentage_of_visits_that_were_bounced %>%</u></strong></h5>
4
4
  <div>
@@ -21,7 +21,7 @@
21
21
  <th class="text-end">Bounce Count</th>
22
22
  </tr>
23
23
  </thead>
24
- <tbody class="text-light">
24
+ <tbody class="text-dark border-dark">
25
25
  <% @most_bounced_pages.each do |controller_name_and_action, count| %>
26
26
  <tr>
27
27
  <td><%= controller_name_and_action %></td>
@@ -1,7 +1,7 @@
1
1
  require "ahoy_matey"
2
2
 
3
- class Matey::BounceRateComponent < ApplicationComponent
4
- def initialize(events:, visits:, limit: 5)
3
+ class Matey::BounceRateComponent < Matey::ApplicationComponent
4
+ def initialize(events:, visits:, limit: 5, color_scheme: "neutral")
5
5
  # Determine the total number of user sessions to the website
6
6
  @total_number_of_user_visits = events.pluck(:visit_id).uniq.count
7
7
 
@@ -17,6 +17,8 @@ class Matey::BounceRateComponent < ApplicationComponent
17
17
  @most_bounced_pages = @single_event_visits_landing_page_count.sort_by { |controller_name_and_action, count| count }.last(limit).reverse
18
18
 
19
19
  # Get the percentage as #-One-Page-Visits / Total-#-Of-Visits
20
- @percentage_of_visits_that_were_bounced = ((@total_number_of_single_event_visits.to_f / (@total_number_of_user_visits == 0 ? 1 : @total_number_of_user_visits)) * 100).round(1)
20
+ @percentage_of_visits_that_were_bounced = ((@total_number_of_single_event_visits.to_f / ((@total_number_of_user_visits == 0) ? 1 : @total_number_of_user_visits)) * 100).round(1)
21
+
22
+ @color_scheme = color_scheme(scheme: color_scheme)
21
23
  end
22
24
  end
@@ -0,0 +1,38 @@
1
+ <div class="card <%= @color_scheme %>">
2
+ <div class="card-body">
3
+ <div class="row">
4
+ <h5 class="text-center">Browser and OS Breakdown</h5>
5
+ <div class="col">
6
+ <p class="text-center">Since <%= time_ago_in_words(@time_window.ago).titleize %> Ago</p>
7
+ <table class='table table-hover table-borderless'>
8
+ <thead class='table-dark'>
9
+ <th>Browser</th>
10
+ <th class='text-center'>Visitor Count</th>
11
+ </thead>
12
+ <tbody class='text-dark border-dark'>
13
+ <% @browsers.each do |browser_name, visitor_count| %>
14
+ <tr>
15
+ <td><%= browser_name %></td>
16
+ <td class='text-center'><%= visitor_count %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+ <table class='table table-hover table-borderless'>
22
+ <thead class='table-dark'>
23
+ <th>OS</th>
24
+ <th class='text-center'>Visitor Count</th>
25
+ </thead>
26
+ <tbody class='text-dark border-dark'>
27
+ <% @operating_systems.each do |operating_system, visitor_count| %>
28
+ <tr>
29
+ <td><%= operating_system %></td>
30
+ <td class='text-center'><%= visitor_count %></td>
31
+ </tr>
32
+ <% end %>
33
+ </tbody>
34
+ </table>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
@@ -0,0 +1,11 @@
1
+ class Matey::BrowserOsBreakdownComponent < Matey::ApplicationComponent
2
+ def initialize(visits:, time_window:, color_scheme: "neutral")
3
+ visits_in_time_window = visits.where(started_at: time_window.ago..)
4
+ @visits_in_time_window = visits_in_time_window.count
5
+ @browsers = visits_in_time_window.group(:browser).count
6
+ @operating_systems = visits_in_time_window.group(:os).count
7
+ @time_window = time_window
8
+
9
+ @color_scheme = color_scheme(scheme: color_scheme)
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ <div class="card <%= @color_scheme %>">
2
+ <div class="card-body">
3
+ <div class="col">
4
+ <div class="col">
5
+ <h5>Daily Active Users</h5>
6
+ </div>
7
+ <div class="col-auto">
8
+ <p>Since <%= time_ago_in_words(@time_window.ago).titleize %> Ago</p>
9
+ <p><%= @distinct_user_visits_by_day %></p>
10
+ <p><%# @distinct_user_visits_by_day2 %></p>
11
+ <%# @visits.each {|e| e} %>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
@@ -0,0 +1,11 @@
1
+ class Matey::DailyActiveUsersComponent < Matey::ApplicationComponent
2
+ def initialize(visits:, time_window:, color_scheme: "neutral")
3
+ @visits = visits
4
+ @time_window = time_window
5
+ visits_in_time_window = visits.where(started_at: time_window.ago..)
6
+ @distinct_user_visits_by_day = visits_in_time_window.order(:day).group(:day).uniq.count
7
+ # @distinct_user_visits_by_day2 = visits_in_time_window.order(:day).group("DATE(started_at)").map { |k, v| [k, v] }.sort
8
+
9
+ @color_scheme = color_scheme(scheme: color_scheme)
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <div class="row">
4
4
  <div class="col">
@@ -1,5 +1,5 @@
1
- class Matey::NewActivityComponent < ApplicationComponent
2
- def initialize(events:, time_window: 1.week)
1
+ class Matey::NewActivityComponent < Matey::ApplicationComponent
2
+ def initialize(events:, time_window: 1.week, color_scheme: "neutral")
3
3
  raise ArgumentError unless events.is_a?(ActiveRecord::Relation)
4
4
  raise ArgumentError unless time_window.is_a?(Integer)
5
5
 
@@ -7,8 +7,10 @@ class Matey::NewActivityComponent < ApplicationComponent
7
7
  previous_period = events.where(time: (2 * time_window).ago..time_window.ago).pluck(:user_id).count
8
8
 
9
9
  @change_active_number = @current_period - previous_period
10
- @change_active_percent = ((@change_active_number.to_f / (previous_period == 0 ? 1 : previous_period)) * 100).truncate(2)
10
+ @change_active_percent = ((@change_active_number.to_f / ((previous_period == 0) ? 1 : previous_period)) * 100).truncate(2)
11
11
 
12
12
  @time_window = time_window
13
+
14
+ @color_scheme = color_scheme(scheme: color_scheme)
13
15
  end
14
16
  end
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <div class="row">
4
4
  <div class="col">
@@ -1,11 +1,13 @@
1
- class Matey::NewUsersComponent < ApplicationComponent
2
- def initialize(users:, time_window: 1.week)
1
+ class Matey::NewUsersComponent < Matey::ApplicationComponent
2
+ def initialize(users:, time_window: 1.week, color_scheme: "neutral")
3
3
  @current_period = users.where(created_at: time_window.ago..Time.current).count
4
4
  previous_period = users.where(created_at: (2 * time_window).ago..time_window.ago).count
5
5
 
6
6
  @change_new_number = @current_period - previous_period
7
- @change_new_percent = ((@change_new_number.to_f / (previous_period == 0 ? 1 : previous_period)) * 100).truncate(2)
7
+ @change_new_percent = ((@change_new_number.to_f / ((previous_period == 0) ? 1 : previous_period)) * 100).truncate(2)
8
8
 
9
9
  @time_window = time_window
10
+
11
+ @color_scheme = color_scheme(scheme: color_scheme)
10
12
  end
11
13
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- <div class="card bg-primary text-light">
3
+ <div class="card <%= @color_scheme %>">
4
4
  <div class="card-body">
5
5
  <h5>Top Events Since <%= time_ago_in_words(@time_window.ago).titleize %> Ago (<%= @time_window.ago.strftime("%m/%d/%Y") %>)</h5>
6
6
  <div>
@@ -11,7 +11,7 @@
11
11
  <th>Count</th>
12
12
  </tr>
13
13
  </thead>
14
- <tbody class="text-light">
14
+ <tbody class="text-dark border-dark">
15
15
  <% @events.each do |action, count| %>
16
16
  <tr>
17
17
  <td><%= action %></td>
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Matey::TopEventsComponent < ApplicationComponent
4
- def initialize(events:, time_window: 1.week, limit: 5)
3
+ class Matey::TopEventsComponent < Matey::ApplicationComponent
4
+ def initialize(events:, time_window: 1.week, limit: 5, color_scheme: "neutral")
5
5
  raise ArgumentError unless events.is_a?(ActiveRecord::Relation)
6
6
  raise ArgumentError unless time_window.is_a?(Integer)
7
7
 
8
8
  @events = events.where(time: time_window.ago..Time.current).limit(limit).order("count(name) DESC").group(:name).count
9
9
  @time_window = time_window
10
+
11
+ @color_scheme = color_scheme(scheme: color_scheme)
10
12
  end
11
13
  end
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <h5>Top Landing Page Visits Since <%= time_ago_in_words(@time_window.ago).titleize %> Ago (<%= @time_window.ago.strftime("%m/%d/%Y") %>)</h5>
4
4
  <div>
@@ -9,7 +9,7 @@
9
9
  <th>Count</th>
10
10
  </tr>
11
11
  </thead>
12
- <tbody class="text-light">
12
+ <tbody class="text-dark border-dark">
13
13
  <% @user_count_by_event.each do |controller_name_and_action, count| %>
14
14
  <tr>
15
15
  <td><%= controller_name_and_action %></td>
@@ -1,5 +1,5 @@
1
- class Matey::TopVisitedPagesTableComponent < ApplicationComponent
2
- def initialize(events:, time_window: 1.week, limit: 10)
1
+ class Matey::TopVisitedPagesTableComponent < Matey::ApplicationComponent
2
+ def initialize(events:, time_window: 1.week, limit: 10, color_scheme: "neutral")
3
3
  # Group events by controller (:name) and action. Aggregate number of unique user actions
4
4
  @user_count_by_event = events.where(started_at: time_window.ago..).pluck(:landing_page).tally
5
5
 
@@ -7,5 +7,7 @@ class Matey::TopVisitedPagesTableComponent < ApplicationComponent
7
7
  @user_count_by_event = @user_count_by_event.sort_by { |controller_name_and_action, count| count }.last(limit).reverse
8
8
 
9
9
  @time_window = time_window
10
+
11
+ @color_scheme = color_scheme(scheme: color_scheme)
10
12
  end
11
13
  end
@@ -1,4 +1,4 @@
1
- <div class="card bg-primary text-light">
1
+ <div class="card <%= @color_scheme %>">
2
2
  <div class="card-body">
3
3
  <h5>User Activity for <i>user id: <%=@user_id%></i> since <i><%= time_ago_in_words(@time_window.ago).titleize %></i> ago </h5>
4
4
  <div>
@@ -9,7 +9,7 @@
9
9
  <th class="text-end">Count</th>
10
10
  </tr>
11
11
  </thead>
12
- <tbody class="text-light">
12
+ <tbody class="text-dark border-dark">
13
13
  <% @count_by_event.each do |event, count| %>
14
14
  <tr>
15
15
  <td><%= event %></td>
@@ -1,10 +1,12 @@
1
1
  require "ahoy_matey"
2
2
 
3
- class Matey::UserEngagementComponent < ApplicationComponent
4
- def initialize(events:, user_id:, time_window: 1.week, limit: 10)
3
+ class Matey::UserEngagementComponent < Matey::ApplicationComponent
4
+ def initialize(events:, user_id:, time_window: 1.week, limit: 10, color_scheme: "neutral")
5
5
  @events_for_user = events.where_props(user_id: user_id).where(time: time_window.ago..Time.current).group(:name).count
6
6
  @count_by_event = @events_for_user.sort_by { |event, count| count }.last(limit).reverse
7
7
  @time_window = time_window
8
8
  @user_id = user_id
9
+
10
+ @color_scheme = color_scheme(scheme: color_scheme)
9
11
  end
10
12
  end
@@ -0,0 +1,26 @@
1
+ <div class="card <%= @color_scheme %>">
2
+ <div class="card-header">
3
+ <h5>Visits By Day of Week since <%= time_ago_in_words(@time_window.ago).titleize %> Ago (<%= @time_window.ago.strftime("%m/%d/%Y") %>) </h5>
4
+ <% if @exclude_days.any? %>
5
+ <p>Excluding <%= @exclude_days.join(', ') %></p>
6
+ <% end %>
7
+ </div>
8
+ <div class="card-body">
9
+ <table class="table table-hover table-borderless table-sm">
10
+ <thead class="table-dark">
11
+ <tr>
12
+ <th class="text-start">DayOfWeek</th>
13
+ <th class="text-end">Count</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody class="text-dark border-dark">
17
+ <% visits_by_day_of_week.each do |day_of_week, count| %>
18
+ <tr>
19
+ <td><%= day_of_week %></td>
20
+ <td class="text-end"><%= count %></td>
21
+ </tr>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
25
+ </div><!-- .card-body -->
26
+ </div><!-- .card -->
@@ -0,0 +1,17 @@
1
+ require "ahoy_matey"
2
+ require "groupdate"
3
+
4
+ class Matey::VisitsByDayOfWeekComponent < Matey::ApplicationComponent
5
+ def initialize(visits:, time_window: 1.month, exclude_days: [], color_scheme: "neutral")
6
+ @visits = visits
7
+ @time_window = time_window
8
+ @exclude_days = exclude_days
9
+ @color_scheme = color_scheme(scheme: color_scheme)
10
+ end
11
+
12
+ # group visits by day in provided time window
13
+ def visits_by_day_of_week
14
+ visits_by_day_of_week = @visits.group_by_day_of_week(:started_at, format: "%A", range: @time_window.ago..).count
15
+ visits_by_day_of_week.except!(*@exclude_days) if @exclude_days.any?
16
+ end
17
+ end
Binary file
Binary file
data/lib/helpers.rb ADDED
@@ -0,0 +1,12 @@
1
+ module ColorSchemeHelper
2
+ def color_scheme(scheme: "blue")
3
+ case scheme
4
+ when "blue"
5
+ "bg-primary text-light"
6
+ when "neutral"
7
+ "bg-light text-dark border-dark"
8
+ else
9
+ "bg-light text-dark border-dark"
10
+ end
11
+ end
12
+ end
data/lib/matey/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Matey
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/matey.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "matey/version"
4
4
 
5
- require_relative "../app/components/application_component"
5
+ require_relative "../app/components/matey/application_component"
6
6
  require_relative "../app/components/matey/active_users_component"
7
7
  require_relative "../app/components/matey/bounce_rate_component"
8
8
  require_relative "../app/components/matey/new_activity_component"
@@ -10,6 +10,9 @@ require_relative "../app/components/matey/new_users_component"
10
10
  require_relative "../app/components/matey/top_events_component"
11
11
  require_relative "../app/components/matey/top_visited_pages_table_component"
12
12
  require_relative "../app/components/matey/user_engagement_component"
13
+ require_relative "../app/components/matey/daily_active_users_component"
14
+ require_relative "../app/components/matey/visits_by_day_of_week_component"
15
+ require_relative "../app/components/matey/browser_os_breakdown_component"
13
16
 
14
17
  module Matey
15
18
  class Error < StandardError; end
data/matey.gemspec CHANGED
@@ -34,8 +34,9 @@ Gem::Specification.new do |spec|
34
34
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
36
 
37
- spec.add_dependency "view_component", "~> 2.74.1"
37
+ spec.add_dependency "view_component", "~> 2.74"
38
38
  spec.add_dependency "ahoy_matey", "~> 4.0"
39
+ spec.add_dependency "groupdate", "~> 6.4.0"
39
40
 
40
41
  spec.add_development_dependency "rspec-rails", "~> 5.0"
41
42
  spec.add_development_dependency "factory_bot_rails", "~> 6.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Loos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-11-04 00:00:00.000000000 Z
12
+ date: 2023-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: view_component
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.74.1
20
+ version: '2.74'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 2.74.1
27
+ version: '2.74'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: ahoy_matey
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '4.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: groupdate
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 6.4.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 6.4.0
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec-rails
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -153,17 +167,22 @@ files:
153
167
  - ".standard.yml"
154
168
  - CHANGELOG.md
155
169
  - CODE_OF_CONDUCT.md
170
+ - COLOR_SCHEMES.md
156
171
  - COMPONENTS.md
157
172
  - Gemfile
158
173
  - Gemfile.lock
159
174
  - LICENSE.txt
160
175
  - README.md
161
176
  - Rakefile
162
- - app/components/application_component.rb
163
177
  - app/components/matey/active_users_component.html.erb
164
178
  - app/components/matey/active_users_component.rb
179
+ - app/components/matey/application_component.rb
165
180
  - app/components/matey/bounce_rate_component.html.erb
166
181
  - app/components/matey/bounce_rate_component.rb
182
+ - app/components/matey/browser_os_breakdown_component.html.erb
183
+ - app/components/matey/browser_os_breakdown_component.rb
184
+ - app/components/matey/daily_active_users_component.html.erb
185
+ - app/components/matey/daily_active_users_component.rb
167
186
  - app/components/matey/new_activity_component.html.erb
168
187
  - app/components/matey/new_activity_component.rb
169
188
  - app/components/matey/new_users_component.html.erb
@@ -174,14 +193,19 @@ files:
174
193
  - app/components/matey/top_visited_pages_table_component.rb
175
194
  - app/components/matey/user_engagement_component.html.erb
176
195
  - app/components/matey/user_engagement_component.rb
196
+ - app/components/matey/visits_by_day_of_week_component.html.erb
197
+ - app/components/matey/visits_by_day_of_week_component.rb
177
198
  - docs/CONTRIBUTING.md
178
199
  - images/.DS_Store
179
200
  - images/activeUsersComponent.png
180
201
  - images/bounceRateComponent.png
202
+ - images/colorSchemeBlue.png
203
+ - images/colorSchemeNeutral.png
181
204
  - images/newActivityComponent.png
182
205
  - images/newUsersComponent.png
183
206
  - images/topEventsComponent.png
184
207
  - images/topVisitedPages.png
208
+ - lib/helpers.rb
185
209
  - lib/matey.rb
186
210
  - lib/matey/version.rb
187
211
  - matey.gemspec
@@ -208,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
232
  - !ruby/object:Gem::Version
209
233
  version: '0'
210
234
  requirements: []
211
- rubygems_version: 3.3.7
235
+ rubygems_version: 3.4.10
212
236
  signing_key:
213
237
  specification_version: 4
214
238
  summary: Track user engagement using Ahoy and ViewComponents.