Skip to content

Commit

Permalink
fix ga4 stats not being able to retrieve events properly, add work sh…
Browse files Browse the repository at this point in the history
…ow to user vitals
  • Loading branch information
orangewolf committed Aug 12, 2024
1 parent bcaa9f6 commit 08a2fe5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 17 deletions.
10 changes: 1 addition & 9 deletions app/services/hyrax/analytics/ga4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ module Ga4
extend ActiveSupport::Concern
# rubocop:disable Metrics/BlockLength
class_methods do
def client
@client
end

def client=(value)
@client = value
end

# Loads configuration options from config/analytics.yml. You only need PRIVATE_KEY_PATH or
# PRIVATE_KEY_VALUE. VALUE takes precedence.
# Expected structure:
Expand Down Expand Up @@ -87,7 +79,7 @@ def account_info
end

def client
self.class.client ||= ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |conf|
@client ||= ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |conf|
conf.credentials = config.account_info
end
end
Expand Down
1 change: 0 additions & 1 deletion app/services/hyrax/analytics/ga4/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def initialize(start_date:,
end_date:,
dimensions: [{ name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }],
metrics: [{ name: 'eventCount' }])
super
@start_date = start_date.to_date
@end_date = end_date.to_date
@dimensions = dimensions
Expand Down
1 change: 0 additions & 1 deletion app/services/hyrax/analytics/ga4/events_daily.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def initialize(start_date:,
end_date:,
dimensions: [{ name: 'date' }, { name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }],
metrics: [{ name: 'eventCount' }])
super
@start_date = start_date.to_date
@end_date = end_date.to_date
@dimensions = dimensions
Expand Down
1 change: 0 additions & 1 deletion app/services/hyrax/analytics/ga4/visits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Analytics
module Ga4
class Visits < Hyrax::Analytics::Ga4::Base
def initialize(start_date:, end_date:, dimensions: [{ name: 'newVsReturning' }], metrics: [{ name: 'sessions' }])
super
@start_date = start_date.to_date
@end_date = end_date.to_date
@dimensions = dimensions
Expand Down
1 change: 0 additions & 1 deletion app/services/hyrax/analytics/ga4/visits_daily.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Analytics
module Ga4
class VisitsDaily < Hyrax::Analytics::Ga4::Base
def initialize(start_date:, end_date:, dimensions: [{ name: 'date' }, { name: 'newVsReturning' }], metrics: [{ name: 'sessions' }])
super
@start_date = start_date.to_date
@end_date = end_date.to_date
@dimensions = dimensions
Expand Down
5 changes: 3 additions & 2 deletions app/views/hyrax/users/_vitals.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<span class="fa fa-upload" aria-hidden="true"></span> <%= link_to_works(user) %>

<ul class="views-downloads-dashboard list-unstyled">
<li><span class="badge badge-optional dark-text"><%= user.total_file_views %></span> <%= t("hyrax.dashboard.stats.file_views").pluralize(user.total_file_views) %></li>
<li><span class="badge badge-optional dark-text"><%= user.total_file_downloads %></span> <%= t("hyrax.dashboard.stats.file_downloads").pluralize(user.total_file_downloads) %></li>
<li><span class="badge badge-optional dark-text"><%= user.total_work_views %></span> <%= t("hyrax.dashboard.stats.work_views").pluralize(user.total_views) %></li>
<li><span class="badge badge-optional dark-text"><%= user.total_file_views %></span> <%= t("hyrax.dashboard.stats.file_views").pluralize(user.total_file_views) %></li>
<li><span class="badge badge-optional dark-text"><%= user.total_file_downloads %></span> <%= t("hyrax.dashboard.stats.file_downloads").pluralize(user.total_file_downloads) %></li>
</ul>
</div>
5 changes: 3 additions & 2 deletions config/locales/hyrax.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,9 @@ en:
graph_reports: Customized Graph Reports
stats:
collections: Collections created
file_downloads: Download
file_views: View
work_views: Metadata View
file_downloads: File Download
file_views: File View
files: Files deposited
heading: Your Statistics
joined_on: Joined on
Expand Down

0 comments on commit 08a2fe5

Please sign in to comment.