Skip to content

Commit 21104bc

Browse files
committed
Disable client when project token is missing
1 parent e35bf94 commit 21104bc

3 files changed

Lines changed: 361 additions & 43 deletions

File tree

src/PostHog/Config/PostHogOptions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Options;
2+
using PostHog.Library;
23

34
namespace PostHog;
45

@@ -26,6 +27,14 @@ public string? ProjectToken
2627

2728
internal bool HasLegacyProjectApiKey => _projectApiKey is not null;
2829

30+
internal void Normalize()
31+
{
32+
_projectToken = _projectToken.NullIfEmpty();
33+
_projectApiKey = _projectApiKey.NullIfEmpty();
34+
PersonalApiKey = PersonalApiKey.NullIfEmpty();
35+
HostUrl = HostUrl.NormalizeHostUrl();
36+
}
37+
2938
/// <summary>
3039
/// Obsolete alias for <see cref="ProjectToken"/>.
3140
/// </summary>
@@ -49,6 +58,11 @@ public string? ProjectApiKey
4958
/// </remarks>
5059
public string? PersonalApiKey { get; set; }
5160

61+
/// <summary>
62+
/// Whether this client is disabled and should no-op instead of sending data to PostHog. (Default: false)
63+
/// </summary>
64+
public bool Disabled { get; set; }
65+
5266
/// <summary>
5367
/// PostHog API host, usually 'https://us.i.posthog.com' (default) or 'https://eu.i.posthog.com'
5468
/// </summary>

0 commit comments

Comments
 (0)