View as Markdown
PostHog icon

PostHog ACTION

Create Project Insight

Create a new insight in a project. See the documentation
  • Action
  • Writes data
  • API key
  • SDK
  • MCP

IMPLEMENTATION

Call this tool

Connect a user's PostHog account once, then configure and run Create Project Insight from your backend or agent.

import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "posthog-create-project-insight",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    posthog: { authProvisionId: "apn_xxxxxxx" },
    organizationId: "Organization ID",
    projectId: "Project ID",
  },
})

console.log(result)

SCHEMA

Inputs

Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.

Create Project Insight inputs
Property Type Description
organizationId Organization ID string
Identifier of an organization
Required Dynamic
projectId Project ID string
Identifier of a project
Required Dynamic
name Name string
Name of the insight
Optional
derivedName Derived Name string
Derived name of the insight
Optional
query Query object

Query object defining the insight. Must be a valid PostHog query object with format: {"kind": "InsightVizNode", "source": {...}}.

Common query types:

  • TrendsQuery: Time-series trend analysis. Example: {"kind": "InsightVizNode", "source": {"kind": "TrendsQuery", "series": [{"kind": "EventsNode", "event": "pageview", "name": "pageview", "math": "total"}], "trendsFilter": {}}}
  • FunnelsQuery: Conversion funnel analysis. Example: {"kind": "InsightVizNode", "source": {"kind": "FunnelsQuery", "series": [{"kind": "EventsNode", "event": "signup_started"}, {"kind": "EventsNode", "event": "signup_completed"}], "funnelsFilter": {}}}
  • RetentionQuery: User retention analysis
  • PathsQuery: User path exploration
  • LifecycleQuery: User lifecycle tracking

See PostHog Query API documentation for complete query specifications.

Optional
description Description string
Description of the insight
Optional
tags Tags string[]
Tags for the insight
Optional
favorited Favorited boolean
Whether the insight is favorited
Optional
deleted Deleted boolean
Whether the insight is deleted
Optional

REFERENCE

Tool details

Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.

Registry key
posthog-create-project-insight
Version
0.0.1
App
PostHog
Authentication
API key
Read-only
No
Destructive
No
Idempotent
No
Open world
Yes