Skip to content

Commit

Permalink
Merge pull request #5284 from samvera/analytics-parser-fallback
Browse files Browse the repository at this point in the history
provide a NullAnalyticsParser if no analytics provider is given
  • Loading branch information
dlpierce authored Dec 10, 2021
2 parents 85c8c7c + f937888 commit 6ecff5a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/services/hyrax/analytics.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# frozen_string_literal: true
module Hyrax
module Analytics
##
# a completely empty module to include if no parser is configured
module NullAnalyticsParser; end

def self.provider_parser
"Hyrax::Analytics::#{Hyrax.config.analytics_provider.to_s.capitalize}"
"Hyrax::Analytics::#{Hyrax.config.analytics_provider.to_s.capitalize}".constantize
rescue NameError => err
Hyrax.logger.warn("Couldn't find an Analtics provider matching "\
" #{Hyrax.config.analytics_provider}. Loading " \
" NullAnalyticsProvider.\n#{err.message}")
NullAnalyticsParser
end
include provider_parser.constantize

include provider_parser
end
end

0 comments on commit 6ecff5a

Please sign in to comment.