diff --git a/.changeset/standardize-event-buffer-defaults.md b/.changeset/standardize-event-buffer-defaults.md new file mode 100644 index 00000000..7dcc947c --- /dev/null +++ b/.changeset/standardize-event-buffer-defaults.md @@ -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. diff --git a/src/PostHog/Config/PostHogOptions.cs b/src/PostHog/Config/PostHogOptions.cs index cf8a8177..bb427ac0 100644 --- a/src/PostHog/Config/PostHogOptions.cs +++ b/src/PostHog/Config/PostHogOptions.cs @@ -174,22 +174,22 @@ public string? PersonalApiKey public int MaxBatchSize { get; set; } = 100; /// - /// 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) /// /// /// This property prevents runaway growth of the queue in the case of network outage or a burst of messages. /// - public int MaxQueueSize { get; set; } = 1000; + public int MaxQueueSize { get; set; } = 10_000; /// - /// The number of events to queue before sending to PostHog (Default: 20) + /// The number of events to queue before sending to PostHog (Default: 100) /// - public int FlushAt { get; set; } = 20; + public int FlushAt { get; set; } = 100; /// - /// The interval between periodic flushes. (Default: 30s) + /// The interval between periodic flushes. (Default: 5s) /// - public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(30); + public TimeSpan FlushInterval { get; set; } = TimeSpan.FromSeconds(5); /// /// The maximum number of retries for failed requests. (Default: 3) diff --git a/tests/UnitTests/Config/RegistrationTests.cs b/tests/UnitTests/Config/RegistrationTests.cs index e513576e..2ce0289e 100644 --- a/tests/UnitTests/Config/RegistrationTests.cs +++ b/tests/UnitTests/Config/RegistrationTests.cs @@ -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() { @@ -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); }