Skip to content

Commit

Permalink
Merge 31c60bc into 39fcfa2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob LaRubbio committed Jul 25, 2019
2 parents 39fcfa2 + 31c60bc commit 80a2e19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/snowplow-tracker/emitters.rb
Expand Up @@ -28,6 +28,7 @@ class Emitter
include Contracts

@@ConfigHash = ({
:path => Maybe[String],
:protocol => Maybe[Or['http', 'https']],
:port => Maybe[Num],
:method => Maybe[Or['get', 'post']],
Expand All @@ -50,7 +51,8 @@ class Emitter
def initialize(endpoint, config={})
config = @@DefaultConfig.merge(config)
@lock = Monitor.new
@collector_uri = as_collector_uri(endpoint, config[:protocol], config[:port], config[:method])
path = config[:path].nil? ? config[:method] == 'get' ? '/i' : '/com.snowplowanalytics.snowplow/tp2' : config[:path]
@collector_uri = as_collector_uri(endpoint, config[:protocol], config[:port], path)
@buffer = []
if not config[:buffer_size].nil?
@buffer_size = config[:buffer_size]
Expand All @@ -70,9 +72,8 @@ def initialize(endpoint, config={})
# Build the collector URI from the configuration hash
#
Contract String, String, Maybe[Num], String => String
def as_collector_uri(endpoint, protocol, port, method)
def as_collector_uri(endpoint, protocol, port, path)
port_string = port == nil ? '' : ":#{port.to_s}"
path = method == 'get' ? '/i' : '/com.snowplowanalytics.snowplow/tp2'

"#{protocol}://#{endpoint}#{port_string}#{path}"
end
Expand Down

0 comments on commit 80a2e19

Please sign in to comment.