Makitoo library

JavaScript

When you are successfully logged in, you can create your application and retrieve the configuration snippets from our integration guide.

You should import Makitoo JavaScript library at the beginning of your <head> tag of your html pages:

<script src="https://features.makitoo.com/js/last/makitoo.min.js"
        data-application="APPLICATION-TOKEN">
</script>

Please note, you need to replace the APPLICATION-TOKEN by the one given in the integration guide.

Identifying users

You can map any non sensitive information in the user object.

// You may use only a string as an identifier (like an email address)
var user = "user-unique-id";

// Or create an object to add attributes
var user = {
    id: "user-unique-id",
    attributes : {
        email: "user@example.com",
        society:"makitoo"
    }
};

mkt.identify(user);

It is recommended to identify the current user to enable advanced audience targeting based on your own attributes.

Environments

Two environments are available, “production” and “test”.

The environment should be set to “test” only for testing purposes, this allows you to have a public configuration for your production environment, and a private configuration to test your developments without interfering with your users.

In order to switch your website from “production” to “test” environment, just add the following data-environment attribute to the previous installation snippet.

<script src="https://features.makitoo.com/js/last/makitoo.min.js"
        data-application="APPLICATION-TOKEN"
        data-environment="test">
</script>

Collect events

You can send KPIs events to measure key metrics (KPIs) for your business.

Use this snippet to track custom events within your application.

// Replace KPI-EVENT with the event name of your KPI.
mkt.track("KPI-EVENT");

To attach some properties to an event, you can add them as key-value pairs.

// Replace KPI-EVENT with the event name of your KPI.
mkt.track("KPI-EVENT", {
    "age": 18,
    "type": "premium-user"
});

Feature flag

Thanks to Makitoo, you can easily ask the library if one feature is enabled or not.

// Replace FEATURE-NAME with the name of your feature
if (mkt.isActive("FEATURE-NAME")) {
    // Enabled for this user
} else {
    // Disabled for this user
}

Default value

You can provide a default value while interrogating a feature.

// Replace FEATURE-NAME with the name of your feature
if (mkt.isActive("FEATURE-NAME", true)) {
    // ...
}

If our library cannot answer for miscellaneous reasons, the default value will be returned. Please note that this default value is set to ‘false’ if omitted.

Feature success

Knowing that a feature is enabled is far different from using this feature.

That’s why, here at Makitoo we provide you a way to send a Feature Usage event when a feature is successfully used.

// Replace FEATURE-NAME with the name of your feature
mkt.success("FEATURE-NAME");

Examples

Jquery

It’s easy to show or hide a feature within a JQuery application.

For example, if you want to feature-flag a button.

<button id="myAwesomeButton">I'm awesome!</button>

You can easily show or hide the button with a JQuery script.

// Show button if "My awesome button" is active
if (mkt.isActive("My awesome button")) {
  $('#myAwesomeButton').show();
} else {
  $('#myAwesomeButton').hide();
}

You can also send a Feature Usage event when your feature is successfully used. Here, it is when someone click on this awesome button.

$('#myAwesomeButton').click(function() {
    mkt.success('My awesome button');
});

AngularJS 1.x

To feature flag a DOM element with AngularJS 1.x, you can create a directive to show or hide your component.

myModule.directive('makitooFeature', [function(){
    return {
        restrict: 'A',
        link: function(scope, element, attrs){
            attrs.$observe('makitooFeature', function(value){
                if (mkt.isActive(value)){
                    element.show();
                }else{
                    element.hide();
                }
            });
        }
    }
}]);

You can use the directive directly in your html and also track feature usage with the native directive ng-click.

<button makitoo-feature="My awesome button"
        ng-click="mkt.success('My awesome button')">
    I'm awesome!
</button>

PHP

First, you should create your account on https://features.makitoo.com/.

When you are successfully logged in, you can create your application and retrieve the configuration snippets from our integration guide.

You can use Makitoo with composer or by cloning our php library.

Git repository Clone the repository from Github into your favorite working directory.

git clone https://github.com/Makitoo/feature-flag-php

You can now import the Makitoo library by using the following snippet.

<?php
    require_once("/path/to/makitoo-php/makitoo.php");
?>

Composer Add Makitoo library to your composer.json file.

composer require makitoo/feature-flag-php

Initializing Makitoo library

Before using the Makitoo library, you have to initialize it.

<?php
    $mkt = Makitoo\Makitoo::create("APPLICATION-TOKEN");
?>

Please note, you need to replace the APPLICATION-TOKEN by the one given in the integration guide.

Environments

Two environments are available, “production” and “test”.

The environment should be set to “test” only for testing purposes, this allows you to have a public configuration for your production environment, and a private configuration to test your developments without interfering with your users.

In order to switch your website from “production” to “test” environment, just use add an option to the library initialization.

<?php
    $mkt = Makitoo\Makitoo::create("APPLICATION-TOKEN", [
        "environmentName" => "test"
    ]);
?>

Please take a loot at the Php Extra options section to learn more about them.

Collect events

You can send KPIs events to measure key metrics (KPIs) for your business.

Use this snippet to track custom events within your application.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace KPI-EVENT with the event name of your KPI.
    $mkt->track("KPI-EVENT", $user);
?>

To attach some properties to an event, you can add them as an associate array.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace KPI-EVENT with the event name of your KPI.
    $mkt->track("KPI-EVENT", $user, [
        "amount" => 42,
        "currency" => "$"
    ]);
?>

Feature flag

Thanks to Makitoo, you can easily ask the library if one feature is enabled or not.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace FEATURE-NAME with the name of your feature
    if ($mkt->isActive("FEATURE-NAME", $user)) {
        // Enabled for this user
    } else {
        // Disabled for this user
    }
?>

Default value

You can provide a default value while interrogating a feature.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace FEATURE-NAME with the name of your feature
    if ($mkt->isActive("FEATURE-NAME", $user, true)) {
        // ...
    }
?>

If our library cannot answer for miscellaneous reasons, the default value will be returned. Please note that this default value is set to ‘false’ if omitted.

Feature success

Knowing that a feature is enabled is far different from using this feature.

That’s why, here at Makitoo we provide you a way to send a Feature Usage event when a feature is successfully used.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace FEATURE-NAME with the name of your feature
    $mkt->success("FEATURE-NAME", $user);
?>

Extra Options

There is several options you can use during the initialization.

Parameter Name Definition Default value
verbose Log details False
cache Implementation of the psr16 Simple implementation using SESSION
ssl Use SSL in sending data routine False
environmentName Targeted environment Production

Example

<?php
    $mkt = Makitoo\Makitoo::create("APPLICATION-TOKEN", [
        "verbose" => true,
        "ssl" => true,
        "environmentName" => "test"
    ]);
?>

Examples

The following example uses both the Makitoo library for PHP and JavaScript.

The PHP one is used to render the html content and hiding one disabled feature.

Whereas, the JavaScript one is used to send KPI & Success events.

<?php
    // Include Makitoo 4 PHP Lib
    require_once("/path/to/makitoo-php/makitoo.php");

    // Instantiate Makitoo 4 PHP Object
    $mkt = Makitoo\Makitoo::create("APPLICATION-TOKEN");

    // Define a userId
    $userId = "user-unique-identifier";
?>


<html>
    <head>
        <title>PHP - JS Makitoo example</title>

        <!-- Include Makitoo 4 JS Lib -->
        <script src="https://features.makitoo.com/js/last/makitoo.min.js"
                data-application="APPLICATION-TOKEN">
        </script>


        <script>
            /*
             * Initialize Makitoo 4 JS with PHP userId
             * This snippet is the most important one
             * It will make the bridge between the two libraries
             *
             * For the sake of example, we directly output the PHP variable inside JavaScript code.
             */
            mkt.setInstallationId(<?php echo "'".$userId."'"; ?>);
        </script>
    </head>
    <body>
        <button onclick="always_here_button()">
            Always here button
        </button>


        <script>
            window.always_here_button = function(){
                mkt.track('always_here_button');
            };
        </script>

        <!-- Hide the second button is the feature 'featured_flagged_button' is disabled -->
        <?php if ($mkt->isActive('featured_flagged_button', $userId, false)): ?>
            <button onclick="featured_flagged_button()">
                Featured flagged button
            </button>
            <script>
                window.featured_flagged_button = function(){
                    mkt.success('featured_flagged_button');
                };
            </script>
        <?php endif; ?>

    </body>
</html>

Ruby

Install the library

First, you should create your account on https://features.makitoo.com/.

When you are successfully logged in, you can create your application and retrieve the configuration snippets from our integration guide.

You can install Makitoo with gem or with bundler.

Gem

Install the dependency.

gem install makitoo-feature_flag

Bundler

Add Makitoo library to your Gemfile.

gem 'makitoo-feature_flag'

Then install the dependency.

bundle install

Once the library is installed, you can now import it by using the following snippet.

require 'makitoo/feature_flag'

Initializing Makitoo library

Before using the Makitoo library, you have to initialize it.

mkt = Makitoo::FeatureFlag::Client.new('APPLICATION-TOKEN')

Please note, you need to replace the APPLICATION-TOKEN by the one given in the integration guide.

Environments

Two environments are available, “production” and “test”.

The environment should be set to “test” only for testing purposes, this allows you to have a public configuration for your production environment, and a private configuration to test your developments without interfering with your users.

In order to switch your website from “production” to “test” environment, just use add an option to the library initialization.

Makitoo::FeatureFlag::Client.new('APPLICATION-TOKEN', {
    environment_name: 'test'
})

Please take a loot at the Extra options ruby section to learn more about them.

Identify your users

Tracking events, targeted feature flag and measuring their effects are relevant only if users are identified right ?

A simple string which represents the user id can be sufficient, but if you want more data, a User object can be created with an identifier and attributes.

user = Makitoo::FeatureFlag::User.new('user-id-here', {
    plan: 'free',
    group: 'beta-tester'
})

Use the created user reference for the future track, is_active and success methods.

Collect events

You can send KPIs events to measure key metrics (KPIs) for your business.

Use this snippet to track custom events within your application.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace KPI-EVENT with the event name of your KPI.
    $mkt->track("KPI-EVENT", $user);
?>

To attach some properties to an event, you can add them as an associate array.

<?php
    // You may use only a string as an identifier (like an email address)
    $user = "user-unique-identifier"

    // Or create an associative array to add attributes
    $user = [
        "id" => "user-unique-identifier",
        "attributes" => [
            "email" => "user@example.com",
            "company" => "makitoo"
        ]
    ];

    // Replace KPI-EVENT with the event name of your KPI.
    $mkt->track("KPI-EVENT", $user, [
        "amount" => 42,
        "currency" => "$"
    ]);
?>

Feature flag

Thanks to Makitoo, you can easily ask the library if one feature is enabled or not.

# For the sake of example, a string is used as a user
user = "user-unique-identifier"

# Replace FEATURE-NAME with the name of your feature
if mkt.is_active("FEATURE-NAME", user)
    # Enabled for this user
else
    # Disabled for this user
end

Default value

You can provide a default value while interrogating a feature.

# For the sake of example, a string is used as a user
user = "user-unique-identifier"

# Replace FEATURE-NAME with the name of your feature
if mkt.is_active("FEATURE-NAME", user, true)
    # ...
end

If our library cannot answer for miscellaneous reasons, the default value will be returned. Please note that this default value is set to ‘false’ if omitted.

Feature success

Knowing that a feature is enabled is far different from using this feature.

That’s why, here at Makitoo we provide you a way to send a Feature Usage event when a feature is successfully used.

# For the sake of example, a string is used as a user
user = "user-unique-identifier"

# Replace FEATURE-NAME with the name of your feature
mkt.success("FEATURE-NAME", user)

Extra Options for Ruby

There is several options you can use during the initialization.

Parameter Name Definition Default value
cache A key / value cache Simple in memory cache
ssl Use SSL in sending data routine False
environmentName Targeted environment Production

Example

mkt = Makitoo::FeatureFlag::Client.new("APPLICATION-TOKEN", {
    verbose: true,
    ssl: true,
    environmentName: "test"
})

Custom cache handler

Here is a class without implementation to complete in order to create a custom cache handler:

class CustomCache
  def get(key)
    # Return the value for the key, nil if absent
  end

  def put(key, value)
    # Store in the cache the value for the corresponding key
  end
end

Java

First, you should create your account on https://features.makitoo.com/.

When you are successfully logged in, you can create your application and retrieve the configuration snippets from our integration guide.

You can use Makitoo with Maven:

<dependency>
    <groupId>com.makitoo</groupId>
    <artifactId>feature-flag</artifactId>
    <version>0.0.1</version>
</dependency>

or with gradle :

compile group: 'com.makitoo', name: 'feature-flag', version: '0.0.1'

Initializing Makitoo library

Before using the Makitoo library, you have to initialize it.

import com.makitoo.Makitoggle;

Makitoggle mkt = new Makitoggle("APPLICATION-TOKEN");

Please note, you need to replace the APPLICATION-TOKEN by the one given in the integration guide.

Environments

Two environments are available, “production” and “test”.

The environment should be set to “test” only for testing purposes, this allows you to have a public configuration for your production environment, and a private configuration to test your developments without interfering with your users.

In order to switch your website from “production” to “test” environment, just use add an option to the library initialization.

import com.makitoo.Makitoggle;
import java.util.Properties;


Makitoggle mkt = new Makitoggle(new Properties(),"APPLICATION-TOKEN", "test");

Collect events

You can send KPIs events to measure key metrics (KPIs) for your business.

Use this snippet to track custom events within your application.

import com.makitoo.Feature;
import com.makitoo.Makitoggle;
import com.makitoo.User;

// identify user
User user = new User("USER_ID");

mkt.track(new Event("KPI-EVENT"), user);

To attach some properties to an event, you can add them as an associate array.

import com.makitoo.Feature;
import com.makitoo.Makitoggle;
import com.makitoo.User;

// identify user
User user = new User("USER_ID");

mkt.track(
        new Event("something")
            .withProperty("age", "18")
            .withProperty("type", "premium-user"),
        user);

Feature flag

Thanks to Makitoo, you can easily ask the library if one feature is enabled or not.

import com.makitoo.Feature;
import com.makitoo.Makitoggle;
import com.makitoo.User;

// define my feature
Feature feature = new Feature("MY FEATURE");

// identify user
User user = new User("USER_ID")
    .withProperty("name", "USER_NAME")
    .withIP(request.getRemoteAddr())
    .withUserAgent(request.getHeader("User-Agent"));

if (mkt.isActive(feature,user) ) {
    // MY FEATURE is active
} else {
    // MY FEATURE is not active
}

Default value

You can provide a default value while interrogating a feature.

import com.makitoo.Feature;

Feature feature = new Feature("MY FEATURE").withDefaultValue(true);

If our library cannot answer for miscellaneous reasons, the default value will be returned. Please note that this default value is set to ‘false’ if omitted.

Feature success

Knowing that a feature is enabled is far different from using this feature.

That’s why, here at Makitoo we provide you a way to send a Feature Usage event when a feature is successfully used.

makitoo.success(feature, user);

Makitoo bridges

In order to correlate your data with your Makitoo feature flags, you need to initialize a bridge. This is usually a single line snippet.

Segment

JavaScript

analytics.ready(mkt.initSegment);

PHP

<?php
    $segmentUserId = "user-unique-identifier-used-for-segment";
    $makitooUserId = "user-unique-identifier-used-for-makitoo";
    $mkt->initSegment($segmentUserId, $makitooUserId);
?>

Ruby

segment_user_id = "user-unique-identifier-used-for-segment"

# For the sake of example, a string is used as a user
user = "user-unique-identifier-used-for-makitoo"

mkt.init_segment(segment_user_id, user)

The next incoming events from segment will be available as KPIs in your dashboard.

Mixpanel

JavaScript

mkt.initMixPanel();

PHP

Available soon. Please ask us if you want to have an early access.

Ruby

Available soon. Please ask us if you want to have an early access.

New Relic

JavaScript

mkt.initNewRelic();

PHP

Available soon. Please ask us if you want to have an early access.

Ruby

Available soon. Please ask us if you want to have an early access.

Keen IO

JavaScript

mkt.initKeenIo();   

PHP

Available soon. Please ask us if you want to have an early access.

Ruby

Available soon. Please ask us if you want to have an early access.

Google Analytics

JavaScript

First of all, in order to create a bridge between Google Analytics and Makitoo, you have to create a custom dimension in your Google Analytics account. In order to so, you can use this link.

_images/ga-custom-dimension.png

Then, report the index of the custom dimension in your Google Analytics Integration

_images/ga-custom-index.png

Once everything done, you simply have to use this snippet to create the bridge :

ga('create', 'XX-XXXXXXXX-X', 'auto');

ga(function(tracker){
    mkt.ready(function(mkt){
        mkt.initGoogleAnalytics(tracker, 1);
    });
});

PHP

Available soon. Please ask us if you want to have an early access.

Ruby

Available soon. Please ask us if you want to have an early access.