All Projects → justeat → Justtweak

justeat / Justtweak

Licence: apache-2.0
JustTweak is a framework for feature flagging and A/B testing for iOS apps.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Justtweak

Unleash
Unleash is the open source feature toggle service.
Stars: ✭ 4,679 (+3340.44%)
Mutual labels:  feature, experiments
Stripe Firebase Extensions
Repository of Firebase Extensions built by Stripe.
Stars: ✭ 133 (-2.21%)
Mutual labels:  firebase
Mlogger
a lightweight and simple logger for Machine Learning
Stars: ✭ 122 (-10.29%)
Mutual labels:  experiments
Combinefirebase
Combine wrapper on Google's iOS Firebase library.
Stars: ✭ 126 (-7.35%)
Mutual labels:  firebase
Pyrebase
A simple python wrapper for the Firebase API.
Stars: ✭ 1,731 (+1172.79%)
Mutual labels:  firebase
Laravel Fcm
Firebase Cloud Messaging (FCM) sender for Laravel
Stars: ✭ 129 (-5.15%)
Mutual labels:  firebase
Mapswipe
MapSwipe mobile application
Stars: ✭ 121 (-11.03%)
Mutual labels:  firebase
Restaurantapp
Android Restaurant Application with QR Code Reader
Stars: ✭ 133 (-2.21%)
Mutual labels:  firebase
React Shopping Cart
🛍️ Simple ecommerce cart application built with React Redux
Stars: ✭ 1,808 (+1229.41%)
Mutual labels:  firebase
Petshop
Pet Shop is an e-commerce application for Android built with Flutter (iOS to come soon).
Stars: ✭ 127 (-6.62%)
Mutual labels:  firebase
Opennpd
C++ detect and train of "A Fast and Accurate Unconstrained Face Detector".
Stars: ✭ 126 (-7.35%)
Mutual labels:  feature
Photoblog Android Blog App
Stars: ✭ 124 (-8.82%)
Mutual labels:  firebase
Timy Messenger
Timy - open source mobile app for groups to communicate and organize themselves. Built with flutter.
Stars: ✭ 1,745 (+1183.09%)
Mutual labels:  firebase
Quickstart Cpp
Firebase Quickstart Samples for C++
Stars: ✭ 123 (-9.56%)
Mutual labels:  firebase
Nextjs Vercel Firebase
Next.js app using API routes to connect with Firestore.
Stars: ✭ 133 (-2.21%)
Mutual labels:  firebase
Paleontologas
Source code of the most popular Paleontological mobile app in the world! Programming sandbox.
Stars: ✭ 122 (-10.29%)
Mutual labels:  firebase
Firebasecloudmessaging Android
FCM is just a demo of Android Application which implement Firebase Cloud Messaging. It made for Google I/O Extended 2016 Bangkok
Stars: ✭ 126 (-7.35%)
Mutual labels:  firebase
Pushnotifications
🐉 A macOS, Linux, Windows app to test push notifications on iOS and Android
Stars: ✭ 1,813 (+1233.09%)
Mutual labels:  firebase
Fluttergram
A fully functional Instagram clone written in Flutter using Firebase / Firestore
Stars: ✭ 1,944 (+1329.41%)
Mutual labels:  firebase
Howlstagram
Stars: ✭ 132 (-2.94%)
Mutual labels:  firebase

JustTweak Banner

JustTweak

Build Status Version License Platform

JustTweak is a framework for feature flagging and A/B testing for iOS apps. It provides a simple facade interface interacting with multiple providers that are queried respecting a given priority. Tweaks represent flags used to drive decisions in the client code.

With JustTweak you can achieve the following:

  • use a JSON local configuration providing default values for experimentation
  • use a number of remote configuration providers such as Firebase and Optmizely to run A/B tests and feature flagging
  • enable, disable, and customize features locally at runtime
  • provide a dedicated UI for customization (this comes particularly handy for feature that are under development to showcase it to stakeholders)

Installation

JustTweak is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "JustTweak"

Implementation

Integration

  • define a JSON configuration file including your features (you can use the included ExampleConfiguration.json as a template)
  • define your features and A/B tests in your services such as Firebase and Optmizely (optional)
  • configure the JustTweak stack as following
static let tweakManager: TweakManager = {
    // mutable configuration (to override tweaks from other configurations)
    let userDefaultsConfiguration = UserDefaultsConfiguration(userDefaults: UserDefaults.standard)

    // remote configurations (optional)
    let optimizelyConfiguration = OptimizelyConfiguration()
    optimizelyConfiguration.userId = <#user_id#>
    let firebaseConfiguration = FirebaseConfiguration()

    // local JSON configuration (default tweaks)
    let jsonFileURL = Bundle.main.url(forResource: "ExampleConfiguration", withExtension: "json")!
    let localConfiguration = LocalConfiguration(jsonURL: jsonFileURL)

    // priority is defined by the order in the configurations array (from highest to lowest)
    let configurations: [Configuration] = [userDefaultsConfiguration,
                                           optimizelyConfiguration,
                                           firebaseConfiguration,
                                           localConfiguration]
    return TweakManager(configurations: configurations)
}()

The order of the objects in the configurations array defines the priority of the configurations.

The MutableConfiguration with the highest priority, such as UserDefaultsConfiguration in the example above, will be used to reflect the changes made in the UI (TweakViewController). The LocalConfiguration should have the lowest priority as it provides the default values from a local configuration and it's the one used by the TweakViewController to populate the UI.

Usage

The three main features of JustTweak can be accessed from the TweakManager instance to drive code path decisions.

  1. Checking if a feature is enabled
// check for a feature to be enabled
let enabled = tweakManager.isFeatureEnabled("some_feature")
if enabled {
    // enable the feature
} else {
    // default behaviour
}
  1. Get the value of a flag for a given feature. TweakManager will return the value from the configuration with the highest priority and automatically fallback to the others if no set value is found.

Use either tweakWith(feature:variable:) or the provided property wrappers.

// check for a tweak value
let tweak = tweakManager.tweakWith(feature: "some_feature", variable: "some_flag")
if let tweak = tweak {
    // tweak was found in some configuration, use tweak.value
} else {
    // tweak was not found in any configuration
}

@TweakProperty and @OptionalTweakProperty property wrappers are available to mark properties representing feature flags. Mind that by using these property wrappers, a static instance of TweakManager is needed.

@TweakProperty(fallbackValue: <#fallback_value#>,
               feature: <#feature_key#>,
               variable: <#variable_key#>,
               tweakManager: <#TweakManager#>)
var labelText: String
@OptionalTweakProperty(fallbackValue: <#nillable_fallback_value#>,
                       feature: <#feature_key#>,
                       variable: <#variable_key#>,
                       tweakManager: <#TweakManager#>)
var meaningOfLife: Int?
  1. Run an A/B test
// check for a tweak value
let variation = tweakManager.activeVariation(for: "some_experiment")
if let variation = variation {
    // act according to the kind of variation (e.g. "control", "variation_1")
} else {
    // default behaviour
}

Caching

The TweakManager provides the option to cache the tweak values in order to improve performance. Caching is disabled by default but can be enabled via the useCache property. When enabled, there are two ways to reset the cache:

  • call the resetCache method on the TweakManager
  • post a TweakConfigurationDidChangeNotification notification

Update a configuration at runtime

JustTweak comes with a ViewController that allows the user to edit the MutableConfiguration with the highest priority.

func presentTweakViewController() {
    let tweakViewController = TweakViewController(style: .grouped, tweakManager: <#TweakManager#>)

    // either present it modally
    let tweaksNavigationController =     UINavigationController(rootViewController:tweakViewController)
    tweaksNavigationController.navigationBar.prefersLargeTitles = true
    present(tweaksNavigationController, animated: true, completion: nil)

    // or push it on an existing UINavigationController
    navigationController?.pushViewController(tweakViewController, animated: true)
}

When a value is modified in any MutableConfiguration, a notification is fired to give the clients the opportunity to react and reflect changes in the UI.

override func viewDidLoad() {
    super.viewDidLoad()
    NotificationCenter.defaultCenter().addObserver(self,
                                                   selector: #selector(updateUI),
                                                   name: TweakConfigurationDidChangeNotification,
                                                   object: nil)
}

@objc func updateUI() {
    // update the UI accordingly
}

Customization

JustTweak comes with three configurations out-of-the-box:

  • UserDefaultsConfiguration which is mutable and uses UserDefaults as a key/value store
  • LocalConfiguration which is read-only and uses a JSON configuration file that is meant to be the default configuration
  • EphemeralConfiguration which is simply an instance of NSMutableDictionary

In addition, JustTweak defines Configuration and MutableConfiguration protocols you can implement to create your own configurations to fit your needs. In the example project you can find a few example configurations which you can use as a starting point.

License

JustTweak is available under the Apache 2.0 license. See the LICENSE file for more info.

  • Just Eat iOS team
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].