vybekiit 0.7.34 → 0.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +520 -9
- package/dist/global-skills/eas-app-stores/SKILL.md +2 -2
- package/dist/global-skills/eas-hosting/SKILL.md +2 -2
- package/dist/global-skills/eas-observe/SKILL.md +7 -15
- package/dist/global-skills/eas-observe/references/queries.md +51 -10
- package/dist/global-skills/eas-observe/references/setup.md +60 -7
- package/dist/global-skills/eas-simulator/SKILL.md +2 -2
- package/dist/global-skills/eas-simulator/references/run-your-app.md +2 -0
- package/dist/global-skills/eas-update/SKILL.md +2 -2
- package/dist/global-skills/eas-update-insights/SKILL.md +2 -2
- package/dist/global-skills/eas-workflows/SKILL.md +2 -2
- package/dist/global-skills/expo-animation/SKILL.md +2 -2
- package/dist/global-skills/expo-app-clip/SKILL.md +2 -2
- package/dist/global-skills/expo-brownfield/SKILL.md +2 -2
- package/dist/global-skills/expo-data-fetching/SKILL.md +2 -2
- package/dist/global-skills/expo-design-system/SKILL.md +2 -2
- package/dist/global-skills/expo-dev-client/SKILL.md +4 -2
- package/dist/global-skills/expo-dom/SKILL.md +2 -2
- package/dist/global-skills/expo-examples/SKILL.md +2 -2
- package/dist/global-skills/expo-migrate-module/SKILL.md +2 -2
- package/dist/global-skills/expo-module/SKILL.md +2 -2
- package/dist/global-skills/expo-native-ui/SKILL.md +2 -2
- package/dist/global-skills/expo-overview/SKILL.md +9 -4
- package/dist/global-skills/expo-overview/references/launch-without-dev-menu.md +24 -0
- package/dist/global-skills/expo-project-structure/SKILL.md +2 -2
- package/dist/global-skills/expo-router/SKILL.md +2 -2
- package/dist/global-skills/expo-ui/SKILL.md +2 -2
- package/dist/global-skills/expo-upgrade/SKILL.md +2 -2
- package/dist/global-skills/expo-web-to-native/SKILL.md +2 -2
- package/dist/global-skills/expo-web-to-native/references/verify-on-device.md +1 -1
- package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +16 -3
- package/dist/global-skills/firebase-app-hosting-basics/references/cli_commands.md +10 -12
- package/dist/global-skills/firebase-app-hosting-basics/references/configuration.md +2 -1
- package/dist/global-skills/firebase-basics/SKILL.md +6 -4
- package/dist/global-skills/firebase-basics/references/web_setup.md +3 -3
- package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +81 -333
- package/dist/global-skills/instrument-feature-flags/references/android.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/api.md +17 -13
- package/dist/global-skills/instrument-feature-flags/references/best-practices.md +35 -35
- package/dist/global-skills/instrument-feature-flags/references/django.md +120 -72
- package/dist/global-skills/instrument-feature-flags/references/dotnet.md +48 -102
- package/dist/global-skills/instrument-feature-flags/references/elixir.md +4 -10
- package/dist/global-skills/instrument-feature-flags/references/flask.md +55 -39
- package/dist/global-skills/instrument-feature-flags/references/flutter.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/go.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/ios.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/java.md +4 -12
- package/dist/global-skills/instrument-feature-flags/references/laravel.md +18 -16
- package/dist/global-skills/instrument-feature-flags/references/next-js.md +44 -54
- package/dist/global-skills/instrument-feature-flags/references/nodejs.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/php.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/python.md +22 -14
- package/dist/global-skills/instrument-feature-flags/references/react-native.md +18 -13
- package/dist/global-skills/instrument-feature-flags/references/react.md +21 -14
- package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +31 -68
- package/dist/global-skills/instrument-feature-flags/references/ruby.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/rust.md +10 -34
- package/dist/global-skills/instrument-feature-flags/references/usage.md +94 -114
- package/dist/global-skills/instrument-feature-flags/references/web.md +21 -13
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-android.md +7 -7
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-expo.md +2 -2
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-laravel.md +2 -2
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-php.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-python.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-swift.md +4 -4
- package/dist/global-skills/instrument-product-analytics/references/android.md +64 -109
- package/dist/global-skills/instrument-product-analytics/references/angular.md +32 -28
- package/dist/global-skills/instrument-product-analytics/references/astro.md +29 -34
- package/dist/global-skills/instrument-product-analytics/references/configuration.md +27 -42
- package/dist/global-skills/instrument-product-analytics/references/django.md +120 -72
- package/dist/global-skills/instrument-product-analytics/references/dotnet.md +48 -102
- package/dist/global-skills/instrument-product-analytics/references/elixir.md +25 -50
- package/dist/global-skills/instrument-product-analytics/references/flask.md +55 -39
- package/dist/global-skills/instrument-product-analytics/references/flutter.md +94 -96
- package/dist/global-skills/instrument-product-analytics/references/go.md +39 -77
- package/dist/global-skills/instrument-product-analytics/references/identify-users.md +24 -26
- package/dist/global-skills/instrument-product-analytics/references/ios.md +22 -22
- package/dist/global-skills/instrument-product-analytics/references/laravel.md +18 -16
- package/dist/global-skills/instrument-product-analytics/references/next-js.md +44 -54
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +32 -34
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +36 -36
- package/dist/global-skills/instrument-product-analytics/references/php.md +42 -87
- package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +15 -12
- package/dist/global-skills/instrument-product-analytics/references/python.md +106 -154
- package/dist/global-skills/instrument-product-analytics/references/react-native.md +97 -176
- package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +29 -40
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +29 -38
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +29 -40
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +32 -37
- package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +31 -68
- package/dist/global-skills/instrument-product-analytics/references/ruby.md +40 -96
- package/dist/global-skills/instrument-product-analytics/references/svelte.md +34 -34
- package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +19 -19
- package/dist/global-skills/instrument-product-analytics/references/usage.md +94 -114
- package/dist/global-skills/instrument-product-analytics/references/vue-js.md +33 -45
- package/dist/global-skills/mongodb-search-and-ai/SKILL.md +40 -22
- package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +8 -2
- package/dist/global-skills/mongodb-search-and-ai/references/quick-start.md +725 -0
- package/dist/global-skills/mongodb-search-and-ai/scripts/quickstart_complete.py +386 -0
- package/dist/global-skills/neon/references/claimable-neon.md +2 -0
- package/dist/global-skills/neon-realtime/references/queries.md +2 -2
- package/dist/global-skills/resend/SKILL.md +1 -1
- package/dist/global-skills/resend/references/inboxes.md +49 -21
- package/dist/global-skills/resend/references/webhooks.md +1 -1
- package/dist/global-skills/stripe-best-practices/SKILL.md +1 -1
- package/dist/global-skills/stripe-best-practices/references/connect.md +1 -1
- package/dist/global-skills/stripe-best-practices/references/security.md +9 -9
- package/dist/global-skills/vybekiitReferences/backend/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/backend/agent/goal-routes.json +303 -18
- package/dist/global-skills/vybekiitReferences/extension/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/extension/agent/goal-routes.json +352 -18
- package/dist/global-skills/vybekiitReferences/mobile/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/mobile/agent/goal-routes.json +413 -22
- package/dist/global-skills/vybekiitReferences/spa/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/spa/agent/goal-routes.json +391 -21
- package/dist/global-skills/vybekiitReferences/web/AGENTS.md +14 -2
- package/dist/global-skills/vybekiitReferences/web/agent/goal-routes.json +490 -32
- package/package.json +8 -8
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
# .NET
|
|
4
4
|
|
|
5
|
+
Canonical URL: https://posthog.com/docs/libraries/dotnet
|
|
6
|
+
|
|
7
|
+
> **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links).
|
|
8
|
+
|
|
9
|
+
## On this page
|
|
10
|
+
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Working with .NET Feature Management](#working-with-net-feature-management)
|
|
13
|
+
- [Using the core package without ASP.NET Core](#using-the-core-package-without-aspnet-core)
|
|
14
|
+
- [Debug mode](#debug-mode)
|
|
15
|
+
- [Identifying users](#identifying-users)
|
|
16
|
+
- [Capturing events](#capturing-events)
|
|
17
|
+
- [Request context](#request-context)
|
|
18
|
+
- [Error tracking](#error-tracking)
|
|
19
|
+
- [Logs](#logs)
|
|
20
|
+
- [Person profiles and properties](#person-profiles-and-properties)
|
|
21
|
+
- [Alias](#alias)
|
|
22
|
+
- [Group analytics](#group-analytics)
|
|
23
|
+
- [Feature flags](#feature-flags)
|
|
24
|
+
- [Experiments (A/B tests)](#experiments-ab-tests)
|
|
25
|
+
- [AI observability](#ai-observability)
|
|
26
|
+
- [GeoIP properties](#geoip-properties)
|
|
27
|
+
- [Serverless environments (Azure Functions/Render/Lambda/...)](#serverless-environments-azure-functionsrenderlambda)
|
|
28
|
+
|
|
5
29
|
This is an optional library you can install if you're working with .NET Core. It uses an internal queue to make calls fast and non-blocking. It also batches requests and flushes asynchronously, making it perfect to use in any part of your web app or other server side application that needs performance.
|
|
6
30
|
|
|
7
31
|
## Installation
|
|
@@ -10,9 +34,7 @@ The `PostHog` package supports any .NET platform that targets .NET Standard 2.1
|
|
|
10
34
|
|
|
11
35
|
> **Note:** We actively test with ASP.NET Core. Other platforms should work but haven't been specifically tested. If you encounter issues, please [report them on GitHub](https://github.com/PostHog/posthog-dotnet/issues).
|
|
12
36
|
|
|
13
|
-
> **Not supported:** Classic UWP (requires .NET Standard 2.0 only). Microsoft has [deprecated UWP](https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/migrate-to-windows-app-sdk/migrate-to-windows-app-sdk-ovw) in favor of the Windows App SDK. For Unity projects, see our dedicated [Unity SDK](/docs/libraries/unity.md).
|
|
14
|
-
|
|
15
|
-
Terminal
|
|
37
|
+
> **Not supported:** Classic UWP (requires .NET Standard 2.0 only). Microsoft has [deprecated UWP](https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/migrate-to-windows-app-sdk/migrate-to-windows-app-sdk-ovw) in favor of the Windows App SDK. For Unity projects, see our dedicated [Unity SDK](https://posthog.com/docs/libraries/unity.md).
|
|
16
38
|
|
|
17
39
|
```bash
|
|
18
40
|
dotnet add package PostHog.AspNetCore
|
|
@@ -20,8 +42,6 @@ dotnet add package PostHog.AspNetCore
|
|
|
20
42
|
|
|
21
43
|
In your `Program.cs` (or `Startup.cs` for ASP.NET Core 2.x) file, add the following code:
|
|
22
44
|
|
|
23
|
-
C#
|
|
24
|
-
|
|
25
45
|
```csharp
|
|
26
46
|
using PostHog;
|
|
27
47
|
|
|
@@ -33,8 +53,6 @@ builder.AddPostHog();
|
|
|
33
53
|
|
|
34
54
|
Make sure to configure PostHog with your project token, instance address, and optional personal API key. For example, in `appsettings.json`:
|
|
35
55
|
|
|
36
|
-
JSON
|
|
37
|
-
|
|
38
56
|
```json
|
|
39
57
|
{
|
|
40
58
|
"PostHog": {
|
|
@@ -48,8 +66,6 @@ JSON
|
|
|
48
66
|
|
|
49
67
|
Use a secrets manager to store your personal API key. For example, when developing locally you can use the `UserSecrets` feature of the `dotnet` CLI:
|
|
50
68
|
|
|
51
|
-
Terminal
|
|
52
|
-
|
|
53
69
|
```bash
|
|
54
70
|
dotnet user-secrets init
|
|
55
71
|
dotnet user-secrets set "PostHog:PersonalApiKey" "phx_..."
|
|
@@ -63,8 +79,6 @@ You can find your project token and instance address in the [project settings](h
|
|
|
63
79
|
|
|
64
80
|
To use feature flags with the .NET Feature Management library, you'll need to implement the `IPostHogFeatureFlagContextProvider` interface. The quickest way to do that is to inherit from the `PostHogFeatureFlagContextProvider` class and override the `GetDistinctId` and `GetFeatureFlagOptionsAsync` methods.
|
|
65
81
|
|
|
66
|
-
C#
|
|
67
|
-
|
|
68
82
|
```csharp
|
|
69
83
|
public class MyFeatureFlagContextProvider(IHttpContextAccessor httpContextAccessor)
|
|
70
84
|
: PostHogFeatureFlagContextProvider
|
|
@@ -91,8 +105,6 @@ public class MyFeatureFlagContextProvider(IHttpContextAccessor httpContextAccess
|
|
|
91
105
|
|
|
92
106
|
Then, register your implementation in `Program.cs` (or `Startup.cs`):
|
|
93
107
|
|
|
94
|
-
C#
|
|
95
|
-
|
|
96
108
|
```csharp
|
|
97
109
|
var builder = WebApplication.CreateBuilder(args);
|
|
98
110
|
builder.AddPostHog(options => {
|
|
@@ -102,8 +114,6 @@ builder.AddPostHog(options => {
|
|
|
102
114
|
|
|
103
115
|
With this in place, you can now use `feature` tag helpers in your Razor views:
|
|
104
116
|
|
|
105
|
-
HTML
|
|
106
|
-
|
|
107
117
|
```html
|
|
108
118
|
<feature name="awesome-new-feature">
|
|
109
119
|
<p>This is the new feature!</p>
|
|
@@ -115,8 +125,6 @@ HTML
|
|
|
115
125
|
|
|
116
126
|
Multivariate feature flags are also supported:
|
|
117
127
|
|
|
118
|
-
HTML
|
|
119
|
-
|
|
120
128
|
```html
|
|
121
129
|
<feature name="awesome-new-feature" value="variant-a">
|
|
122
130
|
<p>This is the new feature variant A!</p>
|
|
@@ -128,8 +136,6 @@ HTML
|
|
|
128
136
|
|
|
129
137
|
You can also use the `FeatureGateAttribute` to gate access to controllers or actions:
|
|
130
138
|
|
|
131
|
-
C#
|
|
132
|
-
|
|
133
139
|
```csharp
|
|
134
140
|
[FeatureGate("awesome-new-feature")]
|
|
135
141
|
public class NewFeatureController : Controller
|
|
@@ -145,24 +151,18 @@ public class NewFeatureController : Controller
|
|
|
145
151
|
|
|
146
152
|
If you're not using ASP.NET Core (for example, in a console application, MAUI app, or Blazor WebAssembly), install the `PostHog` package instead of `PostHog.AspNetCore`. This package has no ASP.NET Core dependencies and can be used in any .NET project targeting .NET Standard 2.1 or .NET 8+.
|
|
147
153
|
|
|
148
|
-
Terminal
|
|
149
|
-
|
|
150
154
|
```bash
|
|
151
155
|
dotnet add package PostHog
|
|
152
156
|
```
|
|
153
157
|
|
|
154
158
|
The `PostHogClient` class must be implemented as a singleton in your project. For `PostHog.AspNetCore`, this is handled by the `builder.AddPostHog();` method. For the `PostHog` package, you can do the following if you're using dependency injection:
|
|
155
159
|
|
|
156
|
-
C#
|
|
157
|
-
|
|
158
160
|
```csharp
|
|
159
161
|
builder.Services.AddPostHog();
|
|
160
162
|
```
|
|
161
163
|
|
|
162
164
|
If you're not using a `builder` (such as in a console application), you can do the following:
|
|
163
165
|
|
|
164
|
-
C#
|
|
165
|
-
|
|
166
166
|
```csharp
|
|
167
167
|
using PostHog;
|
|
168
168
|
|
|
@@ -176,8 +176,6 @@ The `AddPostHog` methods accept an optional `Action<PostHogOptions>` parameter t
|
|
|
176
176
|
|
|
177
177
|
If you're not using dependency injection, you can create a static instance of the `PostHogClient` class and use that everywhere in your project:
|
|
178
178
|
|
|
179
|
-
C#
|
|
180
|
-
|
|
181
179
|
```csharp
|
|
182
180
|
using PostHog;
|
|
183
181
|
|
|
@@ -195,8 +193,6 @@ If you're not seeing the expected events being captured, the feature flags being
|
|
|
195
193
|
|
|
196
194
|
To see detailed logging, set the log level to `Debug` or `Trace` in `appsettings.json`:
|
|
197
195
|
|
|
198
|
-
JSON
|
|
199
|
-
|
|
200
196
|
```json
|
|
201
197
|
{
|
|
202
198
|
"DetailedErrors": true,
|
|
@@ -213,16 +209,14 @@ JSON
|
|
|
213
209
|
|
|
214
210
|
## Identifying users
|
|
215
211
|
|
|
216
|
-
> **Identifying users is required.** Backend events need a `distinct_id` that matches the ID your frontend uses when calling `posthog.identify()`. Without this, backend events are orphaned — they can't be linked to frontend event captures, [session replays](/docs/session-replay.md), [LLM traces](/docs/ai-engineering.md), or [error tracking](/docs/error-tracking.md).
|
|
212
|
+
> **Identifying users is required.** Backend events need a `distinct_id` that matches the ID your frontend uses when calling `posthog.identify()`. Without this, backend events are orphaned — they can't be linked to frontend event captures, [session replays](https://posthog.com/docs/session-replay.md), [LLM traces](https://posthog.com/docs/ai-engineering.md), or [error tracking](https://posthog.com/docs/error-tracking.md).
|
|
217
213
|
>
|
|
218
|
-
> See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
|
|
214
|
+
> See our guide on [identifying users](https://posthog.com/docs/getting-started/identify-users.md) for how to set this up.
|
|
219
215
|
|
|
220
216
|
## Capturing events
|
|
221
217
|
|
|
222
218
|
You can send custom events using `capture`:
|
|
223
219
|
|
|
224
|
-
C#
|
|
225
|
-
|
|
226
220
|
```csharp
|
|
227
221
|
posthog.Capture("distinct_id_of_the_user", "user_signed_up");
|
|
228
222
|
```
|
|
@@ -231,9 +225,7 @@ posthog.Capture("distinct_id_of_the_user", "user_signed_up");
|
|
|
231
225
|
|
|
232
226
|
### Setting event properties
|
|
233
227
|
|
|
234
|
-
Optionally, you can include additional information with the event by including a [properties](/docs/data/events.md#event-properties) object:
|
|
235
|
-
|
|
236
|
-
C#
|
|
228
|
+
Optionally, you can include additional information with the event by including a [properties](https://posthog.com/docs/data/events.md#event-properties) object:
|
|
237
229
|
|
|
238
230
|
```csharp
|
|
239
231
|
posthog.Capture(
|
|
@@ -250,8 +242,6 @@ posthog.Capture(
|
|
|
250
242
|
|
|
251
243
|
If you're aiming for a backend-only implementation of PostHog and won't be capturing events from your frontend, you can send `$pageview` events from your backend like so:
|
|
252
244
|
|
|
253
|
-
C#
|
|
254
|
-
|
|
255
245
|
```csharp
|
|
256
246
|
using PostHog;
|
|
257
247
|
using Microsoft.AspNetCore.Http.Extensions;
|
|
@@ -279,14 +269,12 @@ var app = builder.Build();
|
|
|
279
269
|
app.UsePostHogRequestContext();
|
|
280
270
|
```
|
|
281
271
|
|
|
282
|
-
If you're using [PostHog JS](/docs/libraries/js.md) on the frontend, configure [`tracing_headers`](/docs/libraries/js/config.md#tracing-headers) for your ASP.NET Core backend hostname so browser requests include the session and distinct ID headers.
|
|
272
|
+
If you're using [PostHog JS](https://posthog.com/docs/libraries/js.md) on the frontend, configure [`tracing_headers`](https://posthog.com/docs/libraries/js/config.md#tracing-headers) for your ASP.NET Core backend hostname so browser requests include the session and distinct ID headers.
|
|
283
273
|
|
|
284
274
|
The middleware reads `X-PostHog-Distinct-Id` and `X-PostHog-Session-Id` as request-scoped analytics context. It also adds request metadata such as `$current_url`, `$request_method`, `$request_path`, `$user_agent`, and `$ip`. Explicit distinct IDs and event properties always override request context.
|
|
285
275
|
|
|
286
276
|
Tracing headers are client-controlled analytics context, not authentication or authorization. For security-sensitive server-side decisions, pass an authenticated distinct ID explicitly. You can ignore tracing headers while still collecting request metadata:
|
|
287
277
|
|
|
288
|
-
C#
|
|
289
|
-
|
|
290
278
|
```csharp
|
|
291
279
|
app.UsePostHogRequestContext(options =>
|
|
292
280
|
{
|
|
@@ -302,8 +290,6 @@ You can manually capture exceptions using `CaptureException`. This sends a `$exc
|
|
|
302
290
|
|
|
303
291
|
File names, line numbers, and source context depend on debug information already available from the captured .NET stack trace. PostHog doesn't support uploading .NET PDB files yet, so production builds without runtime-accessible debug information may show less detailed stack frames.
|
|
304
292
|
|
|
305
|
-
C#
|
|
306
|
-
|
|
307
293
|
```csharp
|
|
308
294
|
try
|
|
309
295
|
{
|
|
@@ -317,8 +303,6 @@ catch (Exception exception)
|
|
|
317
303
|
|
|
318
304
|
Add custom properties to include request, tenant, or domain context:
|
|
319
305
|
|
|
320
|
-
C#
|
|
321
|
-
|
|
322
306
|
```csharp
|
|
323
307
|
posthog.CaptureException(
|
|
324
308
|
exception,
|
|
@@ -331,19 +315,17 @@ posthog.CaptureException(
|
|
|
331
315
|
);
|
|
332
316
|
```
|
|
333
317
|
|
|
334
|
-
For the full setup guide, see the [.NET error tracking installation docs](/docs/error-tracking/installation/dotnet.md).
|
|
318
|
+
For the full setup guide, see the [.NET error tracking installation docs](https://posthog.com/docs/error-tracking/installation/dotnet.md).
|
|
335
319
|
|
|
336
320
|
Automatic exception capture is not available in the .NET SDK yet.
|
|
337
321
|
|
|
338
322
|
## Logs
|
|
339
323
|
|
|
340
|
-
[PostHog Logs](/docs/logs.md) doesn't use this SDK. Logs are ingested over OpenTelemetry, so you attach an OTLP exporter to the standard `ILogger` pipeline instead — see the [.NET logs installation guide](/docs/logs/installation/dotnet.md).
|
|
324
|
+
[PostHog Logs](https://posthog.com/docs/logs.md) doesn't use this SDK. Logs are ingested over OpenTelemetry, so you attach an OTLP exporter to the standard `ILogger` pipeline instead — see the [.NET logs installation guide](https://posthog.com/docs/logs/installation/dotnet.md).
|
|
341
325
|
|
|
342
326
|
## Person profiles and properties
|
|
343
327
|
|
|
344
|
-
The .NET SDK captures identified events by default. These create [person profiles](/docs/data/persons.md). To set [person properties](/docs/product-analytics/person-properties.md) in these profiles, include them when capturing an event:
|
|
345
|
-
|
|
346
|
-
C#
|
|
328
|
+
The .NET SDK captures identified events by default. These create [person profiles](https://posthog.com/docs/data/persons.md). To set [person properties](https://posthog.com/docs/product-analytics/person-properties.md) in these profiles, include them when capturing an event:
|
|
347
329
|
|
|
348
330
|
```csharp
|
|
349
331
|
posthog.Capture(
|
|
@@ -354,11 +336,9 @@ posthog.Capture(
|
|
|
354
336
|
);
|
|
355
337
|
```
|
|
356
338
|
|
|
357
|
-
For more details on the difference between `$set` and `$set_once`, see our [person properties docs](/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once).
|
|
358
|
-
|
|
359
|
-
To capture [anonymous events](/docs/data/anonymous-vs-identified-events.md) without person profiles, set the event's `$process_person_profile` property to `false`:
|
|
339
|
+
For more details on the difference between `$set` and `$set_once`, see our [person properties docs](https://posthog.com/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once).
|
|
360
340
|
|
|
361
|
-
|
|
341
|
+
To capture [anonymous events](https://posthog.com/docs/data/anonymous-vs-identified-events.md) without person profiles, set the event's `$process_person_profile` property to `false`:
|
|
362
342
|
|
|
363
343
|
```csharp
|
|
364
344
|
posthog.Capture(
|
|
@@ -376,24 +356,20 @@ Sometimes, you want to assign multiple distinct IDs to a single user. This is he
|
|
|
376
356
|
|
|
377
357
|
In this case, you can use `alias` to assign another distinct ID to the same user.
|
|
378
358
|
|
|
379
|
-
C#
|
|
380
|
-
|
|
381
359
|
```csharp
|
|
382
360
|
await posthog.AliasAsync("current_distinct_id", "new_distinct_id");
|
|
383
361
|
```
|
|
384
362
|
|
|
385
|
-
We strongly recommend reading our docs on [alias](/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
|
|
363
|
+
We strongly recommend reading our docs on [alias](https://posthog.com/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
|
|
386
364
|
|
|
387
365
|
## Group analytics
|
|
388
366
|
|
|
389
|
-
Group analytics allows you to associate an event with a group (e.g. teams, organizations, etc.). Read the [group analytics](/docs/product-analytics/group-analytics.md) guide for more information.
|
|
367
|
+
Group analytics allows you to associate an event with a group (e.g. teams, organizations, etc.). Read the [group analytics](https://posthog.com/docs/product-analytics/group-analytics.md) guide for more information.
|
|
390
368
|
|
|
391
|
-
> **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on our [pricing page](/pricing.md).
|
|
369
|
+
> **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on our [pricing page](https://posthog.com/pricing.md).
|
|
392
370
|
|
|
393
371
|
To capture an event and associate it with a group, add the `groups` argument to your `Capture` call:
|
|
394
372
|
|
|
395
|
-
C#
|
|
396
|
-
|
|
397
373
|
```csharp
|
|
398
374
|
posthog.Capture(
|
|
399
375
|
"user_distinct_id",
|
|
@@ -403,8 +379,6 @@ posthog.Capture(
|
|
|
403
379
|
|
|
404
380
|
Update properties on a group, use the `GroupIdentifyAsync` method:
|
|
405
381
|
|
|
406
|
-
C#
|
|
407
|
-
|
|
408
382
|
```csharp
|
|
409
383
|
await posthog.GroupIdentifyAsync(
|
|
410
384
|
type: "company",
|
|
@@ -421,7 +395,7 @@ The `name` is a special property which is used in the PostHog UI for the name of
|
|
|
421
395
|
|
|
422
396
|
## Feature flags
|
|
423
397
|
|
|
424
|
-
PostHog's [feature flags](/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
|
|
398
|
+
PostHog's [feature flags](https://posthog.com/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
|
|
425
399
|
|
|
426
400
|
There are two steps to implement feature flags in .NET:
|
|
427
401
|
|
|
@@ -431,8 +405,6 @@ Call `EvaluateFlagsAsync()` once for the user, then read values from the returne
|
|
|
431
405
|
|
|
432
406
|
#### Boolean feature flags
|
|
433
407
|
|
|
434
|
-
C#
|
|
435
|
-
|
|
436
408
|
```csharp
|
|
437
409
|
var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
|
|
438
410
|
|
|
@@ -446,8 +418,6 @@ if (flags.IsEnabled("flag-key"))
|
|
|
446
418
|
|
|
447
419
|
#### Multivariate feature flags
|
|
448
420
|
|
|
449
|
-
C#
|
|
450
|
-
|
|
451
421
|
```csharp
|
|
452
422
|
var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
|
|
453
423
|
|
|
@@ -467,9 +437,9 @@ if (enabledVariant == "variant-key") // replace "variant-key" with the key of yo
|
|
|
467
437
|
|
|
468
438
|
### Step 2: Include feature flag information when capturing events
|
|
469
439
|
|
|
470
|
-
If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
|
|
440
|
+
If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
|
|
471
441
|
|
|
472
|
-
> **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
|
|
442
|
+
> **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
|
|
473
443
|
|
|
474
444
|
There are two methods you can use to include feature flag information in your events:
|
|
475
445
|
|
|
@@ -477,8 +447,6 @@ There are two methods you can use to include feature flag information in your ev
|
|
|
477
447
|
|
|
478
448
|
Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
|
|
479
449
|
|
|
480
|
-
C#
|
|
481
|
-
|
|
482
450
|
```csharp
|
|
483
451
|
var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
|
|
484
452
|
|
|
@@ -500,8 +468,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
|
|
|
500
468
|
|
|
501
469
|
To reduce event property bloat, pass a filtered snapshot:
|
|
502
470
|
|
|
503
|
-
C#
|
|
504
|
-
|
|
505
471
|
```csharp
|
|
506
472
|
// Attach only flags accessed with IsEnabled() or GetFlag() before this call
|
|
507
473
|
posthog.Capture(
|
|
@@ -526,8 +492,6 @@ posthog.Capture(
|
|
|
526
492
|
|
|
527
493
|
In the event properties, include `$feature/feature_flag_name: variant_key`:
|
|
528
494
|
|
|
529
|
-
C#
|
|
530
|
-
|
|
531
495
|
```csharp
|
|
532
496
|
posthog.Capture(
|
|
533
497
|
"distinct_id_of_your_user",
|
|
@@ -544,8 +508,6 @@ posthog.Capture(
|
|
|
544
508
|
|
|
545
509
|
By default, `EvaluateFlagsAsync()` evaluates every flag for the user. If you only need a few flags, pass `FlagKeysToEvaluate` to request only those flags:
|
|
546
510
|
|
|
547
|
-
C#
|
|
548
|
-
|
|
549
511
|
```csharp
|
|
550
512
|
var flags = await posthog.EvaluateFlagsAsync(
|
|
551
513
|
"distinct_id_of_your_user",
|
|
@@ -558,7 +520,7 @@ var flags = await posthog.EvaluateFlagsAsync(
|
|
|
558
520
|
|
|
559
521
|
### Sending `$feature_flag_called` events
|
|
560
522
|
|
|
561
|
-
Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `EvaluateFlagsAsync()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
|
|
523
|
+
Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `EvaluateFlagsAsync()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
|
|
562
524
|
|
|
563
525
|
The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
|
|
564
526
|
|
|
@@ -566,14 +528,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
|
|
|
566
528
|
|
|
567
529
|
### Advanced: Overriding server properties
|
|
568
530
|
|
|
569
|
-
Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
|
|
531
|
+
Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
|
|
570
532
|
|
|
571
533
|
You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
|
|
572
534
|
|
|
573
535
|
For example:
|
|
574
536
|
|
|
575
|
-
C#
|
|
576
|
-
|
|
577
537
|
```csharp
|
|
578
538
|
var flags = await posthog.EvaluateFlagsAsync(
|
|
579
539
|
"distinct_id_of_the_user",
|
|
@@ -634,8 +594,6 @@ Simply include any of these properties in the `person_properties` parameter alon
|
|
|
634
594
|
|
|
635
595
|
Configure evaluation contexts so this SDK only evaluates flags intended for the matching application, platform, or product area. For ASP.NET Core apps using `PostHog.AspNetCore`, add them to the `PostHog` configuration section:
|
|
636
596
|
|
|
637
|
-
JSON
|
|
638
|
-
|
|
639
597
|
```json
|
|
640
598
|
{
|
|
641
599
|
"PostHog": {
|
|
@@ -648,8 +606,6 @@ JSON
|
|
|
648
606
|
|
|
649
607
|
For code-based configuration, set `EvaluationContexts` on `PostHogOptions`:
|
|
650
608
|
|
|
651
|
-
C#
|
|
652
|
-
|
|
653
609
|
```csharp
|
|
654
610
|
var posthog = new PostHogClient(new PostHogOptions
|
|
655
611
|
{
|
|
@@ -661,7 +617,7 @@ var posthog = new PostHogClient(new PostHogOptions
|
|
|
661
617
|
|
|
662
618
|
Remote `/flags` requests from `EvaluateFlagsAsync()` include `evaluation_contexts` when configured.
|
|
663
619
|
|
|
664
|
-
For more details, see the [evaluation contexts guide](/docs/feature-flags/evaluation-contexts.md).
|
|
620
|
+
For more details, see the [evaluation contexts guide](https://posthog.com/docs/feature-flags/evaluation-contexts.md).
|
|
665
621
|
|
|
666
622
|
### Local evaluation
|
|
667
623
|
|
|
@@ -669,13 +625,11 @@ Evaluating feature flags requires making a request to PostHog for each flag. How
|
|
|
669
625
|
|
|
670
626
|
It is best practice to use local evaluation flags when possible, since this enables you to resolve flags faster and with fewer API calls.
|
|
671
627
|
|
|
672
|
-
For details on how to implement local evaluation, see our [local evaluation guide](/docs/feature-flags/local-evaluation.md).
|
|
628
|
+
For details on how to implement local evaluation, see our [local evaluation guide](https://posthog.com/docs/feature-flags/local-evaluation.md).
|
|
673
629
|
|
|
674
630
|
## Experiments (A/B tests)
|
|
675
631
|
|
|
676
|
-
Since [experiments](/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code:
|
|
677
|
-
|
|
678
|
-
C#
|
|
632
|
+
Since [experiments](https://posthog.com/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code:
|
|
679
633
|
|
|
680
634
|
```csharp
|
|
681
635
|
var flags = await posthog.EvaluateFlagsAsync("user_distinct_id");
|
|
@@ -687,13 +641,13 @@ if (variant == "variant-name")
|
|
|
687
641
|
}
|
|
688
642
|
```
|
|
689
643
|
|
|
690
|
-
It's also possible to [run experiments without using feature flags](/docs/experiments/running-experiments-without-feature-flags.md).
|
|
644
|
+
It's also possible to [run experiments without using feature flags](https://posthog.com/docs/experiments/running-experiments-without-feature-flags.md).
|
|
691
645
|
|
|
692
646
|
## AI observability
|
|
693
647
|
|
|
694
|
-
`PostHog.AI` adds [AI observability](/docs/ai-observability.md) for .NET applications using OpenAI or Azure OpenAI. It is currently pre-release, so expect breaking changes before a stable release.
|
|
648
|
+
`PostHog.AI` adds [AI observability](https://posthog.com/docs/ai-observability.md) for .NET applications using OpenAI or Azure OpenAI. It is currently pre-release, so expect breaking changes before a stable release.
|
|
695
649
|
|
|
696
|
-
For installation instructions, see the [OpenAI guide for .NET](/docs/ai-observability/installation/openai.md#net-support) or the [Azure OpenAI guide for .NET](/docs/ai-observability/installation/azure-openai.md#net-support).
|
|
650
|
+
For installation instructions, see the [OpenAI guide for .NET](https://posthog.com/docs/ai-observability/installation/openai.md#net-support) or the [Azure OpenAI guide for .NET](https://posthog.com/docs/ai-observability/installation/azure-openai.md#net-support).
|
|
697
651
|
|
|
698
652
|
## GeoIP properties
|
|
699
653
|
|
|
@@ -704,11 +658,3 @@ The `posthog-dotnet` library disregards the server IP, does not add the GeoIP pr
|
|
|
704
658
|
By default, the library buffers events before sending them to the `/batch` endpoint for better performance. This can lead to lost events in serverless environments if the .NET process is terminated by the platform before the buffer is fully flushed.
|
|
705
659
|
|
|
706
660
|
To avoid this, call `await posthog.FlushAsync()` after processing every request by adding it as a middleware to your server. This allows `posthog.Capture()` to remain asynchronous for better performance.
|
|
707
|
-
|
|
708
|
-
### Still have questions?
|
|
709
|
-
|
|
710
|
-
Ask PostHog AI
|
|
711
|
-
|
|
712
|
-
### Was this page useful?
|
|
713
|
-
|
|
714
|
-
HelpfulCould be better
|