Skip to content

Commit 90e0c94

Browse files
authored
chore: standardize event buffer defaults (#262)
1 parent e7e34b3 commit 90e0c94

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"PostHog": patch
3+
---
4+
5+
Standardize event buffering defaults at a 10,000-event queue, 100-event flush threshold, 100-event maximum batch size, and 5-second flush interval.

src/PostHog/Config/PostHogOptions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,22 @@ public string? PersonalApiKey
174174
public int MaxBatchSize { get; set; } = 100;
175175

176176
/// <summary>
177-
/// The max number of messages to store in the queue before we start dropping messages. (Default: 1000)
177+
/// The max number of messages to store in the queue before we start dropping messages. (Default: 10000)
178178
/// </summary>
179179
/// <remarks>
180180
/// This property prevents runaway growth of the queue in the case of network outage or a burst of messages.
181181
/// </remarks>
182-
public int MaxQueueSize { get; set; } = 1000;
182+
public int MaxQueueSize { get; set; } = 10_000;
183183

184184
/// <summary>
185-
/// The number of events to queue before sending to PostHog (Default: 20)
185+
/// The number of events to queue before sending to PostHog (Default: 100)
186186
/// </summary>
187-
public int FlushAt { get; set; } = 20;
187+
public int FlushAt { get; set; } = 100;
188188

189189
/// <summary>
190-
/// The interval between periodic flushes. (Default: 30s)
190+
/// The interval between periodic flushes. (Default: 5s)
191191
/// </summary>
192-
public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(30);
192+
public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(5);
193193

194194
/// <summary>
195195
/// The maximum number of retries for failed requests. (Default: 3)

tests/UnitTests/Config/RegistrationTests.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,23 @@ public void CanReadConfiguration()
8282
["Family"] = "Starks"
8383
}, options.SuperProperties);
8484
// Check the defaults
85-
Assert.Equal(1000, options.MaxQueueSize);
86-
Assert.Equal(TimeSpan.FromSeconds(30), options.FlushInterval);
85+
Assert.Equal(10_000, options.MaxQueueSize);
86+
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
8787
Assert.Equal(TimeSpan.FromMinutes(10), options.FeatureFlagSentCacheSlidingExpiration);
8888
Assert.Equal(50_000, options.FeatureFlagSentCacheSizeLimit);
8989
}
9090

91+
[Fact]
92+
public void UsesStandardEventBufferDefaults()
93+
{
94+
var options = new PostHogOptions();
95+
96+
Assert.Equal(10_000, options.MaxQueueSize);
97+
Assert.Equal(100, options.FlushAt);
98+
Assert.Equal(100, options.MaxBatchSize);
99+
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
100+
}
101+
91102
[Fact]
92103
public void CanReadSecretKeyConfiguration()
93104
{
@@ -240,7 +251,7 @@ public void AllowsOverridingConfiguration()
240251
["House"] = "Tully"
241252
}, options.SuperProperties);
242253
// Check the defaults
243-
Assert.Equal(TimeSpan.FromSeconds(30), options.FlushInterval);
254+
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
244255
Assert.Equal(TimeSpan.FromMinutes(10), options.FeatureFlagSentCacheSlidingExpiration);
245256
Assert.Equal(50_000, options.FeatureFlagSentCacheSizeLimit);
246257
}

0 commit comments

Comments
 (0)