ahoy_captain 0.11.0 → 0.11.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8ee0971d696dceab133146c4f8a53a0e7f687c474497bc49ee8bf914bda2430
4
- data.tar.gz: 3fc99cc0c51f8abbb07acbbf6a39e9f77a5b2adcabc6bd8e5e0583c0bd77b1af
3
+ metadata.gz: 550735e026fe60170552c09149ee5dceb1d874020c131f49c9a79a6d1c04982f
4
+ data.tar.gz: 9a782cddeb96ba6726980ae8f0c5b332f51756b8114b88dc63af91a2739776ea
5
5
  SHA512:
6
- metadata.gz: 99352a390c1f4641d5664882e5807909f4948f77f8b3ab3de89c4e5bad2773b78f6ff4ced0433d490ffa8db1050e6f5b284ad43086b4521328ab5e9af2f01a2c
7
- data.tar.gz: 7b13a9571dcc60c6d4a8ab4677cdd6f0fd77123a192a5833e1e837a2f3117e5beed71ab4cb3ab00b66de3b8dafa134f30eeb72f9da98cddf5d3040b7c2dfb963
6
+ metadata.gz: 021c101c8ff731e860b85baab37836fdb9f1dc5a038c90cd5411b9f0e628b8918823fdc7446164620414bce1a20560a7284dd6d63753ad4ab6c1f1541aed17d8
7
+ data.tar.gz: b0a5fc48678367faa56299f2462b92edf3331adc4df3f0cc685b68584cfea4604d76437528007ce27e5c3173312945d514e2399a65efad1d4b473e2a134b6690
@@ -2,8 +2,32 @@ import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ["title"]
5
+ connect() {
6
+ this.frame = this.element.querySelector('turbo-frame');
7
+ const targetNode = this.frame;
8
+ const config = { attributes: true };
9
+
10
+ const callback = (mutationList, observer) => {
11
+ for (const mutation of mutationList) {
12
+ if (mutation.type === "attributes") {
13
+ this.handleFrameLoad(mutation.attributeName)
14
+ }
15
+ }
16
+ };
17
+
18
+ const observer = new MutationObserver(callback);
19
+ observer.observe(targetNode, config);
20
+ }
21
+
22
+ handleFrameLoad(status) {
23
+ if(!this.frame.hasAttribute('skeleton')) {
24
+ if(status === 'busy') {
25
+ this.frame.innerHTML = document.querySelector('#tile-loader-template').innerHTML;
26
+ }
27
+ }
28
+ }
29
+
5
30
  setTitle(event) {
6
31
  this.titleTarget.innerHTML = event.target.title || event.target.text
7
32
  }
8
-
9
33
  }
@@ -0,0 +1,17 @@
1
+ <div class="dropdown dropdown-end" data-controller='dropdown-label'>
2
+ <label
3
+ tabindex="0"
4
+ class="cursor-pointer flex <%= classes %>"
5
+ data-action='click->dropdown-label#removeHidden'
6
+ >
7
+ <span data-dropdown-label-target="label"><%= title %></span>
8
+
9
+ </label>
10
+ <ul class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52" data-dropdown-label-target="close">
11
+ <% links.each do |link| %>
12
+ <li data-action="click->dropdown-label#setLabel">
13
+ <%= link %>
14
+ <li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
@@ -1,17 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class AhoyCaptain::ComparisonLinkComponent < AhoyCaptain::DropdownLinkComponent
3
+ class AhoyCaptain::ComparisonLinkComponent < ViewComponent::Base
4
4
  include ::AhoyCaptain::CompareMode
5
5
  include ::AhoyCaptain::RangeOptions
6
6
  include ::AhoyCaptain::Rangeable
7
7
 
8
+ renders_many :links
9
+ renders_one :header
10
+
11
+ attr_reader :title, :classes
8
12
  def initialize(title: "", classes: "btn btn-sm btn-base-100 no-underline hover:bg-base-100")
9
13
  @classes = classes
10
14
  end
11
15
 
12
16
  # cheating
13
17
  def title
14
- self.with_option_content(options_for_option)
18
+ self.with_link_content(options_for_option)
15
19
 
16
20
  comparison_mode.label
17
21
  end
@@ -22,12 +26,12 @@ class AhoyCaptain::ComparisonLinkComponent < AhoyCaptain::DropdownLinkComponent
22
26
 
23
27
  def options_for_option
24
28
  [
25
- (link_to "Disable Comparison", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: false))),
26
- (link_to "Previous period", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :previous)), class: selected(:previous, :true)),
27
- (link_to "Year-over-year", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :year)), class: selected(:year)),
28
29
  (link_to "Custom period", "javascript:customComparisonModal.showModal()", class: selected(:custom)),
30
+ (link_to "Year-over-year", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :year)), class: selected(:year)),
31
+ (link_to "Previous period", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: :previous)), class: selected(:previous, :true)),
32
+ (link_to "Disable Comparison", AhoyCaptain::Engine.routes.url_helpers.root_path(**helpers.search_params.merge(comparison: false))),
29
33
 
30
- ].join.html_safe
34
+ ].reverse.join.html_safe
31
35
  end
32
36
 
33
37
  private
@@ -1,7 +1,6 @@
1
1
  module AhoyCaptain
2
2
  class RangeFromParams
3
3
  def self.from_params(params)
4
-
5
4
  compare = ComparisonMode.new(params)
6
5
  new(period: params[:period], start_date: params[:start_date], end_date: params[:end_date], date: params[:date], comparison: compare.enabled?(false), raw: params).tap { |instance| instance.build }
7
6
  end
@@ -0,0 +1,12 @@
1
+ <div class="mt-5" >
2
+ <div role="status" class="animate-pulse">
3
+ <div class="flex justify-between w-full mb-2">
4
+ <div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-32"></div>
5
+ <div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24"></div>
6
+ </div>
7
+ <% 10.times do |i| %>
8
+ <div class="h-6 bg-gray-200 dark:bg-gray-700 max-w-[<%= 100 - (i * 10) %>%] mb-2.5"></div>
9
+ <% end %>
10
+ <span class="sr-only">Loading...</span>
11
+ </div>
12
+ </div>
@@ -1,4 +1,7 @@
1
1
  <main class='w-screen overflow-hidden' data-action="combobox:init@window->application#comboboxInit">
2
+ <script id="tile-loader-template" type="template/html">
3
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
4
+ </script>
2
5
  <%= render AhoyCaptain::StickyNavComponent.new do |nav| %>
3
6
  <% nav.with_realtime_update do %>
4
7
  <%= turbo_frame_tag :realtime, src: realtime_path, data: { controller: "realtime", "realtime-interval-value" => AhoyCaptain.config.realtime_interval.to_i }, loading: :lazy %>
@@ -8,8 +11,32 @@
8
11
  <div class="grid grid-cols-1 lg:grid-cols-2 grid-flow-row gap-4 min-h-screen pb-4 max-w-6xl mx-auto">
9
12
  <%= render AhoyCaptain::TileComponent.new(wide: true, classes: "p-4 m-2") do |component| %>
10
13
  <% component.with_statistic_display do %>
11
- <%= turbo_frame_tag :stats, src: stats_path(search_params), loading: :lazy %>
14
+ <%= turbo_frame_tag :stats, src: stats_path(search_params), loading: :lazy, skeleton: false do %>
15
+ <div class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0">
16
+ <% 6.times do %>
17
+ <div class="relative px-4 md:px-6 w-1/2 my-4 w-auto group cursor-pointer" >
18
+ <div role="status" class="max-w-sm animate-pulse">
19
+ <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[120px] mb-2.5"></div>
20
+ <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5 max-w-[60px]"></div>
21
+ <span class="sr-only">Loading...</span>
22
+ </div>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ <% end %>
12
27
  <%= turbo_frame_tag :chart, src: stats_unique_visitors_path(search_params) do %>
28
+ <div role="status" class="p-4 animate-pulse md:p-6">
29
+ <div class="flex items-baseline mt-4 space-x-6">
30
+ <div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
31
+ <div class="w-full h-56 bg-gray-200 rounded-t-lg dark:bg-gray-700"></div>
32
+ <div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
33
+ <div class="w-full h-64 bg-gray-200 rounded-t-lg dark:bg-gray-700"></div>
34
+ <div class="w-full bg-gray-200 rounded-t-lg h-80 dark:bg-gray-700"></div>
35
+ <div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
36
+ <div class="w-full bg-gray-200 rounded-t-lg h-80 dark:bg-gray-700"></div>
37
+ </div>
38
+ <span class="sr-only">Loading...</span>
39
+ </div>
13
40
  <% end %>
14
41
  <% end %>
15
42
 
@@ -17,21 +44,23 @@
17
44
 
18
45
  <%= render AhoyCaptain::TileComponent.new(title: 'Top Sources') do |component| %>
19
46
  <% component.with_display_links do %>
20
- <div class="flex text-xs font-medium text-gray-400 space-x-2">
21
- <div class="relative inline-block text-left">
22
- <%= component.link_to "All", sources_path(search_params), data: { turbo_frame: "sources" } %>
23
- <%= render AhoyCaptain::DropdownLinkComponent.new(title: "Campaign") do |dropdown| %>
24
- <% %w{utm_source utm_medium utm_term utm_content utm_campaign}.each do |source| %>
25
- <%= dropdown.link_to source.titleize.gsub("Utm", "UTM"), public_send("campaign_#{source}_path".to_sym, **search_params), data: { turbo_frame: "sources" } %>
26
- <% end %>
47
+ <div class="flex text-xs font-medium text-gray-400 space-x-2">
48
+ <div class="relative inline-block text-left">
49
+ <%= component.link_to "All", sources_path(search_params), data: { turbo_frame: "sources" } %>
50
+ <%= render AhoyCaptain::DropdownLinkComponent.new(title: "Campaign") do |dropdown| %>
51
+ <% %w{utm_source utm_medium utm_term utm_content utm_campaign}.each do |source| %>
52
+ <%= dropdown.link_to source.titleize.gsub("Utm", "UTM"), public_send("campaign_#{source}_path".to_sym, **search_params), data: { turbo_frame: "sources" } %>
27
53
  <% end %>
28
- </div>
54
+ <% end %>
29
55
  </div>
56
+ </div>
30
57
 
31
58
 
32
59
  <% end %>
33
60
  <% component.with_statistic_display do %>
34
- <%= turbo_frame_tag :sources, src: sources_path(search_params), loading: :lazy %>
61
+ <%= turbo_frame_tag :sources, src: sources_path(search_params), loading: :lazy do %>
62
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
63
+ <% end %>
35
64
  <% end %>
36
65
  <% component.with_details_cta do %>
37
66
  <button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#sources" class="link no-underline ">Details</button>
@@ -51,7 +80,9 @@
51
80
 
52
81
  <% end %>
53
82
  <% component.with_statistic_display do %>
54
- <%= turbo_frame_tag :pages, src: top_pages_path(search_params), loading: :lazy %>
83
+ <%= turbo_frame_tag :pages, src: top_pages_path(search_params), loading: :lazy do %>
84
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
85
+ <% end %>
55
86
  <% end %>
56
87
  <% component.with_details_cta do %>
57
88
  <button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#pages" class="link no-underline ">Details</button>
@@ -70,7 +101,10 @@
70
101
  </div>
71
102
  <% end %>
72
103
  <% component.with_statistic_display do %>
73
- <%= turbo_frame_tag :geography, src: locations_map_path(search_params), loading: :lazy %>
104
+ <%= turbo_frame_tag :geography, src: locations_map_path(search_params), loading: :lazy do %>
105
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
106
+
107
+ <% end %>
74
108
  <% end %>
75
109
  <% component.with_details_cta do %>
76
110
  <button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#geography" class="link no-underline ">Details</button>
@@ -88,7 +122,10 @@
88
122
  </div>
89
123
  <% end %>
90
124
  <% component.with_statistic_display do %>
91
- <%= turbo_frame_tag :devices, src: devices_browsers_path(search_params), loading: :lazy %>
125
+ <%= turbo_frame_tag :devices, src: devices_browsers_path(search_params), loading: :lazy do %>
126
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
127
+
128
+ <% end %>
92
129
  <% end %>
93
130
  <% component.with_details_cta do %>
94
131
  <button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#devices" class="link no-underline ">Details</button>
@@ -119,7 +156,10 @@
119
156
  <% end %>
120
157
  <% component.with_statistic_display do %>
121
158
  <div class="p-4">
122
- <%= turbo_frame_tag :goals, src: goals_path(search_params), loading: :lazy %>
159
+ <%= turbo_frame_tag :goals, src: goals_path(search_params), loading: :lazy do %>
160
+ <%= render '/ahoy_captain/layouts/shared/tile_loader' %>
161
+ <% end %>
162
+
123
163
  </div>
124
164
  <% end %>
125
165
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= turbo_frame_tag :stats, data: { controller: "active-frame-link" } do %>
2
- <dl class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0" data-controller="active-links" data-active-links-classes-value='["text-primary"]'>
2
+ <div class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0" data-controller="active-links" data-active-links-classes-value='["text-primary"]'>
3
3
  <% if @presenter.send(:range).realtime? %>
4
4
  <%= render stats_container(@presenter.unique_visitors, stats_unique_visitors_url(search_params), "Unique Visits (30 min)", :number_with_delimiter, true) %>
5
5
  <%= render stats_container(@presenter.total_pageviews, stats_total_pageviews_path(search_params), "Total Pageviews (30 min)", :number_with_delimiter) %>
@@ -11,5 +11,5 @@
11
11
  <%= render stats_container(@presenter.bounce_rate, stats_bounce_rates_path(search_params), "Bounce Rate", :number_with_delimiter) %>
12
12
  <%= render stats_container(@presenter.visit_duration, stats_visit_durations_url(search_params), "Visit Duration", :number_to_duration) %>
13
13
  <% end %>
14
- </dl>
14
+ </div>
15
15
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module AhoyCaptain
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  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.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshmn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-19 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -388,6 +388,7 @@ files:
388
388
  - app/assets/manifest/ahoy_captain/manifest.js
389
389
  - app/components/ahoy_captain/combobox_component.html.erb
390
390
  - app/components/ahoy_captain/combobox_component.rb
391
+ - app/components/ahoy_captain/comparison_link_component.html.erb
391
392
  - app/components/ahoy_captain/comparison_link_component.rb
392
393
  - app/components/ahoy_captain/dropdown_button_component.html.erb
393
394
  - app/components/ahoy_captain/dropdown_button_component.rb
@@ -528,6 +529,7 @@ files:
528
529
  - app/views/ahoy_captain/funnels/show.html.erb
529
530
  - app/views/ahoy_captain/goals/index.html.erb
530
531
  - app/views/ahoy_captain/layouts/application.html.erb
532
+ - app/views/ahoy_captain/layouts/shared/_tile_loader.html.erb
531
533
  - app/views/ahoy_captain/locations/cities/index.html+details.erb
532
534
  - app/views/ahoy_captain/locations/cities/index.html.erb
533
535
  - app/views/ahoy_captain/locations/countries/index.html+details.erb