Skip to content

Commit

Permalink
feat(analytics): introduce the region parameter to instantiate the An…
Browse files Browse the repository at this point in the history
…alyticsClient

Fix #697
  • Loading branch information
aseure committed Mar 31, 2020
1 parent b0e2d17 commit a710872
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Algolia.Search/Clients/AnalyticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public class AnalyticsClient : IAnalyticsClient
/// </summary>
/// <param name="applicationId">Your application ID</param>
/// <param name="apiKey">Your Api KEY</param>
public AnalyticsClient(string applicationId, string apiKey) : this(
new AnalyticsConfig(applicationId, apiKey), new AlgoliaHttpRequester())
/// <param name="region">Region where your analytics data is stored and processed</param>
public AnalyticsClient(string applicationId, string apiKey, string region = "us") : this(
new AnalyticsConfig(applicationId, apiKey, region), new AlgoliaHttpRequester())
{
}

Expand Down
8 changes: 6 additions & 2 deletions src/Algolia.Search/Clients/AnalyticsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ public sealed class AnalyticsConfig : AlgoliaConfig
/// </summary>
/// <param name="applicationId">Your application ID</param>
/// <param name="apiKey">Your API Key</param>
public AnalyticsConfig(string applicationId, string apiKey) : base(applicationId, apiKey)
/// <param name="region">Region where your analytics data is stored and processed</param>
public AnalyticsConfig(string applicationId, string apiKey, string region = "us") : base(applicationId, apiKey)
{
DefaultHosts = new List<StatefulHost>
{
new StatefulHost {Url = "analytics.algolia.com", Accept = CallType.Read | CallType.Write}
new StatefulHost
{
Url = $"analytics.{region}.algolia.com", Accept = CallType.Read | CallType.Write
}
};

Compression = CompressionType.NONE;
Expand Down

0 comments on commit a710872

Please sign in to comment.