Skip to content

Commit 14dface

Browse files
revert: SaveVariation to include userProfile
1 parent d0f59b6 commit 14dface

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

OptimizelySDK/Bucketing/DecisionService.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ OptimizelyDecideOption[] options
220220
{
221221
if (UserProfileService != null && !ignoreUPS)
222222
{
223-
SaveVariation(experiment, decisionVariationResult.ResultObject);
223+
var bucketerUserProfile = _userProfile ??
224+
new UserProfile(userId,
225+
new Dictionary<string, Decision>());
226+
SaveVariation(experiment, decisionVariationResult.ResultObject,
227+
bucketerUserProfile);
224228
}
225229
else
226230
{
@@ -475,14 +479,22 @@ ProjectConfig config
475479
/// </summary>
476480
/// <param name="experiment">The experiment the user was buck</param>
477481
/// <param name="variation">The Variation to save.</param>
478-
public void SaveVariation(Experiment experiment, Variation variation)
482+
/// <param name = "userProfile" > instance of the user information.</param>
483+
public void SaveVariation(Experiment experiment, Variation variation,
484+
UserProfile userProfile
485+
)
479486
{
480487
//only save if the user has implemented a user profile service
481488
if (UserProfileService == null)
482489
{
483490
return;
484491
}
485492

493+
if (_userProfile == null)
494+
{
495+
_userProfile = userProfile;
496+
}
497+
486498
Decision decision;
487499
if (_userProfile.ExperimentBucketMap.ContainsKey(experiment.Id))
488500
{
@@ -507,8 +519,8 @@ private void SaveToUserProfileService(Experiment experiment = null,
507519
)
508520
{
509521
var useSpecificLogEntry = experiment != null && variation != null &&
510-
!string.IsNullOrEmpty(_userProfile?.UserId);
511-
522+
!string.IsNullOrEmpty(_userProfile?.UserId);
523+
512524
try
513525
{
514526
if (_userProfile != null)
@@ -536,6 +548,7 @@ private void SaveToUserProfileService(Experiment experiment = null,
536548
{
537549
Logger.Log(LogLevel.ERROR, "Failed to save user profile after batch decision.");
538550
}
551+
539552
ErrorHandler.HandleError(
540553
new Exceptions.OptimizelyRuntimeException(exception.Message));
541554
}

0 commit comments

Comments
 (0)