Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/standardize-event-buffer-defaults.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"PostHog": patch
---

Standardize event buffering defaults at a 10,000-event queue, 100-event flush threshold, 100-event maximum batch size, and 5-second flush interval.
12 changes: 6 additions & 6 deletions src/PostHog/Config/PostHogOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,22 @@ public string? PersonalApiKey
public int MaxBatchSize { get; set; } = 100;

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

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

/// <summary>
/// The interval between periodic flushes. (Default: 30s)
/// The interval between periodic flushes. (Default: 5s)
/// </summary>
public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(30);
public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(5);

/// <summary>
/// The maximum number of retries for failed requests. (Default: 3)
Expand Down
17 changes: 14 additions & 3 deletions tests/UnitTests/Config/RegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,23 @@ public void CanReadConfiguration()
["Family"] = "Starks"
}, options.SuperProperties);
// Check the defaults
Assert.Equal(1000, options.MaxQueueSize);
Assert.Equal(TimeSpan.FromSeconds(30), options.FlushInterval);
Assert.Equal(10_000, options.MaxQueueSize);
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
Assert.Equal(TimeSpan.FromMinutes(10), options.FeatureFlagSentCacheSlidingExpiration);
Assert.Equal(50_000, options.FeatureFlagSentCacheSizeLimit);
}

[Fact]
public void UsesStandardEventBufferDefaults()
{
var options = new PostHogOptions();

Assert.Equal(10_000, options.MaxQueueSize);
Assert.Equal(100, options.FlushAt);
Assert.Equal(100, options.MaxBatchSize);
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
}

[Fact]
public void CanReadSecretKeyConfiguration()
{
Expand Down Expand Up @@ -240,7 +251,7 @@ public void AllowsOverridingConfiguration()
["House"] = "Tully"
}, options.SuperProperties);
// Check the defaults
Assert.Equal(TimeSpan.FromSeconds(30), options.FlushInterval);
Assert.Equal(TimeSpan.FromSeconds(5), options.FlushInterval);
Assert.Equal(TimeSpan.FromMinutes(10), options.FeatureFlagSentCacheSlidingExpiration);
Assert.Equal(50_000, options.FeatureFlagSentCacheSizeLimit);
}
Expand Down
Loading