Skip to content

Commit efb1f73

Browse files
authored
Merge pull request #20 from PostHog/vdekrijger-docs-update
docs: Update for readability
2 parents fcbcff3 + f5cb100 commit efb1f73

File tree

2 files changed

+77
-74
lines changed

2 files changed

+77
-74
lines changed

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
## 0.1.0 (Unreleased)
1+
# Changelog
22

3-
FEATURES:
3+
## 1.0.0
4+
5+
### Features
6+
7+
- **New Resource:** `posthog_insight` - Create and manage insights with full query JSON support (Trends, Funnels, etc.)
8+
- **New Resource:** `posthog_dashboard` - Manage dashboards with name, description, tags, and pinned status
9+
- **New Resource:** `posthog_feature_flag` - Feature flags with filters, rollout percentages, multivariate variants, and payloads
10+
- **New Resource:** `posthog_alert` - Threshold-based alerting on insights with configurable intervals and notifications
11+
- **New Resource:** `posthog_hog_function` - Hog functions for destinations, webhooks, and transformations
12+
13+
### Provider Features
14+
15+
- Support for US and EU PostHog Cloud, plus self-hosted instances
16+
- Automatic retry with exponential backoff for rate limits and transient errors
17+
- Import support for all resources

README.md

Lines changed: 61 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,111 @@
1-
# Terraform Provider Scaffolding (Terraform Plugin Framework)
1+
# Terraform Provider for PostHog
22

3-
_This template repository is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). The template repository built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) can be found at [terraform-provider-scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._
3+
Terraform provider for managing [PostHog](https://posthog.com) resources.
44

5-
This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:
5+
## Documentation
66

7-
- A resource and a data source (`internal/provider/`),
8-
- Examples (`examples/`) and generated documentation (`docs/`),
9-
- Miscellaneous meta files.
10-
11-
These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _Terraform Plugin Framework specific guides are titled accordingly._
12-
13-
Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub.
14-
15-
Once you've written your provider, you'll want to [publish it on the Terraform Registry](https://developer.hashicorp.com/terraform/registry/providers/publishing) so that others can use it.
7+
For usage documentation and supported resources, see the [Terraform Registry](https://registry.terraform.io/providers/posthog/posthog/latest/docs).
168

179
## Requirements
1810

1911
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
2012
- [Go](https://golang.org/doc/install) >= 1.24
2113

22-
## Building The Provider
23-
24-
1. Clone the repository
25-
1. Enter the repository directory
26-
1. Build the provider using the Go `install` command:
14+
## Building the Provider
2715

2816
```shell
2917
go install
3018
```
3119

32-
## Adding Dependencies
20+
## Local Development
21+
22+
The `playground/` directory lets you test provider changes locally without publishing.
23+
24+
### Setup
3325

34-
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
35-
Please see the Go documentation for the most up to date information about using Go modules.
26+
1. Create your Terraform config in `playground/` (e.g., `playground/demo.tf`)
3627

37-
To add a new dependency `github.com/author/dependency` to your Terraform provider:
28+
2. Build the provider and run terraform:
3829

3930
```shell
40-
go get github.com/author/dependency
41-
go mod tidy
42-
```
31+
# Plan changes
32+
make playground-plan
4333

44-
Then commit the changes to `go.mod` and `go.sum`.
45-
46-
## Using the provider
47-
48-
Configure the provider with your PostHog host, personal API key, and default project/environment ID. All resources inherit this project scope.
49-
50-
```hcl
51-
provider "posthog" {
52-
host = "https://us.posthog.com"
53-
api_key = var.posthog_api_key
54-
project_id = var.posthog_project_id
55-
}
56-
57-
resource "posthog_insight" "weekly_signups" {
58-
name = "Weekly signups"
59-
description = "Tracks sign up volume per week"
60-
derived_name = "Weekly signups"
61-
62-
query_json = jsonencode({
63-
kind = "InsightVizNode"
64-
source = {
65-
kind = "TrendsQuery"
66-
series = [{
67-
kind= "EventsNode"
68-
name = "$pageview"
69-
event = "$pageview"
70-
math= "total"
71-
}]
72-
version = 2
73-
trendsFilter = {}
74-
}
75-
})
76-
tags = ["managed-by:terraform"]
77-
create_in_folder = "Unfiled/Insights"
78-
}
34+
# Apply changes
35+
make playground-apply
7936
```
8037

81-
To import an existing insight, run:
38+
This builds the provider binary and configures Terraform to use your local build via `dev_overrides` - no `terraform init` required.
39+
40+
### Manual Setup
41+
42+
If you prefer to test outside the playground directory:
8243

8344
```shell
84-
terraform import posthog_insight.weekly_signups "<insight_id>"
45+
# Build the provider
46+
make playground-binary
47+
48+
# Point Terraform to your local build
49+
export TF_CLI_CONFIG_FILE=/path/to/terraform-provider-posthog/playground/terraformrc
50+
51+
# Run terraform commands in any directory
52+
terraform plan
53+
terraform apply
8554
```
8655

87-
## Developing the Provider
56+
### Cleanup
8857

89-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
58+
```shell
59+
make playground-clean
60+
```
61+
62+
## Testing
9063

91-
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
64+
### Unit Tests
9265

93-
To generate or update documentation, run `make generate`.
66+
```shell
67+
go test ./...
68+
```
9469

95-
In order to run the full suite of Acceptance tests, run `make testacc`.
70+
### Acceptance Tests
9671

97-
*Note:* Acceptance tests create real resources, and often cost money to run.
72+
Acceptance tests run against a real PostHog instance and create actual resources:
9873

9974
```shell
75+
export POSTHOG_API_KEY="your-api-key"
76+
export POSTHOG_PROJECT_ID="12345"
77+
export POSTHOG_HOST="https://us.posthog.com"
78+
10079
make testacc
10180
```
10281

82+
## Generating Documentation
83+
84+
```shell
85+
make generate
86+
```
87+
10388
## Releasing
10489

105-
Releases are automated via GoReleaser when a signed tag is pushed. The Makefile provides convenience targets for creating releases:
90+
Releases are automated via GoReleaser when a signed tag is pushed. The Makefile provides convenience targets:
10691

10792
```shell
10893
# Alpha releases (pre-release, for early testing)
109-
make release-alpha VERSION=0.1.0 NUM=1 # creates v0.1.0-alpha.1
94+
make release-alpha VERSION=1.0.0 NUM=1 # creates v1.0.0-alpha.1
11095

11196
# Beta releases (pre-release, feature complete)
112-
make release-beta VERSION=0.1.0 NUM=1 # creates v0.1.0-beta.1
97+
make release-beta VERSION=1.0.0 NUM=1 # creates v1.0.0-beta.1
11398

11499
# Stable releases
115-
make release VERSION=0.1.0 # creates v0.1.0
100+
make release VERSION=1.0.0 # creates v1.0.0
116101
```
117102

118103
**Requirements:**
119104
- GPG key configured for signing (`git tag -s`)
120105
- GPG key added to your GitHub account (for the "Verified" badge)
121106

122-
Pre-release versions (alpha, beta) won't be installed by default — users must explicitly pin to them in their Terraform configuration.
107+
Pre-release versions (alpha, beta) won't be installed by default - users must explicitly pin to them in their Terraform configuration.
108+
109+
## License
110+
111+
See [LICENSE](LICENSE).

0 commit comments

Comments
 (0)