Skip to content

Commit 8841e89

Browse files
committed
Implement comments
1 parent c3da120 commit 8841e89

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

OptimizelySDK/Event/Builder/EventBuilder.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,9 @@ public virtual LogEvent CreateImpressionEvent(ProjectConfig config, Experiment e
242242
GetImpressionOrConversionParamsWithCommonParams(commonParams,
243243
new object[] { impressionOnlyParams });
244244

245-
var region = !string.IsNullOrEmpty(config.Region) ? config.Region : "US";
245+
var region = !string.IsNullOrEmpty(config.Region) && EventFactory.EventEndpoints.ContainsKey(config.Region) ? config.Region : "US";
246246

247-
var endpoint = EventFactory.EventEndpoints.ContainsKey(region)
248-
? EventFactory.EventEndpoints[region]
249-
: EventFactory.EventEndpoints["US"];
247+
var endpoint = EventFactory.EventEndpoints[region]
250248

251249
return new LogEvent(endpoint, impressionParams, HTTP_VERB, HTTP_HEADERS);
252250
}
@@ -274,11 +272,9 @@ public virtual LogEvent CreateConversionEvent(ProjectConfig config, string event
274272
var conversionParams =
275273
GetImpressionOrConversionParamsWithCommonParams(commonParams, conversionOnlyParams);
276274

277-
var region = !string.IsNullOrEmpty(config.Region) ? config.Region : "US";
275+
var region = !string.IsNullOrEmpty(config.Region) && EventFactory.EventEndpoints.ContainsKey(config.Region) ? config.Region : "US";
278276

279-
var endpoint = EventFactory.EventEndpoints.ContainsKey(region)
280-
? EventFactory.EventEndpoints[region]
281-
: EventFactory.EventEndpoints["US"];
277+
var endpoint = EventFactory.EventEndpoints[region]
282278

283279
return new LogEvent(endpoint, conversionParams, HTTP_VERB, HTTP_HEADERS);
284280
}

OptimizelySDK/Event/EventFactory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class EventFactory
3535
private const string CUSTOM_ATTRIBUTE_FEATURE_TYPE = "custom";
3636

3737
// Supported regions for event endpoints
38-
public static readonly string[] SupportedRegions = { "US", "EU" };
38+
public static string[] SupportedRegions => EventEndpoints.Keys.ToArray();
3939

4040
// Dictionary of event endpoints for different regions
4141
public static readonly Dictionary<string, string> EventEndpoints = new Dictionary<string, string>
@@ -91,7 +91,10 @@ public static LogEvent CreateLogEvent(UserEvent[] userEvents, ILogger logger)
9191
var userContext = userEvent.Context;
9292

9393
// Get region from the event's context, default to US if not specified
94-
region = !string.IsNullOrEmpty(userContext.Region) ? userContext.Region : "US";
94+
if (!string.IsNullOrEmpty(userContext.Region))
95+
{
96+
region = userContext.Region;
97+
}
9598

9699
builder.WithClientName(userContext.ClientName).
97100
WithClientVersion(userContext.ClientVersion).

0 commit comments

Comments
 (0)