npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-optimizely

v0.4.0

Published

Cordova plugin for the Optimizely Mobile SDKs

Downloads

11

Readme

Optimizely Cordova Plugin

iOS Build Build Status

Android Build Circle CI

Cordova Plugin for the Optimizely iOS and Android SDKs

Allows developers developing hybrids apps using Cordova platforms such as Phonegap, Crosswalk, Ionic, Intel XDK to use the Optimizely SDKs for A/B testing and beyond!

  • [Android SDK Version 1.4.1](http://developers.optimizely.com/android/changelog/index.html#\31 -4-1)
  • [iOS SDK Version 1.4.0](http://developers.optimizely.com/ios/changelog/index.html#\31 -4-0)

Table of Contents

  1. Usage
  2. Available Features
  3. Live Variables
  4. Code Blocks
  5. APIs

Installation

Edge

cordova plugin add https://github.com/optimizely/optimizely-cordova-plugin

Stable (via npm)

cordova plugin add cordova-plugin-optimizely

Uninstall plugin

Use the cordova CLI to remove the plugin

cordova plugin remove cordova-plugin-optimizely

Start A/B Testing!

  1. If you haven't already, sign up for an account at Optimizely

  2. Create a Android or iOS project

  3. Grab your project token

  4. Register Live Variables and Code Blocks

  5. Call startOptimizely with your token

window.optimizely.startOptimizely(<token>)
  .then(
    function(result) {
      // success callback
    },
    function(error) {
      // error callback
    }
  )

Available Features

The optimizely cordova plugin allows cordova based apps to use the Live Variable and Code Block features of the Optimizely Mobile SDKs. Visual experiments are currently not supported.

1. Live Variables

Live Variables allow you to designate variables in your app that can be assigned values in the Optimizely editor. These values can be modified by Optimizely's editor even after you have released your app to the app store. For example, you might want to create an experiment that tests various values for gravity.

To register a live variable you can call the Optimizely API:

window.optimizely.numberVariable('gravity', 9.8)
  .then(
    function() {
      // this callback function will execute once the variable has been registered with the Optimizely SDK
    },
    function(errorMsg) {
     // error callback
    }
  );

To use the live variable:

window.optimizely.numberForKey('gravity')
  .then(
    function(variableValue) {
      // this callback function will execute once the plugin has retrieved the stored value for the given variable key.
    },
    function(errorMsg) {
      // error callback
    }
  );

2. Code Blocks

Code Blocks allow developers to create variations that execute different code paths. For example, one use case might be to test various checkout flows.

To register a code block:

window.optimizely.codeBlock('checkoutFlow', ['single_page', 'multi_page'])
  .then(
    function() {
      // success callback
    },
    function(errorMsg) {
      // error callback
    }
  );

To use a code block:

window.optimizely.executeCodeBlock(
  'checkoutFlow',
  [
    function() {
      // single page checkout flow
    },
    function() {
      // multi page checkout flow
    }
  ],
  this,
  function(errorMsg) {
    // error callback
  }
)

APIs

Aside from the APIs for registering and using Live Variables and Code Blocks, the plugin also exposes the following APIs:

  • window.optimizely.enabledEditor()
  • window.optimizely.refreshExperimentData()
  • window.optimizely.setCustomTag(tagName, tagValue)
  • window.optimizely.startOptimizely(projectToken)
  • window.optimizely.trackEvent('eventName')
  • window.optimizely.trackRevenueWithDescription(100, 'revenueDescription')

All API calls return a Promise object using the ES6 promise specification.

For more information on these APIs please visit Android Docs or iOS Docs

More documentation coming soon!