Skip to content

Commit af47c22

Browse files
committed
Add .NET to adding experiment code
1 parent de25e3e commit af47c22

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

contents/docs/experiments/adding-experiment-code.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ if feature_flag.enabled == "variant-name" do
149149
end
150150
```
151151

152+
```dotnet
153+
var featureFlag = await posthog.GetFeatureFlagAsync("experiment-feature-flag-key", "user_distinct_id");
154+
155+
if (featureFlag is { VariantKey: "variant-name" })
156+
{
157+
// Do something
158+
}
159+
```
152160
</MultiLanguage>
153161

154162
> Since feature flags are not supported yet in our Java and Rust SDKs, to run an experiment using these SDKs see our docs on [how to run experiments without feature flags](/docs/experiments/running-experiments-without-feature-flags). This also applies to running experiments using our API.
@@ -230,6 +238,13 @@ posthog.capture(
230238
);
231239
```
232240

241+
```dotnet
242+
posthog.Capture(
243+
"distinct_id",
244+
"event_name_of_your_goal_metric",
245+
properties: new() { ["$feature/experiment-feature-flag-key"] = "variant-name" }
246+
);
247+
```
233248
</MultiLanguage>
234249

235250
import Tab from "components/Tab"
@@ -238,6 +253,7 @@ import NodeMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags
238253
import GoMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags-code-go-set-send-feature-flags-to-true.mdx"
239254
import PythonMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags-code-python-set-send-feature-flags-to-true.mdx"
240255
import PHPMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags-code-php-set-send-feature-flags-to-true.mdx"
256+
import DotNetMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags-code-dotnet-set-send-feature-flags-to-true.mdx"
241257

242258
### Method 2: Set `send_feature_flags` to `true`
243259

@@ -265,5 +281,8 @@ import PHPMethod2 from "../integrate/feature-flags-code/_snippets/feature-flags-
265281
<Tab.Panel>
266282
<GoMethod2 />
267283
</Tab.Panel>
284+
<Tab.Panel>
285+
<DotNetMethod2 />
286+
</Tab.Panel>
268287
</Tab.Panels>
269288
</Tab.Group>

0 commit comments

Comments
 (0)