Skip to content

Commit 18b6429

Browse files
committed
Add OS and framework info to captured events
1 parent d01bcd0 commit 18b6429

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PostHog/Api/PostHogApiClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net.Http.Headers;
22
using System.Net.Http.Json;
3+
using System.Runtime.InteropServices;
34
using Microsoft.Extensions.Logging;
45
using Microsoft.Extensions.Options;
56
using PostHog.Config;
@@ -41,6 +42,10 @@ public PostHogApiClient(
4142
_timeProvider = timeProvider;
4243

4344
_httpClient = httpClient;
45+
var framework = RuntimeInformation.FrameworkDescription;
46+
var os = RuntimeInformation.OSDescription;
47+
var arch = RuntimeInformation.ProcessArchitecture;
48+
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd($"{LibraryName}/{VersionConstants.Version} ({framework}; {os}; {arch})");
4449

4550
logger.LogTraceApiClientCreated(HostUrl);
4651
}
@@ -156,6 +161,9 @@ void PrepareAndMutatePayload(Dictionary<string, object> payload)
156161
var properties = payload.GetOrAdd<string, Dictionary<string, object>>("properties");
157162

158163
properties["$lib"] = LibraryName;
164+
properties["$os"] = RuntimeInformation.OSDescription;
165+
properties["$framework"] = RuntimeInformation.FrameworkDescription;
166+
properties["$arch"] = RuntimeInformation.ProcessArchitecture;
159167
properties["$lib_version"] = VersionConstants.Version;
160168
properties["$geoip_disable"] = true;
161169

0 commit comments

Comments
 (0)