NameError (uninitialized constant SnowplowTracker::SelfDescribingJson): when making a snowplow tracker in ruby

63 Views Asked by At

I get the error: NameError (uninitialized constant SnowplowTracker::SelfDescribingJson): When I try to initialize a Self describing JSON in ruby. Heres some example code that fails:

require 'snowplow-tracker'
require 'contracts'
require 'webmock'

e = SnowplowTracker::Emitter.new('com.acme')
t = SnowplowTracker::Tracker.new(e)
t.track_self_describing_event(SnowplowTracker::SelfDescribingJson.new(
  "iglu:com.example_company/save_game/jsonschema/1-0-2",
  {
    "saveId" => "4321",
    "level" => 23,
    "difficultyLevel" => "HARD",
    "dlContent" => true
  }
))

Strangly Emitter and Tracker will not throw an error. Heres some more context:

  • Using Ruby 2.5.5
  • gemfile contains all of the requirements and is bundled
1

There are 1 best solutions below

0
On

I solved this. in my gemfile I had:

    gem 'contracts', '~> 0.16.0'
    gem 'webmock', '~> 3.8', '>= 3.8.3'
    gem 'snowplow-tracker'

should have been:

    gem 'contracts', '~> 0.11.0'
    gem 'webmock', '~> 3.8', '>= 3.8.3'
    gem 'snowplow-tracker', '~> 0.6.1'

If you get this error check what version's are available here: https://rubygems.org/gems/snowplow-tracker/versions/0.6.1

The tracker also depended on an older version of contracts but bundle told me what one to use.