internal EvaluationDetail <JToken> GetValueForVariationOrRollout(VariationOrRollout vr, User user, EvaluationReason reason) { var index = vr.VariationIndexForUser(user, Key, Salt); if (index == null) { Log.ErrorFormat("Data inconsistency in feature flag \"{0}\": variation/rollout object with no variation or rollout", Key); return(ErrorResult(EvaluationErrorKind.MALFORMED_FLAG)); } return(GetVariation(index.Value, reason)); }
internal FeatureFlag(string key, int version, bool on, List <Prerequisite> prerequisites, string salt, List <Target> targets, List <Rule> rules, VariationOrRollout fallthrough, int?offVariation, List <JToken> variations, bool deleted) { Key = key; Version = version; On = on; Prerequisites = prerequisites; Salt = salt; Targets = targets; Rules = rules; Fallthrough = fallthrough; OffVariation = offVariation; Variations = variations; Deleted = deleted; }
internal FeatureFlag(string key, int version, bool on, List <Prerequisite> prerequisites, string salt, List <Target> targets, List <Rule> rules, VariationOrRollout fallthrough, int?offVariation, List <JToken> variations, bool trackEvents, long?debugEventsUntilDate, bool deleted, bool clientSide) { Key = key; Version = version; On = on; Prerequisites = prerequisites; Salt = salt; Targets = targets; Rules = rules; Fallthrough = fallthrough; OffVariation = offVariation; Variations = variations; TrackEvents = trackEvents; DebugEventsUntilDate = debugEventsUntilDate; Deleted = deleted; ClientSide = clientSide; }
public bool MatchesUser(User user, string segmentKey, string salt) { foreach (var c in Clauses) { if (!c.MatchesUserNoSegments(user)) { return(false); } } // If the Weight is absent, this rule matches if (!Weight.HasValue) { return(true); } // All of the clauses are met. See if the user buckets in String by = (BucketBy == null) ? "key" : BucketBy; double bucket = VariationOrRollout.BucketUser(user, segmentKey, by, salt); double weight = (double)this.Weight / 100000F; return(bucket < weight); }