lib/vanity/experiment/ab_test.rb in vanity-1.2.0 vs lib/vanity/experiment/ab_test.rb in vanity-1.3.0

- old
+ new

@@ -193,12 +193,19 @@ index = alternative_for(identity) redis.sadd key("alts:#{index}:participants"), identity check_completion! end else - index = redis[key("outcome")] || alternative_for(identify) + index = redis[key("outcome")] || alternative_for(identity) end @alternatives[index.to_i] + end + + # Returns fingerprint (hash) for given alternative. Can be used to lookup + # alternative for experiment without revealing what values are available + # (e.g. choosing alternative from HTTP query parameter). + def fingerprint(alternative) + Digest::MD5.hexdigest("#{id}:#{alternative.id}")[-10,10] end # -- Testing --