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
added check that if SendFlagDecision is true then send the event
  • Loading branch information
mnoman09 committed Sep 25, 2020
commit 314f13bd14717361806ff8087fb0e4a63398340c
19 changes: 12 additions & 7 deletions OptimizelySDK/Event/UserEventFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OptimizelySDK.Entity;
using OptimizelySDK.Bucketing;
using OptimizelySDK.Entity;
using OptimizelySDK.Event.Entity;

namespace OptimizelySDK.Event
Expand Down Expand Up @@ -48,13 +49,17 @@ public static ImpressionEvent CreateImpressionEvent(ProjectConfig projectConfig,
string flagKey,
string flagType)
{

if ((flagType == FeatureDecision.DECISION_SOURCE_ROLLOUT || variation == null) && !projectConfig.SendFlagDecisions)
{
return null;
}

var eventContext = new EventContext.Builder()
.WithProjectId(projectConfig.ProjectId)
.WithAccountId(projectConfig.AccountId)
.WithAnonymizeIP(projectConfig.AnonymizeIP)
.WithRevision(projectConfig.Revision)
.Build();
.WithProjectId(projectConfig.ProjectId)
.WithAccountId(projectConfig.AccountId)
.WithAnonymizeIP(projectConfig.AnonymizeIP)
.WithRevision(projectConfig.Revision)
.Build();

var variationKey = variation?.Key;
var metadata = new DecisionMetadata(flagKey, flagType, variationKey);
Expand Down
6 changes: 6 additions & 0 deletions OptimizelySDK/Optimizely.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ public virtual bool IsFeatureEnabled(string featureKey, string userId, UserAttri
{
featureEnabled = variation.FeatureEnabled.GetValueOrDefault();

// This information is only necessary for feature tests.
// For rollouts experiments and variations are an implementation detail only.
if (decision.Source == FeatureDecision.DECISION_SOURCE_FEATURE_TEST)
{
sourceInfo["experimentKey"] = decision.Experiment.Key;
Expand Down Expand Up @@ -691,6 +693,10 @@ private void SendImpressionEvent(Experiment experiment, Variation variation, str
if (experiment.IsExperimentRunning)
{
var userEvent = UserEventFactory.CreateImpressionEvent(config, experiment, variation.Id, userId, userAttributes, flagKey, flagType);
if (userEvent == null)
{
return;
}
EventProcessor.Process(userEvent);
Logger.Log(LogLevel.INFO, $"Activating user {userId} in experiment {experiment.Key}.");

Expand Down