debian-mirror-gitlab/lib/gitlab/tracking/destinations/snowplow_micro.rb

63 lines
1.4 KiB
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
#
module Gitlab
module Tracking
module Destinations
class SnowplowMicro < Snowplow
include ::Gitlab::Utils::StrongMemoize
extend ::Gitlab::Utils::Override
DEFAULT_URI = 'http://localhost:9090'
override :options
def options(group)
super.update(
protocol: uri.scheme,
port: uri.port,
force_secure_tracker: false
2022-01-26 12:08:38 +05:30
).transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end
override :enabled?
def enabled?
true
2021-12-11 22:18:48 +05:30
end
override :hostname
def hostname
"#{uri.host}:#{uri.port}"
end
def uri
strong_memoize(:snowplow_uri) do
2022-08-13 15:12:31 +05:30
base = base_uri
uri = URI(base)
uri = URI("http://#{base}") unless %w[http https].include?(uri.scheme)
2021-12-11 22:18:48 +05:30
uri
end
end
2022-01-26 12:08:38 +05:30
private
2021-12-11 22:18:48 +05:30
override :cookie_domain
def cookie_domain
'.gitlab.com'
end
override :protocol
def protocol
uri.scheme
end
2022-08-13 15:12:31 +05:30
def base_uri
url = Gitlab.config.snowplow_micro.address
scheme = Gitlab.config.gitlab.https ? 'https' : 'http'
"#{scheme}://#{url}"
rescue Settingslogic::MissingSetting
2022-08-27 11:52:29 +05:30
DEFAULT_URI
2022-08-13 15:12:31 +05:30
end
2021-12-11 22:18:48 +05:30
end
end
end
end