Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plugins/PostHog/v1/configValidation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"steps": [
{
"displayName": "Authenticate",
"dataStream": {
"name": "currentUser"
},
"required": true,
"error": "Could not authenticate with PostHog. Check that your personal API key is valid, has not expired, and that the correct region is selected.",
"success": "Connected to PostHog successfully."
}
]
}
30 changes: 30 additions & 0 deletions plugins/PostHog/v1/custom_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"name": "PostHog Organization",
"sourceType": "PostHog Organization",
"icon": "building",
"singular": "Organization",
"plural": "Organizations"
},
{
"name": "PostHog Project",
"sourceType": "PostHog Project",
"icon": "cube",
"singular": "Project",
"plural": "Projects"
},
{
"name": "PostHog Member",
"sourceType": "PostHog Member",
"icon": "user",
"singular": "Member",
"plural": "Members"
},
{
"name": "PostHog Feature Flag",
"sourceType": "PostHog Feature Flag",
"icon": "flag",
"singular": "Feature Flag",
"plural": "Feature Flags"
}
]
68 changes: 68 additions & 0 deletions plugins/PostHog/v1/dataStreams/activeHours.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "activeHours",
"displayName": "Active Hours",
"description": "Event activity by day of week and hour of day for a project",
"tags": [
"Web Analytics"
],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "post",
"endpointPath": "api/projects/{{object.rawId}}/query/",
"postBody": {
"query": {
"kind": "HogQLQuery",
"query": "SELECT toDayOfWeek(timestamp) AS day_of_week, toHour(timestamp) AS hour_of_day, count() AS events FROM events WHERE event = '$pageview' AND timestamp >= toDateTime('{{timeframe.start}}') AND timestamp < toDateTime('{{timeframe.end}}') GROUP BY day_of_week, hour_of_day ORDER BY day_of_week, hour_of_day"
}
},
"postRequestScript": "activeHours.js"
},
"matches": {
"sourceType": {
"type": "oneOf",
"values": [
"PostHog Project"
]
}
},
"metadata": [
{
"name": "day_name",
"displayName": "Day",
"shape": "string",
"role": "label"
},
{
"name": "day_of_week",
"displayName": "Day of Week",
"shape": "number",
"visible": false
},
{
"name": "hour_of_day",
"displayName": "Hour",
"shape": "number"
},
{
"name": "events",
"displayName": "Events",
"shape": "number",
"role": "value"
}
],
"timeframes": true,
"defaultShaping": {
"sort": {
"by": [
[
"day_of_week",
"asc"
],
[
"hour_of_day",
"asc"
]
]
}
}
}
53 changes: 53 additions & 0 deletions plugins/PostHog/v1/dataStreams/activeUsers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "activeUsers",
"displayName": "Active Users",
"description": "Number of unique active users per day for a project",
"tags": [
"Users",
"Analytics"
],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "post",
"endpointPath": "api/projects/{{object.rawId}}/query/",
"postBody": {
"query": {
"kind": "HogQLQuery",
"query": "SELECT toStartOfDay(timestamp) AS day, count(DISTINCT person_id) AS active_users FROM events WHERE timestamp >= toDateTime('{{timeframe.start}}') AND timestamp < toDateTime('{{timeframe.end}}') GROUP BY day ORDER BY day"
}
},
"postRequestScript": "activeUsers.js"
},
"matches": {
"sourceType": {
"type": "oneOf",
"values": [
"PostHog Project"
]
}
},
"metadata": [
{
"name": "day",
"displayName": "Day",
"shape": "date",
"role": "timestamp"
},
{
"name": "active_users",
"displayName": "Active Users",
"shape": "number",
"role": "value"
}
],
"timeframes": [
"last7days",
"last30days",
"thisMonth",
"lastMonth",
"thisQuarter",
"thisYear",
"lastQuarter",
"lastYear"
]
}
40 changes: 40 additions & 0 deletions plugins/PostHog/v1/dataStreams/currentUser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "currentUser",
"displayName": "Current User",
"description": "Returns the authenticated PostHog user",
"tags": [
"User"
],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "get",
"endpointPath": "api/users/@me/",
"postRequestScript": "currentUser.js"
},
"matches": "none",
"metadata": [
{
"name": "uuid",
"displayName": "ID",
"visible": false
},
{
"name": "email",
"displayName": "Email",
"role": "label"
},
{
"name": "first_name",
"displayName": "First name"
},
{
"name": "distinct_id",
"displayName": "Distinct ID",
"visible": false
}
],
"timeframes": false,
"visibility": {
"type": "hidden"
}
}
55 changes: 55 additions & 0 deletions plugins/PostHog/v1/dataStreams/eventBreakdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "eventBreakdown",
"displayName": "Event Breakdown",
"description": "Top events by count within the selected timeframe for a project",
"tags": [
"Events",
"Analytics"
],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "post",
"endpointPath": "api/projects/{{object.rawId}}/query/",
"postBody": {
"query": {
"kind": "HogQLQuery",
"query": "SELECT event AS event_name, count() AS count FROM events WHERE timestamp >= toDateTime('{{timeframe.start}}') AND timestamp < toDateTime('{{timeframe.end}}') GROUP BY event ORDER BY count DESC LIMIT 25"
}
},
"postRequestScript": "eventBreakdown.js"
},
"matches": {
"sourceType": {
"type": "oneOf",
"values": [
"PostHog Project"
]
}
},
"metadata": [
{
"name": "event_name",
"displayName": "Event",
"shape": "string",
"role": "label"
},
{
"name": "count",
"displayName": "Count",
"shape": "number",
"role": "value"
}
],
"timeframes": true,
"defaultTimeframe": "dashboard",
"defaultShaping": {
"sort": {
"by": [
[
"count",
"desc"
]
]
}
}
}
58 changes: 58 additions & 0 deletions plugins/PostHog/v1/dataStreams/eventVolume.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "eventVolume",
"displayName": "Event Volume",
"description": "Event count over time for a project, optionally filtered to a single event name",
"tags": [
"Events",
"Analytics"
],
"baseDataSourceName": "httpRequestScopedSingle",
"config": {
"httpMethod": "post",
"endpointPath": "api/projects/{{object.rawId}}/query/",
"postBody": {
"query": {
"kind": "HogQLQuery",
"query": "SELECT toStartOfHour(timestamp) AS time, count() AS events FROM events WHERE timestamp >= toDateTime('{{timeframe.start}}') AND timestamp < toDateTime('{{timeframe.end}}') {{event ? \"AND event = '\" + event.split(\"'\").join(\"''\") + \"'\" : ''}} GROUP BY time ORDER BY time"
}
},
"postRequestScript": "eventVolume.js"
},
"matches": {
"sourceType": {
"type": "oneOf",
"values": [
"PostHog Project"
]
}
},
"ui": [
{
"type": "text",
"name": "event",
"label": "Event name (optional)",
"help": "Filter to a specific event name, e.g. $pageview. Leave blank to count all events."
}
],
"metadata": [
{
"name": "time",
"displayName": "Time",
"shape": "date",
"role": "timestamp"
},
{
"name": "events",
"displayName": "Events",
"shape": "number",
"role": "value"
}
],
"timeframes": [
"last1hour",
"last12hours",
"last24hours",
"last7days",
"last30days"
]
}
Loading
Loading