Skip to content

Add OptOut / OptIn / IsOptOut support #197

Description

@marandaneto

Problem Statement

The .NET SDK currently has a Disabled option that is read once when PostHogClient is constructed, but it does not expose runtime opt-out controls like other PostHog SDKs.

Other SDKs commonly provide APIs such as OptOut, OptIn, and IsOptOut so applications can dynamically stop and resume capture, for example after a user changes privacy preferences or tracking consent.

Without these APIs, callers may try to mutate PostHogOptions.Disabled after the client is created, but that has no effect because the disabled state is captured during client construction.

Solution Brainstorm

Add runtime opt-out APIs to the .NET SDK, matching the behavior and naming conventions of other PostHog SDKs where possible:

  • OptOut() / OptOutAsync()
  • OptIn() / OptInAsync()
  • IsOptOut / IsOptOut()

Consider whether opt-out state should be:

  • in-memory only for server-side usage,
  • persisted through an injectable store, or
  • configurable per client/application environment.

When opted out, capture/identify/group/feature-flag calls should no-op consistently and log clearly enough for operators to understand why.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions