Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverted removal of Activating user log and added condition to do not…
… log if experiment is null
  • Loading branch information
mnoman09 committed Oct 1, 2020
commit 724a86bccc82bbaf1a82b88799677e3ab01ca2f3
6 changes: 6 additions & 0 deletions OptimizelySDK.Tests/OptimizelyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ public void TestActivateNoAudienceNoAttributes()
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [user_1] is in experiment [group_experiment_1] of group [7722400015]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [9525] to user [user_1] with bucketing ID [user_1]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [user_1] is in variation [group_exp_1_var_2] of experiment [group_experiment_1]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user user_1 in experiment group_experiment_1."), Times.Once);

Assert.IsTrue(TestData.CompareObjects(GroupVariation, variation));
}
Expand Down Expand Up @@ -429,6 +430,7 @@ public void TestActivateWithAttributes()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [3037] to user [test_user] with bucketing ID [test_user]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [test_user] is in variation [control] of experiment [test_experiment]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "This decision will not be saved since the UserProfileService is null."));
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user test_user in experiment test_experiment."), Times.Once);

Assert.IsTrue(TestData.CompareObjects(VariationWithKeyControl, variation));
}
Expand All @@ -448,6 +450,7 @@ public void TestActivateWithNullAttributes()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "User \"test_user\" is not in the forced variation map."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [3037] to user [test_user] with bucketing ID [test_user]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [test_user] is in variation [control] of experiment [test_experiment]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user test_user in experiment test_experiment."), Times.Once);

Assert.IsTrue(TestData.CompareObjects(VariationWithKeyControl, variation));
}
Expand Down Expand Up @@ -487,6 +490,7 @@ public void TestActivateWithTypedAttributes()

LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [3037] to user [test_user] with bucketing ID [test_user]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [test_user] is in variation [control] of experiment [test_experiment]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user test_user in experiment test_experiment."), Times.Once);

Assert.IsTrue(TestData.CompareObjects(VariationWithKeyControl, variation));
}
Expand Down Expand Up @@ -680,6 +684,7 @@ public void TestInvalidDispatchImpressionEvent()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [3037] to user [test_user] with bucketing ID [test_user]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [test_user] is in variation [control] of experiment [test_experiment]."), Times.Once);

LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user test_user in experiment test_experiment."), Times.Once);
// Need to see how error handler can be verified.
LoggerMock.Verify(l => l.Log(LogLevel.ERROR, It.IsAny<string>()), Times.Once);

Expand Down Expand Up @@ -1074,6 +1079,7 @@ public void TestActivateNoAudienceNoAttributesAfterSetForcedVariation()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, "Assigned bucket [9525] to user [user_1] with bucketing ID [user_1]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "User [user_1] is in variation [group_exp_1_var_2] of experiment [group_experiment_1]."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "This decision will not be saved since the UserProfileService is null."), Times.Once);
LoggerMock.Verify(l => l.Log(LogLevel.INFO, "Activating user user_1 in experiment group_experiment_1."), Times.Once);

Assert.IsTrue(TestData.CompareObjects(GroupVariation, variation));
}
Expand Down
5 changes: 4 additions & 1 deletion OptimizelySDK/Optimizely.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,11 @@ private void SendImpressionEvent(Experiment experiment, Variation variation, str
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should log at this point.

}
EventProcessor.Process(userEvent);
//Logger.Log(LogLevel.INFO, $"Activating user {userId} in experiment {experiment.Key}.");

if (experiment != null)
{
Logger.Log(LogLevel.INFO, $"Activating user {userId} in experiment {experiment.Key}.");
}
// Kept For backwards compatibility.
// This notification is deprecated and the new DecisionNotifications
// are sent via their respective method calls.
Expand Down