Issues with Ruby Tracker on Ruby 2.5.5

The documentation for the Snowplow Ruby Tracker states that “The Snowplow Ruby Tracker is compatible with Ruby versions 1.9.3, 2.0.0, and 2.1.0.”
In a fit of denial I implemented one anyways on our app that uses ruby version 2.5.5. Now I get the error:
NameError (uninitialized constant SnowplowTracker::SelfDescribingJson):
When the following code gets run:
context = [ SnowplowTracker::SelfDescribingJson.new( 'iglu:com.my_company/schema/jsonschema/1-0-0', { 'variable' => value, } ) ]
I am able to set up the tracker and async emitter just fine with no errors. I was curious; Is this error due to the Ruby Version? Is 2.5.5 incompatible with the tracker? And if so, are the plans to make this tracker more widely available?

Thanks,

Hi @Preston-D

The Ruby tracker should be fine on more recent versions, the documentation is driven by the versions which travis runs against when build (which do need an update, I must admit).

I’ve tested it on 2.5.5, 2.6.5 and 2.7.0 and with the simple example below, it seems fine. The example below is sending events to a collector (Snowplow Micro) that I have running locally on my machine, please update the emitter URL and Port to point to your collector.

Assuming gem install snowplow-tracker has been run and installed.

require 'snowplow-tracker'

emitter = SnowplowTracker::AsyncEmitter.new("localhost", {
    :protocol => 'http',
    :method => 'post',
    :port => 9090,
    :buffer_size => 1
})

tracker = SnowplowTracker::Tracker.new(emitter)

tracker.track_screen_view('Move page', nil, [
    SnowplowTracker::SelfDescribingJson.new(
        'iglu:com.my_company/movie/jsonschema/1-0-0',
        {
            'movie_name' => 'Solaris'
        }
    )
])

tracker.flush

This sends an event and gives me the following output:

I, [2020-07-28T15:23:00.764433 #1137]  INFO -- : SnowplowTracker::AsyncEmitter initialized with endpoint http://localhost:9090/com.snowplowanalytics.snowplow/tp2
I, [2020-07-28T15:23:00.765074 #1137]  INFO -- : Starting synchronous flush
I, [2020-07-28T15:23:00.765158 #1137]  INFO -- : Attempting to send 1 request
I, [2020-07-28T15:23:00.765185 #1137]  INFO -- : Sending POST request to http://localhost:9090/com.snowplowanalytics.snowplow/tp2...
I, [2020-07-28T15:23:00.791366 #1137]  INFO -- : POST request to http://localhost:9090/com.snowplowanalytics.snowplow/tp2 finished with status code 200
I, [2020-07-28T15:23:00.791446 #1137]  INFO -- : Skipping sending events since buffer is empty
I, [2020-07-28T15:23:00.791485 #1137]  INFO -- : Finished synchronous flush

I was able to fix this by specifying the version of the ruby gem to be the latest of the snowplow tracker, like:
gem ‘snowplow-tracker’, ‘~> 0.6.1’

1 Like