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
2 changes: 1 addition & 1 deletion components/posthog/actions/capture-event/capture-event.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "posthog-capture-event",
name: "Capture Event",
description: "Captures a given event within the PostHog system. [See the documentation](https://posthog.com/docs/api/post-only-endpoints#single-event)",
version: "0.0.5",
version: "0.0.6",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import posthog from "../../posthog.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "posthog-create-project-insight",
name: "Create Project Insight",
description: "Create a new insight in a project. [See the documentation](https://posthog.com/docs/api/insights#post-api-projects-project_id-insights)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
idempotentHint: false,
},
type: "action",
props: {
posthog,
organizationId: {
propDefinition: [
posthog,
"organizationId",
],
},
projectId: {
propDefinition: [
posthog,
"projectId",
(c) => ({
organizationId: c.organizationId,
}),
],
},
name: {
type: "string",
label: "Name",
description: "Name of the insight",
optional: true,
},
derivedName: {
type: "string",
label: "Derived Name",
description: "Derived name of the insight",
optional: true,
},
query: {
type: "object",
label: "Query",
description: "Query object defining the insight. Must be a valid PostHog query object (e.g., InsightVizNode with source)",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Description of the insight",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Tags for the insight",
optional: true,
},
favorited: {
type: "boolean",
label: "Favorited",
description: "Whether the insight is favorited",
optional: true,
},
deleted: {
type: "boolean",
label: "Deleted",
description: "Whether the insight is deleted",
optional: true,
},
},
async run({ $ }) {
const {
posthog,
projectId,
name,
derivedName,
query,
description,
tags,
favorited,
deleted,
} = this;

const insight = await posthog.createInsight({
$,
projectId,
data: {
name,
derived_name: derivedName,
query: utils.parseJson(query),
description,
tags: utils.parseJson(tags),
favorited,
deleted,
},
});

$.export("$summary", `Successfully created insight${name
? ` "${name}"`
: ""} with ID ${insight.id}`);
return insight;
},
};
2 changes: 1 addition & 1 deletion components/posthog/actions/create-query/create-query.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "posthog-create-query",
name: "Create Query",
description: "Create a HogQLQuery and return the results. [See the documentation](https://posthog.com/docs/api/queries#creating-a-query)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/posthog/actions/get-cohorts/get-cohorts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "posthog-get-cohorts",
name: "Get Cohorts",
description: "Retrieve a list of cohorts. [See the documentation](https://posthog.com/docs/api/cohorts#get-api-projects-project_id-cohorts)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/posthog/actions/get-persons/get-persons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "posthog-get-persons",
name: "Get Persons",
description: "Retrieve a list of persons. [See the documentation](https://posthog.com/docs/api/persons#get-api-projects-project_id-persons)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import posthog from "../../posthog.app.mjs";

export default {
key: "posthog-get-project-insight",
name: "Get Project Insight",
description: "Retrieve a specific insight from a project. [See the documentation](https://posthog.com/docs/api/insights#get-api-projects-project_id-insights-id)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
type: "action",
props: {
posthog,
organizationId: {
propDefinition: [
posthog,
"organizationId",
],
},
projectId: {
propDefinition: [
posthog,
"projectId",
(c) => ({
organizationId: c.organizationId,
}),
],
},
insightId: {
propDefinition: [
posthog,
"insightId",
(c) => ({
projectId: c.projectId,
}),
],
},
fromDashboard: {
type: "string",
label: "From Dashboard",
description: "Only if loading an insight in the context of a dashboard: The relevant dashboard's ID. When set, the specified dashboard's filters and date range override will be applied.",
optional: true,
},
refresh: {
type: "string",
label: "Refresh",
description: "Whether to refresh the insight. Options: `force_cache`, `blocking`, `async`, `lazy_async`, `force_blocking`, `force_async`",
optional: true,
default: "force_cache",
options: [
"force_cache",
"blocking",
"async",
"lazy_async",
"force_blocking",
"force_async",
],
},
},
async run({ $ }) {
const {
posthog,
projectId,
insightId,
fromDashboard,
refresh,
} = this;

const insight = await posthog.getInsight({
$,
projectId,
insightId,
params: {
from_dashboard: fromDashboard,
refresh,
},
});

$.export("$summary", `Successfully retrieved insight with ID ${insightId}`);
return insight;
},
};
2 changes: 1 addition & 1 deletion components/posthog/actions/get-surveys/get-surveys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "posthog-get-surveys",
name: "Get Surveys",
description: "Retrieve a list of surveys. [See the documentation](https://posthog.com/docs/api/surveys#get-api-projects-project_id-surveys)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import posthog from "../../posthog.app.mjs";

export default {
key: "posthog-list-project-insights",
name: "List Project Insights",
description: "Retrieve a list of insights for a project. [See the documentation](https://posthog.com/docs/api/insights#get-api-projects-project_id-insights)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
type: "action",
props: {
posthog,
organizationId: {
propDefinition: [
posthog,
"organizationId",
],
},
projectId: {
propDefinition: [
posthog,
"projectId",
(c) => ({
organizationId: c.organizationId,
}),
],
},
basic: {
type: "boolean",
label: "Basic",
description: "Return basic insight metadata only (no results, faster).",
optional: true,
},
refresh: {
type: "string",
label: "Refresh",
description: "Whether to refresh the retrieved insights. Options: `force_cache`, `blocking`, `async`, `lazy_async`, `force_blocking`, `force_async`. Default: `force_cache`",
optional: true,
default: "force_cache",
options: [
"force_cache",
"blocking",
"async",
"lazy_async",
"force_blocking",
"force_async",
],
Comment on lines +44 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to a constants.mjs file.

},
maxResults: {
propDefinition: [
posthog,
"maxResults",
],
},
},
async run({ $ }) {
const {
posthog,
projectId,
basic,
refresh,
maxResults,
} = this;

const insights = await posthog.iterateResults({
fn: posthog.listInsights,
args: {
$,
projectId,
params: {
basic,
refresh,
},
},
max: maxResults,
});

$.export("$summary", `Successfully retrieved ${insights.length} insight${insights.length === 1
? ""
: "s"}`);
return insights;
},
};
Loading
Loading