Which arm of an experiment a visitor sees. Pure.
Assignment is a HASH of the visitor and the experiment, not a coin flip and not a row in a table. Three consequences, all of them the reason for the choice: the same visitor always sees the same arm without anything being stored, two processes agree without talking to each other, and a test can assert an assignment instead of stubbing a random.
The experiments themselves come from tokens.edn — the same declaration the
stylesheet is generated from — so an arm that exists at runtime is an arm
that shipped its CSS and passed the contrast gate.
Which arm of an experiment a visitor sees. Pure. Assignment is a HASH of the visitor and the experiment, not a coin flip and not a row in a table. Three consequences, all of them the reason for the choice: the same visitor always sees the same arm without anything being stored, two processes agree without talking to each other, and a test can assert an assignment instead of stubbing a random. The experiments themselves come from `tokens.edn` — the same declaration the stylesheet is generated from — so an arm that exists at runtime is an arm that shipped its CSS and passed the contrast gate.
(assign experiments visitor)Every experiment's arm for visitor, as {experiment variant}.
Every experiment's arm for `visitor`, as {experiment variant}.
(attribute-string attributes)attributes as text for an HTML open tag.
`attributes` as text for an HTML open tag.
(attributes experiments assignments)assignments as the HTML attributes that select them, {attribute value}.
This is the whole runtime cost of an experiment: one attribute on <html>. Every arm's CSS is already in the stylesheet, so nothing loads, nothing flashes, and nothing has to be re-rendered when the assignment changes.
`assignments` as the HTML attributes that select them, {attribute value}.
This is the whole runtime cost of an experiment: one attribute on <html>.
Every arm's CSS is already in the stylesheet, so nothing loads, nothing
flashes, and nothing has to be re-rendered when the assignment changes.(describe experiments assignments)What the browser is told about the running experiments: the arm it is in, and the arms that exist. Never the assignment rule, and never another visitor's assignment.
What the browser is told about the running experiments: the arm it is in, and the arms that exist. Never the assignment rule, and never another visitor's assignment.
(variant-for experiment-name {:keys [variants default]} visitor)The arm of experiment that visitor sees.
Falls back to the declared default when there is no visitor to hash — an anonymous first request gets the control arm rather than a random one, so a crawler cannot skew a test and an uncookied visitor sees the safe design.
The arm of `experiment` that `visitor` sees. Falls back to the declared default when there is no visitor to hash — an anonymous first request gets the control arm rather than a random one, so a crawler cannot skew a test and an uncookied visitor sees the safe design.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |