Integrations / PostHog
PostHog
Product analytics (US cloud): run HogQL queries, list events, persons and feature flags.
6 actions
API key
6 read0 write
Calls us.posthog.com
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "posthog" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
This toolkit uses a single credential and requests no scopes.
Actions
List eventsreadposthog.list_eventsList recent raw events of a project, optionally for one event name or person. Prefer run_hogql_query for anything analytic.
| Input | Type | Description | |
|---|---|---|---|
project_id | string | Required | Project id |
event | string | Optional | Event name, e.g. $pageview |
distinct_id | string | Optional | Only this person's distinct id |
after | string | Optional | ISO time: only events after this |
before | string | Optional | ISO time: only events before this |
limit | integer | Optional | Page size |
await setu.execute({
userId: "user_1",
action: "posthog.list_events",
input: {
"project_id": "<project_id>"
},
});List feature flagsreadposthog.list_feature_flagsList a project's feature flags: id, key, name, whether active and rollout filters.
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Page size |
offset | integer | Optional | Items to skip |
project_id | string | Required | Project id |
search | string | Optional | Search by key or name |
active | string | Optional | Filter on serving state |
await setu.execute({
userId: "user_1",
action: "posthog.list_feature_flags",
input: {
"project_id": "<project_id>"
},
});List organizationsreadposthog.list_organizationsList the PostHog organizations the key can access. Organization ids are needed to list projects.
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Page size |
offset | integer | Optional | Items to skip |
await setu.execute({
userId: "user_1",
action: "posthog.list_organizations",
input: {},
});List personsreadposthog.list_personsList or search the people tracked in a project by email, name or distinct id.
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Page size |
offset | integer | Optional | Items to skip |
project_id | string | Required | Project id |
search | string | Optional | Search by email, name, person id or distinct id |
email | string | Optional | Exact email |
distinct_id | string | Optional | Exact distinct id |
await setu.execute({
userId: "user_1",
action: "posthog.list_persons",
input: {
"project_id": "<project_id>"
},
});List projectsreadposthog.list_projectsList the projects of a PostHog organization: numeric project id and name. The project id is used by every other action.
| Input | Type | Description | |
|---|---|---|---|
limit | integer | Optional | Page size |
offset | integer | Optional | Items to skip |
organization_id | string | Required | Organization id (uuid) |
await setu.execute({
userId: "user_1",
action: "posthog.list_projects",
input: {
"organization_id": "<organization_id>"
},
});Run HogQL queryreadposthog.run_hogql_queryRun a read-only HogQL (SQL-like) query against a project's analytics data, e.g. counts of events by day. Add your own LIMIT; without one at most 100 rows return.
| Input | Type | Description | |
|---|---|---|---|
project_id | string | Required | Project id |
query | string | Required | HogQL text, e.g. select event, count() from events group by event limit 20 |
name | string | Optional | Label for the query log |
await setu.execute({
userId: "user_1",
action: "posthog.run_hogql_query",
input: {
"project_id": "<project_id>",
"query": "<query>"
},
});