Skip to content

Commit

Permalink
Add path to emitter config hash.
Browse files Browse the repository at this point in the history
The javascript tracker allows setting of the snowplow endpoint path. This change brings that feature to the ruby tracker.
  • Loading branch information
Rob LaRubbio committed Jul 25, 2019
1 parent 39fcfa2 commit 31c60bc
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 31c60bc

Please sign in to comment.