pulumi-posthog 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,344 @@
1
+ # Pulumi PostHog Provider
2
+
3
+ A Pulumi provider for managing PostHog analytics, product insights, and feature flag resources, dynamically bridged from the [Terraform PostHog Provider](https://github.com/PostHog/terraform-provider-posthog).
4
+
5
+ ## Introduction
6
+
7
+ This package provides a Pulumi provider that enables you to manage your PostHog product analytics and feature flag infrastructure using TypeScript, JavaScript, Python, Go, or C#. The provider is automatically generated from the Terraform PostHog provider, giving you access to all its functionality within the Pulumi ecosystem.
8
+
9
+ ### Features
10
+
11
+ - **Product Analytics**: Configure projects, cohorts, and insights for analyzing user behavior
12
+ - **Feature Flags**: Create and manage feature flags with rollout strategies and targeting rules
13
+ - **Event Actions**: Define custom actions to track specific user behaviors
14
+ - **Annotations**: Add context to your analytics with time-based annotations
15
+ - **Dashboards**: Build and maintain custom dashboards for data visualization
16
+ - **Experiments**: Run A/B tests and multivariate experiments
17
+ - **Session Recording**: Configure session recording settings and filters
18
+ - **TypeScript Support**: Full type safety with comprehensive TypeScript definitions
19
+
20
+ ## Installation
21
+
22
+ ### npm
23
+
24
+ ```bash
25
+ npm install pulumi-posthog
26
+ ```
27
+
28
+ ### yarn
29
+
30
+ ```bash
31
+ yarn add pulumi-posthog
32
+ ```
33
+
34
+ ### pnpm
35
+
36
+ ```bash
37
+ pnpm add pulumi-posthog
38
+ ```
39
+
40
+ ### bun
41
+
42
+ ```bash
43
+ bun add pulumi-posthog
44
+ ```
45
+
46
+ ## Configuration
47
+
48
+ Before using the PostHog provider, you need to configure your API credentials.
49
+
50
+ ### Required Configuration
51
+
52
+ - **API Key**: Your PostHog Personal API Key
53
+ - **Host**: Your PostHog instance URL (e.g., `https://app.posthog.com` or your self-hosted URL)
54
+
55
+ ### Environment Variables
56
+
57
+ ```bash
58
+ export POSTHOG_API_KEY="your-api-key-here"
59
+ export POSTHOG_HOST="https://app.posthog.com"
60
+ ```
61
+
62
+ ### Pulumi Configuration
63
+
64
+ ```typescript
65
+ import * as pulumi from '@pulumi/pulumi'
66
+
67
+ const config = new pulumi.Config('posthog')
68
+ config.require('apiKey')
69
+ config.require('host')
70
+ ```
71
+
72
+ Or using the Pulumi CLI:
73
+
74
+ ```bash
75
+ pulumi config set posthog:apiKey "your-api-key-here" --secret
76
+ pulumi config set posthog:host "https://app.posthog.com"
77
+ ```
78
+
79
+ ## Quick Start
80
+
81
+ ### Feature Flag Example
82
+
83
+ ```typescript
84
+ import * as pulumi from '@pulumi/pulumi'
85
+ import * as posthog from 'pulumi-posthog'
86
+
87
+ // Create a feature flag
88
+ const betaFeature = new posthog.FeatureFlag('beta-feature', {
89
+ key: 'new-dashboard',
90
+ name: 'New Dashboard Beta',
91
+ active: true,
92
+ filters: {
93
+ groups: [
94
+ {
95
+ properties: [],
96
+ rolloutPercentage: 25,
97
+ },
98
+ ],
99
+ },
100
+ })
101
+
102
+ // Export the feature flag key
103
+ export const featureFlagKey = betaFeature.key
104
+ ```
105
+
106
+ ### Project Example
107
+
108
+ ```typescript
109
+ import * as pulumi from '@pulumi/pulumi'
110
+ import * as posthog from 'pulumi-posthog'
111
+
112
+ // Create a new project
113
+ const project = new posthog.Project('analytics-project', {
114
+ name: 'Production Analytics',
115
+ isDemo: false,
116
+ })
117
+
118
+ // Export the project ID
119
+ export const projectId = project.id
120
+ ```
121
+
122
+ ### Action Example
123
+
124
+ ```typescript
125
+ import * as pulumi from '@pulumi/pulumi'
126
+ import * as posthog from 'pulumi-posthog'
127
+
128
+ // Create a custom action to track button clicks
129
+ const buttonClickAction = new posthog.Action('button-click', {
130
+ name: 'Checkout Button Click',
131
+ description: 'Tracks when users click the checkout button',
132
+ steps: [
133
+ {
134
+ event: '$autocapture',
135
+ selector: '#checkout-button',
136
+ url: '/cart',
137
+ },
138
+ ],
139
+ })
140
+
141
+ // Export the action ID
142
+ export const actionId = buttonClickAction.id
143
+ ```
144
+
145
+ ## Available Resources
146
+
147
+ This provider supports the following PostHog resources:
148
+
149
+ - **Projects**: Manage PostHog projects
150
+ - **Feature Flags**: Create and configure feature flags with targeting rules
151
+ - **Actions**: Define custom event actions
152
+ - **Cohorts**: Create user segments based on properties and behaviors
153
+ - **Annotations**: Add contextual markers to your analytics timeline
154
+ - **Dashboards**: Build custom dashboards
155
+ - **Insights**: Configure analytics insights
156
+ - **Webhooks**: Set up webhook integrations
157
+
158
+ ## Advanced Usage
159
+
160
+ ### Feature Flag with Complex Targeting
161
+
162
+ ```typescript
163
+ import * as posthog from 'pulumi-posthog'
164
+
165
+ const advancedFlag = new posthog.FeatureFlag('advanced-targeting', {
166
+ key: 'premium-features',
167
+ name: 'Premium Features',
168
+ active: true,
169
+ filters: {
170
+ groups: [
171
+ {
172
+ properties: [
173
+ {
174
+ key: 'plan',
175
+ value: 'premium',
176
+ type: 'person',
177
+ operator: 'exact',
178
+ },
179
+ ],
180
+ rolloutPercentage: 100,
181
+ },
182
+ {
183
+ properties: [],
184
+ rolloutPercentage: 10, // 10% rollout for non-premium users
185
+ },
186
+ ],
187
+ },
188
+ ensureExperienceContinuity: true,
189
+ })
190
+ ```
191
+
192
+ ### Multi-Resource Setup
193
+
194
+ ```typescript
195
+ import * as pulumi from '@pulumi/pulumi'
196
+ import * as posthog from 'pulumi-posthog'
197
+
198
+ // Create a project
199
+ const project = new posthog.Project('app-project', {
200
+ name: 'My Application',
201
+ })
202
+
203
+ // Create an action within the project
204
+ const signupAction = new posthog.Action(
205
+ 'signup-action',
206
+ {
207
+ name: 'User Signup',
208
+ description: 'Tracks successful user signups',
209
+ projectId: project.id,
210
+ steps: [
211
+ {
212
+ event: 'signup_completed',
213
+ },
214
+ ],
215
+ },
216
+ { dependsOn: [project] },
217
+ )
218
+
219
+ // Create a cohort of users who signed up
220
+ const signupCohort = new posthog.Cohort(
221
+ 'signup-cohort',
222
+ {
223
+ name: 'Signed Up Users',
224
+ projectId: project.id,
225
+ filters: {
226
+ properties: {
227
+ type: 'AND',
228
+ values: [
229
+ {
230
+ type: 'action',
231
+ key: signupAction.id,
232
+ },
233
+ ],
234
+ },
235
+ },
236
+ },
237
+ { dependsOn: [signupAction] },
238
+ )
239
+
240
+ export const projectName = project.name
241
+ export const actionId = signupAction.id
242
+ export const cohortId = signupCohort.id
243
+ ```
244
+
245
+ ## Authentication
246
+
247
+ ### Getting Your API Key
248
+
249
+ 1. Log in to your PostHog instance
250
+ 2. Navigate to **Settings** → **User** → **Personal API Keys**
251
+ 3. Click **Create Personal API Key**
252
+ 4. Copy the generated key
253
+ 5. Set it as an environment variable or Pulumi config:
254
+
255
+ ```bash
256
+ # Environment variable
257
+ export POSTHOG_API_KEY="phx_your_api_key_here"
258
+
259
+ # Or Pulumi config (recommended)
260
+ pulumi config set posthog:apiKey "phx_your_api_key_here" --secret
261
+ ```
262
+
263
+ ### Self-Hosted PostHog
264
+
265
+ If you're using a self-hosted PostHog instance, configure the host:
266
+
267
+ ```bash
268
+ export POSTHOG_HOST="https://posthog.yourcompany.com"
269
+ # or
270
+ pulumi config set posthog:host "https://posthog.yourcompany.com"
271
+ ```
272
+
273
+ ## Documentation
274
+
275
+ For detailed documentation on all available resources and their properties, visit:
276
+
277
+ - [PostHog Documentation](https://posthog.com/docs)
278
+ - [Terraform PostHog Provider](https://registry.terraform.io/providers/PostHog/posthog/latest/docs)
279
+ - [Pulumi Documentation](https://www.pulumi.com/docs/)
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Authentication Errors
284
+
285
+ If you encounter authentication errors:
286
+
287
+ 1. Verify your API key is correct and not expired
288
+ 2. Ensure your API key has the necessary permissions
289
+ 3. Check that your host URL is correctly configured
290
+ 4. Confirm network connectivity to your PostHog instance
291
+
292
+ ### Resource Not Found
293
+
294
+ If resources aren't found after creation:
295
+
296
+ 1. Check that you're using the correct project ID
297
+ 2. Verify the resource was created successfully in the PostHog UI
298
+ 3. Ensure your API key has access to the project
299
+
300
+ ### Common Issues
301
+
302
+ **Issue**: `401 Unauthorized` error
303
+ **Solution**: Verify your API key is valid and properly configured
304
+
305
+ **Issue**: `403 Forbidden` error
306
+ **Solution**: Check that your API key has the required permissions for the operation
307
+
308
+ **Issue**: Resources not appearing in PostHog UI
309
+ **Solution**: Wait a few moments for replication, or check if you're viewing the correct project
310
+
311
+ ## Examples
312
+
313
+ For more examples, check out the [examples directory](https://github.com/hckhanh/pulumi-any-terraform/tree/main/examples) in the repository.
314
+
315
+ ## Contributing
316
+
317
+ Contributions are welcome! Please read the [Contributing Guide](https://github.com/hckhanh/pulumi-any-terraform/blob/main/CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
318
+
319
+ ## Support
320
+
321
+ - **Issues**: [GitHub Issues](https://github.com/hckhanh/pulumi-any-terraform/issues)
322
+ - **Discussions**: [GitHub Discussions](https://github.com/hckhanh/pulumi-any-terraform/discussions)
323
+ - **PostHog Community**: [PostHog Slack](https://posthog.com/slack)
324
+
325
+ ## License
326
+
327
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/hckhanh/pulumi-any-terraform/blob/main/LICENSE) file for details.
328
+
329
+ ## Acknowledgments
330
+
331
+ - [PostHog](https://posthog.com/) for building an amazing product analytics platform
332
+ - [Terraform PostHog Provider](https://github.com/PostHog/terraform-provider-posthog) maintainers
333
+ - [Pulumi](https://www.pulumi.com/) for the infrastructure as code platform
334
+ - The open-source community for continuous support and contributions
335
+
336
+ ## Related Projects
337
+
338
+ - [PostHog](https://github.com/PostHog/posthog) - Open-source product analytics
339
+ - [Pulumi Terraform Bridge](https://github.com/pulumi/pulumi-terraform-bridge) - Bridge technology
340
+ - [Other Pulumi Providers](https://github.com/hckhanh/pulumi-any-terraform) - More bridged providers
341
+
342
+ ---
343
+
344
+ **Part of the [Pulumi Any Terraform](https://github.com/hckhanh/pulumi-any-terraform) collection**
package/bin/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * PostHog Pulumi Provider
3
+ *
4
+ * This package provides a Pulumi provider for managing PostHog resources.
5
+ * The TypeScript SDK is dynamically generated from the Terraform PostHog provider.
6
+ *
7
+ * To use this provider, install it via npm and configure your PostHog credentials:
8
+ *
9
+ * ```typescript
10
+ * import * as posthog from 'pulumi-posthog';
11
+ * ```
12
+ *
13
+ * For more information, see the README.md file.
14
+ */
15
+ export declare const version = "1.0.1";
package/bin/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // *** WARNING: This is a placeholder file. ***
3
+ // *** The actual implementation will be generated by pulumi-language-nodejs. ***
4
+ // *** To generate the SDK, run: pulumi package gen-sdk <schema> ***
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.version = void 0;
7
+ /**
8
+ * PostHog Pulumi Provider
9
+ *
10
+ * This package provides a Pulumi provider for managing PostHog resources.
11
+ * The TypeScript SDK is dynamically generated from the Terraform PostHog provider.
12
+ *
13
+ * To use this provider, install it via npm and configure your PostHog credentials:
14
+ *
15
+ * ```typescript
16
+ * import * as posthog from 'pulumi-posthog';
17
+ * ```
18
+ *
19
+ * For more information, see the README.md file.
20
+ */
21
+ exports.version = "1.0.1";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,iFAAiF;AACjF,oEAAoE;;;AAEpE;;;;;;;;;;;;;GAaG;AAEU,QAAA,OAAO,GAAG,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "pulumi-posthog",
3
+ "description": "A Pulumi provider for managing PostHog analytics, feature flags, and product insights resources, dynamically bridged from the Terraform PostHog provider with support for projects, feature flags, actions, annotations, and dashboards.",
4
+ "version": "0.0.0",
5
+ "homepage": "https://pulumi.khanh.id",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hckhanh/pulumi-any-terraform.git",
9
+ "directory": "packages/posthog"
10
+ },
11
+ "private": false,
12
+ "sideEffects": false,
13
+ "main": "./bin/index.js",
14
+ "module": "./bin/index.js",
15
+ "types": "./bin/index.d.ts",
16
+ "exports": {
17
+ ".": "./bin/index.js",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "dependencies": {
21
+ "async-mutex": "0.5.0"
22
+ },
23
+ "devDependencies": {
24
+ "@pulumi/pulumi": "3.215.0",
25
+ "@types/node": "24.10.7",
26
+ "typescript": "5.9.3"
27
+ },
28
+ "peerDependencies": {
29
+ "@pulumi/pulumi": ">=3.190.0 <4"
30
+ },
31
+ "files": [
32
+ "bin",
33
+ "README.md"
34
+ ],
35
+ "keywords": [
36
+ "pulumi",
37
+ "posthog",
38
+ "analytics",
39
+ "feature-flags",
40
+ "product-analytics",
41
+ "event-tracking",
42
+ "session-recording",
43
+ "experiments",
44
+ "insights",
45
+ "terraform",
46
+ "provider",
47
+ "infrastructure"
48
+ ],
49
+ "license": "MIT",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "pulumi": {
54
+ "resource": true,
55
+ "name": "terraform-provider",
56
+ "version": "1.0.2",
57
+ "parameterization": {
58
+ "name": "posthog",
59
+ "version": "0.0.0",
60
+ "value": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkudGVycmFmb3JtLmlvL3Bvc3Rob2cvcG9zdGhvZyIsInZlcnNpb24iOiIwLjAuMCJ9fQ=="
61
+ }
62
+ }
63
+ }