{"id":18347958,"url":"https://github.com/collaborne/app-experiment-behavior","last_synced_at":"2026-01-23T15:41:54.230Z","repository":{"id":57741168,"uuid":"91096249","full_name":"Collaborne/app-experiment-behavior","owner":"Collaborne","description":"Polymer behavior for simple A/B/... experiments","archived":false,"fork":false,"pushed_at":"2018-11-21T13:15:33.000Z","size":23,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T15:08:04.103Z","etag":null,"topics":["polymer"],"latest_commit_sha":null,"homepage":"https://www.webcomponents.org/element/Collaborne/app-experiment-behavior","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Collaborne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-12T13:50:28.000Z","updated_at":"2019-06-22T16:52:58.000Z","dependencies_parsed_at":"2022-09-09T06:01:32.219Z","dependency_job_id":null,"html_url":"https://github.com/Collaborne/app-experiment-behavior","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fapp-experiment-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fapp-experiment-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fapp-experiment-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fapp-experiment-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Collaborne","download_url":"https://codeload.github.com/Collaborne/app-experiment-behavior/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248128011,"owners_count":21052337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["polymer"],"created_at":"2024-11-05T21:15:52.157Z","updated_at":"2026-01-23T15:41:54.194Z","avatar_url":"https://github.com/Collaborne.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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) [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/Collaborne/app-experiment-behavior)\n\n[![Published on Vaadin  Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/Collaborneapp-experiment-behavior)\n[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/Collaborneapp-experiment-behavior.svg)](https://vaadin.com/directory/component/Collaborneapp-experiment-behavior)\n\nPolymer behavior for simple A/B/... experiments\n\n### Usage\n\n**See this [blog post](https://medium.com/collaborne-engineering/a-b-testing-made-easy-with-polymer-7038b22779af) for a detailed tutorial.**\n\nUsing this behavior is (fairly) easy:\n\n`bower install app-experiment-behavior`\n\nAfter that you need to reference the behavior and provide the viewer information for your component:\n\n```html\n\u003cdom-module is=\"experiment-component\"\u003e\n\t\u003ctemplate\u003e\n\t\t\u003cstyle\u003e\n\t\t\t:host {\n\t\t\t\tmargin: 2em;\n\t\t\t}\n\t\t\u003c/style\u003e\n\n\t\t\u003cdiv\u003e[[_greeting]]\u003c/div\u003e\n\t\u003c/template\u003e\n\n\t\u003cscript\u003e\n\t\t// Simple example for how to set the oracle with a custom extraction function.\n\t\tconst oracle = Polymer.AppExperiment.Oracle.VIEWER_HASH(viewerId =\u003e viewerId);\n\n\t\tPolymer({\n\t\t\tis: 'experiment-component',\n\n\t\t\tproperties: {\n\t\t\t\texperimentViewer: String,\n\n\t\t\t\t_greeting: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\tcomputed: '_computeGreeting(experiment)'\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tbehaviors: [\n\t\t\t\tPolymer.AppExperiment.Behavior('experiment-component:greeting', [ 'world', 'universe' ], { oracle })\n\t\t\t],\n\n\t\t\t_computeGreeting(experiment) {\n\t\t\t\tconst greetings = {\n\t\t\t\t\t'world': 'Hello, World!',\n\t\t\t\t\t'universe': 'Jo, Universe!'\n\t\t\t\t}\n\n\t\t\t\treturn greetings[experiment];\n\t\t\t}\n\t\t})\n\t\u003c/script\u003e\n\u003c/dom-module\u003e\n```\n\nIn 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:\n\n```js\nconst MyViewerBehavior = {\n\tproperties: {\n\t\texperimentViewer: {\n\t\t\ttype: Object,\n\t\t\tcomputed: '_computeExperimentViewer(...)'\n\t\t},\n\t},\n\n\t_computeExperimentViewer(...) {\n\t\t// Calculate the viewer based on the given inputs\n\t}\n};\n\nfunction MyExperimentBehavior() {\n\treturn [...Polymer.AppExperimentBehavior.apply(this, arguments), MyViewerBehavior ];\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollaborne%2Fapp-experiment-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcollaborne%2Fapp-experiment-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollaborne%2Fapp-experiment-behavior/lists"}