Skip to content

Commit d6258f1

Browse files
fix: WIP tests & code under tests
1 parent 236728b commit d6258f1

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

OptimizelySDK/Bucketing/DecisionService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,15 @@ UserProfile userProfile
463463

464464
public void AddDecisionToUnitOfWork(string userId, string experimentId, Decision decision)
465465
{
466-
_decisionUnitOfWork.AddDecision(userId, experimentId, decision);
466+
if (UserProfileService == null)
467+
{
468+
return;
469+
}
470+
471+
if (!string.IsNullOrEmpty(experimentId))
472+
{
473+
_decisionUnitOfWork.AddDecision(userId, experimentId, decision);
474+
}
467475
}
468476

469477
/// <summary>

OptimizelySDK/Bucketing/DecisionUnitOfWork.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class DecisionUnitOfWork
2525

2626
public void AddDecision(string userId, string experimentId, Decision decision)
2727
{
28+
if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(experimentId))
29+
{
30+
return;
31+
}
32+
2833
if (!_decisions.ContainsKey(userId))
2934
{
3035
_decisions[userId] = new Dictionary<string, Decision>();

OptimizelySDK/Optimizely.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,9 @@ internal OptimizelyDecision Decide(OptimizelyUserContext user,
926926
decisionReasons += flagDecisionResult.DecisionReasons;
927927
decision = flagDecisionResult.ResultObject;
928928
}
929-
930-
// TODO: Fix when the flag is a rollout instead of an experiment
929+
931930
DecisionService.AddDecisionToUnitOfWork(userId, decision.Experiment?.Id,
932-
new Decision(decision.Variation?.Id ?? ""));
931+
new Decision(decision.Variation?.Id));
933932

934933
var featureEnabled = false;
935934

0 commit comments

Comments
 (0)