Skip to content

AB Test

Vinicius Stock edited this page Feb 19, 2019 · 3 revisions

AB Test type settings

Setting

Sail.set(:my_ab_test_setting, true)
Sail.set(:my_ab_test_setting, "true")

Getting

Sail.get(:my_ab_test_setting)
=> true

Sail.get(:my_ab_test_setting) do |setting_value|
  puts setting_value
end
=> true

Examples

If AB Test settings are set to true, they will randomly return true or false. If they are set to false, they will always return false. These can be used to test out functionality for a portion of the users. If you need to control the percentage for your ab tests, then the throttle setting is a better fit.

In this example, a mailer decides which promotional email to send based on the ab test setting.

# app/models/user.rb
class User < ApplicationRecord
  .
  .

  def send_promotional_email
    if Sail.get(:enable_new_promotional_email_tests)
      Mailer.new_promotional_email(to: "someone@domain.com").deliver_now
    else
      Mailer.old_promotional_email(to: "someone@domain.com").deliver_now
    end
  end
end
Clone this wiki locally