2021-11-09 01:13:00 -05:00
|
|
|
# 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
|
2021-11-22 22:12:38 -05:00
|
|
|
).transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
|
2021-11-09 01:13:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
override :hostname
|
|
|
|
def hostname
|
|
|
|
"#{uri.host}:#{uri.port}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def uri
|
|
|
|
strong_memoize(:snowplow_uri) do
|
|
|
|
uri = URI(ENV['SNOWPLOW_MICRO_URI'] || DEFAULT_URI)
|
|
|
|
uri = URI("http://#{ENV['SNOWPLOW_MICRO_URI']}") unless %w[http https].include?(uri.scheme)
|
|
|
|
uri
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-24 07:10:21 -05:00
|
|
|
private
|
|
|
|
|
2021-11-09 01:13:00 -05:00
|
|
|
override :cookie_domain
|
|
|
|
def cookie_domain
|
|
|
|
'.gitlab.com'
|
|
|
|
end
|
|
|
|
|
|
|
|
override :protocol
|
|
|
|
def protocol
|
|
|
|
uri.scheme
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|