Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

on_ramp

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

on_ramp

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

OnRamp

This gem provides two related but distinct pieces of functionality:

  1. Percentage ramp ups of experiments that are intended to test load or the like
  2. Segmenting users into a/b variants for experimentation purposes

Installation

Add this line to your application's Gemfile:

gem 'on_ramp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install on_ramp

Usage

Configure the gem in an initializer using the configure method

# /initializers/experiment.rb
OnRamp.configure do |config|
    config.ab_experiments = "/initializers/experiments.yaml"
end

Your yaml file will look similar to the below:

experiment_name:
 ramp: 20
 variants:
   control: 50
   variant_a: 50

See below for example code.

Simple use case ramping only

If you want to slowly ramp out a change to a subset of users, the following code is the simplest way to do so. This is not the recommended way to run an experiment. For running an experiment see below OnRamp.ab_variant

# school.rb

def cool_name
  if OnRamp.ramped?(:experiment_name, owner.id)
    "COOOL" + name
  else
    name
  end
end

As you can see here, the #ramped? method will return true if the user is in the ramped up group and false if they aren't. As you adjust the ramping, more users will experience the ramped up code path.

Simple use case experiment

The ab_variant method does not necessarily return a value. It will return nil if the unique_id you've passed is not yet ramped up. If you have configured your experiment with 100% ramp, then #ab_variant will always return a value.

def cool_name_experiment
 case OnRamp.ab_variant(:cool_name, owner.id)
 when "variant_a"
   "COOOL" + name
 when "variant_b"
   "C000L" + name
 when "control"
   control_group_name
 else
   name
 end
end

It may be common to have control and non-ramped experiences be the same, it's very easy with the case else clause.

def cool_name_final
 case Experiment::ab_variant(:cool_name, owner.id)
 when "variant_a"
   "COOOL" + name
 when "variant_b"
   "C000L" + name
 else
   name
 end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rspec spec/ to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

FAQs

Package last updated on 26 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc