Walkthrough
Let's do a quick walkthrough of some KickPlan basics using the SDK and the command line. You'll need to install the SDK before starting this guide.
For this walkthrough, we're going to bee adding the Ruby SDK to a Rails app, but the process is similar for other languages and frameworks.
First choose one of the 👩💻 SDKs in the language of your choice. In this walkthrough, we're going to be using the Ruby SDK.
Add the following to your Gemfile and run bundle install.
Create an initializer called kickplan.rb and add the following.
See the SDK docs for a full list of configuration options.
Set environment variables for your control plane endpoint URL and your API key.
You will need to generate an API key from the Settings/API Keys screen in the Kickplan App.
Your control plane endpoint URL will be provided by Kickplan Support during onboarding. It looks something like this (note the /api at the end):
https://example-organization-name.fly.dev/api
In the Rails console, let's check that everything is working.
Enter Kickplan::config.endpoint and confirm the listed endpoint is correct.
All good? Great, let's have some fun.
Now we're going to start modeling a very simple demo application from the command line. Lets say we are running a To-Do List App with two plans, Basic and Pro, which are differentiated by the number of lists you're allowed to create. Basic plans can have 3 lists, Pro plans can have 10 lists.
Let's create a Feature called lists and model the different variants we want to support in the Kickplan app.
Enter lists as the key, Lists as the name, and add a Description if you like.
Now enter the variants for this feature. In this case, we want to define basic and pro variants that are set to 3 and 10, respectively. If you wanted to allow the Pro plan to create unlimited lists, you'd just set the value to a very high integer, say 99999.
You can also define the default behaviors for when the feature is on and off.
Click Create and your feature should look something like the following.
Back in the Rails console, let's retrieve details of our feature.
You should get a response that looks something like:
#<Kickplan::Schemas::Resolution key="lists" value=3 error_code=nil error_message=nil metadata=nil reason=nil variant=nil>
Notice that our default value from the basic variant (ie, 3) is returned.
Features are good, but they are usually part of a Plan, so let's create a couple of Plans.
In the Kickplan app, navigate to the Plans section and create a Basic and a Pro plan. Under each plan, select Feature Access, and click Add Feature.
Select the lists feature and for Setting, select "Always variant below". Set the Basic Plan lists feature variant to basic (3 lists), and the Pro Plan lists feature variant to pro (10 lists).
In practice, features and plans only become valuable when you connect them to the accounts in your product. Let's create one from the console.
In the example above, we mapped the user id to the key (as a string), the user name to the name property, and set the account's plans to "pro" using the plan key.
To retrieve account-level access to a feature, we can pass the account key as context and Kickplan will respond with the corresponding feature values.