Open jillpe opened 2 months ago
Confirmed, move forward with Google Analytics
# In Rails console in Rancher hyku-demo-hyrax
# getting the user that we know created viewed works
user = User.find_by email: 'support@notch8.com’
ids = []
depositor_field = 'depositor_ssim’
::FileSet.search_in_batches("#{depositor_field}:\"#{user.user_key}\"", fl: "id") do |group|
ids.concat group.map { |doc| doc["id"] }
end
# getting a work we know from Google Analytics was viewed (Horse)
f = Hyrax.query_service.find_by id: '64f11b7f-51f9-4c75-8c51-c0252932be92’
# checked that the work was included in the FileSet
ids.include? f.id.to_s
# => true
# returns an array of FileDownloadStat for the given work
FileDownloadStat.statistics(f, 1.week.ago, user)
# shows the client_email that should have access to the Google Analytics account to resolve "user doesn't have sufficient permissions" issue we saw when clicking the Analytics button
ENV['GOOGLE_ACCOUNT_JSON']
# creates a scheduled job, had to manually run the job
UserStatCollectionJob.perform_now
# when we first ran this it didn't take long enough, we needed to jumpstart it
Hyrax::UserStatImporter.new.import
# troublshooting
FileDownloadStat.where('date > ?', 1.day.ago).count
# => 0
FileDownloadStat.where('date > ?', 2.day.ago).destroy_all
# we did the following to trick the importer into starting again
UserStat.where(user_id: user.id).order(date: :asc).last
UserStat.where(user_id: user.id).order(date: :asc).last.destroy
# ran this again and it took longer
Hyrax::UserStatImporter.new.import
# Looked in Dashboard > Activity > Your activity > Profile
# Saw the downloads increase from 5 to 22
Summary
SOW Description of Work WVU’s Google or Motomo analytics account will be configured into the system to provide robust user, work, and collection level analytics in keeping with the Hyrax and Hyku standards.