trevosdk

Trevo server SDK for Ruby — deterministic variant assignment and event tracking for Trevo experiments. Zero dependencies; Ruby 3.2+.

gem install trevosdk
# config/initializers/trevosdk.rb (Rails) or anywhere at boot
Trevosdk.init(ENV.fetch("TREVO_SECRET_KEY"))

variant = Trevosdk.client.get_variant("checkout-cta", user_id: current_user.id)
if variant == "treatment"
  # alternate experience
end

Trevosdk.client.track("checkout_started", user_id: current_user.id, properties: {plan: "pro"})

get_variant reads an immutable in-memory config snapshot — no network call — safe from Rails controllers, Sidekiq jobs, and scripts alike. Config refresh and event delivery run on background threads; events flush at process exit, or deterministically via flush / close.

Assignment is byte-identical to every other Trevo SDK: the same user gets the same variant in the browser and on the backend, verified against the shared conformance corpus.

Full docs at docs.trevosdk.com.