Directory

← Back

app-experiment-behavior

Polymer behavior for simple A/B/... experiments

Author

Rating

Popularity

<100

[ This description is mirrored from README.md at github.com/Collaborne/app-experiment-behavior on 2019-05-22 ]

Demo and API Docs

app-experiment-behavior Bower version Build Status

Polymer 1.x behavior for simple A/B/... experiments

Usage

See this blog post for a detailed tutorial.

Using this behavior is (fairly) easy:

bower install app-experiment-behavior

After that you need to reference the behavior and provide the viewer information for your component:

<dom-module is="experiment-component">
    <template>
        <style>
            :host {
                margin: 2em;
            }
        </style>

        <div>[[_greeting]]</div>
    </template>

    <script>
        // Simple example for how to set the oracle with a custom extraction function.
        const oracle = Polymer.AppExperiment.Oracle.VIEWER_HASH(viewerId => viewerId);

        Polymer({
            is: 'experiment-component',

            properties: {
                experimentViewer: String,

                _greeting: {
                    type: String,
                    computed: '_computeGreeting(experiment)'
                }
            },

            behaviors: [
                Polymer.AppExperiment.Behavior('experiment-component:greeting', [ 'world', 'universe' ], { oracle })
            ],

            _computeGreeting(experiment) {
                const greetings = {
                    'world': 'Hello, World!',
                    'universe': 'Jo, Universe!'
                }

                return greetings[experiment];
            }
        })
    </script>
</dom-module>

In this example the component provides the 'experimentViewer' property directly, but this could be extracted into a separate behavior, allowing you to simplify code in your app even more:

const MyViewerBehavior = {
    properties: {
        experimentViewer: {
            type: Object,
            computed: '_computeExperimentViewer(...)'
        },
    },

    _computeExperimentViewer(...) {
        // Calculate the viewer based on the given inputs
    }
};

function MyExperimentBehavior() {
    return [...Polymer.AppExperimentBehavior.apply(this, arguments), MyViewerBehavior ];
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Dependencies

  • polymer#Polymer/polymer#^1.9.1
Released
2017-05-15
Maturity
IMPORTED
License
Apache License 2.0

Compatibility

Framework
Polymer 1.0+
Polymer 2.0+ in 2.0.0
Browser
Browser Independent

app-experiment-behavior - Vaadin Add-on Directory

Polymer behavior for simple A/B/... experiments app-experiment-behavior - Vaadin Add-on Directory
**[ This description is mirrored from README.md at [github.com/Collaborne/app-experiment-behavior](https://github.com//Collaborne/app-experiment-behavior/blob/v1.1.0/README.md) on 2019-05-22 ]** _[Demo and API Docs](http://collaborne.github.io/app-experiment-behavior)_ # app-experiment-behavior [![Bower version](https://badge.fury.io/bo/app-experiment-behavior.svg)](http://badge.fury.io/bo/app-experiment-behavior) [![Build Status](https://travis-ci.org/Collaborne/app-experiment-behavior.svg?branch=master)](https://travis-ci.org/Collaborne/app-experiment-behavior) Polymer 1.x behavior for simple A/B/... experiments ### Usage **See this [blog post](https://medium.com/collaborne-engineering/a-b-testing-made-easy-with-polymer-7038b22779af) for a detailed tutorial.** Using this behavior is (fairly) easy: `bower install app-experiment-behavior` After that you need to reference the behavior and provide the viewer information for your component: ```html ``` In this example the component provides the 'experimentViewer' property directly, but this could be extracted into a separate behavior, allowing you to simplify code in your app even more: ```js const MyViewerBehavior = { properties: { experimentViewer: { type: Object, computed: '_computeExperimentViewer(...)' }, }, _computeExperimentViewer(...) { // Calculate the viewer based on the given inputs } }; function MyExperimentBehavior() { return [...Polymer.AppExperimentBehavior.apply(this, arguments), MyViewerBehavior ]; } ```
Online