Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions context/commandments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ commandments:
- Avoid deprecated feature flag helpers such as `IsFeatureEnabled`, `GetFeatureFlag`, `GetFeatureFlagPayload`, and `Capture.SendFeatureFlags` in new code
- For error tracking, use `posthog.NewDefaultException(...)` for direct captures or wrap `log/slog` with `posthog.NewSlogCaptureHandler(...)` for automatic warning-and-above exception capture

rust:
- posthog-rs is the Rust SDK crate; add it with `cargo add posthog-rs` and construct the client with `posthog_rs::client(options).await`
- Create one client per process and share it (for example an `Arc` in your app state or a `OnceCell`); do not build a new client per request or task
- Configure the project token and host from environment variables via `ClientOptions` (the `(api_key, host)` tuple); never hardcode PostHog secrets
- Because `capture` is fire-and-forget, always call `client.flush().await` and `client.shutdown().await` during graceful shutdown so queued events are delivered before exit
- Server-side captures must set a stable `distinct_id` on `Event::new(event, distinct_id)` that matches frontend identify calls; avoid anonymous or literal IDs for business events
- The SDK has no `identify` or `alias` helper; set person properties by inserting a `$set` property on an event
- For feature flags, call `client.evaluate_flags(distinct_id, EvaluateFlagsOptions::default()).await` once per user/request, then read values from the returned snapshot with `is_enabled(...)`
- For error tracking, use `client.capture_exception_with(&err, CaptureExceptionOptions::new()...)`; the `error-tracking` feature is enabled by default in recent versions
- The Rust SDK has no surveys or session replay support; do not promise or scaffold those features

dotnet:
- posthog-dotnet package names are `PostHog` for general .NET apps and `PostHog.AspNetCore` for ASP.NET Core apps
- Use environment variables, user secrets, or configuration providers for `ProjectToken`, `HostUrl`, and `PersonalApiKey`; never hardcode PostHog secrets
Expand Down
9 changes: 9 additions & 0 deletions context/skills/integration/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ variants:
docs_urls:
- https://posthog.com/docs/libraries/go.md

- id: rust
framework: rust
example_paths: example-apps/rust
display_name: Rust
description: PostHog integration for Rust applications using the posthog-rs SDK
tags: [rust]
docs_urls:
- https://posthog.com/docs/libraries/rust.md

- id: swift
framework: swift
example_paths:
Expand Down
3 changes: 3 additions & 0 deletions context/skip-patterns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ global:
- bin/
- obj/

# Rust
- target/

# PHP General
- vendor
- .phpunit.result.cache
Expand Down
8 changes: 8 additions & 0 deletions example-apps/rust/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copy this file to `.env` and fill in your values, then export them
# (e.g. `export $(grep -v '^#' .env | xargs)`) before running the app.

# Your PostHog project token (from Project settings).
POSTHOG_PROJECT_TOKEN=your_posthog_project_token

# PostHog host. Defaults to https://us.i.posthog.com when unset.
POSTHOG_HOST=https://us.i.posthog.com
2 changes: 2 additions & 0 deletions example-apps/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
.env
Loading
Loading