Thank you for your interest in contributing to the PostHog Unity SDK! This document provides guidelines and instructions for development.
- .NET SDK 8.0+
- Unity 2021.3 LTS or later (for testing in-editor)
- Git
-
Clone the repository:
git clone https://github.com/PostHog/posthog-unity.git cd posthog-unity -
Run the bootstrap script to install dependencies:
bin/bootstrap
posthog-unity/
├── com.posthog.unity/ # Unity package (main SDK)
│ ├── Runtime/ # SDK source code
│ ├── Editor/ # Unity Editor integrations
│ └── Samples~/ # Example code
├── tests/
│ └── PostHog.Unity.Tests/ # Unit tests
├── bin/ # Development scripts
│ ├── bootstrap # Install dependencies
│ ├── fmt # Format code
│ └── test # Run tests
├── scripts/ # Release scripts
│ └── bump-version.sh # Sync version to platform files
├── .changeset/ # Changeset files for versioning
└── .github/workflows/ # CI/CD pipelines
Run all unit tests:
bin/testRun tests with a filter:
bin/test --filter "FeatureFlag"Run tests with verbose output:
bin/test --verboseFormat all C# files:
bin/fmtCheck formatting without making changes (used in CI):
bin/fmt --checkThe formatter uses:
dotnet formatfor code style (file-scoped namespaces, etc.)- CSharpier for whitespace formatting
Build the SDK to verify it compiles:
bin/build- Use file-scoped namespaces
- Follow C# naming conventions (PascalCase for public members, camelCase with underscore prefix for private fields)
- Add XML documentation comments for public APIs
- Keep methods focused and short
- Write tests for new functionality
-
Create a branch from
mainwith a descriptive name -
Write tests for any new functionality
-
Run tests and formatting before submitting:
bin/fmt && bin/test -
Keep commits clean with clear, concise messages
-
Update documentation if you're changing public APIs
- Tests pass (
bin/test) - Code is formatted (
bin/fmt --check) - Documentation updated (if applicable)
- No breaking changes (or clearly documented if intentional)
To test the SDK in a Unity project:
- Open Unity Package Manager
- Click "+" and select "Add package from disk"
- Navigate to
com.posthog.unity/package.json - The SDK will be imported into your project
Releases are managed through GitHub Actions. See RELEASING.md for the full release process.
- Open an issue for bugs or feature requests
- Check existing issues before creating new ones
- Join the PostHog community Slack for questions
By contributing, you agree that your contributions will be licensed under the MIT License.