@keystrokehq/posthog 0.0.9 → 0.0.16-integration-id-canonicalization.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 +28 -48
- package/dist/{client.mjs → client-BZWd9-On.mjs} +195 -4
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +3 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +5 -1
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/posthog.credential-set-C8TimFgo.d.mts +30 -0
- package/dist/posthog.credential-set-DwYnDkeD.mjs +28 -0
- package/dist/{schemas.d.mts → schemas/index.d.mts} +4 -4
- package/dist/{schemas.mjs → schemas/index.mjs} +1 -1
- package/dist/surveys-update.operation-C0MYZZ04.mjs +3836 -0
- package/dist/surveys-update.operation-gxREsmzk.d.mts +4578 -0
- package/dist/{triggers.d.mts → triggers/index.d.mts} +4 -4
- package/dist/{triggers.mjs → triggers/index.mjs} +5 -6
- package/package.json +13 -85
- package/dist/_official/index.d.mts +0 -2
- package/dist/_official/index.mjs +0 -3
- package/dist/_runtime/index.d.mts +0 -6
- package/dist/_runtime/index.mjs +0 -3
- package/dist/actions.d.mts +0 -244
- package/dist/actions.mjs +0 -129
- package/dist/annotations.d.mts +0 -185
- package/dist/annotations.mjs +0 -141
- package/dist/capture.d.mts +0 -177
- package/dist/capture.mjs +0 -241
- package/dist/client.d.mts +0 -50
- package/dist/cohorts.d.mts +0 -229
- package/dist/cohorts.mjs +0 -185
- package/dist/connection.d.mts +0 -2
- package/dist/connection.mjs +0 -3
- package/dist/dashboards.d.mts +0 -434
- package/dist/dashboards.mjs +0 -356
- package/dist/decide.d.mts +0 -74
- package/dist/decide.mjs +0 -75
- package/dist/errors.d.mts +0 -58
- package/dist/errors.mjs +0 -120
- package/dist/events-management.d.mts +0 -294
- package/dist/events-management.mjs +0 -242
- package/dist/factory-C3ssyfSy.mjs +0 -7
- package/dist/feature-flags.d.mts +0 -416
- package/dist/feature-flags.mjs +0 -317
- package/dist/http-BYcjqxPi.mjs +0 -84
- package/dist/insights.d.mts +0 -409
- package/dist/insights.mjs +0 -346
- package/dist/integration-BN7xcpga.d.mts +0 -63
- package/dist/integration-D0HdrI0T.mjs +0 -120
- package/dist/organizations.d.mts +0 -257
- package/dist/organizations.mjs +0 -219
- package/dist/persons.d.mts +0 -369
- package/dist/persons.mjs +0 -345
- package/dist/projects.d.mts +0 -348
- package/dist/projects.mjs +0 -287
- package/dist/session-recordings.d.mts +0 -391
- package/dist/session-recordings.mjs +0 -308
- package/dist/surveys.d.mts +0 -287
- package/dist/surveys.mjs +0 -208
- package/dist/webhook-management.d.mts +0 -188
- package/dist/webhook-management.mjs +0 -152
|
@@ -0,0 +1,3836 @@
|
|
|
1
|
+
import { t as posthogCredentialSet } from "./posthog.credential-set-DwYnDkeD.mjs";
|
|
2
|
+
import { actionSchema, analyticsEventSchema, annotationSchema, captureResponseSchema, cohortSchema, dashboardCollaboratorSchema, dashboardSchema, dashboardTemplateSchema, decideResponseSchema, eventDefinitionSchema, featureFlagFiltersSchema, featureFlagRoleAccessSchema, featureFlagSchema, insightSchema, localEvaluationResponseSchema, organizationSchema, paginatedResponseSchema, personSchema, projectIdInputShape, projectMemberSchema, projectSchema, propertiesBagSchema, sessionRecordingPlaylistSchema, sessionRecordingSchema, sharingConfigurationSchema, surveySchema } from "./schemas/index.mjs";
|
|
3
|
+
import { n as createPosthogIngestClient, r as createPosthogManagementClient, t as createPosthogDecideClient } from "./client-BZWd9-On.mjs";
|
|
4
|
+
import { Operation } from "@keystrokehq/core";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
//#region src/utils/domain-inputs/webhook-management.ts
|
|
8
|
+
const actionIdInput = {
|
|
9
|
+
...projectIdInputShape,
|
|
10
|
+
actionId: z.number().int()
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/operations/action-webhooks-attach.operation.ts
|
|
15
|
+
const actionWebhooksAttachOperation = new Operation({
|
|
16
|
+
id: "posthog.action-webhooks-attach",
|
|
17
|
+
name: "PostHog Attach Action Webhook",
|
|
18
|
+
description: "Enable Slack-webhook posting on an action with a message format",
|
|
19
|
+
credentialSets: [posthogCredentialSet],
|
|
20
|
+
input: z.object({
|
|
21
|
+
...actionIdInput,
|
|
22
|
+
slack_message_format: z.string().min(1)
|
|
23
|
+
}),
|
|
24
|
+
output: actionSchema,
|
|
25
|
+
needsApproval: true,
|
|
26
|
+
run: async (input, context) => {
|
|
27
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
28
|
+
const projectId = client.projectId(input.projectId);
|
|
29
|
+
return client.request({
|
|
30
|
+
method: "PATCH",
|
|
31
|
+
path: `/api/projects/${projectId}/actions/${input.actionId}/`,
|
|
32
|
+
body: {
|
|
33
|
+
post_to_slack: true,
|
|
34
|
+
slack_message_format: input.slack_message_format
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/operations/action-webhooks-detach.operation.ts
|
|
42
|
+
const actionWebhooksDetachOperation = new Operation({
|
|
43
|
+
id: "posthog.action-webhooks-detach",
|
|
44
|
+
name: "PostHog Detach Action Webhook",
|
|
45
|
+
description: "Disable Slack-webhook posting on an action",
|
|
46
|
+
credentialSets: [posthogCredentialSet],
|
|
47
|
+
input: z.object(actionIdInput),
|
|
48
|
+
output: actionSchema,
|
|
49
|
+
needsApproval: true,
|
|
50
|
+
run: async (input, context) => {
|
|
51
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
52
|
+
const projectId = client.projectId(input.projectId);
|
|
53
|
+
return client.request({
|
|
54
|
+
method: "PATCH",
|
|
55
|
+
path: `/api/projects/${projectId}/actions/${input.actionId}/`,
|
|
56
|
+
body: {
|
|
57
|
+
post_to_slack: false,
|
|
58
|
+
slack_message_format: null
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/operations/action-webhooks-list.operation.ts
|
|
66
|
+
const actionWebhooksListOperation = new Operation({
|
|
67
|
+
id: "posthog.action-webhooks-list",
|
|
68
|
+
name: "PostHog List Action Webhooks",
|
|
69
|
+
description: "List actions configured to post to a Slack webhook",
|
|
70
|
+
credentialSets: [posthogCredentialSet],
|
|
71
|
+
input: z.object({
|
|
72
|
+
...projectIdInputShape,
|
|
73
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
74
|
+
}),
|
|
75
|
+
output: paginatedResponseSchema(actionSchema),
|
|
76
|
+
run: async (input, context) => {
|
|
77
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
78
|
+
const projectId = client.projectId(input.projectId);
|
|
79
|
+
return client.request({
|
|
80
|
+
method: "GET",
|
|
81
|
+
path: `/api/projects/${projectId}/actions/`,
|
|
82
|
+
query: {
|
|
83
|
+
limit: input.limit,
|
|
84
|
+
post_to_slack: true
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/utils/domain-inputs/surveys.ts
|
|
92
|
+
const idInput$3 = {
|
|
93
|
+
...projectIdInputShape,
|
|
94
|
+
id: z.string().min(1)
|
|
95
|
+
};
|
|
96
|
+
const writeShape$1 = {
|
|
97
|
+
name: z.string().optional(),
|
|
98
|
+
description: z.string().nullable().optional(),
|
|
99
|
+
type: z.enum([
|
|
100
|
+
"popover",
|
|
101
|
+
"api",
|
|
102
|
+
"widget",
|
|
103
|
+
"button",
|
|
104
|
+
"full_screen",
|
|
105
|
+
"email"
|
|
106
|
+
]).optional(),
|
|
107
|
+
questions: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
108
|
+
conditions: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
109
|
+
appearance: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
110
|
+
targeting_flag_id: z.number().int().nullable().optional(),
|
|
111
|
+
start_date: z.string().nullable().optional(),
|
|
112
|
+
end_date: z.string().nullable().optional(),
|
|
113
|
+
responses_limit: z.number().int().nullable().optional(),
|
|
114
|
+
archived: z.boolean().optional()
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/operations/actions-create.operation.ts
|
|
119
|
+
const actionsCreateOperation = new Operation({
|
|
120
|
+
id: "posthog.actions-create",
|
|
121
|
+
name: "PostHog Create Action",
|
|
122
|
+
description: "Create a new action",
|
|
123
|
+
credentialSets: [posthogCredentialSet],
|
|
124
|
+
input: z.object({
|
|
125
|
+
...projectIdInputShape,
|
|
126
|
+
...writeShape$1,
|
|
127
|
+
name: z.string().min(1)
|
|
128
|
+
}),
|
|
129
|
+
output: actionSchema,
|
|
130
|
+
needsApproval: true,
|
|
131
|
+
run: async (input, context) => {
|
|
132
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
133
|
+
const projectId = client.projectId(input.projectId);
|
|
134
|
+
const { projectId: _pid, ...body } = input;
|
|
135
|
+
return client.request({
|
|
136
|
+
method: "POST",
|
|
137
|
+
path: `/api/projects/${projectId}/actions/`,
|
|
138
|
+
body
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/operations/actions-delete.operation.ts
|
|
145
|
+
const actionsDeleteOperation = new Operation({
|
|
146
|
+
id: "posthog.actions-delete",
|
|
147
|
+
name: "PostHog Delete Action",
|
|
148
|
+
description: "Soft-delete an action",
|
|
149
|
+
credentialSets: [posthogCredentialSet],
|
|
150
|
+
input: z.object(idInput$3),
|
|
151
|
+
output: actionSchema,
|
|
152
|
+
needsApproval: true,
|
|
153
|
+
run: async (input, context) => {
|
|
154
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
155
|
+
const projectId = client.projectId(input.projectId);
|
|
156
|
+
return client.request({
|
|
157
|
+
method: "PATCH",
|
|
158
|
+
path: `/api/projects/${projectId}/actions/${input.id}/`,
|
|
159
|
+
body: { deleted: true }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/operations/actions-get.operation.ts
|
|
166
|
+
const actionsGetOperation = new Operation({
|
|
167
|
+
id: "posthog.actions-get",
|
|
168
|
+
name: "PostHog Get Action",
|
|
169
|
+
description: "Retrieve an action by id",
|
|
170
|
+
credentialSets: [posthogCredentialSet],
|
|
171
|
+
input: z.object(idInput$3),
|
|
172
|
+
output: actionSchema,
|
|
173
|
+
run: async (input, context) => {
|
|
174
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
175
|
+
const projectId = client.projectId(input.projectId);
|
|
176
|
+
return client.request({
|
|
177
|
+
method: "GET",
|
|
178
|
+
path: `/api/projects/${projectId}/actions/${input.id}/`
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/operations/actions-list.operation.ts
|
|
185
|
+
const actionsListOperation = new Operation({
|
|
186
|
+
id: "posthog.actions-list",
|
|
187
|
+
name: "PostHog List Actions",
|
|
188
|
+
description: "List actions in a project",
|
|
189
|
+
credentialSets: [posthogCredentialSet],
|
|
190
|
+
input: z.object({
|
|
191
|
+
...projectIdInputShape,
|
|
192
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
193
|
+
offset: z.number().int().min(0).optional(),
|
|
194
|
+
search: z.string().optional()
|
|
195
|
+
}),
|
|
196
|
+
output: paginatedResponseSchema(actionSchema),
|
|
197
|
+
run: async (input, context) => {
|
|
198
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
199
|
+
const projectId = client.projectId(input.projectId);
|
|
200
|
+
return client.request({
|
|
201
|
+
method: "GET",
|
|
202
|
+
path: `/api/projects/${projectId}/actions/`,
|
|
203
|
+
query: {
|
|
204
|
+
limit: input.limit,
|
|
205
|
+
offset: input.offset,
|
|
206
|
+
search: input.search
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/operations/actions-update.operation.ts
|
|
214
|
+
const actionsUpdateOperation = new Operation({
|
|
215
|
+
id: "posthog.actions-update",
|
|
216
|
+
name: "PostHog Update Action",
|
|
217
|
+
description: "Partial update to an action",
|
|
218
|
+
credentialSets: [posthogCredentialSet],
|
|
219
|
+
input: z.object({
|
|
220
|
+
...idInput$3,
|
|
221
|
+
...writeShape$1
|
|
222
|
+
}),
|
|
223
|
+
output: actionSchema,
|
|
224
|
+
needsApproval: true,
|
|
225
|
+
run: async (input, context) => {
|
|
226
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
227
|
+
const projectId = client.projectId(input.projectId);
|
|
228
|
+
const { projectId: _pid, id, ...body } = input;
|
|
229
|
+
return client.request({
|
|
230
|
+
method: "PATCH",
|
|
231
|
+
path: `/api/projects/${projectId}/actions/${id}/`,
|
|
232
|
+
body
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/operations/alias-person.operation.ts
|
|
239
|
+
const aliasPersonOperation = new Operation({
|
|
240
|
+
id: "posthog.alias-person",
|
|
241
|
+
name: "PostHog Alias Person",
|
|
242
|
+
description: "Merge one distinct_id into another via a $create_alias event",
|
|
243
|
+
credentialSets: [posthogCredentialSet],
|
|
244
|
+
input: z.object({
|
|
245
|
+
distinctId: z.string().min(1),
|
|
246
|
+
alias: z.string().min(1),
|
|
247
|
+
timestamp: z.iso.datetime().optional()
|
|
248
|
+
}),
|
|
249
|
+
output: captureResponseSchema,
|
|
250
|
+
needsApproval: true,
|
|
251
|
+
run: async (input, context) => {
|
|
252
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
253
|
+
return client.request({
|
|
254
|
+
method: "POST",
|
|
255
|
+
path: "/capture/",
|
|
256
|
+
body: {
|
|
257
|
+
api_key: client.projectApiKey(),
|
|
258
|
+
event: "$create_alias",
|
|
259
|
+
distinct_id: input.distinctId,
|
|
260
|
+
properties: { alias: input.alias },
|
|
261
|
+
...input.timestamp ? { timestamp: input.timestamp } : {}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/operations/annotations-create.operation.ts
|
|
269
|
+
const annotationsCreateOperation = new Operation({
|
|
270
|
+
id: "posthog.annotations-create",
|
|
271
|
+
name: "PostHog Create Annotation",
|
|
272
|
+
description: "Create a new annotation",
|
|
273
|
+
credentialSets: [posthogCredentialSet],
|
|
274
|
+
input: z.object({
|
|
275
|
+
...projectIdInputShape,
|
|
276
|
+
...writeShape$1,
|
|
277
|
+
content: z.string().min(1),
|
|
278
|
+
date_marker: z.string().min(1)
|
|
279
|
+
}),
|
|
280
|
+
output: annotationSchema,
|
|
281
|
+
needsApproval: true,
|
|
282
|
+
run: async (input, context) => {
|
|
283
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
284
|
+
const projectId = client.projectId(input.projectId);
|
|
285
|
+
const { projectId: _pid, ...body } = input;
|
|
286
|
+
return client.request({
|
|
287
|
+
method: "POST",
|
|
288
|
+
path: `/api/projects/${projectId}/annotations/`,
|
|
289
|
+
body
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/operations/annotations-delete.operation.ts
|
|
296
|
+
const annotationsDeleteOperation = new Operation({
|
|
297
|
+
id: "posthog.annotations-delete",
|
|
298
|
+
name: "PostHog Delete Annotation",
|
|
299
|
+
description: "Delete an annotation",
|
|
300
|
+
credentialSets: [posthogCredentialSet],
|
|
301
|
+
input: z.object(idInput$3),
|
|
302
|
+
output: z.object({ success: z.boolean() }),
|
|
303
|
+
needsApproval: true,
|
|
304
|
+
run: async (input, context) => {
|
|
305
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
306
|
+
const projectId = client.projectId(input.projectId);
|
|
307
|
+
await client.request({
|
|
308
|
+
method: "DELETE",
|
|
309
|
+
path: `/api/projects/${projectId}/annotations/${input.id}/`
|
|
310
|
+
});
|
|
311
|
+
return { success: true };
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/operations/annotations-get.operation.ts
|
|
317
|
+
const annotationsGetOperation = new Operation({
|
|
318
|
+
id: "posthog.annotations-get",
|
|
319
|
+
name: "PostHog Get Annotation",
|
|
320
|
+
description: "Retrieve an annotation by id",
|
|
321
|
+
credentialSets: [posthogCredentialSet],
|
|
322
|
+
input: z.object(idInput$3),
|
|
323
|
+
output: annotationSchema,
|
|
324
|
+
run: async (input, context) => {
|
|
325
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
326
|
+
const projectId = client.projectId(input.projectId);
|
|
327
|
+
return client.request({
|
|
328
|
+
method: "GET",
|
|
329
|
+
path: `/api/projects/${projectId}/annotations/${input.id}/`
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/operations/annotations-list.operation.ts
|
|
336
|
+
const annotationsListOperation = new Operation({
|
|
337
|
+
id: "posthog.annotations-list",
|
|
338
|
+
name: "PostHog List Annotations",
|
|
339
|
+
description: "List annotations in a project",
|
|
340
|
+
credentialSets: [posthogCredentialSet],
|
|
341
|
+
input: z.object({
|
|
342
|
+
...projectIdInputShape,
|
|
343
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
344
|
+
offset: z.number().int().min(0).optional(),
|
|
345
|
+
search: z.string().optional(),
|
|
346
|
+
scope: z.enum([
|
|
347
|
+
"dashboard_item",
|
|
348
|
+
"project",
|
|
349
|
+
"organization"
|
|
350
|
+
]).optional(),
|
|
351
|
+
dashboardItemId: z.number().int().optional()
|
|
352
|
+
}),
|
|
353
|
+
output: paginatedResponseSchema(annotationSchema),
|
|
354
|
+
run: async (input, context) => {
|
|
355
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
356
|
+
const projectId = client.projectId(input.projectId);
|
|
357
|
+
return client.request({
|
|
358
|
+
method: "GET",
|
|
359
|
+
path: `/api/projects/${projectId}/annotations/`,
|
|
360
|
+
query: {
|
|
361
|
+
limit: input.limit,
|
|
362
|
+
offset: input.offset,
|
|
363
|
+
search: input.search,
|
|
364
|
+
scope: input.scope,
|
|
365
|
+
dashboardItemId: input.dashboardItemId
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/operations/annotations-update.operation.ts
|
|
373
|
+
const annotationsUpdateOperation = new Operation({
|
|
374
|
+
id: "posthog.annotations-update",
|
|
375
|
+
name: "PostHog Update Annotation",
|
|
376
|
+
description: "Partial update to an annotation",
|
|
377
|
+
credentialSets: [posthogCredentialSet],
|
|
378
|
+
input: z.object({
|
|
379
|
+
...idInput$3,
|
|
380
|
+
...writeShape$1
|
|
381
|
+
}),
|
|
382
|
+
output: annotationSchema,
|
|
383
|
+
needsApproval: true,
|
|
384
|
+
run: async (input, context) => {
|
|
385
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
386
|
+
const projectId = client.projectId(input.projectId);
|
|
387
|
+
const { projectId: _pid, id, ...body } = input;
|
|
388
|
+
return client.request({
|
|
389
|
+
method: "PATCH",
|
|
390
|
+
path: `/api/projects/${projectId}/annotations/${id}/`,
|
|
391
|
+
body
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/operations/capture-batch-events.operation.ts
|
|
398
|
+
const captureBatchEventsOperation = new Operation({
|
|
399
|
+
id: "posthog.capture-batch-events",
|
|
400
|
+
name: "PostHog Capture Batch",
|
|
401
|
+
description: "Capture up to 100 analytics events via the PostHog /batch endpoint",
|
|
402
|
+
credentialSets: [posthogCredentialSet],
|
|
403
|
+
input: z.object({ events: z.array(z.object({
|
|
404
|
+
event: z.string().min(1),
|
|
405
|
+
distinct_id: z.string().min(1),
|
|
406
|
+
properties: propertiesBagSchema.optional(),
|
|
407
|
+
timestamp: z.iso.datetime().optional(),
|
|
408
|
+
uuid: z.string().optional()
|
|
409
|
+
})).min(1) }),
|
|
410
|
+
output: captureResponseSchema,
|
|
411
|
+
needsApproval: true,
|
|
412
|
+
run: async (input, context) => {
|
|
413
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
414
|
+
return client.request({
|
|
415
|
+
method: "POST",
|
|
416
|
+
path: "/batch/",
|
|
417
|
+
body: {
|
|
418
|
+
api_key: client.projectApiKey(),
|
|
419
|
+
batch: input.events
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/utils/domain-inputs/capture.ts
|
|
427
|
+
const eventNameInput = {
|
|
428
|
+
event: z.string().min(1),
|
|
429
|
+
distinctId: z.string().min(1),
|
|
430
|
+
timestamp: z.iso.datetime().optional(),
|
|
431
|
+
uuid: z.string().optional(),
|
|
432
|
+
properties: propertiesBagSchema.optional()
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/operations/capture-event.operation.ts
|
|
437
|
+
const captureEventOperation = new Operation({
|
|
438
|
+
id: "posthog.capture-event",
|
|
439
|
+
name: "PostHog Capture Event",
|
|
440
|
+
description: "Capture a single analytics event via the PostHog /capture endpoint",
|
|
441
|
+
credentialSets: [posthogCredentialSet],
|
|
442
|
+
input: z.object(eventNameInput),
|
|
443
|
+
output: captureResponseSchema,
|
|
444
|
+
needsApproval: true,
|
|
445
|
+
run: async (input, context) => {
|
|
446
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
447
|
+
return client.request({
|
|
448
|
+
method: "POST",
|
|
449
|
+
path: "/capture/",
|
|
450
|
+
body: {
|
|
451
|
+
api_key: client.projectApiKey(),
|
|
452
|
+
event: input.event,
|
|
453
|
+
distinct_id: input.distinctId,
|
|
454
|
+
...input.properties ? { properties: input.properties } : {},
|
|
455
|
+
...input.timestamp ? { timestamp: input.timestamp } : {},
|
|
456
|
+
...input.uuid ? { uuid: input.uuid } : {}
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/operations/cohorts-activity.operation.ts
|
|
464
|
+
const cohortsActivityOperation = new Operation({
|
|
465
|
+
id: "posthog.cohorts-activity",
|
|
466
|
+
name: "PostHog Cohort Activity",
|
|
467
|
+
description: "Fetch activity log for a cohort",
|
|
468
|
+
credentialSets: [posthogCredentialSet],
|
|
469
|
+
input: z.object({
|
|
470
|
+
...idInput$3,
|
|
471
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
472
|
+
}),
|
|
473
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
474
|
+
run: async (input, context) => {
|
|
475
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
476
|
+
const projectId = client.projectId(input.projectId);
|
|
477
|
+
return client.request({
|
|
478
|
+
method: "GET",
|
|
479
|
+
path: `/api/projects/${projectId}/cohorts/${input.id}/activity/`,
|
|
480
|
+
query: { limit: input.limit }
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/operations/cohorts-create.operation.ts
|
|
487
|
+
const cohortsCreateOperation = new Operation({
|
|
488
|
+
id: "posthog.cohorts-create",
|
|
489
|
+
name: "PostHog Create Cohort",
|
|
490
|
+
description: "Create a new cohort",
|
|
491
|
+
credentialSets: [posthogCredentialSet],
|
|
492
|
+
input: z.object({
|
|
493
|
+
...projectIdInputShape,
|
|
494
|
+
...writeShape$1,
|
|
495
|
+
name: z.string().min(1)
|
|
496
|
+
}),
|
|
497
|
+
output: cohortSchema,
|
|
498
|
+
needsApproval: true,
|
|
499
|
+
run: async (input, context) => {
|
|
500
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
501
|
+
const projectId = client.projectId(input.projectId);
|
|
502
|
+
const { projectId: _pid, ...body } = input;
|
|
503
|
+
return client.request({
|
|
504
|
+
method: "POST",
|
|
505
|
+
path: `/api/projects/${projectId}/cohorts/`,
|
|
506
|
+
body
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/operations/cohorts-delete.operation.ts
|
|
513
|
+
const cohortsDeleteOperation = new Operation({
|
|
514
|
+
id: "posthog.cohorts-delete",
|
|
515
|
+
name: "PostHog Delete Cohort",
|
|
516
|
+
description: "Soft-delete a cohort",
|
|
517
|
+
credentialSets: [posthogCredentialSet],
|
|
518
|
+
input: z.object(idInput$3),
|
|
519
|
+
output: cohortSchema,
|
|
520
|
+
needsApproval: true,
|
|
521
|
+
run: async (input, context) => {
|
|
522
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
523
|
+
const projectId = client.projectId(input.projectId);
|
|
524
|
+
return client.request({
|
|
525
|
+
method: "PATCH",
|
|
526
|
+
path: `/api/projects/${projectId}/cohorts/${input.id}/`,
|
|
527
|
+
body: { deleted: true }
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/operations/cohorts-duplicate-as-static.operation.ts
|
|
534
|
+
const cohortsDuplicateAsStaticOperation = new Operation({
|
|
535
|
+
id: "posthog.cohorts-duplicate-as-static",
|
|
536
|
+
name: "PostHog Duplicate Cohort As Static",
|
|
537
|
+
description: "Duplicate a cohort as a static cohort",
|
|
538
|
+
credentialSets: [posthogCredentialSet],
|
|
539
|
+
input: z.object(idInput$3),
|
|
540
|
+
output: cohortSchema,
|
|
541
|
+
needsApproval: true,
|
|
542
|
+
run: async (input, context) => {
|
|
543
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
544
|
+
const projectId = client.projectId(input.projectId);
|
|
545
|
+
return client.request({
|
|
546
|
+
method: "POST",
|
|
547
|
+
path: `/api/projects/${projectId}/cohorts/${input.id}/duplicate_as_static_cohort/`
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/operations/cohorts-get.operation.ts
|
|
554
|
+
const cohortsGetOperation = new Operation({
|
|
555
|
+
id: "posthog.cohorts-get",
|
|
556
|
+
name: "PostHog Get Cohort",
|
|
557
|
+
description: "Retrieve a cohort by id",
|
|
558
|
+
credentialSets: [posthogCredentialSet],
|
|
559
|
+
input: z.object(idInput$3),
|
|
560
|
+
output: cohortSchema,
|
|
561
|
+
run: async (input, context) => {
|
|
562
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
563
|
+
const projectId = client.projectId(input.projectId);
|
|
564
|
+
return client.request({
|
|
565
|
+
method: "GET",
|
|
566
|
+
path: `/api/projects/${projectId}/cohorts/${input.id}/`
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/operations/cohorts-list.operation.ts
|
|
573
|
+
const cohortsListOperation = new Operation({
|
|
574
|
+
id: "posthog.cohorts-list",
|
|
575
|
+
name: "PostHog List Cohorts",
|
|
576
|
+
description: "List cohorts in a project",
|
|
577
|
+
credentialSets: [posthogCredentialSet],
|
|
578
|
+
input: z.object({
|
|
579
|
+
...projectIdInputShape,
|
|
580
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
581
|
+
offset: z.number().int().min(0).optional(),
|
|
582
|
+
search: z.string().optional()
|
|
583
|
+
}),
|
|
584
|
+
output: paginatedResponseSchema(cohortSchema),
|
|
585
|
+
run: async (input, context) => {
|
|
586
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
587
|
+
const projectId = client.projectId(input.projectId);
|
|
588
|
+
return client.request({
|
|
589
|
+
method: "GET",
|
|
590
|
+
path: `/api/projects/${projectId}/cohorts/`,
|
|
591
|
+
query: {
|
|
592
|
+
limit: input.limit,
|
|
593
|
+
offset: input.offset,
|
|
594
|
+
search: input.search
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/operations/cohorts-persons.operation.ts
|
|
602
|
+
const cohortsPersonsOperation = new Operation({
|
|
603
|
+
id: "posthog.cohorts-persons",
|
|
604
|
+
name: "PostHog List Cohort Persons",
|
|
605
|
+
description: "List persons in a cohort",
|
|
606
|
+
credentialSets: [posthogCredentialSet],
|
|
607
|
+
input: z.object({
|
|
608
|
+
...idInput$3,
|
|
609
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
610
|
+
offset: z.number().int().min(0).optional()
|
|
611
|
+
}),
|
|
612
|
+
output: paginatedResponseSchema(personSchema),
|
|
613
|
+
run: async (input, context) => {
|
|
614
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
615
|
+
const projectId = client.projectId(input.projectId);
|
|
616
|
+
return client.request({
|
|
617
|
+
method: "GET",
|
|
618
|
+
path: `/api/projects/${projectId}/cohorts/${input.id}/persons/`,
|
|
619
|
+
query: {
|
|
620
|
+
limit: input.limit,
|
|
621
|
+
offset: input.offset
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/operations/cohorts-update.operation.ts
|
|
629
|
+
const cohortsUpdateOperation = new Operation({
|
|
630
|
+
id: "posthog.cohorts-update",
|
|
631
|
+
name: "PostHog Update Cohort",
|
|
632
|
+
description: "Partial update to a cohort",
|
|
633
|
+
credentialSets: [posthogCredentialSet],
|
|
634
|
+
input: z.object({
|
|
635
|
+
...idInput$3,
|
|
636
|
+
...writeShape$1
|
|
637
|
+
}),
|
|
638
|
+
output: cohortSchema,
|
|
639
|
+
needsApproval: true,
|
|
640
|
+
run: async (input, context) => {
|
|
641
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
642
|
+
const projectId = client.projectId(input.projectId);
|
|
643
|
+
const { projectId: _pid, id, ...body } = input;
|
|
644
|
+
return client.request({
|
|
645
|
+
method: "PATCH",
|
|
646
|
+
path: `/api/projects/${projectId}/cohorts/${id}/`,
|
|
647
|
+
body
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/operations/dashboard-templates-create.operation.ts
|
|
654
|
+
const dashboardTemplatesCreateOperation = new Operation({
|
|
655
|
+
id: "posthog.dashboard-templates-create",
|
|
656
|
+
name: "PostHog Create Dashboard Template",
|
|
657
|
+
description: "Create a dashboard template from a dashboard",
|
|
658
|
+
credentialSets: [posthogCredentialSet],
|
|
659
|
+
input: z.object({
|
|
660
|
+
...projectIdInputShape,
|
|
661
|
+
template_name: z.string().min(1),
|
|
662
|
+
dashboard_description: z.string().nullable().optional(),
|
|
663
|
+
dashboard_filters: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
664
|
+
tags: z.array(z.string()).optional(),
|
|
665
|
+
tiles: z.array(z.record(z.string(), z.unknown())).optional()
|
|
666
|
+
}),
|
|
667
|
+
output: dashboardTemplateSchema,
|
|
668
|
+
needsApproval: true,
|
|
669
|
+
run: async (input, context) => {
|
|
670
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
671
|
+
const projectId = client.projectId(input.projectId);
|
|
672
|
+
const { projectId: _pid, ...body } = input;
|
|
673
|
+
return client.request({
|
|
674
|
+
method: "POST",
|
|
675
|
+
path: `/api/projects/${projectId}/dashboard_templates/`,
|
|
676
|
+
body
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/operations/dashboard-templates-delete.operation.ts
|
|
683
|
+
const dashboardTemplatesDeleteOperation = new Operation({
|
|
684
|
+
id: "posthog.dashboard-templates-delete",
|
|
685
|
+
name: "PostHog Delete Dashboard Template",
|
|
686
|
+
description: "Delete a dashboard template",
|
|
687
|
+
credentialSets: [posthogCredentialSet],
|
|
688
|
+
input: z.object({
|
|
689
|
+
...projectIdInputShape,
|
|
690
|
+
templateId: z.string().min(1)
|
|
691
|
+
}),
|
|
692
|
+
output: z.object({ success: z.boolean() }),
|
|
693
|
+
needsApproval: true,
|
|
694
|
+
run: async (input, context) => {
|
|
695
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
696
|
+
const projectId = client.projectId(input.projectId);
|
|
697
|
+
await client.request({
|
|
698
|
+
method: "DELETE",
|
|
699
|
+
path: `/api/projects/${projectId}/dashboard_templates/${input.templateId}/`
|
|
700
|
+
});
|
|
701
|
+
return { success: true };
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/operations/dashboard-templates-get.operation.ts
|
|
707
|
+
const dashboardTemplatesGetOperation = new Operation({
|
|
708
|
+
id: "posthog.dashboard-templates-get",
|
|
709
|
+
name: "PostHog Get Dashboard Template",
|
|
710
|
+
description: "Retrieve a dashboard template by id",
|
|
711
|
+
credentialSets: [posthogCredentialSet],
|
|
712
|
+
input: z.object({
|
|
713
|
+
...projectIdInputShape,
|
|
714
|
+
templateId: z.string().min(1)
|
|
715
|
+
}),
|
|
716
|
+
output: dashboardTemplateSchema,
|
|
717
|
+
run: async (input, context) => {
|
|
718
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
719
|
+
const projectId = client.projectId(input.projectId);
|
|
720
|
+
return client.request({
|
|
721
|
+
method: "GET",
|
|
722
|
+
path: `/api/projects/${projectId}/dashboard_templates/${input.templateId}/`
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/operations/dashboard-templates-list.operation.ts
|
|
729
|
+
const dashboardTemplatesListOperation = new Operation({
|
|
730
|
+
id: "posthog.dashboard-templates-list",
|
|
731
|
+
name: "PostHog List Dashboard Templates",
|
|
732
|
+
description: "List dashboard templates available in a project",
|
|
733
|
+
credentialSets: [posthogCredentialSet],
|
|
734
|
+
input: z.object({
|
|
735
|
+
...projectIdInputShape,
|
|
736
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
737
|
+
offset: z.number().int().min(0).optional()
|
|
738
|
+
}),
|
|
739
|
+
output: paginatedResponseSchema(dashboardTemplateSchema),
|
|
740
|
+
run: async (input, context) => {
|
|
741
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
742
|
+
const projectId = client.projectId(input.projectId);
|
|
743
|
+
return client.request({
|
|
744
|
+
method: "GET",
|
|
745
|
+
path: `/api/projects/${projectId}/dashboard_templates/`,
|
|
746
|
+
query: {
|
|
747
|
+
limit: input.limit,
|
|
748
|
+
offset: input.offset
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
//#endregion
|
|
755
|
+
//#region src/operations/dashboard-templates-update.operation.ts
|
|
756
|
+
const dashboardTemplatesUpdateOperation = new Operation({
|
|
757
|
+
id: "posthog.dashboard-templates-update",
|
|
758
|
+
name: "PostHog Update Dashboard Template",
|
|
759
|
+
description: "Partial update to a dashboard template",
|
|
760
|
+
credentialSets: [posthogCredentialSet],
|
|
761
|
+
input: z.object({
|
|
762
|
+
...projectIdInputShape,
|
|
763
|
+
templateId: z.string().min(1),
|
|
764
|
+
template_name: z.string().optional(),
|
|
765
|
+
dashboard_description: z.string().nullable().optional(),
|
|
766
|
+
dashboard_filters: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
767
|
+
tags: z.array(z.string()).optional(),
|
|
768
|
+
tiles: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
769
|
+
deleted: z.boolean().optional()
|
|
770
|
+
}),
|
|
771
|
+
output: dashboardTemplateSchema,
|
|
772
|
+
needsApproval: true,
|
|
773
|
+
run: async (input, context) => {
|
|
774
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
775
|
+
const projectId = client.projectId(input.projectId);
|
|
776
|
+
const { projectId: _pid, templateId, ...body } = input;
|
|
777
|
+
return client.request({
|
|
778
|
+
method: "PATCH",
|
|
779
|
+
path: `/api/projects/${projectId}/dashboard_templates/${templateId}/`,
|
|
780
|
+
body
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/operations/dashboards-activity.operation.ts
|
|
787
|
+
const dashboardsActivityOperation = new Operation({
|
|
788
|
+
id: "posthog.dashboards-activity",
|
|
789
|
+
name: "PostHog Dashboard Activity",
|
|
790
|
+
description: "Fetch activity log for a dashboard",
|
|
791
|
+
credentialSets: [posthogCredentialSet],
|
|
792
|
+
input: z.object({
|
|
793
|
+
...idInput$3,
|
|
794
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
795
|
+
}),
|
|
796
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
797
|
+
run: async (input, context) => {
|
|
798
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
799
|
+
const projectId = client.projectId(input.projectId);
|
|
800
|
+
return client.request({
|
|
801
|
+
method: "GET",
|
|
802
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/activity/`,
|
|
803
|
+
query: { limit: input.limit }
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/operations/dashboards-collaborators-add.operation.ts
|
|
810
|
+
const dashboardsCollaboratorsAddOperation = new Operation({
|
|
811
|
+
id: "posthog.dashboards-collaborators-add",
|
|
812
|
+
name: "PostHog Add Dashboard Collaborator",
|
|
813
|
+
description: "Add a collaborator to a dashboard",
|
|
814
|
+
credentialSets: [posthogCredentialSet],
|
|
815
|
+
input: z.object({
|
|
816
|
+
...idInput$3,
|
|
817
|
+
user_uuid: z.string().min(1),
|
|
818
|
+
access_level: z.enum(["can_view", "can_edit"]).default("can_view")
|
|
819
|
+
}),
|
|
820
|
+
output: dashboardCollaboratorSchema,
|
|
821
|
+
needsApproval: true,
|
|
822
|
+
run: async (input, context) => {
|
|
823
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
824
|
+
const projectId = client.projectId(input.projectId);
|
|
825
|
+
return client.request({
|
|
826
|
+
method: "POST",
|
|
827
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/collaborators/`,
|
|
828
|
+
body: {
|
|
829
|
+
user_uuid: input.user_uuid,
|
|
830
|
+
level: input.access_level
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
//#endregion
|
|
837
|
+
//#region src/operations/dashboards-collaborators-list.operation.ts
|
|
838
|
+
const dashboardsCollaboratorsListOperation = new Operation({
|
|
839
|
+
id: "posthog.dashboards-collaborators-list",
|
|
840
|
+
name: "PostHog List Dashboard Collaborators",
|
|
841
|
+
description: "List collaborators on a dashboard",
|
|
842
|
+
credentialSets: [posthogCredentialSet],
|
|
843
|
+
input: z.object(idInput$3),
|
|
844
|
+
output: paginatedResponseSchema(dashboardCollaboratorSchema),
|
|
845
|
+
run: async (input, context) => {
|
|
846
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
847
|
+
const projectId = client.projectId(input.projectId);
|
|
848
|
+
return client.request({
|
|
849
|
+
method: "GET",
|
|
850
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/collaborators/`
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/operations/dashboards-collaborators-remove.operation.ts
|
|
857
|
+
const dashboardsCollaboratorsRemoveOperation = new Operation({
|
|
858
|
+
id: "posthog.dashboards-collaborators-remove",
|
|
859
|
+
name: "PostHog Remove Dashboard Collaborator",
|
|
860
|
+
description: "Remove a collaborator from a dashboard",
|
|
861
|
+
credentialSets: [posthogCredentialSet],
|
|
862
|
+
input: z.object({
|
|
863
|
+
...idInput$3,
|
|
864
|
+
collaboratorId: z.number().int()
|
|
865
|
+
}),
|
|
866
|
+
output: z.object({ success: z.boolean() }),
|
|
867
|
+
needsApproval: true,
|
|
868
|
+
run: async (input, context) => {
|
|
869
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
870
|
+
const projectId = client.projectId(input.projectId);
|
|
871
|
+
await client.request({
|
|
872
|
+
method: "DELETE",
|
|
873
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/collaborators/${input.collaboratorId}/`
|
|
874
|
+
});
|
|
875
|
+
return { success: true };
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/operations/dashboards-create.operation.ts
|
|
881
|
+
const dashboardsCreateOperation = new Operation({
|
|
882
|
+
id: "posthog.dashboards-create",
|
|
883
|
+
name: "PostHog Create Dashboard",
|
|
884
|
+
description: "Create a new dashboard",
|
|
885
|
+
credentialSets: [posthogCredentialSet],
|
|
886
|
+
input: z.object({
|
|
887
|
+
...projectIdInputShape,
|
|
888
|
+
...writeShape$1,
|
|
889
|
+
name: z.string().min(1)
|
|
890
|
+
}),
|
|
891
|
+
output: dashboardSchema,
|
|
892
|
+
needsApproval: true,
|
|
893
|
+
run: async (input, context) => {
|
|
894
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
895
|
+
const projectId = client.projectId(input.projectId);
|
|
896
|
+
const { projectId: _pid, ...body } = input;
|
|
897
|
+
return client.request({
|
|
898
|
+
method: "POST",
|
|
899
|
+
path: `/api/projects/${projectId}/dashboards/`,
|
|
900
|
+
body
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
//#endregion
|
|
906
|
+
//#region src/operations/dashboards-delete.operation.ts
|
|
907
|
+
const dashboardsDeleteOperation = new Operation({
|
|
908
|
+
id: "posthog.dashboards-delete",
|
|
909
|
+
name: "PostHog Delete Dashboard",
|
|
910
|
+
description: "Soft-delete a dashboard",
|
|
911
|
+
credentialSets: [posthogCredentialSet],
|
|
912
|
+
input: z.object(idInput$3),
|
|
913
|
+
output: dashboardSchema,
|
|
914
|
+
needsApproval: true,
|
|
915
|
+
run: async (input, context) => {
|
|
916
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
917
|
+
const projectId = client.projectId(input.projectId);
|
|
918
|
+
return client.request({
|
|
919
|
+
method: "PATCH",
|
|
920
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/`,
|
|
921
|
+
body: { deleted: true }
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
//#endregion
|
|
927
|
+
//#region src/operations/dashboards-get.operation.ts
|
|
928
|
+
const dashboardsGetOperation = new Operation({
|
|
929
|
+
id: "posthog.dashboards-get",
|
|
930
|
+
name: "PostHog Get Dashboard",
|
|
931
|
+
description: "Retrieve a dashboard by id",
|
|
932
|
+
credentialSets: [posthogCredentialSet],
|
|
933
|
+
input: z.object(idInput$3),
|
|
934
|
+
output: dashboardSchema,
|
|
935
|
+
run: async (input, context) => {
|
|
936
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
937
|
+
const projectId = client.projectId(input.projectId);
|
|
938
|
+
return client.request({
|
|
939
|
+
method: "GET",
|
|
940
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/`
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
//#endregion
|
|
946
|
+
//#region src/operations/dashboards-list.operation.ts
|
|
947
|
+
const dashboardsListOperation = new Operation({
|
|
948
|
+
id: "posthog.dashboards-list",
|
|
949
|
+
name: "PostHog List Dashboards",
|
|
950
|
+
description: "List dashboards in a project",
|
|
951
|
+
credentialSets: [posthogCredentialSet],
|
|
952
|
+
input: z.object({
|
|
953
|
+
...projectIdInputShape,
|
|
954
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
955
|
+
offset: z.number().int().min(0).optional(),
|
|
956
|
+
search: z.string().optional(),
|
|
957
|
+
pinned: z.boolean().optional()
|
|
958
|
+
}),
|
|
959
|
+
output: paginatedResponseSchema(dashboardSchema),
|
|
960
|
+
run: async (input, context) => {
|
|
961
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
962
|
+
const projectId = client.projectId(input.projectId);
|
|
963
|
+
return client.request({
|
|
964
|
+
method: "GET",
|
|
965
|
+
path: `/api/projects/${projectId}/dashboards/`,
|
|
966
|
+
query: {
|
|
967
|
+
limit: input.limit,
|
|
968
|
+
offset: input.offset,
|
|
969
|
+
search: input.search,
|
|
970
|
+
pinned: input.pinned
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region src/operations/dashboards-sharing-get.operation.ts
|
|
978
|
+
const dashboardsSharingGetOperation = new Operation({
|
|
979
|
+
id: "posthog.dashboards-sharing-get",
|
|
980
|
+
name: "PostHog Get Dashboard Sharing",
|
|
981
|
+
description: "Fetch sharing configuration for a dashboard",
|
|
982
|
+
credentialSets: [posthogCredentialSet],
|
|
983
|
+
input: z.object(idInput$3),
|
|
984
|
+
output: sharingConfigurationSchema,
|
|
985
|
+
run: async (input, context) => {
|
|
986
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
987
|
+
const projectId = client.projectId(input.projectId);
|
|
988
|
+
return client.request({
|
|
989
|
+
method: "GET",
|
|
990
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/sharing/`
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/operations/dashboards-sharing-update.operation.ts
|
|
997
|
+
const dashboardsSharingUpdateOperation = new Operation({
|
|
998
|
+
id: "posthog.dashboards-sharing-update",
|
|
999
|
+
name: "PostHog Update Dashboard Sharing",
|
|
1000
|
+
description: "Enable or disable sharing for a dashboard",
|
|
1001
|
+
credentialSets: [posthogCredentialSet],
|
|
1002
|
+
input: z.object({
|
|
1003
|
+
...idInput$3,
|
|
1004
|
+
enabled: z.boolean()
|
|
1005
|
+
}),
|
|
1006
|
+
output: sharingConfigurationSchema,
|
|
1007
|
+
needsApproval: true,
|
|
1008
|
+
run: async (input, context) => {
|
|
1009
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1010
|
+
const projectId = client.projectId(input.projectId);
|
|
1011
|
+
return client.request({
|
|
1012
|
+
method: "PATCH",
|
|
1013
|
+
path: `/api/projects/${projectId}/dashboards/${input.id}/sharing/`,
|
|
1014
|
+
body: { enabled: input.enabled }
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region src/operations/dashboards-update.operation.ts
|
|
1021
|
+
const dashboardsUpdateOperation = new Operation({
|
|
1022
|
+
id: "posthog.dashboards-update",
|
|
1023
|
+
name: "PostHog Update Dashboard",
|
|
1024
|
+
description: "Partial update to a dashboard",
|
|
1025
|
+
credentialSets: [posthogCredentialSet],
|
|
1026
|
+
input: z.object({
|
|
1027
|
+
...idInput$3,
|
|
1028
|
+
...writeShape$1
|
|
1029
|
+
}),
|
|
1030
|
+
output: dashboardSchema,
|
|
1031
|
+
needsApproval: true,
|
|
1032
|
+
run: async (input, context) => {
|
|
1033
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1034
|
+
const projectId = client.projectId(input.projectId);
|
|
1035
|
+
const { projectId: _pid, id, ...body } = input;
|
|
1036
|
+
return client.request({
|
|
1037
|
+
method: "PATCH",
|
|
1038
|
+
path: `/api/projects/${projectId}/dashboards/${id}/`,
|
|
1039
|
+
body
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/operations/decide-feature-flags.operation.ts
|
|
1046
|
+
const decideFeatureFlagsOperation = new Operation({
|
|
1047
|
+
id: "posthog.decide-feature-flags",
|
|
1048
|
+
name: "PostHog Decide Feature Flags",
|
|
1049
|
+
description: "Evaluate all feature flags for a distinct_id via the /decide endpoint",
|
|
1050
|
+
credentialSets: [posthogCredentialSet],
|
|
1051
|
+
input: z.object({
|
|
1052
|
+
distinctId: z.string().min(1),
|
|
1053
|
+
personProperties: propertiesBagSchema.optional(),
|
|
1054
|
+
groups: z.record(z.string(), z.string()).optional(),
|
|
1055
|
+
groupProperties: z.record(z.string(), propertiesBagSchema).optional(),
|
|
1056
|
+
version: z.number().int().min(1).default(3)
|
|
1057
|
+
}),
|
|
1058
|
+
output: decideResponseSchema,
|
|
1059
|
+
run: async (input, context) => {
|
|
1060
|
+
const client = createPosthogDecideClient(context.credentials.posthog);
|
|
1061
|
+
return client.request({
|
|
1062
|
+
method: "POST",
|
|
1063
|
+
path: "/decide/",
|
|
1064
|
+
query: { v: input.version },
|
|
1065
|
+
body: {
|
|
1066
|
+
api_key: client.projectApiKey(),
|
|
1067
|
+
distinct_id: input.distinctId,
|
|
1068
|
+
...input.personProperties ? { person_properties: input.personProperties } : {},
|
|
1069
|
+
...input.groups ? { groups: input.groups } : {},
|
|
1070
|
+
...input.groupProperties ? { group_properties: input.groupProperties } : {}
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
//#endregion
|
|
1077
|
+
//#region src/operations/decide-feature-flags-local.operation.ts
|
|
1078
|
+
const decideFeatureFlagsLocalOperation = new Operation({
|
|
1079
|
+
id: "posthog.decide-feature-flags-local",
|
|
1080
|
+
name: "PostHog Local Evaluation Payload",
|
|
1081
|
+
description: "Fetch the local-evaluation payload for all feature flags in a project",
|
|
1082
|
+
credentialSets: [posthogCredentialSet],
|
|
1083
|
+
input: z.object({
|
|
1084
|
+
projectId: z.union([z.string(), z.number().int()]).optional(),
|
|
1085
|
+
sendCohorts: z.boolean().default(true)
|
|
1086
|
+
}),
|
|
1087
|
+
output: localEvaluationResponseSchema,
|
|
1088
|
+
run: async (input, context) => {
|
|
1089
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1090
|
+
const projectId = client.projectId(input.projectId);
|
|
1091
|
+
return client.request({
|
|
1092
|
+
method: "GET",
|
|
1093
|
+
path: `/api/projects/${projectId}/feature_flags/local_evaluation/`,
|
|
1094
|
+
query: { send_cohorts: input.sendCohorts }
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/utils/domain-inputs/events-management.ts
|
|
1101
|
+
const eventDefIdInput = {
|
|
1102
|
+
...projectIdInputShape,
|
|
1103
|
+
id: z.string().min(1)
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/operations/event-definitions-delete.operation.ts
|
|
1108
|
+
const eventDefinitionsDeleteOperation = new Operation({
|
|
1109
|
+
id: "posthog.event-definitions-delete",
|
|
1110
|
+
name: "PostHog Delete Event Definition",
|
|
1111
|
+
description: "Delete an event definition",
|
|
1112
|
+
credentialSets: [posthogCredentialSet],
|
|
1113
|
+
input: z.object(eventDefIdInput),
|
|
1114
|
+
output: z.object({ success: z.boolean() }),
|
|
1115
|
+
needsApproval: true,
|
|
1116
|
+
run: async (input, context) => {
|
|
1117
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1118
|
+
const projectId = client.projectId(input.projectId);
|
|
1119
|
+
await client.request({
|
|
1120
|
+
method: "DELETE",
|
|
1121
|
+
path: `/api/projects/${projectId}/event_definitions/${input.id}/`
|
|
1122
|
+
});
|
|
1123
|
+
return { success: true };
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
//#endregion
|
|
1128
|
+
//#region src/operations/event-definitions-get.operation.ts
|
|
1129
|
+
const eventDefinitionsGetOperation = new Operation({
|
|
1130
|
+
id: "posthog.event-definitions-get",
|
|
1131
|
+
name: "PostHog Get Event Definition",
|
|
1132
|
+
description: "Retrieve an event definition by id",
|
|
1133
|
+
credentialSets: [posthogCredentialSet],
|
|
1134
|
+
input: z.object(eventDefIdInput),
|
|
1135
|
+
output: eventDefinitionSchema,
|
|
1136
|
+
run: async (input, context) => {
|
|
1137
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1138
|
+
const projectId = client.projectId(input.projectId);
|
|
1139
|
+
return client.request({
|
|
1140
|
+
method: "GET",
|
|
1141
|
+
path: `/api/projects/${projectId}/event_definitions/${input.id}/`
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region src/operations/event-definitions-list.operation.ts
|
|
1148
|
+
const eventDefinitionsListOperation = new Operation({
|
|
1149
|
+
id: "posthog.event-definitions-list",
|
|
1150
|
+
name: "PostHog List Event Definitions",
|
|
1151
|
+
description: "List event definitions (the schema for captured events)",
|
|
1152
|
+
credentialSets: [posthogCredentialSet],
|
|
1153
|
+
input: z.object({
|
|
1154
|
+
...projectIdInputShape,
|
|
1155
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
1156
|
+
offset: z.number().int().min(0).optional(),
|
|
1157
|
+
search: z.string().optional()
|
|
1158
|
+
}),
|
|
1159
|
+
output: paginatedResponseSchema(eventDefinitionSchema),
|
|
1160
|
+
run: async (input, context) => {
|
|
1161
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1162
|
+
const projectId = client.projectId(input.projectId);
|
|
1163
|
+
return client.request({
|
|
1164
|
+
method: "GET",
|
|
1165
|
+
path: `/api/projects/${projectId}/event_definitions/`,
|
|
1166
|
+
query: {
|
|
1167
|
+
limit: input.limit,
|
|
1168
|
+
offset: input.offset,
|
|
1169
|
+
search: input.search
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region src/operations/event-definitions-update.operation.ts
|
|
1177
|
+
const eventDefinitionsUpdateOperation = new Operation({
|
|
1178
|
+
id: "posthog.event-definitions-update",
|
|
1179
|
+
name: "PostHog Update Event Definition",
|
|
1180
|
+
description: "Update description, owner, tags, or verified status on an event definition",
|
|
1181
|
+
credentialSets: [posthogCredentialSet],
|
|
1182
|
+
input: z.object({
|
|
1183
|
+
...eventDefIdInput,
|
|
1184
|
+
description: z.string().nullable().optional(),
|
|
1185
|
+
owner: z.number().int().nullable().optional(),
|
|
1186
|
+
tags: z.array(z.string()).optional(),
|
|
1187
|
+
verified: z.boolean().optional()
|
|
1188
|
+
}),
|
|
1189
|
+
output: eventDefinitionSchema,
|
|
1190
|
+
needsApproval: true,
|
|
1191
|
+
run: async (input, context) => {
|
|
1192
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1193
|
+
const projectId = client.projectId(input.projectId);
|
|
1194
|
+
const { projectId: _pid, id, ...body } = input;
|
|
1195
|
+
return client.request({
|
|
1196
|
+
method: "PATCH",
|
|
1197
|
+
path: `/api/projects/${projectId}/event_definitions/${id}/`,
|
|
1198
|
+
body
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/operations/events-get.operation.ts
|
|
1205
|
+
const eventsGetOperation = new Operation({
|
|
1206
|
+
id: "posthog.events-get",
|
|
1207
|
+
name: "PostHog Get Event",
|
|
1208
|
+
description: "Retrieve a single event by id",
|
|
1209
|
+
credentialSets: [posthogCredentialSet],
|
|
1210
|
+
input: z.object({
|
|
1211
|
+
...projectIdInputShape,
|
|
1212
|
+
id: z.string().min(1)
|
|
1213
|
+
}),
|
|
1214
|
+
output: analyticsEventSchema,
|
|
1215
|
+
run: async (input, context) => {
|
|
1216
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1217
|
+
const projectId = client.projectId(input.projectId);
|
|
1218
|
+
return client.request({
|
|
1219
|
+
method: "GET",
|
|
1220
|
+
path: `/api/projects/${projectId}/events/${input.id}/`
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/operations/events-list.operation.ts
|
|
1227
|
+
const eventsListOperation = new Operation({
|
|
1228
|
+
id: "posthog.events-list",
|
|
1229
|
+
name: "PostHog List Events",
|
|
1230
|
+
description: "Query captured events",
|
|
1231
|
+
credentialSets: [posthogCredentialSet],
|
|
1232
|
+
input: z.object({
|
|
1233
|
+
...projectIdInputShape,
|
|
1234
|
+
limit: z.number().int().min(1).max(1e3).optional(),
|
|
1235
|
+
offset: z.number().int().min(0).optional(),
|
|
1236
|
+
event: z.string().optional(),
|
|
1237
|
+
distinct_id: z.string().optional(),
|
|
1238
|
+
after: z.iso.datetime().optional(),
|
|
1239
|
+
before: z.iso.datetime().optional(),
|
|
1240
|
+
person_id: z.union([z.string(), z.number().int()]).optional()
|
|
1241
|
+
}),
|
|
1242
|
+
output: paginatedResponseSchema(analyticsEventSchema),
|
|
1243
|
+
run: async (input, context) => {
|
|
1244
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1245
|
+
const projectId = client.projectId(input.projectId);
|
|
1246
|
+
return client.request({
|
|
1247
|
+
method: "GET",
|
|
1248
|
+
path: `/api/projects/${projectId}/events/`,
|
|
1249
|
+
query: {
|
|
1250
|
+
limit: input.limit,
|
|
1251
|
+
offset: input.offset,
|
|
1252
|
+
event: input.event,
|
|
1253
|
+
distinct_id: input.distinct_id,
|
|
1254
|
+
after: input.after,
|
|
1255
|
+
before: input.before,
|
|
1256
|
+
person_id: input.person_id
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/operations/events-values.operation.ts
|
|
1264
|
+
const eventsValuesOperation = new Operation({
|
|
1265
|
+
id: "posthog.events-values",
|
|
1266
|
+
name: "PostHog Event Property Values",
|
|
1267
|
+
description: "Fetch distinct values for an event property",
|
|
1268
|
+
credentialSets: [posthogCredentialSet],
|
|
1269
|
+
input: z.object({
|
|
1270
|
+
...projectIdInputShape,
|
|
1271
|
+
key: z.string().min(1),
|
|
1272
|
+
value: z.string().optional()
|
|
1273
|
+
}),
|
|
1274
|
+
output: z.array(z.record(z.string(), z.unknown())),
|
|
1275
|
+
run: async (input, context) => {
|
|
1276
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1277
|
+
const projectId = client.projectId(input.projectId);
|
|
1278
|
+
return client.request({
|
|
1279
|
+
method: "GET",
|
|
1280
|
+
path: `/api/projects/${projectId}/events/values/`,
|
|
1281
|
+
query: {
|
|
1282
|
+
key: input.key,
|
|
1283
|
+
value: input.value
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/operations/feature-flags-activity.operation.ts
|
|
1291
|
+
const featureFlagsActivityOperation = new Operation({
|
|
1292
|
+
id: "posthog.feature-flags-activity",
|
|
1293
|
+
name: "PostHog Feature Flag Activity",
|
|
1294
|
+
description: "Fetch activity log for a feature flag",
|
|
1295
|
+
credentialSets: [posthogCredentialSet],
|
|
1296
|
+
input: z.object({
|
|
1297
|
+
...idInput$3,
|
|
1298
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
1299
|
+
}),
|
|
1300
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
1301
|
+
run: async (input, context) => {
|
|
1302
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1303
|
+
const projectId = client.projectId(input.projectId);
|
|
1304
|
+
return client.request({
|
|
1305
|
+
method: "GET",
|
|
1306
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/activity/`,
|
|
1307
|
+
query: { limit: input.limit }
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region src/utils/domain-inputs/feature-flags.ts
|
|
1314
|
+
const idInput$2 = {
|
|
1315
|
+
...projectIdInputShape,
|
|
1316
|
+
id: z.number().int()
|
|
1317
|
+
};
|
|
1318
|
+
const flagWriteShape = {
|
|
1319
|
+
key: z.string().min(1),
|
|
1320
|
+
name: z.string().optional(),
|
|
1321
|
+
filters: featureFlagFiltersSchema.optional(),
|
|
1322
|
+
active: z.boolean().optional(),
|
|
1323
|
+
deleted: z.boolean().optional(),
|
|
1324
|
+
rollout_percentage: z.number().nullable().optional(),
|
|
1325
|
+
ensure_experience_continuity: z.boolean().optional(),
|
|
1326
|
+
tags: z.array(z.string()).optional()
|
|
1327
|
+
};
|
|
1328
|
+
const listInput = z.object({
|
|
1329
|
+
...projectIdInputShape,
|
|
1330
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
1331
|
+
offset: z.number().int().min(0).optional(),
|
|
1332
|
+
active: z.boolean().optional(),
|
|
1333
|
+
search: z.string().optional(),
|
|
1334
|
+
type: z.string().optional(),
|
|
1335
|
+
created_by: z.number().int().optional()
|
|
1336
|
+
});
|
|
1337
|
+
const listOutput = paginatedResponseSchema(featureFlagSchema);
|
|
1338
|
+
|
|
1339
|
+
//#endregion
|
|
1340
|
+
//#region src/operations/feature-flags-create.operation.ts
|
|
1341
|
+
const featureFlagsCreateOperation = new Operation({
|
|
1342
|
+
id: "posthog.feature-flags-create",
|
|
1343
|
+
name: "PostHog Create Feature Flag",
|
|
1344
|
+
description: "Create a new feature flag",
|
|
1345
|
+
credentialSets: [posthogCredentialSet],
|
|
1346
|
+
input: z.object({
|
|
1347
|
+
...projectIdInputShape,
|
|
1348
|
+
...flagWriteShape
|
|
1349
|
+
}),
|
|
1350
|
+
output: featureFlagSchema,
|
|
1351
|
+
needsApproval: true,
|
|
1352
|
+
run: async (input, context) => {
|
|
1353
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1354
|
+
const projectId = client.projectId(input.projectId);
|
|
1355
|
+
const { projectId: _ignored, ...body } = input;
|
|
1356
|
+
return client.request({
|
|
1357
|
+
method: "POST",
|
|
1358
|
+
path: `/api/projects/${projectId}/feature_flags/`,
|
|
1359
|
+
body
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region src/operations/feature-flags-dashboards.operation.ts
|
|
1366
|
+
const featureFlagsDashboardsOperation = new Operation({
|
|
1367
|
+
id: "posthog.feature-flags-dashboards",
|
|
1368
|
+
name: "PostHog Feature Flag Dashboards",
|
|
1369
|
+
description: "Fetch dashboards linked to a feature flag",
|
|
1370
|
+
credentialSets: [posthogCredentialSet],
|
|
1371
|
+
input: z.object(idInput$3),
|
|
1372
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
1373
|
+
run: async (input, context) => {
|
|
1374
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1375
|
+
const projectId = client.projectId(input.projectId);
|
|
1376
|
+
return client.request({
|
|
1377
|
+
method: "GET",
|
|
1378
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/dashboards/`
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
|
|
1383
|
+
//#endregion
|
|
1384
|
+
//#region src/operations/feature-flags-delete.operation.ts
|
|
1385
|
+
const featureFlagsDeleteOperation = new Operation({
|
|
1386
|
+
id: "posthog.feature-flags-delete",
|
|
1387
|
+
name: "PostHog Delete Feature Flag",
|
|
1388
|
+
description: "Soft-delete a feature flag",
|
|
1389
|
+
credentialSets: [posthogCredentialSet],
|
|
1390
|
+
input: z.object(idInput$3),
|
|
1391
|
+
output: featureFlagSchema,
|
|
1392
|
+
needsApproval: true,
|
|
1393
|
+
run: async (input, context) => {
|
|
1394
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1395
|
+
const projectId = client.projectId(input.projectId);
|
|
1396
|
+
return client.request({
|
|
1397
|
+
method: "PATCH",
|
|
1398
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
1399
|
+
body: { deleted: true }
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
//#endregion
|
|
1405
|
+
//#region src/operations/feature-flags-disable.operation.ts
|
|
1406
|
+
const featureFlagsDisableOperation = new Operation({
|
|
1407
|
+
id: "posthog.feature-flags-disable",
|
|
1408
|
+
name: "PostHog Disable Feature Flag",
|
|
1409
|
+
description: "Deactivate a feature flag",
|
|
1410
|
+
credentialSets: [posthogCredentialSet],
|
|
1411
|
+
input: z.object(idInput$3),
|
|
1412
|
+
output: featureFlagSchema,
|
|
1413
|
+
needsApproval: true,
|
|
1414
|
+
run: async (input, context) => {
|
|
1415
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1416
|
+
const projectId = client.projectId(input.projectId);
|
|
1417
|
+
return client.request({
|
|
1418
|
+
method: "PATCH",
|
|
1419
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
1420
|
+
body: { active: false }
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
//#endregion
|
|
1426
|
+
//#region src/operations/feature-flags-enable.operation.ts
|
|
1427
|
+
const featureFlagsEnableOperation = new Operation({
|
|
1428
|
+
id: "posthog.feature-flags-enable",
|
|
1429
|
+
name: "PostHog Enable Feature Flag",
|
|
1430
|
+
description: "Activate a feature flag",
|
|
1431
|
+
credentialSets: [posthogCredentialSet],
|
|
1432
|
+
input: z.object(idInput$3),
|
|
1433
|
+
output: featureFlagSchema,
|
|
1434
|
+
needsApproval: true,
|
|
1435
|
+
run: async (input, context) => {
|
|
1436
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1437
|
+
const projectId = client.projectId(input.projectId);
|
|
1438
|
+
return client.request({
|
|
1439
|
+
method: "PATCH",
|
|
1440
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
1441
|
+
body: { active: true }
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
//#endregion
|
|
1447
|
+
//#region src/operations/feature-flags-get.operation.ts
|
|
1448
|
+
const featureFlagsGetOperation = new Operation({
|
|
1449
|
+
id: "posthog.feature-flags-get",
|
|
1450
|
+
name: "PostHog Get Feature Flag",
|
|
1451
|
+
description: "Retrieve a feature flag by numeric id",
|
|
1452
|
+
credentialSets: [posthogCredentialSet],
|
|
1453
|
+
input: z.object(idInput$3),
|
|
1454
|
+
output: featureFlagSchema,
|
|
1455
|
+
run: async (input, context) => {
|
|
1456
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1457
|
+
const projectId = client.projectId(input.projectId);
|
|
1458
|
+
return client.request({
|
|
1459
|
+
method: "GET",
|
|
1460
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
//#endregion
|
|
1466
|
+
//#region src/operations/feature-flags-list.operation.ts
|
|
1467
|
+
const featureFlagsListOperation = new Operation({
|
|
1468
|
+
id: "posthog.feature-flags-list",
|
|
1469
|
+
name: "PostHog List Feature Flags",
|
|
1470
|
+
description: "List feature flags for a project",
|
|
1471
|
+
credentialSets: [posthogCredentialSet],
|
|
1472
|
+
input: listInput,
|
|
1473
|
+
output: listOutput,
|
|
1474
|
+
run: async (input, context) => {
|
|
1475
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1476
|
+
const projectId = client.projectId(input.projectId);
|
|
1477
|
+
return client.request({
|
|
1478
|
+
method: "GET",
|
|
1479
|
+
path: `/api/projects/${projectId}/feature_flags/`,
|
|
1480
|
+
query: {
|
|
1481
|
+
limit: input.limit,
|
|
1482
|
+
offset: input.offset,
|
|
1483
|
+
active: input.active,
|
|
1484
|
+
search: input.search,
|
|
1485
|
+
type: input.type,
|
|
1486
|
+
created_by: input.created_by
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
|
|
1492
|
+
//#endregion
|
|
1493
|
+
//#region src/operations/feature-flags-my-flags.operation.ts
|
|
1494
|
+
const featureFlagsMyFlagsOperation = new Operation({
|
|
1495
|
+
id: "posthog.feature-flags-my-flags",
|
|
1496
|
+
name: "PostHog My Feature Flags",
|
|
1497
|
+
description: "Fetch the feature flags evaluated for the calling user",
|
|
1498
|
+
credentialSets: [posthogCredentialSet],
|
|
1499
|
+
input: z.object(projectIdInputShape),
|
|
1500
|
+
output: z.array(z.record(z.string(), z.unknown())),
|
|
1501
|
+
run: async (input, context) => {
|
|
1502
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1503
|
+
const projectId = client.projectId(input.projectId);
|
|
1504
|
+
return client.request({
|
|
1505
|
+
method: "GET",
|
|
1506
|
+
path: `/api/projects/${projectId}/feature_flags/my_flags/`
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
//#endregion
|
|
1512
|
+
//#region src/operations/feature-flags-remote-config.operation.ts
|
|
1513
|
+
const featureFlagsRemoteConfigOperation = new Operation({
|
|
1514
|
+
id: "posthog.feature-flags-remote-config",
|
|
1515
|
+
name: "PostHog Feature Flag Remote Config",
|
|
1516
|
+
description: "Fetch the remote-config payload for a feature flag",
|
|
1517
|
+
credentialSets: [posthogCredentialSet],
|
|
1518
|
+
input: z.object({
|
|
1519
|
+
...idInput$3,
|
|
1520
|
+
distinctId: z.string().min(1)
|
|
1521
|
+
}),
|
|
1522
|
+
output: z.record(z.string(), z.unknown()),
|
|
1523
|
+
run: async (input, context) => {
|
|
1524
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1525
|
+
const projectId = client.projectId(input.projectId);
|
|
1526
|
+
return client.request({
|
|
1527
|
+
method: "GET",
|
|
1528
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/remote_config/`,
|
|
1529
|
+
query: { distinct_id: input.distinctId }
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1534
|
+
//#endregion
|
|
1535
|
+
//#region src/operations/feature-flags-role-access-create.operation.ts
|
|
1536
|
+
const featureFlagsRoleAccessCreateOperation = new Operation({
|
|
1537
|
+
id: "posthog.feature-flags-role-access-create",
|
|
1538
|
+
name: "PostHog Create Feature Flag Role Access",
|
|
1539
|
+
description: "Grant a role access to a feature flag",
|
|
1540
|
+
credentialSets: [posthogCredentialSet],
|
|
1541
|
+
input: z.object({
|
|
1542
|
+
...idInput$3,
|
|
1543
|
+
role: z.number().int()
|
|
1544
|
+
}),
|
|
1545
|
+
output: featureFlagRoleAccessSchema,
|
|
1546
|
+
needsApproval: true,
|
|
1547
|
+
run: async (input, context) => {
|
|
1548
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1549
|
+
const projectId = client.projectId(input.projectId);
|
|
1550
|
+
return client.request({
|
|
1551
|
+
method: "POST",
|
|
1552
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`,
|
|
1553
|
+
body: { role: input.role }
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
|
|
1558
|
+
//#endregion
|
|
1559
|
+
//#region src/operations/feature-flags-role-access-delete.operation.ts
|
|
1560
|
+
const featureFlagsRoleAccessDeleteOperation = new Operation({
|
|
1561
|
+
id: "posthog.feature-flags-role-access-delete",
|
|
1562
|
+
name: "PostHog Delete Feature Flag Role Access",
|
|
1563
|
+
description: "Revoke a role access rule for a feature flag",
|
|
1564
|
+
credentialSets: [posthogCredentialSet],
|
|
1565
|
+
input: z.object({
|
|
1566
|
+
...idInput$3,
|
|
1567
|
+
roleAccessId: z.number().int()
|
|
1568
|
+
}),
|
|
1569
|
+
output: z.object({ success: z.boolean() }),
|
|
1570
|
+
needsApproval: true,
|
|
1571
|
+
run: async (input, context) => {
|
|
1572
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1573
|
+
const projectId = client.projectId(input.projectId);
|
|
1574
|
+
await client.request({
|
|
1575
|
+
method: "DELETE",
|
|
1576
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/${input.roleAccessId}/`
|
|
1577
|
+
});
|
|
1578
|
+
return { success: true };
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
//#endregion
|
|
1583
|
+
//#region src/operations/feature-flags-role-access-list.operation.ts
|
|
1584
|
+
const featureFlagsRoleAccessListOperation = new Operation({
|
|
1585
|
+
id: "posthog.feature-flags-role-access-list",
|
|
1586
|
+
name: "PostHog List Feature Flag Role Access",
|
|
1587
|
+
description: "List role access rules for a feature flag",
|
|
1588
|
+
credentialSets: [posthogCredentialSet],
|
|
1589
|
+
input: z.object(idInput$3),
|
|
1590
|
+
output: paginatedResponseSchema(featureFlagRoleAccessSchema),
|
|
1591
|
+
run: async (input, context) => {
|
|
1592
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1593
|
+
const projectId = client.projectId(input.projectId);
|
|
1594
|
+
return client.request({
|
|
1595
|
+
method: "GET",
|
|
1596
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
//#endregion
|
|
1602
|
+
//#region src/operations/feature-flags-status.operation.ts
|
|
1603
|
+
const featureFlagsStatusOperation = new Operation({
|
|
1604
|
+
id: "posthog.feature-flags-status",
|
|
1605
|
+
name: "PostHog Feature Flag Status",
|
|
1606
|
+
description: "Fetch computed status summary for a feature flag",
|
|
1607
|
+
credentialSets: [posthogCredentialSet],
|
|
1608
|
+
input: z.object(idInput$3),
|
|
1609
|
+
output: z.record(z.string(), z.unknown()),
|
|
1610
|
+
run: async (input, context) => {
|
|
1611
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1612
|
+
const projectId = client.projectId(input.projectId);
|
|
1613
|
+
return client.request({
|
|
1614
|
+
method: "GET",
|
|
1615
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/status/`
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
//#endregion
|
|
1621
|
+
//#region src/operations/feature-flags-update.operation.ts
|
|
1622
|
+
const featureFlagsUpdateOperation = new Operation({
|
|
1623
|
+
id: "posthog.feature-flags-update",
|
|
1624
|
+
name: "PostHog Update Feature Flag",
|
|
1625
|
+
description: "Partially update a feature flag",
|
|
1626
|
+
credentialSets: [posthogCredentialSet],
|
|
1627
|
+
input: z.object({
|
|
1628
|
+
...idInput$3,
|
|
1629
|
+
key: z.string().min(1).optional(),
|
|
1630
|
+
name: z.string().optional(),
|
|
1631
|
+
filters: featureFlagFiltersSchema.optional(),
|
|
1632
|
+
active: z.boolean().optional(),
|
|
1633
|
+
deleted: z.boolean().optional(),
|
|
1634
|
+
rollout_percentage: z.number().nullable().optional(),
|
|
1635
|
+
ensure_experience_continuity: z.boolean().optional(),
|
|
1636
|
+
tags: z.array(z.string()).optional()
|
|
1637
|
+
}),
|
|
1638
|
+
output: featureFlagSchema,
|
|
1639
|
+
needsApproval: true,
|
|
1640
|
+
run: async (input, context) => {
|
|
1641
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1642
|
+
const projectId = client.projectId(input.projectId);
|
|
1643
|
+
const { projectId: _pid, id, ...body } = input;
|
|
1644
|
+
return client.request({
|
|
1645
|
+
method: "PATCH",
|
|
1646
|
+
path: `/api/projects/${projectId}/feature_flags/${id}/`,
|
|
1647
|
+
body
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
|
|
1652
|
+
//#endregion
|
|
1653
|
+
//#region src/operations/group-identify.operation.ts
|
|
1654
|
+
const groupIdentifyOperation = new Operation({
|
|
1655
|
+
id: "posthog.group-identify",
|
|
1656
|
+
name: "PostHog Group Identify",
|
|
1657
|
+
description: "Attach properties to a group (organization, project, etc.) via $groupidentify",
|
|
1658
|
+
credentialSets: [posthogCredentialSet],
|
|
1659
|
+
input: z.object({
|
|
1660
|
+
distinctId: z.string().min(1),
|
|
1661
|
+
groupType: z.string().min(1),
|
|
1662
|
+
groupKey: z.string().min(1),
|
|
1663
|
+
groupProperties: propertiesBagSchema.optional(),
|
|
1664
|
+
timestamp: z.iso.datetime().optional()
|
|
1665
|
+
}),
|
|
1666
|
+
output: captureResponseSchema,
|
|
1667
|
+
needsApproval: true,
|
|
1668
|
+
run: async (input, context) => {
|
|
1669
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
1670
|
+
return client.request({
|
|
1671
|
+
method: "POST",
|
|
1672
|
+
path: "/capture/",
|
|
1673
|
+
body: {
|
|
1674
|
+
api_key: client.projectApiKey(),
|
|
1675
|
+
event: "$groupidentify",
|
|
1676
|
+
distinct_id: input.distinctId,
|
|
1677
|
+
properties: {
|
|
1678
|
+
$group_type: input.groupType,
|
|
1679
|
+
$group_key: input.groupKey,
|
|
1680
|
+
$group_set: input.groupProperties ?? {}
|
|
1681
|
+
},
|
|
1682
|
+
...input.timestamp ? { timestamp: input.timestamp } : {}
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
|
|
1688
|
+
//#endregion
|
|
1689
|
+
//#region src/operations/identify-person.operation.ts
|
|
1690
|
+
const identifyPersonOperation = new Operation({
|
|
1691
|
+
id: "posthog.identify-person",
|
|
1692
|
+
name: "PostHog Identify Person",
|
|
1693
|
+
description: "Associate a distinct_id with person properties via a $identify event",
|
|
1694
|
+
credentialSets: [posthogCredentialSet],
|
|
1695
|
+
input: z.object({
|
|
1696
|
+
distinctId: z.string().min(1),
|
|
1697
|
+
properties: propertiesBagSchema.optional(),
|
|
1698
|
+
propertiesOnce: propertiesBagSchema.optional(),
|
|
1699
|
+
timestamp: z.iso.datetime().optional()
|
|
1700
|
+
}),
|
|
1701
|
+
output: captureResponseSchema,
|
|
1702
|
+
needsApproval: true,
|
|
1703
|
+
run: async (input, context) => {
|
|
1704
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
1705
|
+
const properties = {};
|
|
1706
|
+
if (input.properties) properties.$set = input.properties;
|
|
1707
|
+
if (input.propertiesOnce) properties.$set_once = input.propertiesOnce;
|
|
1708
|
+
return client.request({
|
|
1709
|
+
method: "POST",
|
|
1710
|
+
path: "/capture/",
|
|
1711
|
+
body: {
|
|
1712
|
+
api_key: client.projectApiKey(),
|
|
1713
|
+
event: "$identify",
|
|
1714
|
+
distinct_id: input.distinctId,
|
|
1715
|
+
properties,
|
|
1716
|
+
...input.timestamp ? { timestamp: input.timestamp } : {}
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
|
|
1722
|
+
//#endregion
|
|
1723
|
+
//#region src/operations/insights-activity.operation.ts
|
|
1724
|
+
const insightsActivityOperation = new Operation({
|
|
1725
|
+
id: "posthog.insights-activity",
|
|
1726
|
+
name: "PostHog Insight Activity",
|
|
1727
|
+
description: "Fetch activity log for an insight",
|
|
1728
|
+
credentialSets: [posthogCredentialSet],
|
|
1729
|
+
input: z.object({
|
|
1730
|
+
...idInput$3,
|
|
1731
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
1732
|
+
}),
|
|
1733
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
1734
|
+
run: async (input, context) => {
|
|
1735
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1736
|
+
const projectId = client.projectId(input.projectId);
|
|
1737
|
+
return client.request({
|
|
1738
|
+
method: "GET",
|
|
1739
|
+
path: `/api/projects/${projectId}/insights/${input.id}/activity/`,
|
|
1740
|
+
query: { limit: input.limit }
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
});
|
|
1744
|
+
|
|
1745
|
+
//#endregion
|
|
1746
|
+
//#region src/operations/insights-activity-feed.operation.ts
|
|
1747
|
+
const insightsActivityFeedOperation = new Operation({
|
|
1748
|
+
id: "posthog.insights-activity-feed",
|
|
1749
|
+
name: "PostHog Insights Activity Feed",
|
|
1750
|
+
description: "Fetch the project-wide insights activity feed",
|
|
1751
|
+
credentialSets: [posthogCredentialSet],
|
|
1752
|
+
input: z.object({
|
|
1753
|
+
...projectIdInputShape,
|
|
1754
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
1755
|
+
}),
|
|
1756
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
1757
|
+
run: async (input, context) => {
|
|
1758
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1759
|
+
const projectId = client.projectId(input.projectId);
|
|
1760
|
+
return client.request({
|
|
1761
|
+
method: "GET",
|
|
1762
|
+
path: `/api/projects/${projectId}/insights/activity/`,
|
|
1763
|
+
query: { limit: input.limit }
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1768
|
+
//#endregion
|
|
1769
|
+
//#region src/operations/insights-create.operation.ts
|
|
1770
|
+
const insightsCreateOperation = new Operation({
|
|
1771
|
+
id: "posthog.insights-create",
|
|
1772
|
+
name: "PostHog Create Insight",
|
|
1773
|
+
description: "Create a new insight",
|
|
1774
|
+
credentialSets: [posthogCredentialSet],
|
|
1775
|
+
input: z.object({
|
|
1776
|
+
...projectIdInputShape,
|
|
1777
|
+
...writeShape$1
|
|
1778
|
+
}),
|
|
1779
|
+
output: insightSchema,
|
|
1780
|
+
needsApproval: true,
|
|
1781
|
+
run: async (input, context) => {
|
|
1782
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1783
|
+
const projectId = client.projectId(input.projectId);
|
|
1784
|
+
const { projectId: _pid, ...body } = input;
|
|
1785
|
+
return client.request({
|
|
1786
|
+
method: "POST",
|
|
1787
|
+
path: `/api/projects/${projectId}/insights/`,
|
|
1788
|
+
body
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
|
|
1793
|
+
//#endregion
|
|
1794
|
+
//#region src/operations/insights-delete.operation.ts
|
|
1795
|
+
const insightsDeleteOperation = new Operation({
|
|
1796
|
+
id: "posthog.insights-delete",
|
|
1797
|
+
name: "PostHog Delete Insight",
|
|
1798
|
+
description: "Soft-delete an insight",
|
|
1799
|
+
credentialSets: [posthogCredentialSet],
|
|
1800
|
+
input: z.object(idInput$3),
|
|
1801
|
+
output: insightSchema,
|
|
1802
|
+
needsApproval: true,
|
|
1803
|
+
run: async (input, context) => {
|
|
1804
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1805
|
+
const projectId = client.projectId(input.projectId);
|
|
1806
|
+
return client.request({
|
|
1807
|
+
method: "PATCH",
|
|
1808
|
+
path: `/api/projects/${projectId}/insights/${input.id}/`,
|
|
1809
|
+
body: { deleted: true }
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
|
|
1814
|
+
//#endregion
|
|
1815
|
+
//#region src/operations/insights-funnel.operation.ts
|
|
1816
|
+
const insightsFunnelOperation = new Operation({
|
|
1817
|
+
id: "posthog.insights-funnel",
|
|
1818
|
+
name: "PostHog Insight Funnel",
|
|
1819
|
+
description: "Execute a funnel query",
|
|
1820
|
+
credentialSets: [posthogCredentialSet],
|
|
1821
|
+
input: z.object({
|
|
1822
|
+
...projectIdInputShape,
|
|
1823
|
+
query: z.record(z.string(), z.unknown())
|
|
1824
|
+
}),
|
|
1825
|
+
output: z.record(z.string(), z.unknown()),
|
|
1826
|
+
run: async (input, context) => {
|
|
1827
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1828
|
+
const projectId = client.projectId(input.projectId);
|
|
1829
|
+
return client.request({
|
|
1830
|
+
method: "POST",
|
|
1831
|
+
path: `/api/projects/${projectId}/insights/funnel/`,
|
|
1832
|
+
body: input.query
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
|
|
1837
|
+
//#endregion
|
|
1838
|
+
//#region src/operations/insights-get.operation.ts
|
|
1839
|
+
const insightsGetOperation = new Operation({
|
|
1840
|
+
id: "posthog.insights-get",
|
|
1841
|
+
name: "PostHog Get Insight",
|
|
1842
|
+
description: "Retrieve a single insight by id",
|
|
1843
|
+
credentialSets: [posthogCredentialSet],
|
|
1844
|
+
input: z.object(idInput$3),
|
|
1845
|
+
output: insightSchema,
|
|
1846
|
+
run: async (input, context) => {
|
|
1847
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1848
|
+
const projectId = client.projectId(input.projectId);
|
|
1849
|
+
return client.request({
|
|
1850
|
+
method: "GET",
|
|
1851
|
+
path: `/api/projects/${projectId}/insights/${input.id}/`
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
|
|
1856
|
+
//#endregion
|
|
1857
|
+
//#region src/operations/insights-list.operation.ts
|
|
1858
|
+
const insightsListOperation = new Operation({
|
|
1859
|
+
id: "posthog.insights-list",
|
|
1860
|
+
name: "PostHog List Insights",
|
|
1861
|
+
description: "List insights in a project",
|
|
1862
|
+
credentialSets: [posthogCredentialSet],
|
|
1863
|
+
input: z.object({
|
|
1864
|
+
...projectIdInputShape,
|
|
1865
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
1866
|
+
offset: z.number().int().min(0).optional(),
|
|
1867
|
+
search: z.string().optional(),
|
|
1868
|
+
favorited: z.boolean().optional(),
|
|
1869
|
+
saved: z.boolean().optional(),
|
|
1870
|
+
created_by: z.number().int().optional(),
|
|
1871
|
+
dashboards: z.array(z.number().int()).optional()
|
|
1872
|
+
}),
|
|
1873
|
+
output: paginatedResponseSchema(insightSchema),
|
|
1874
|
+
run: async (input, context) => {
|
|
1875
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1876
|
+
const projectId = client.projectId(input.projectId);
|
|
1877
|
+
return client.request({
|
|
1878
|
+
method: "GET",
|
|
1879
|
+
path: `/api/projects/${projectId}/insights/`,
|
|
1880
|
+
query: {
|
|
1881
|
+
limit: input.limit,
|
|
1882
|
+
offset: input.offset,
|
|
1883
|
+
search: input.search,
|
|
1884
|
+
favorited: input.favorited,
|
|
1885
|
+
saved: input.saved,
|
|
1886
|
+
created_by: input.created_by,
|
|
1887
|
+
...input.dashboards ? { dashboards: input.dashboards.join(",") } : {}
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
|
|
1893
|
+
//#endregion
|
|
1894
|
+
//#region src/operations/insights-my-insights.operation.ts
|
|
1895
|
+
const insightsMyInsightsOperation = new Operation({
|
|
1896
|
+
id: "posthog.insights-my-insights",
|
|
1897
|
+
name: "PostHog My Insights",
|
|
1898
|
+
description: "Fetch insights owned by the calling user",
|
|
1899
|
+
credentialSets: [posthogCredentialSet],
|
|
1900
|
+
input: z.object({
|
|
1901
|
+
...projectIdInputShape,
|
|
1902
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
1903
|
+
}),
|
|
1904
|
+
output: paginatedResponseSchema(insightSchema),
|
|
1905
|
+
run: async (input, context) => {
|
|
1906
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1907
|
+
const projectId = client.projectId(input.projectId);
|
|
1908
|
+
return client.request({
|
|
1909
|
+
method: "GET",
|
|
1910
|
+
path: `/api/projects/${projectId}/insights/my_last_viewed/`,
|
|
1911
|
+
query: { limit: input.limit }
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
|
|
1916
|
+
//#endregion
|
|
1917
|
+
//#region src/operations/insights-path.operation.ts
|
|
1918
|
+
const insightsPathOperation = new Operation({
|
|
1919
|
+
id: "posthog.insights-path",
|
|
1920
|
+
name: "PostHog Insight Path",
|
|
1921
|
+
description: "Execute a user-path query",
|
|
1922
|
+
credentialSets: [posthogCredentialSet],
|
|
1923
|
+
input: z.object({
|
|
1924
|
+
...projectIdInputShape,
|
|
1925
|
+
query: z.record(z.string(), z.unknown())
|
|
1926
|
+
}),
|
|
1927
|
+
output: z.record(z.string(), z.unknown()),
|
|
1928
|
+
run: async (input, context) => {
|
|
1929
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1930
|
+
const projectId = client.projectId(input.projectId);
|
|
1931
|
+
return client.request({
|
|
1932
|
+
method: "POST",
|
|
1933
|
+
path: `/api/projects/${projectId}/insights/path/`,
|
|
1934
|
+
body: input.query
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1939
|
+
//#endregion
|
|
1940
|
+
//#region src/operations/insights-retention.operation.ts
|
|
1941
|
+
const insightsRetentionOperation = new Operation({
|
|
1942
|
+
id: "posthog.insights-retention",
|
|
1943
|
+
name: "PostHog Insight Retention",
|
|
1944
|
+
description: "Fetch retention report for an insight/query combination",
|
|
1945
|
+
credentialSets: [posthogCredentialSet],
|
|
1946
|
+
input: z.object({
|
|
1947
|
+
...projectIdInputShape,
|
|
1948
|
+
query: z.record(z.string(), z.unknown())
|
|
1949
|
+
}),
|
|
1950
|
+
output: z.record(z.string(), z.unknown()),
|
|
1951
|
+
run: async (input, context) => {
|
|
1952
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1953
|
+
const projectId = client.projectId(input.projectId);
|
|
1954
|
+
return client.request({
|
|
1955
|
+
method: "POST",
|
|
1956
|
+
path: `/api/projects/${projectId}/insights/retention/`,
|
|
1957
|
+
body: input.query
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
|
|
1962
|
+
//#endregion
|
|
1963
|
+
//#region src/operations/insights-sharing-get.operation.ts
|
|
1964
|
+
const insightsSharingGetOperation = new Operation({
|
|
1965
|
+
id: "posthog.insights-sharing-get",
|
|
1966
|
+
name: "PostHog Get Insight Sharing",
|
|
1967
|
+
description: "Fetch sharing configuration for an insight",
|
|
1968
|
+
credentialSets: [posthogCredentialSet],
|
|
1969
|
+
input: z.object(idInput$3),
|
|
1970
|
+
output: sharingConfigurationSchema,
|
|
1971
|
+
run: async (input, context) => {
|
|
1972
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1973
|
+
const projectId = client.projectId(input.projectId);
|
|
1974
|
+
return client.request({
|
|
1975
|
+
method: "GET",
|
|
1976
|
+
path: `/api/projects/${projectId}/insights/${input.id}/sharing/`
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
|
|
1981
|
+
//#endregion
|
|
1982
|
+
//#region src/operations/insights-sharing-update.operation.ts
|
|
1983
|
+
const insightsSharingUpdateOperation = new Operation({
|
|
1984
|
+
id: "posthog.insights-sharing-update",
|
|
1985
|
+
name: "PostHog Update Insight Sharing",
|
|
1986
|
+
description: "Enable or disable sharing for an insight",
|
|
1987
|
+
credentialSets: [posthogCredentialSet],
|
|
1988
|
+
input: z.object({
|
|
1989
|
+
...idInput$3,
|
|
1990
|
+
enabled: z.boolean()
|
|
1991
|
+
}),
|
|
1992
|
+
output: sharingConfigurationSchema,
|
|
1993
|
+
needsApproval: true,
|
|
1994
|
+
run: async (input, context) => {
|
|
1995
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
1996
|
+
const projectId = client.projectId(input.projectId);
|
|
1997
|
+
return client.request({
|
|
1998
|
+
method: "PATCH",
|
|
1999
|
+
path: `/api/projects/${projectId}/insights/${input.id}/sharing/`,
|
|
2000
|
+
body: { enabled: input.enabled }
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
|
|
2005
|
+
//#endregion
|
|
2006
|
+
//#region src/operations/insights-trend.operation.ts
|
|
2007
|
+
const insightsTrendOperation = new Operation({
|
|
2008
|
+
id: "posthog.insights-trend",
|
|
2009
|
+
name: "PostHog Execute Insight Query",
|
|
2010
|
+
description: "Execute an ad-hoc trend/funnel/retention/etc. query",
|
|
2011
|
+
credentialSets: [posthogCredentialSet],
|
|
2012
|
+
input: z.object({
|
|
2013
|
+
...projectIdInputShape,
|
|
2014
|
+
query: z.record(z.string(), z.unknown()),
|
|
2015
|
+
refresh: z.boolean().optional()
|
|
2016
|
+
}),
|
|
2017
|
+
output: z.record(z.string(), z.unknown()),
|
|
2018
|
+
run: async (input, context) => {
|
|
2019
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2020
|
+
const projectId = client.projectId(input.projectId);
|
|
2021
|
+
return client.request({
|
|
2022
|
+
method: "POST",
|
|
2023
|
+
path: `/api/projects/${projectId}/query/`,
|
|
2024
|
+
body: {
|
|
2025
|
+
query: input.query,
|
|
2026
|
+
refresh: input.refresh ?? false
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
|
|
2032
|
+
//#endregion
|
|
2033
|
+
//#region src/operations/insights-trend-chart.operation.ts
|
|
2034
|
+
const insightsTrendChartOperation = new Operation({
|
|
2035
|
+
id: "posthog.insights-trend-chart",
|
|
2036
|
+
name: "PostHog Insight Trend",
|
|
2037
|
+
description: "Execute a trend query",
|
|
2038
|
+
credentialSets: [posthogCredentialSet],
|
|
2039
|
+
input: z.object({
|
|
2040
|
+
...projectIdInputShape,
|
|
2041
|
+
query: z.record(z.string(), z.unknown())
|
|
2042
|
+
}),
|
|
2043
|
+
output: z.record(z.string(), z.unknown()),
|
|
2044
|
+
run: async (input, context) => {
|
|
2045
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2046
|
+
const projectId = client.projectId(input.projectId);
|
|
2047
|
+
return client.request({
|
|
2048
|
+
method: "POST",
|
|
2049
|
+
path: `/api/projects/${projectId}/insights/trend/`,
|
|
2050
|
+
body: input.query
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
|
|
2055
|
+
//#endregion
|
|
2056
|
+
//#region src/operations/insights-update.operation.ts
|
|
2057
|
+
const insightsUpdateOperation = new Operation({
|
|
2058
|
+
id: "posthog.insights-update",
|
|
2059
|
+
name: "PostHog Update Insight",
|
|
2060
|
+
description: "Partial update to an insight",
|
|
2061
|
+
credentialSets: [posthogCredentialSet],
|
|
2062
|
+
input: z.object({
|
|
2063
|
+
...idInput$3,
|
|
2064
|
+
...writeShape$1
|
|
2065
|
+
}),
|
|
2066
|
+
output: insightSchema,
|
|
2067
|
+
needsApproval: true,
|
|
2068
|
+
run: async (input, context) => {
|
|
2069
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2070
|
+
const projectId = client.projectId(input.projectId);
|
|
2071
|
+
const { projectId: _pid, id, ...body } = input;
|
|
2072
|
+
return client.request({
|
|
2073
|
+
method: "PATCH",
|
|
2074
|
+
path: `/api/projects/${projectId}/insights/${id}/`,
|
|
2075
|
+
body
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
});
|
|
2079
|
+
|
|
2080
|
+
//#endregion
|
|
2081
|
+
//#region src/operations/insights-viewed.operation.ts
|
|
2082
|
+
const insightsViewedOperation = new Operation({
|
|
2083
|
+
id: "posthog.insights-viewed",
|
|
2084
|
+
name: "PostHog Mark Insight Viewed",
|
|
2085
|
+
description: "Record that the calling user viewed an insight",
|
|
2086
|
+
credentialSets: [posthogCredentialSet],
|
|
2087
|
+
input: z.object(idInput$3),
|
|
2088
|
+
output: z.object({ success: z.boolean() }),
|
|
2089
|
+
needsApproval: true,
|
|
2090
|
+
run: async (input, context) => {
|
|
2091
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2092
|
+
const projectId = client.projectId(input.projectId);
|
|
2093
|
+
await client.request({
|
|
2094
|
+
method: "POST",
|
|
2095
|
+
path: `/api/projects/${projectId}/insights/${input.id}/viewed/`
|
|
2096
|
+
});
|
|
2097
|
+
return { success: true };
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
|
|
2101
|
+
//#endregion
|
|
2102
|
+
//#region src/utils/domain-inputs/organizations.ts
|
|
2103
|
+
const orgInput = { organizationId: z.string().min(1) };
|
|
2104
|
+
|
|
2105
|
+
//#endregion
|
|
2106
|
+
//#region src/operations/organization-invites-create.operation.ts
|
|
2107
|
+
const organizationInvitesCreateOperation = new Operation({
|
|
2108
|
+
id: "posthog.organization-invites-create",
|
|
2109
|
+
name: "PostHog Create Organization Invite",
|
|
2110
|
+
description: "Invite a user to an organization",
|
|
2111
|
+
credentialSets: [posthogCredentialSet],
|
|
2112
|
+
input: z.object({
|
|
2113
|
+
...orgInput,
|
|
2114
|
+
target_email: z.email(),
|
|
2115
|
+
level: z.number().int().optional(),
|
|
2116
|
+
first_name: z.string().optional()
|
|
2117
|
+
}),
|
|
2118
|
+
output: z.record(z.string(), z.unknown()),
|
|
2119
|
+
needsApproval: true,
|
|
2120
|
+
run: async (input, context) => {
|
|
2121
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2122
|
+
const { organizationId, ...body } = input;
|
|
2123
|
+
return client.request({
|
|
2124
|
+
method: "POST",
|
|
2125
|
+
path: `/api/organizations/${organizationId}/invites/`,
|
|
2126
|
+
body
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
|
|
2131
|
+
//#endregion
|
|
2132
|
+
//#region src/operations/organization-invites-delete.operation.ts
|
|
2133
|
+
const organizationInvitesDeleteOperation = new Operation({
|
|
2134
|
+
id: "posthog.organization-invites-delete",
|
|
2135
|
+
name: "PostHog Delete Organization Invite",
|
|
2136
|
+
description: "Revoke an organization invite",
|
|
2137
|
+
credentialSets: [posthogCredentialSet],
|
|
2138
|
+
input: z.object({
|
|
2139
|
+
...orgInput,
|
|
2140
|
+
inviteId: z.string().min(1)
|
|
2141
|
+
}),
|
|
2142
|
+
output: z.object({ success: z.boolean() }),
|
|
2143
|
+
needsApproval: true,
|
|
2144
|
+
run: async (input, context) => {
|
|
2145
|
+
await createPosthogManagementClient(context.credentials.posthog).request({
|
|
2146
|
+
method: "DELETE",
|
|
2147
|
+
path: `/api/organizations/${input.organizationId}/invites/${input.inviteId}/`
|
|
2148
|
+
});
|
|
2149
|
+
return { success: true };
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
|
|
2153
|
+
//#endregion
|
|
2154
|
+
//#region src/operations/organization-invites-list.operation.ts
|
|
2155
|
+
const organizationInvitesListOperation = new Operation({
|
|
2156
|
+
id: "posthog.organization-invites-list",
|
|
2157
|
+
name: "PostHog List Organization Invites",
|
|
2158
|
+
description: "List outstanding invites for an organization",
|
|
2159
|
+
credentialSets: [posthogCredentialSet],
|
|
2160
|
+
input: z.object({
|
|
2161
|
+
...orgInput,
|
|
2162
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
2163
|
+
}),
|
|
2164
|
+
output: paginatedResponseSchema(z.record(z.string(), z.unknown())),
|
|
2165
|
+
run: async (input, context) => {
|
|
2166
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2167
|
+
method: "GET",
|
|
2168
|
+
path: `/api/organizations/${input.organizationId}/invites/`,
|
|
2169
|
+
query: { limit: input.limit }
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
|
|
2174
|
+
//#endregion
|
|
2175
|
+
//#region src/operations/organization-members-list.operation.ts
|
|
2176
|
+
const organizationMembersListOperation = new Operation({
|
|
2177
|
+
id: "posthog.organization-members-list",
|
|
2178
|
+
name: "PostHog List Organization Members",
|
|
2179
|
+
description: "List members of an organization",
|
|
2180
|
+
credentialSets: [posthogCredentialSet],
|
|
2181
|
+
input: z.object({
|
|
2182
|
+
...orgInput,
|
|
2183
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
2184
|
+
offset: z.number().int().min(0).optional()
|
|
2185
|
+
}),
|
|
2186
|
+
output: paginatedResponseSchema(projectMemberSchema),
|
|
2187
|
+
run: async (input, context) => {
|
|
2188
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2189
|
+
method: "GET",
|
|
2190
|
+
path: `/api/organizations/${input.organizationId}/members/`,
|
|
2191
|
+
query: {
|
|
2192
|
+
limit: input.limit,
|
|
2193
|
+
offset: input.offset
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
|
|
2199
|
+
//#endregion
|
|
2200
|
+
//#region src/operations/organization-members-remove.operation.ts
|
|
2201
|
+
const organizationMembersRemoveOperation = new Operation({
|
|
2202
|
+
id: "posthog.organization-members-remove",
|
|
2203
|
+
name: "PostHog Remove Organization Member",
|
|
2204
|
+
description: "Remove a user from an organization",
|
|
2205
|
+
credentialSets: [posthogCredentialSet],
|
|
2206
|
+
input: z.object({
|
|
2207
|
+
...orgInput,
|
|
2208
|
+
userUuid: z.string().min(1)
|
|
2209
|
+
}),
|
|
2210
|
+
output: z.object({ success: z.boolean() }),
|
|
2211
|
+
needsApproval: true,
|
|
2212
|
+
run: async (input, context) => {
|
|
2213
|
+
await createPosthogManagementClient(context.credentials.posthog).request({
|
|
2214
|
+
method: "DELETE",
|
|
2215
|
+
path: `/api/organizations/${input.organizationId}/members/${input.userUuid}/`
|
|
2216
|
+
});
|
|
2217
|
+
return { success: true };
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2220
|
+
|
|
2221
|
+
//#endregion
|
|
2222
|
+
//#region src/operations/organization-members-update.operation.ts
|
|
2223
|
+
const organizationMembersUpdateOperation = new Operation({
|
|
2224
|
+
credentialSets: [posthogCredentialSet],
|
|
2225
|
+
id: "posthog.organization-members-update",
|
|
2226
|
+
name: "PostHog Update Organization Member",
|
|
2227
|
+
description: "Update an organization member's role",
|
|
2228
|
+
input: z.object({
|
|
2229
|
+
...orgInput,
|
|
2230
|
+
userUuid: z.string().min(1),
|
|
2231
|
+
level: z.number().int()
|
|
2232
|
+
}),
|
|
2233
|
+
output: projectMemberSchema,
|
|
2234
|
+
needsApproval: true,
|
|
2235
|
+
run: async (input, context) => {
|
|
2236
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2237
|
+
method: "PATCH",
|
|
2238
|
+
path: `/api/organizations/${input.organizationId}/members/${input.userUuid}/`,
|
|
2239
|
+
body: { level: input.level }
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
|
|
2244
|
+
//#endregion
|
|
2245
|
+
//#region src/operations/organizations-create.operation.ts
|
|
2246
|
+
const organizationsCreateOperation = new Operation({
|
|
2247
|
+
id: "posthog.organizations-create",
|
|
2248
|
+
name: "PostHog Create Organization",
|
|
2249
|
+
description: "Create a new organization",
|
|
2250
|
+
credentialSets: [posthogCredentialSet],
|
|
2251
|
+
input: z.object({
|
|
2252
|
+
name: z.string().min(1),
|
|
2253
|
+
slug: z.string().optional()
|
|
2254
|
+
}),
|
|
2255
|
+
output: organizationSchema,
|
|
2256
|
+
needsApproval: true,
|
|
2257
|
+
run: async (input, context) => {
|
|
2258
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2259
|
+
method: "POST",
|
|
2260
|
+
path: "/api/organizations/",
|
|
2261
|
+
body: input
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2265
|
+
|
|
2266
|
+
//#endregion
|
|
2267
|
+
//#region src/operations/organizations-delete.operation.ts
|
|
2268
|
+
const organizationsDeleteOperation = new Operation({
|
|
2269
|
+
id: "posthog.organizations-delete",
|
|
2270
|
+
name: "PostHog Delete Organization",
|
|
2271
|
+
description: "Delete an organization",
|
|
2272
|
+
credentialSets: [posthogCredentialSet],
|
|
2273
|
+
input: z.object(orgInput),
|
|
2274
|
+
output: z.object({ success: z.boolean() }),
|
|
2275
|
+
needsApproval: true,
|
|
2276
|
+
run: async (input, context) => {
|
|
2277
|
+
await createPosthogManagementClient(context.credentials.posthog).request({
|
|
2278
|
+
method: "DELETE",
|
|
2279
|
+
path: `/api/organizations/${input.organizationId}/`
|
|
2280
|
+
});
|
|
2281
|
+
return { success: true };
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
|
|
2285
|
+
//#endregion
|
|
2286
|
+
//#region src/operations/organizations-get.operation.ts
|
|
2287
|
+
const organizationsGetOperation = new Operation({
|
|
2288
|
+
id: "posthog.organizations-get",
|
|
2289
|
+
name: "PostHog Get Organization",
|
|
2290
|
+
description: "Retrieve an organization by id",
|
|
2291
|
+
credentialSets: [posthogCredentialSet],
|
|
2292
|
+
input: z.object(orgInput),
|
|
2293
|
+
output: organizationSchema,
|
|
2294
|
+
run: async (input, context) => {
|
|
2295
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2296
|
+
method: "GET",
|
|
2297
|
+
path: `/api/organizations/${input.organizationId}/`
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
|
|
2302
|
+
//#endregion
|
|
2303
|
+
//#region src/operations/organizations-list.operation.ts
|
|
2304
|
+
const organizationsListOperation = new Operation({
|
|
2305
|
+
id: "posthog.organizations-list",
|
|
2306
|
+
name: "PostHog List Organizations",
|
|
2307
|
+
description: "List organizations the personal API key can access",
|
|
2308
|
+
credentialSets: [posthogCredentialSet],
|
|
2309
|
+
input: z.object({
|
|
2310
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
2311
|
+
offset: z.number().int().min(0).optional()
|
|
2312
|
+
}),
|
|
2313
|
+
output: paginatedResponseSchema(organizationSchema),
|
|
2314
|
+
run: async (input, context) => {
|
|
2315
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
2316
|
+
method: "GET",
|
|
2317
|
+
path: "/api/organizations/",
|
|
2318
|
+
query: {
|
|
2319
|
+
limit: input.limit,
|
|
2320
|
+
offset: input.offset
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
});
|
|
2325
|
+
|
|
2326
|
+
//#endregion
|
|
2327
|
+
//#region src/operations/organizations-update.operation.ts
|
|
2328
|
+
const organizationsUpdateOperation = new Operation({
|
|
2329
|
+
id: "posthog.organizations-update",
|
|
2330
|
+
name: "PostHog Update Organization",
|
|
2331
|
+
description: "Partial update to an organization",
|
|
2332
|
+
credentialSets: [posthogCredentialSet],
|
|
2333
|
+
input: z.object({
|
|
2334
|
+
...orgInput,
|
|
2335
|
+
name: z.string().optional(),
|
|
2336
|
+
slug: z.string().optional()
|
|
2337
|
+
}),
|
|
2338
|
+
output: organizationSchema,
|
|
2339
|
+
needsApproval: true,
|
|
2340
|
+
run: async (input, context) => {
|
|
2341
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2342
|
+
const { organizationId, ...body } = input;
|
|
2343
|
+
return client.request({
|
|
2344
|
+
method: "PATCH",
|
|
2345
|
+
path: `/api/organizations/${organizationId}/`,
|
|
2346
|
+
body
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
});
|
|
2350
|
+
|
|
2351
|
+
//#endregion
|
|
2352
|
+
//#region src/operations/persons-activity.operation.ts
|
|
2353
|
+
const personsActivityOperation = new Operation({
|
|
2354
|
+
id: "posthog.persons-activity",
|
|
2355
|
+
name: "PostHog Person Activity",
|
|
2356
|
+
description: "Fetch recent activity for a person",
|
|
2357
|
+
credentialSets: [posthogCredentialSet],
|
|
2358
|
+
input: z.object({
|
|
2359
|
+
...idInput$3,
|
|
2360
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
2361
|
+
}),
|
|
2362
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
2363
|
+
run: async (input, context) => {
|
|
2364
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2365
|
+
const projectId = client.projectId(input.projectId);
|
|
2366
|
+
return client.request({
|
|
2367
|
+
method: "GET",
|
|
2368
|
+
path: `/api/projects/${projectId}/persons/${input.id}/activity/`,
|
|
2369
|
+
query: { limit: input.limit }
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
|
|
2374
|
+
//#endregion
|
|
2375
|
+
//#region src/operations/persons-activity-feed.operation.ts
|
|
2376
|
+
const personsActivityFeedOperation = new Operation({
|
|
2377
|
+
id: "posthog.persons-activity-feed",
|
|
2378
|
+
name: "PostHog Persons Activity Feed",
|
|
2379
|
+
description: "Fetch the project-wide persons activity feed",
|
|
2380
|
+
credentialSets: [posthogCredentialSet],
|
|
2381
|
+
input: z.object({
|
|
2382
|
+
...projectIdInputShape,
|
|
2383
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
2384
|
+
}),
|
|
2385
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
2386
|
+
run: async (input, context) => {
|
|
2387
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2388
|
+
const projectId = client.projectId(input.projectId);
|
|
2389
|
+
return client.request({
|
|
2390
|
+
method: "GET",
|
|
2391
|
+
path: `/api/projects/${projectId}/persons/activity/`,
|
|
2392
|
+
query: { limit: input.limit }
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
});
|
|
2396
|
+
|
|
2397
|
+
//#endregion
|
|
2398
|
+
//#region src/operations/persons-delete.operation.ts
|
|
2399
|
+
const personsDeleteOperation = new Operation({
|
|
2400
|
+
id: "posthog.persons-delete",
|
|
2401
|
+
name: "PostHog Delete Person",
|
|
2402
|
+
description: "Delete a person and optionally their associated events",
|
|
2403
|
+
credentialSets: [posthogCredentialSet],
|
|
2404
|
+
input: z.object({
|
|
2405
|
+
...idInput$3,
|
|
2406
|
+
delete_events: z.boolean().optional()
|
|
2407
|
+
}),
|
|
2408
|
+
output: z.object({ success: z.boolean() }),
|
|
2409
|
+
needsApproval: true,
|
|
2410
|
+
run: async (input, context) => {
|
|
2411
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2412
|
+
const projectId = client.projectId(input.projectId);
|
|
2413
|
+
await client.request({
|
|
2414
|
+
method: "DELETE",
|
|
2415
|
+
path: `/api/projects/${projectId}/persons/${input.id}/`,
|
|
2416
|
+
query: input.delete_events !== void 0 ? { delete_events: input.delete_events } : void 0
|
|
2417
|
+
});
|
|
2418
|
+
return { success: true };
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
|
|
2422
|
+
//#endregion
|
|
2423
|
+
//#region src/operations/persons-delete-property.operation.ts
|
|
2424
|
+
const personsDeletePropertyOperation = new Operation({
|
|
2425
|
+
id: "posthog.persons-delete-property",
|
|
2426
|
+
name: "PostHog Delete Person Property",
|
|
2427
|
+
description: "Remove a single property from a person",
|
|
2428
|
+
credentialSets: [posthogCredentialSet],
|
|
2429
|
+
input: z.object({
|
|
2430
|
+
...idInput$3,
|
|
2431
|
+
key: z.string().min(1)
|
|
2432
|
+
}),
|
|
2433
|
+
output: z.object({ success: z.boolean() }),
|
|
2434
|
+
needsApproval: true,
|
|
2435
|
+
run: async (input, context) => {
|
|
2436
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2437
|
+
const projectId = client.projectId(input.projectId);
|
|
2438
|
+
await client.request({
|
|
2439
|
+
method: "POST",
|
|
2440
|
+
path: `/api/projects/${projectId}/persons/${input.id}/delete_property/`,
|
|
2441
|
+
body: { $unset: input.key }
|
|
2442
|
+
});
|
|
2443
|
+
return { success: true };
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
|
|
2447
|
+
//#endregion
|
|
2448
|
+
//#region src/utils/domain-inputs/persons.ts
|
|
2449
|
+
const idInput$1 = {
|
|
2450
|
+
...projectIdInputShape,
|
|
2451
|
+
id: z.union([z.number().int(), z.string()])
|
|
2452
|
+
};
|
|
2453
|
+
const listSchema = paginatedResponseSchema(personSchema);
|
|
2454
|
+
|
|
2455
|
+
//#endregion
|
|
2456
|
+
//#region src/operations/persons-funnel.operation.ts
|
|
2457
|
+
const personsFunnelOperation = new Operation({
|
|
2458
|
+
id: "posthog.persons-funnel",
|
|
2459
|
+
name: "PostHog Persons Funnel",
|
|
2460
|
+
description: "Fetch persons dropping through a funnel",
|
|
2461
|
+
credentialSets: [posthogCredentialSet],
|
|
2462
|
+
input: z.object({
|
|
2463
|
+
...projectIdInputShape,
|
|
2464
|
+
filter: z.record(z.string(), z.unknown()),
|
|
2465
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
2466
|
+
offset: z.number().int().min(0).optional()
|
|
2467
|
+
}),
|
|
2468
|
+
output: listSchema,
|
|
2469
|
+
run: async (input, context) => {
|
|
2470
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2471
|
+
const projectId = client.projectId(input.projectId);
|
|
2472
|
+
return client.request({
|
|
2473
|
+
method: "POST",
|
|
2474
|
+
path: `/api/projects/${projectId}/persons/funnel/`,
|
|
2475
|
+
body: input.filter,
|
|
2476
|
+
query: {
|
|
2477
|
+
limit: input.limit,
|
|
2478
|
+
offset: input.offset
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
|
|
2484
|
+
//#endregion
|
|
2485
|
+
//#region src/operations/persons-get.operation.ts
|
|
2486
|
+
const personsGetOperation = new Operation({
|
|
2487
|
+
id: "posthog.persons-get",
|
|
2488
|
+
name: "PostHog Get Person",
|
|
2489
|
+
description: "Retrieve a single person by id",
|
|
2490
|
+
credentialSets: [posthogCredentialSet],
|
|
2491
|
+
input: z.object(idInput$3),
|
|
2492
|
+
output: personSchema,
|
|
2493
|
+
run: async (input, context) => {
|
|
2494
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2495
|
+
const projectId = client.projectId(input.projectId);
|
|
2496
|
+
return client.request({
|
|
2497
|
+
method: "GET",
|
|
2498
|
+
path: `/api/projects/${projectId}/persons/${input.id}/`
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
});
|
|
2502
|
+
|
|
2503
|
+
//#endregion
|
|
2504
|
+
//#region src/operations/persons-lifecycle.operation.ts
|
|
2505
|
+
const personsLifecycleOperation = new Operation({
|
|
2506
|
+
id: "posthog.persons-lifecycle",
|
|
2507
|
+
name: "PostHog Persons Lifecycle",
|
|
2508
|
+
description: "Fetch persons matching a lifecycle query",
|
|
2509
|
+
credentialSets: [posthogCredentialSet],
|
|
2510
|
+
input: z.object({
|
|
2511
|
+
...projectIdInputShape,
|
|
2512
|
+
filter: z.record(z.string(), z.unknown()),
|
|
2513
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
2514
|
+
}),
|
|
2515
|
+
output: listSchema,
|
|
2516
|
+
run: async (input, context) => {
|
|
2517
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2518
|
+
const projectId = client.projectId(input.projectId);
|
|
2519
|
+
return client.request({
|
|
2520
|
+
method: "POST",
|
|
2521
|
+
path: `/api/projects/${projectId}/persons/lifecycle/`,
|
|
2522
|
+
body: input.filter,
|
|
2523
|
+
query: { limit: input.limit }
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
|
|
2528
|
+
//#endregion
|
|
2529
|
+
//#region src/operations/persons-list.operation.ts
|
|
2530
|
+
const personsListOperation = new Operation({
|
|
2531
|
+
id: "posthog.persons-list",
|
|
2532
|
+
name: "PostHog List Persons",
|
|
2533
|
+
description: "List persons with optional search, email, or distinct-id filters",
|
|
2534
|
+
credentialSets: [posthogCredentialSet],
|
|
2535
|
+
input: z.object({
|
|
2536
|
+
...projectIdInputShape,
|
|
2537
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
2538
|
+
offset: z.number().int().min(0).optional(),
|
|
2539
|
+
search: z.string().optional(),
|
|
2540
|
+
distinct_id: z.string().optional(),
|
|
2541
|
+
email: z.email().optional(),
|
|
2542
|
+
properties: z.array(z.record(z.string(), z.unknown())).optional()
|
|
2543
|
+
}),
|
|
2544
|
+
output: listSchema,
|
|
2545
|
+
run: async (input, context) => {
|
|
2546
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2547
|
+
const projectId = client.projectId(input.projectId);
|
|
2548
|
+
return client.request({
|
|
2549
|
+
method: "GET",
|
|
2550
|
+
path: `/api/projects/${projectId}/persons/`,
|
|
2551
|
+
query: {
|
|
2552
|
+
limit: input.limit,
|
|
2553
|
+
offset: input.offset,
|
|
2554
|
+
search: input.search,
|
|
2555
|
+
distinct_id: input.distinct_id,
|
|
2556
|
+
email: input.email,
|
|
2557
|
+
...input.properties ? { properties: JSON.stringify(input.properties) } : {}
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
|
|
2563
|
+
//#endregion
|
|
2564
|
+
//#region src/operations/persons-merge.operation.ts
|
|
2565
|
+
const personsMergeOperation = new Operation({
|
|
2566
|
+
id: "posthog.persons-merge",
|
|
2567
|
+
name: "PostHog Merge Persons",
|
|
2568
|
+
description: "Merge two persons together (destination receives events from source)",
|
|
2569
|
+
credentialSets: [posthogCredentialSet],
|
|
2570
|
+
input: z.object({
|
|
2571
|
+
...idInput$3,
|
|
2572
|
+
source_id: z.union([z.number().int(), z.string()])
|
|
2573
|
+
}),
|
|
2574
|
+
output: personSchema,
|
|
2575
|
+
needsApproval: true,
|
|
2576
|
+
run: async (input, context) => {
|
|
2577
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2578
|
+
const projectId = client.projectId(input.projectId);
|
|
2579
|
+
return client.request({
|
|
2580
|
+
method: "POST",
|
|
2581
|
+
path: `/api/projects/${projectId}/persons/${input.id}/merge/`,
|
|
2582
|
+
body: { ids: [input.source_id] }
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
|
|
2587
|
+
//#endregion
|
|
2588
|
+
//#region src/operations/persons-reset-name.operation.ts
|
|
2589
|
+
const personsResetNameOperation = new Operation({
|
|
2590
|
+
id: "posthog.persons-reset-name",
|
|
2591
|
+
name: "PostHog Reset Person Name",
|
|
2592
|
+
description: "Reset a person displayed-name override",
|
|
2593
|
+
credentialSets: [posthogCredentialSet],
|
|
2594
|
+
input: z.object(idInput$3),
|
|
2595
|
+
output: personSchema,
|
|
2596
|
+
needsApproval: true,
|
|
2597
|
+
run: async (input, context) => {
|
|
2598
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2599
|
+
const projectId = client.projectId(input.projectId);
|
|
2600
|
+
return client.request({
|
|
2601
|
+
method: "POST",
|
|
2602
|
+
path: `/api/projects/${projectId}/persons/${input.id}/reset_name/`
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
2606
|
+
|
|
2607
|
+
//#endregion
|
|
2608
|
+
//#region src/operations/persons-split.operation.ts
|
|
2609
|
+
const personsSplitOperation = new Operation({
|
|
2610
|
+
id: "posthog.persons-split",
|
|
2611
|
+
name: "PostHog Split Person",
|
|
2612
|
+
description: "Split a person by separating their distinct_ids",
|
|
2613
|
+
credentialSets: [posthogCredentialSet],
|
|
2614
|
+
input: z.object({
|
|
2615
|
+
...idInput$3,
|
|
2616
|
+
main_distinct_id: z.string().optional()
|
|
2617
|
+
}),
|
|
2618
|
+
output: z.object({ success: z.boolean() }),
|
|
2619
|
+
needsApproval: true,
|
|
2620
|
+
run: async (input, context) => {
|
|
2621
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2622
|
+
const projectId = client.projectId(input.projectId);
|
|
2623
|
+
await client.request({
|
|
2624
|
+
method: "POST",
|
|
2625
|
+
path: `/api/projects/${projectId}/persons/${input.id}/split/`,
|
|
2626
|
+
body: input.main_distinct_id ? { main_distinct_id: input.main_distinct_id } : {}
|
|
2627
|
+
});
|
|
2628
|
+
return { success: true };
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
|
|
2632
|
+
//#endregion
|
|
2633
|
+
//#region src/operations/persons-trends.operation.ts
|
|
2634
|
+
const personsTrendsOperation = new Operation({
|
|
2635
|
+
id: "posthog.persons-trends",
|
|
2636
|
+
name: "PostHog Persons Trends",
|
|
2637
|
+
description: "Fetch persons matching a trend query",
|
|
2638
|
+
credentialSets: [posthogCredentialSet],
|
|
2639
|
+
input: z.object({
|
|
2640
|
+
...projectIdInputShape,
|
|
2641
|
+
filter: z.record(z.string(), z.unknown()),
|
|
2642
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
2643
|
+
offset: z.number().int().min(0).optional()
|
|
2644
|
+
}),
|
|
2645
|
+
output: listSchema,
|
|
2646
|
+
run: async (input, context) => {
|
|
2647
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2648
|
+
const projectId = client.projectId(input.projectId);
|
|
2649
|
+
return client.request({
|
|
2650
|
+
method: "GET",
|
|
2651
|
+
path: `/api/projects/${projectId}/persons/trends/`,
|
|
2652
|
+
query: {
|
|
2653
|
+
limit: input.limit,
|
|
2654
|
+
offset: input.offset,
|
|
2655
|
+
...Object.fromEntries(Object.entries(input.filter).map(([k, v]) => [k, typeof v === "string" ? v : JSON.stringify(v)]))
|
|
2656
|
+
}
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
});
|
|
2660
|
+
|
|
2661
|
+
//#endregion
|
|
2662
|
+
//#region src/operations/persons-update.operation.ts
|
|
2663
|
+
const personsUpdateOperation = new Operation({
|
|
2664
|
+
id: "posthog.persons-update",
|
|
2665
|
+
name: "PostHog Update Person",
|
|
2666
|
+
description: "Update a person (partial update)",
|
|
2667
|
+
credentialSets: [posthogCredentialSet],
|
|
2668
|
+
input: z.object({
|
|
2669
|
+
...idInput$3,
|
|
2670
|
+
properties: propertiesBagSchema.optional(),
|
|
2671
|
+
name: z.string().optional()
|
|
2672
|
+
}),
|
|
2673
|
+
output: personSchema,
|
|
2674
|
+
needsApproval: true,
|
|
2675
|
+
run: async (input, context) => {
|
|
2676
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2677
|
+
const projectId = client.projectId(input.projectId);
|
|
2678
|
+
const { projectId: _pid, id, ...body } = input;
|
|
2679
|
+
return client.request({
|
|
2680
|
+
method: "PATCH",
|
|
2681
|
+
path: `/api/projects/${projectId}/persons/${id}/`,
|
|
2682
|
+
body
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
});
|
|
2686
|
+
|
|
2687
|
+
//#endregion
|
|
2688
|
+
//#region src/operations/persons-update-property.operation.ts
|
|
2689
|
+
const personsUpdatePropertyOperation = new Operation({
|
|
2690
|
+
id: "posthog.persons-update-property",
|
|
2691
|
+
name: "PostHog Update Person Property",
|
|
2692
|
+
description: "Set a single property on a person",
|
|
2693
|
+
credentialSets: [posthogCredentialSet],
|
|
2694
|
+
input: z.object({
|
|
2695
|
+
...idInput$3,
|
|
2696
|
+
key: z.string().min(1),
|
|
2697
|
+
value: z.unknown()
|
|
2698
|
+
}),
|
|
2699
|
+
output: personSchema,
|
|
2700
|
+
needsApproval: true,
|
|
2701
|
+
run: async (input, context) => {
|
|
2702
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2703
|
+
const projectId = client.projectId(input.projectId);
|
|
2704
|
+
return client.request({
|
|
2705
|
+
method: "POST",
|
|
2706
|
+
path: `/api/projects/${projectId}/persons/${input.id}/update_property/`,
|
|
2707
|
+
body: {
|
|
2708
|
+
key: input.key,
|
|
2709
|
+
value: input.value
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
|
|
2715
|
+
//#endregion
|
|
2716
|
+
//#region src/operations/persons-values.operation.ts
|
|
2717
|
+
const personsValuesOperation = new Operation({
|
|
2718
|
+
id: "posthog.persons-values",
|
|
2719
|
+
name: "PostHog Person Property Values",
|
|
2720
|
+
description: "Fetch distinct values for a person property",
|
|
2721
|
+
credentialSets: [posthogCredentialSet],
|
|
2722
|
+
input: z.object({
|
|
2723
|
+
...projectIdInputShape,
|
|
2724
|
+
key: z.string().min(1),
|
|
2725
|
+
value: z.string().optional()
|
|
2726
|
+
}),
|
|
2727
|
+
output: z.array(z.record(z.string(), z.unknown())),
|
|
2728
|
+
run: async (input, context) => {
|
|
2729
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2730
|
+
const projectId = client.projectId(input.projectId);
|
|
2731
|
+
return client.request({
|
|
2732
|
+
method: "GET",
|
|
2733
|
+
path: `/api/projects/${projectId}/persons/values/`,
|
|
2734
|
+
query: {
|
|
2735
|
+
key: input.key,
|
|
2736
|
+
value: input.value
|
|
2737
|
+
}
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2740
|
+
});
|
|
2741
|
+
|
|
2742
|
+
//#endregion
|
|
2743
|
+
//#region src/operations/pipeline-destinations-create.operation.ts
|
|
2744
|
+
const pipelineDestinationsCreateOperation = new Operation({
|
|
2745
|
+
id: "posthog.pipeline-destinations-create",
|
|
2746
|
+
name: "PostHog Create Pipeline Destination",
|
|
2747
|
+
description: "Configure a pipeline destination plugin (e.g. webhook delivery)",
|
|
2748
|
+
credentialSets: [posthogCredentialSet],
|
|
2749
|
+
input: z.object({
|
|
2750
|
+
...projectIdInputShape,
|
|
2751
|
+
plugin: z.number().int(),
|
|
2752
|
+
enabled: z.boolean().default(true),
|
|
2753
|
+
order: z.number().int().optional(),
|
|
2754
|
+
config: z.record(z.string(), z.unknown())
|
|
2755
|
+
}),
|
|
2756
|
+
output: z.record(z.string(), z.unknown()),
|
|
2757
|
+
needsApproval: true,
|
|
2758
|
+
run: async (input, context) => {
|
|
2759
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2760
|
+
const projectId = client.projectId(input.projectId);
|
|
2761
|
+
const { projectId: _pid, ...body } = input;
|
|
2762
|
+
return client.request({
|
|
2763
|
+
method: "POST",
|
|
2764
|
+
path: `/api/projects/${projectId}/plugin_configs/`,
|
|
2765
|
+
body
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
});
|
|
2769
|
+
|
|
2770
|
+
//#endregion
|
|
2771
|
+
//#region src/operations/pipeline-destinations-delete.operation.ts
|
|
2772
|
+
const pipelineDestinationsDeleteOperation = new Operation({
|
|
2773
|
+
id: "posthog.pipeline-destinations-delete",
|
|
2774
|
+
name: "PostHog Delete Pipeline Destination",
|
|
2775
|
+
description: "Remove a pipeline destination configuration",
|
|
2776
|
+
credentialSets: [posthogCredentialSet],
|
|
2777
|
+
input: z.object({
|
|
2778
|
+
...projectIdInputShape,
|
|
2779
|
+
pluginConfigId: z.number().int()
|
|
2780
|
+
}),
|
|
2781
|
+
output: z.object({ success: z.boolean() }),
|
|
2782
|
+
needsApproval: true,
|
|
2783
|
+
run: async (input, context) => {
|
|
2784
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2785
|
+
const projectId = client.projectId(input.projectId);
|
|
2786
|
+
await client.request({
|
|
2787
|
+
method: "DELETE",
|
|
2788
|
+
path: `/api/projects/${projectId}/plugin_configs/${input.pluginConfigId}/`
|
|
2789
|
+
});
|
|
2790
|
+
return { success: true };
|
|
2791
|
+
}
|
|
2792
|
+
});
|
|
2793
|
+
|
|
2794
|
+
//#endregion
|
|
2795
|
+
//#region src/operations/pipeline-destinations-list.operation.ts
|
|
2796
|
+
const pipelineDestinationsListOperation = new Operation({
|
|
2797
|
+
id: "posthog.pipeline-destinations-list",
|
|
2798
|
+
name: "PostHog List Pipeline Destinations",
|
|
2799
|
+
description: "List configured pipeline destinations (plugin-configs)",
|
|
2800
|
+
credentialSets: [posthogCredentialSet],
|
|
2801
|
+
input: z.object({
|
|
2802
|
+
...projectIdInputShape,
|
|
2803
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
2804
|
+
}),
|
|
2805
|
+
output: paginatedResponseSchema(z.record(z.string(), z.unknown())),
|
|
2806
|
+
run: async (input, context) => {
|
|
2807
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2808
|
+
const projectId = client.projectId(input.projectId);
|
|
2809
|
+
return client.request({
|
|
2810
|
+
method: "GET",
|
|
2811
|
+
path: `/api/projects/${projectId}/plugin_configs/`,
|
|
2812
|
+
query: { limit: input.limit }
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2816
|
+
|
|
2817
|
+
//#endregion
|
|
2818
|
+
//#region src/utils/domain-inputs/projects.ts
|
|
2819
|
+
const projectIdInput = { projectId: z.union([z.string(), z.number().int()]).optional() };
|
|
2820
|
+
const memberIdInput = {
|
|
2821
|
+
...projectIdInput,
|
|
2822
|
+
memberId: z.number().int()
|
|
2823
|
+
};
|
|
2824
|
+
const writeShape = {
|
|
2825
|
+
name: z.string().optional(),
|
|
2826
|
+
slack_incoming_webhook: z.string().nullable().optional(),
|
|
2827
|
+
anonymize_ips: z.boolean().optional(),
|
|
2828
|
+
completed_snippet_onboarding: z.boolean().optional(),
|
|
2829
|
+
test_account_filters: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
2830
|
+
timezone: z.string().optional(),
|
|
2831
|
+
access_control: z.boolean().optional(),
|
|
2832
|
+
app_urls: z.array(z.string()).optional(),
|
|
2833
|
+
session_recording_opt_in: z.boolean().optional(),
|
|
2834
|
+
autocapture_opt_out: z.boolean().optional()
|
|
2835
|
+
};
|
|
2836
|
+
|
|
2837
|
+
//#endregion
|
|
2838
|
+
//#region src/operations/project-members-add.operation.ts
|
|
2839
|
+
const projectMembersAddOperation = new Operation({
|
|
2840
|
+
id: "posthog.project-members-add",
|
|
2841
|
+
name: "PostHog Add Project Member",
|
|
2842
|
+
description: "Add a user to a project with a given access level",
|
|
2843
|
+
credentialSets: [posthogCredentialSet],
|
|
2844
|
+
input: z.object({
|
|
2845
|
+
...projectIdInput,
|
|
2846
|
+
user_uuid: z.string().min(1),
|
|
2847
|
+
level: z.number().int()
|
|
2848
|
+
}),
|
|
2849
|
+
output: projectMemberSchema,
|
|
2850
|
+
needsApproval: true,
|
|
2851
|
+
run: async (input, context) => {
|
|
2852
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2853
|
+
const projectId = client.projectId(input.projectId);
|
|
2854
|
+
return client.request({
|
|
2855
|
+
method: "POST",
|
|
2856
|
+
path: `/api/projects/${projectId}/explicit_members/`,
|
|
2857
|
+
body: {
|
|
2858
|
+
user_uuid: input.user_uuid,
|
|
2859
|
+
level: input.level
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
|
|
2865
|
+
//#endregion
|
|
2866
|
+
//#region src/operations/project-members-list.operation.ts
|
|
2867
|
+
const projectMembersListOperation = new Operation({
|
|
2868
|
+
id: "posthog.project-members-list",
|
|
2869
|
+
name: "PostHog List Project Members",
|
|
2870
|
+
description: "List members of a project",
|
|
2871
|
+
credentialSets: [posthogCredentialSet],
|
|
2872
|
+
input: z.object({
|
|
2873
|
+
...projectIdInput,
|
|
2874
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
2875
|
+
offset: z.number().int().min(0).optional()
|
|
2876
|
+
}),
|
|
2877
|
+
output: paginatedResponseSchema(projectMemberSchema),
|
|
2878
|
+
run: async (input, context) => {
|
|
2879
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2880
|
+
const projectId = client.projectId(input.projectId);
|
|
2881
|
+
return client.request({
|
|
2882
|
+
method: "GET",
|
|
2883
|
+
path: `/api/projects/${projectId}/explicit_members/`,
|
|
2884
|
+
query: {
|
|
2885
|
+
limit: input.limit,
|
|
2886
|
+
offset: input.offset
|
|
2887
|
+
}
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
});
|
|
2891
|
+
|
|
2892
|
+
//#endregion
|
|
2893
|
+
//#region src/operations/project-members-remove.operation.ts
|
|
2894
|
+
const projectMembersRemoveOperation = new Operation({
|
|
2895
|
+
id: "posthog.project-members-remove",
|
|
2896
|
+
name: "PostHog Remove Project Member",
|
|
2897
|
+
description: "Remove a user from a project",
|
|
2898
|
+
credentialSets: [posthogCredentialSet],
|
|
2899
|
+
input: z.object(memberIdInput),
|
|
2900
|
+
output: z.object({ success: z.boolean() }),
|
|
2901
|
+
needsApproval: true,
|
|
2902
|
+
run: async (input, context) => {
|
|
2903
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2904
|
+
const projectId = client.projectId(input.projectId);
|
|
2905
|
+
await client.request({
|
|
2906
|
+
method: "DELETE",
|
|
2907
|
+
path: `/api/projects/${projectId}/explicit_members/${input.memberId}/`
|
|
2908
|
+
});
|
|
2909
|
+
return { success: true };
|
|
2910
|
+
}
|
|
2911
|
+
});
|
|
2912
|
+
|
|
2913
|
+
//#endregion
|
|
2914
|
+
//#region src/operations/project-members-update.operation.ts
|
|
2915
|
+
const projectMembersUpdateOperation = new Operation({
|
|
2916
|
+
credentialSets: [posthogCredentialSet],
|
|
2917
|
+
id: "posthog.project-members-update",
|
|
2918
|
+
name: "PostHog Update Project Member",
|
|
2919
|
+
description: "Update a project member's access level",
|
|
2920
|
+
input: z.object({
|
|
2921
|
+
...memberIdInput,
|
|
2922
|
+
level: z.number().int()
|
|
2923
|
+
}),
|
|
2924
|
+
output: projectMemberSchema,
|
|
2925
|
+
needsApproval: true,
|
|
2926
|
+
run: async (input, context) => {
|
|
2927
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2928
|
+
const projectId = client.projectId(input.projectId);
|
|
2929
|
+
return client.request({
|
|
2930
|
+
method: "PATCH",
|
|
2931
|
+
path: `/api/projects/${projectId}/explicit_members/${input.memberId}/`,
|
|
2932
|
+
body: { level: input.level }
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
|
|
2937
|
+
//#endregion
|
|
2938
|
+
//#region src/operations/projects-activity.operation.ts
|
|
2939
|
+
const projectsActivityOperation = new Operation({
|
|
2940
|
+
id: "posthog.projects-activity",
|
|
2941
|
+
name: "PostHog Project Activity",
|
|
2942
|
+
description: "Fetch the project-level activity feed",
|
|
2943
|
+
credentialSets: [posthogCredentialSet],
|
|
2944
|
+
input: z.object({
|
|
2945
|
+
...projectIdInput,
|
|
2946
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
2947
|
+
}),
|
|
2948
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
2949
|
+
run: async (input, context) => {
|
|
2950
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2951
|
+
const projectId = client.projectId(input.projectId);
|
|
2952
|
+
return client.request({
|
|
2953
|
+
method: "GET",
|
|
2954
|
+
path: `/api/projects/${projectId}/activity/`,
|
|
2955
|
+
query: { limit: input.limit }
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2959
|
+
|
|
2960
|
+
//#endregion
|
|
2961
|
+
//#region src/operations/projects-add-user-integration.operation.ts
|
|
2962
|
+
const projectsAddUserIntegrationOperation = new Operation({
|
|
2963
|
+
id: "posthog.projects-add-user-integration",
|
|
2964
|
+
name: "PostHog Add Project User Integration",
|
|
2965
|
+
description: "Attach arbitrary user-integration properties to a project",
|
|
2966
|
+
credentialSets: [posthogCredentialSet],
|
|
2967
|
+
input: z.object({
|
|
2968
|
+
...projectIdInput,
|
|
2969
|
+
properties: propertiesBagSchema
|
|
2970
|
+
}),
|
|
2971
|
+
output: z.record(z.string(), z.unknown()),
|
|
2972
|
+
needsApproval: true,
|
|
2973
|
+
run: async (input, context) => {
|
|
2974
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
2975
|
+
const projectId = client.projectId(input.projectId);
|
|
2976
|
+
return client.request({
|
|
2977
|
+
method: "POST",
|
|
2978
|
+
path: `/api/projects/${projectId}/add_user_interaction/`,
|
|
2979
|
+
body: input.properties
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
});
|
|
2983
|
+
|
|
2984
|
+
//#endregion
|
|
2985
|
+
//#region src/operations/projects-create.operation.ts
|
|
2986
|
+
const projectsCreateOperation = new Operation({
|
|
2987
|
+
id: "posthog.projects-create",
|
|
2988
|
+
name: "PostHog Create Project",
|
|
2989
|
+
description: "Create a new project in an organization",
|
|
2990
|
+
credentialSets: [posthogCredentialSet],
|
|
2991
|
+
input: z.object({
|
|
2992
|
+
...orgInput,
|
|
2993
|
+
...writeShape$1,
|
|
2994
|
+
name: z.string().min(1)
|
|
2995
|
+
}),
|
|
2996
|
+
output: projectSchema,
|
|
2997
|
+
needsApproval: true,
|
|
2998
|
+
run: async (input, context) => {
|
|
2999
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3000
|
+
const { organizationId, ...body } = input;
|
|
3001
|
+
return client.request({
|
|
3002
|
+
method: "POST",
|
|
3003
|
+
path: `/api/organizations/${organizationId}/projects/`,
|
|
3004
|
+
body
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
});
|
|
3008
|
+
|
|
3009
|
+
//#endregion
|
|
3010
|
+
//#region src/operations/projects-delete.operation.ts
|
|
3011
|
+
const projectsDeleteOperation = new Operation({
|
|
3012
|
+
id: "posthog.projects-delete",
|
|
3013
|
+
name: "PostHog Delete Project",
|
|
3014
|
+
description: "Delete a project",
|
|
3015
|
+
credentialSets: [posthogCredentialSet],
|
|
3016
|
+
input: z.object(projectIdInput),
|
|
3017
|
+
output: z.object({ success: z.boolean() }),
|
|
3018
|
+
needsApproval: true,
|
|
3019
|
+
run: async (input, context) => {
|
|
3020
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3021
|
+
const projectId = client.projectId(input.projectId);
|
|
3022
|
+
await client.request({
|
|
3023
|
+
method: "DELETE",
|
|
3024
|
+
path: `/api/projects/${projectId}/`
|
|
3025
|
+
});
|
|
3026
|
+
return { success: true };
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
|
|
3030
|
+
//#endregion
|
|
3031
|
+
//#region src/operations/projects-get.operation.ts
|
|
3032
|
+
const projectsGetOperation = new Operation({
|
|
3033
|
+
id: "posthog.projects-get",
|
|
3034
|
+
name: "PostHog Get Project",
|
|
3035
|
+
description: "Retrieve a project by id",
|
|
3036
|
+
credentialSets: [posthogCredentialSet],
|
|
3037
|
+
input: z.object(projectIdInput),
|
|
3038
|
+
output: projectSchema,
|
|
3039
|
+
run: async (input, context) => {
|
|
3040
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3041
|
+
const projectId = client.projectId(input.projectId);
|
|
3042
|
+
return client.request({
|
|
3043
|
+
method: "GET",
|
|
3044
|
+
path: `/api/projects/${projectId}/`
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
});
|
|
3048
|
+
|
|
3049
|
+
//#endregion
|
|
3050
|
+
//#region src/operations/projects-is-generic-email-provider.operation.ts
|
|
3051
|
+
const projectsIsGenericEmailProviderOperation = new Operation({
|
|
3052
|
+
id: "posthog.projects-is-generic-email-provider",
|
|
3053
|
+
name: "PostHog Check Generic Email",
|
|
3054
|
+
description: "Check if an email domain is a generic provider",
|
|
3055
|
+
credentialSets: [posthogCredentialSet],
|
|
3056
|
+
input: z.object({
|
|
3057
|
+
...projectIdInput,
|
|
3058
|
+
email: z.email()
|
|
3059
|
+
}),
|
|
3060
|
+
output: z.object({ is_generic_email_provider: z.boolean() }),
|
|
3061
|
+
run: async (input, context) => {
|
|
3062
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3063
|
+
const projectId = client.projectId(input.projectId);
|
|
3064
|
+
return client.request({
|
|
3065
|
+
method: "GET",
|
|
3066
|
+
path: `/api/projects/${projectId}/is_generic_email_provider/`,
|
|
3067
|
+
query: { email: input.email }
|
|
3068
|
+
});
|
|
3069
|
+
}
|
|
3070
|
+
});
|
|
3071
|
+
|
|
3072
|
+
//#endregion
|
|
3073
|
+
//#region src/operations/projects-list.operation.ts
|
|
3074
|
+
const projectsListOperation = new Operation({
|
|
3075
|
+
id: "posthog.projects-list",
|
|
3076
|
+
name: "PostHog List Projects",
|
|
3077
|
+
description: "List projects in an organization",
|
|
3078
|
+
credentialSets: [posthogCredentialSet],
|
|
3079
|
+
input: z.object({
|
|
3080
|
+
...orgInput,
|
|
3081
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
3082
|
+
offset: z.number().int().min(0).optional()
|
|
3083
|
+
}),
|
|
3084
|
+
output: paginatedResponseSchema(projectSchema),
|
|
3085
|
+
run: async (input, context) => {
|
|
3086
|
+
return createPosthogManagementClient(context.credentials.posthog).request({
|
|
3087
|
+
method: "GET",
|
|
3088
|
+
path: `/api/organizations/${input.organizationId}/projects/`,
|
|
3089
|
+
query: {
|
|
3090
|
+
limit: input.limit,
|
|
3091
|
+
offset: input.offset
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
});
|
|
3096
|
+
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/operations/projects-reset-token.operation.ts
|
|
3099
|
+
const projectsResetTokenOperation = new Operation({
|
|
3100
|
+
id: "posthog.projects-reset-token",
|
|
3101
|
+
name: "PostHog Rotate Project API Key",
|
|
3102
|
+
description: "Reset (rotate) the project API token",
|
|
3103
|
+
credentialSets: [posthogCredentialSet],
|
|
3104
|
+
input: z.object(projectIdInput),
|
|
3105
|
+
output: projectSchema,
|
|
3106
|
+
needsApproval: true,
|
|
3107
|
+
run: async (input, context) => {
|
|
3108
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3109
|
+
const projectId = client.projectId(input.projectId);
|
|
3110
|
+
return client.request({
|
|
3111
|
+
method: "PATCH",
|
|
3112
|
+
path: `/api/projects/${projectId}/reset_token/`
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
});
|
|
3116
|
+
|
|
3117
|
+
//#endregion
|
|
3118
|
+
//#region src/operations/projects-update.operation.ts
|
|
3119
|
+
const projectsUpdateOperation = new Operation({
|
|
3120
|
+
id: "posthog.projects-update",
|
|
3121
|
+
name: "PostHog Update Project",
|
|
3122
|
+
description: "Partial update to a project",
|
|
3123
|
+
credentialSets: [posthogCredentialSet],
|
|
3124
|
+
input: z.object({
|
|
3125
|
+
...projectIdInput,
|
|
3126
|
+
...writeShape$1
|
|
3127
|
+
}),
|
|
3128
|
+
output: projectSchema,
|
|
3129
|
+
needsApproval: true,
|
|
3130
|
+
run: async (input, context) => {
|
|
3131
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3132
|
+
const projectId = client.projectId(input.projectId);
|
|
3133
|
+
const { projectId: _pid, ...body } = input;
|
|
3134
|
+
return client.request({
|
|
3135
|
+
method: "PATCH",
|
|
3136
|
+
path: `/api/projects/${projectId}/`,
|
|
3137
|
+
body
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
|
|
3142
|
+
//#endregion
|
|
3143
|
+
//#region src/operations/property-definitions-get.operation.ts
|
|
3144
|
+
const propertyDefinitionsGetOperation = new Operation({
|
|
3145
|
+
id: "posthog.property-definitions-get",
|
|
3146
|
+
name: "PostHog Get Property Definition",
|
|
3147
|
+
description: "Retrieve a property definition by id",
|
|
3148
|
+
credentialSets: [posthogCredentialSet],
|
|
3149
|
+
input: z.object(eventDefIdInput),
|
|
3150
|
+
output: eventDefinitionSchema,
|
|
3151
|
+
run: async (input, context) => {
|
|
3152
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3153
|
+
const projectId = client.projectId(input.projectId);
|
|
3154
|
+
return client.request({
|
|
3155
|
+
method: "GET",
|
|
3156
|
+
path: `/api/projects/${projectId}/property_definitions/${input.id}/`
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
});
|
|
3160
|
+
|
|
3161
|
+
//#endregion
|
|
3162
|
+
//#region src/operations/property-definitions-list.operation.ts
|
|
3163
|
+
const propertyDefinitionsListOperation = new Operation({
|
|
3164
|
+
id: "posthog.property-definitions-list",
|
|
3165
|
+
name: "PostHog List Property Definitions",
|
|
3166
|
+
description: "List property definitions",
|
|
3167
|
+
credentialSets: [posthogCredentialSet],
|
|
3168
|
+
input: z.object({
|
|
3169
|
+
...projectIdInputShape,
|
|
3170
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
3171
|
+
offset: z.number().int().min(0).optional(),
|
|
3172
|
+
search: z.string().optional(),
|
|
3173
|
+
type: z.string().optional(),
|
|
3174
|
+
event_names: z.array(z.string()).optional()
|
|
3175
|
+
}),
|
|
3176
|
+
output: paginatedResponseSchema(eventDefinitionSchema),
|
|
3177
|
+
run: async (input, context) => {
|
|
3178
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3179
|
+
const projectId = client.projectId(input.projectId);
|
|
3180
|
+
return client.request({
|
|
3181
|
+
method: "GET",
|
|
3182
|
+
path: `/api/projects/${projectId}/property_definitions/`,
|
|
3183
|
+
query: {
|
|
3184
|
+
limit: input.limit,
|
|
3185
|
+
offset: input.offset,
|
|
3186
|
+
search: input.search,
|
|
3187
|
+
type: input.type,
|
|
3188
|
+
...input.event_names ? { event_names: input.event_names.join(",") } : {}
|
|
3189
|
+
}
|
|
3190
|
+
});
|
|
3191
|
+
}
|
|
3192
|
+
});
|
|
3193
|
+
|
|
3194
|
+
//#endregion
|
|
3195
|
+
//#region src/operations/property-definitions-update.operation.ts
|
|
3196
|
+
const propertyDefinitionsUpdateOperation = new Operation({
|
|
3197
|
+
id: "posthog.property-definitions-update",
|
|
3198
|
+
name: "PostHog Update Property Definition",
|
|
3199
|
+
description: "Update description, owner, tags, or verified status on a property definition",
|
|
3200
|
+
credentialSets: [posthogCredentialSet],
|
|
3201
|
+
input: z.object({
|
|
3202
|
+
...eventDefIdInput,
|
|
3203
|
+
description: z.string().nullable().optional(),
|
|
3204
|
+
tags: z.array(z.string()).optional(),
|
|
3205
|
+
verified: z.boolean().optional()
|
|
3206
|
+
}),
|
|
3207
|
+
output: eventDefinitionSchema,
|
|
3208
|
+
needsApproval: true,
|
|
3209
|
+
run: async (input, context) => {
|
|
3210
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3211
|
+
const projectId = client.projectId(input.projectId);
|
|
3212
|
+
const { projectId: _pid, id, ...body } = input;
|
|
3213
|
+
return client.request({
|
|
3214
|
+
method: "PATCH",
|
|
3215
|
+
path: `/api/projects/${projectId}/property_definitions/${id}/`,
|
|
3216
|
+
body
|
|
3217
|
+
});
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3220
|
+
|
|
3221
|
+
//#endregion
|
|
3222
|
+
//#region src/utils/domain-inputs/session-recordings.ts
|
|
3223
|
+
const idInput = {
|
|
3224
|
+
...projectIdInputShape,
|
|
3225
|
+
id: z.string().min(1)
|
|
3226
|
+
};
|
|
3227
|
+
const playlistIdInput = {
|
|
3228
|
+
...projectIdInputShape,
|
|
3229
|
+
playlistId: z.union([z.string(), z.number().int()])
|
|
3230
|
+
};
|
|
3231
|
+
|
|
3232
|
+
//#endregion
|
|
3233
|
+
//#region src/operations/session-recording-playlists-add-recording.operation.ts
|
|
3234
|
+
const sessionRecordingPlaylistsAddRecordingOperation = new Operation({
|
|
3235
|
+
id: "posthog.session-recording-playlists-add-recording",
|
|
3236
|
+
name: "PostHog Add Recording To Playlist",
|
|
3237
|
+
description: "Add a recording to a session replay playlist",
|
|
3238
|
+
credentialSets: [posthogCredentialSet],
|
|
3239
|
+
input: z.object({
|
|
3240
|
+
...playlistIdInput,
|
|
3241
|
+
session_recording_id: z.string().min(1)
|
|
3242
|
+
}),
|
|
3243
|
+
output: z.record(z.string(), z.unknown()),
|
|
3244
|
+
needsApproval: true,
|
|
3245
|
+
run: async (input, context) => {
|
|
3246
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3247
|
+
const projectId = client.projectId(input.projectId);
|
|
3248
|
+
return client.request({
|
|
3249
|
+
method: "POST",
|
|
3250
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${input.playlistId}/recordings/${input.session_recording_id}/`
|
|
3251
|
+
});
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
|
|
3255
|
+
//#endregion
|
|
3256
|
+
//#region src/operations/session-recording-playlists-create.operation.ts
|
|
3257
|
+
const sessionRecordingPlaylistsCreateOperation = new Operation({
|
|
3258
|
+
id: "posthog.session-recording-playlists-create",
|
|
3259
|
+
name: "PostHog Create Replay Playlist",
|
|
3260
|
+
description: "Create a new session replay playlist",
|
|
3261
|
+
credentialSets: [posthogCredentialSet],
|
|
3262
|
+
input: z.object({
|
|
3263
|
+
...projectIdInputShape,
|
|
3264
|
+
name: z.string().optional(),
|
|
3265
|
+
description: z.string().nullable().optional(),
|
|
3266
|
+
pinned: z.boolean().optional(),
|
|
3267
|
+
filters: z.record(z.string(), z.unknown()).optional()
|
|
3268
|
+
}),
|
|
3269
|
+
output: sessionRecordingPlaylistSchema,
|
|
3270
|
+
needsApproval: true,
|
|
3271
|
+
run: async (input, context) => {
|
|
3272
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3273
|
+
const projectId = client.projectId(input.projectId);
|
|
3274
|
+
const { projectId: _pid, ...body } = input;
|
|
3275
|
+
return client.request({
|
|
3276
|
+
method: "POST",
|
|
3277
|
+
path: `/api/projects/${projectId}/session_recording_playlists/`,
|
|
3278
|
+
body
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
|
|
3283
|
+
//#endregion
|
|
3284
|
+
//#region src/operations/session-recording-playlists-delete.operation.ts
|
|
3285
|
+
const sessionRecordingPlaylistsDeleteOperation = new Operation({
|
|
3286
|
+
id: "posthog.session-recording-playlists-delete",
|
|
3287
|
+
name: "PostHog Delete Replay Playlist",
|
|
3288
|
+
description: "Delete a session replay playlist",
|
|
3289
|
+
credentialSets: [posthogCredentialSet],
|
|
3290
|
+
input: z.object(playlistIdInput),
|
|
3291
|
+
output: z.object({ success: z.boolean() }),
|
|
3292
|
+
needsApproval: true,
|
|
3293
|
+
run: async (input, context) => {
|
|
3294
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3295
|
+
const projectId = client.projectId(input.projectId);
|
|
3296
|
+
await client.request({
|
|
3297
|
+
method: "DELETE",
|
|
3298
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${input.playlistId}/`
|
|
3299
|
+
});
|
|
3300
|
+
return { success: true };
|
|
3301
|
+
}
|
|
3302
|
+
});
|
|
3303
|
+
|
|
3304
|
+
//#endregion
|
|
3305
|
+
//#region src/operations/session-recording-playlists-get.operation.ts
|
|
3306
|
+
const sessionRecordingPlaylistsGetOperation = new Operation({
|
|
3307
|
+
id: "posthog.session-recording-playlists-get",
|
|
3308
|
+
name: "PostHog Get Replay Playlist",
|
|
3309
|
+
description: "Retrieve a session replay playlist by id",
|
|
3310
|
+
credentialSets: [posthogCredentialSet],
|
|
3311
|
+
input: z.object(playlistIdInput),
|
|
3312
|
+
output: sessionRecordingPlaylistSchema,
|
|
3313
|
+
run: async (input, context) => {
|
|
3314
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3315
|
+
const projectId = client.projectId(input.projectId);
|
|
3316
|
+
return client.request({
|
|
3317
|
+
method: "GET",
|
|
3318
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${input.playlistId}/`
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
});
|
|
3322
|
+
|
|
3323
|
+
//#endregion
|
|
3324
|
+
//#region src/operations/session-recording-playlists-list.operation.ts
|
|
3325
|
+
const sessionRecordingPlaylistsListOperation = new Operation({
|
|
3326
|
+
id: "posthog.session-recording-playlists-list",
|
|
3327
|
+
name: "PostHog List Replay Playlists",
|
|
3328
|
+
description: "List session replay playlists",
|
|
3329
|
+
credentialSets: [posthogCredentialSet],
|
|
3330
|
+
input: z.object({
|
|
3331
|
+
...projectIdInputShape,
|
|
3332
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
3333
|
+
offset: z.number().int().min(0).optional()
|
|
3334
|
+
}),
|
|
3335
|
+
output: paginatedResponseSchema(sessionRecordingPlaylistSchema),
|
|
3336
|
+
run: async (input, context) => {
|
|
3337
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3338
|
+
const projectId = client.projectId(input.projectId);
|
|
3339
|
+
return client.request({
|
|
3340
|
+
method: "GET",
|
|
3341
|
+
path: `/api/projects/${projectId}/session_recording_playlists/`,
|
|
3342
|
+
query: {
|
|
3343
|
+
limit: input.limit,
|
|
3344
|
+
offset: input.offset
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
|
|
3350
|
+
//#endregion
|
|
3351
|
+
//#region src/operations/session-recording-playlists-recordings-list.operation.ts
|
|
3352
|
+
const sessionRecordingPlaylistsRecordingsListOperation = new Operation({
|
|
3353
|
+
id: "posthog.session-recording-playlists-recordings-list",
|
|
3354
|
+
name: "PostHog List Playlist Recordings",
|
|
3355
|
+
description: "List recordings in a session replay playlist",
|
|
3356
|
+
credentialSets: [posthogCredentialSet],
|
|
3357
|
+
input: z.object({
|
|
3358
|
+
...playlistIdInput,
|
|
3359
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
3360
|
+
}),
|
|
3361
|
+
output: paginatedResponseSchema(sessionRecordingSchema),
|
|
3362
|
+
run: async (input, context) => {
|
|
3363
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3364
|
+
const projectId = client.projectId(input.projectId);
|
|
3365
|
+
return client.request({
|
|
3366
|
+
method: "GET",
|
|
3367
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${input.playlistId}/recordings/`,
|
|
3368
|
+
query: { limit: input.limit }
|
|
3369
|
+
});
|
|
3370
|
+
}
|
|
3371
|
+
});
|
|
3372
|
+
|
|
3373
|
+
//#endregion
|
|
3374
|
+
//#region src/operations/session-recording-playlists-remove-recording.operation.ts
|
|
3375
|
+
const sessionRecordingPlaylistsRemoveRecordingOperation = new Operation({
|
|
3376
|
+
id: "posthog.session-recording-playlists-remove-recording",
|
|
3377
|
+
name: "PostHog Remove Recording From Playlist",
|
|
3378
|
+
description: "Remove a recording from a session replay playlist",
|
|
3379
|
+
credentialSets: [posthogCredentialSet],
|
|
3380
|
+
input: z.object({
|
|
3381
|
+
...playlistIdInput,
|
|
3382
|
+
session_recording_id: z.string().min(1)
|
|
3383
|
+
}),
|
|
3384
|
+
output: z.object({ success: z.boolean() }),
|
|
3385
|
+
needsApproval: true,
|
|
3386
|
+
run: async (input, context) => {
|
|
3387
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3388
|
+
const projectId = client.projectId(input.projectId);
|
|
3389
|
+
await client.request({
|
|
3390
|
+
method: "DELETE",
|
|
3391
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${input.playlistId}/recordings/${input.session_recording_id}/`
|
|
3392
|
+
});
|
|
3393
|
+
return { success: true };
|
|
3394
|
+
}
|
|
3395
|
+
});
|
|
3396
|
+
|
|
3397
|
+
//#endregion
|
|
3398
|
+
//#region src/operations/session-recording-playlists-update.operation.ts
|
|
3399
|
+
const sessionRecordingPlaylistsUpdateOperation = new Operation({
|
|
3400
|
+
id: "posthog.session-recording-playlists-update",
|
|
3401
|
+
name: "PostHog Update Replay Playlist",
|
|
3402
|
+
description: "Partial update to a session replay playlist",
|
|
3403
|
+
credentialSets: [posthogCredentialSet],
|
|
3404
|
+
input: z.object({
|
|
3405
|
+
...playlistIdInput,
|
|
3406
|
+
name: z.string().optional(),
|
|
3407
|
+
description: z.string().nullable().optional(),
|
|
3408
|
+
pinned: z.boolean().optional(),
|
|
3409
|
+
filters: z.record(z.string(), z.unknown()).optional(),
|
|
3410
|
+
deleted: z.boolean().optional()
|
|
3411
|
+
}),
|
|
3412
|
+
output: sessionRecordingPlaylistSchema,
|
|
3413
|
+
needsApproval: true,
|
|
3414
|
+
run: async (input, context) => {
|
|
3415
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3416
|
+
const projectId = client.projectId(input.projectId);
|
|
3417
|
+
const { projectId: _pid, playlistId, ...body } = input;
|
|
3418
|
+
return client.request({
|
|
3419
|
+
method: "PATCH",
|
|
3420
|
+
path: `/api/projects/${projectId}/session_recording_playlists/${playlistId}/`,
|
|
3421
|
+
body
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
});
|
|
3425
|
+
|
|
3426
|
+
//#endregion
|
|
3427
|
+
//#region src/operations/session-recordings-delete.operation.ts
|
|
3428
|
+
const sessionRecordingsDeleteOperation = new Operation({
|
|
3429
|
+
id: "posthog.session-recordings-delete",
|
|
3430
|
+
name: "PostHog Delete Session Recording",
|
|
3431
|
+
description: "Delete a session recording",
|
|
3432
|
+
credentialSets: [posthogCredentialSet],
|
|
3433
|
+
input: z.object(idInput$3),
|
|
3434
|
+
output: z.object({ success: z.boolean() }),
|
|
3435
|
+
needsApproval: true,
|
|
3436
|
+
run: async (input, context) => {
|
|
3437
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3438
|
+
const projectId = client.projectId(input.projectId);
|
|
3439
|
+
await client.request({
|
|
3440
|
+
method: "DELETE",
|
|
3441
|
+
path: `/api/projects/${projectId}/session_recordings/${input.id}/`
|
|
3442
|
+
});
|
|
3443
|
+
return { success: true };
|
|
3444
|
+
}
|
|
3445
|
+
});
|
|
3446
|
+
|
|
3447
|
+
//#endregion
|
|
3448
|
+
//#region src/operations/session-recordings-get.operation.ts
|
|
3449
|
+
const sessionRecordingsGetOperation = new Operation({
|
|
3450
|
+
id: "posthog.session-recordings-get",
|
|
3451
|
+
name: "PostHog Get Session Recording",
|
|
3452
|
+
description: "Retrieve a session recording by id",
|
|
3453
|
+
credentialSets: [posthogCredentialSet],
|
|
3454
|
+
input: z.object(idInput$3),
|
|
3455
|
+
output: sessionRecordingSchema,
|
|
3456
|
+
run: async (input, context) => {
|
|
3457
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3458
|
+
const projectId = client.projectId(input.projectId);
|
|
3459
|
+
return client.request({
|
|
3460
|
+
method: "GET",
|
|
3461
|
+
path: `/api/projects/${projectId}/session_recordings/${input.id}/`
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
});
|
|
3465
|
+
|
|
3466
|
+
//#endregion
|
|
3467
|
+
//#region src/operations/session-recordings-list.operation.ts
|
|
3468
|
+
const sessionRecordingsListOperation = new Operation({
|
|
3469
|
+
id: "posthog.session-recordings-list",
|
|
3470
|
+
name: "PostHog List Session Recordings",
|
|
3471
|
+
description: "List session recordings, optionally filtered",
|
|
3472
|
+
credentialSets: [posthogCredentialSet],
|
|
3473
|
+
input: z.object({
|
|
3474
|
+
...projectIdInputShape,
|
|
3475
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
3476
|
+
offset: z.number().int().min(0).optional(),
|
|
3477
|
+
distinct_id: z.string().optional(),
|
|
3478
|
+
date_from: z.string().optional(),
|
|
3479
|
+
date_to: z.string().optional(),
|
|
3480
|
+
person_uuid: z.string().optional()
|
|
3481
|
+
}),
|
|
3482
|
+
output: paginatedResponseSchema(sessionRecordingSchema),
|
|
3483
|
+
run: async (input, context) => {
|
|
3484
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3485
|
+
const projectId = client.projectId(input.projectId);
|
|
3486
|
+
return client.request({
|
|
3487
|
+
method: "GET",
|
|
3488
|
+
path: `/api/projects/${projectId}/session_recordings/`,
|
|
3489
|
+
query: {
|
|
3490
|
+
limit: input.limit,
|
|
3491
|
+
offset: input.offset,
|
|
3492
|
+
distinct_id: input.distinct_id,
|
|
3493
|
+
date_from: input.date_from,
|
|
3494
|
+
date_to: input.date_to,
|
|
3495
|
+
person_uuid: input.person_uuid
|
|
3496
|
+
}
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
|
|
3501
|
+
//#endregion
|
|
3502
|
+
//#region src/operations/session-recordings-properties.operation.ts
|
|
3503
|
+
const sessionRecordingsPropertiesOperation = new Operation({
|
|
3504
|
+
id: "posthog.session-recordings-properties",
|
|
3505
|
+
name: "PostHog Session Recording Properties",
|
|
3506
|
+
description: "Fetch aggregated properties for a session recording",
|
|
3507
|
+
credentialSets: [posthogCredentialSet],
|
|
3508
|
+
input: z.object(idInput$3),
|
|
3509
|
+
output: z.record(z.string(), z.unknown()),
|
|
3510
|
+
run: async (input, context) => {
|
|
3511
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3512
|
+
const projectId = client.projectId(input.projectId);
|
|
3513
|
+
return client.request({
|
|
3514
|
+
method: "GET",
|
|
3515
|
+
path: `/api/projects/${projectId}/session_recordings/${input.id}/properties/`
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
|
|
3520
|
+
//#endregion
|
|
3521
|
+
//#region src/operations/session-recordings-snapshots.operation.ts
|
|
3522
|
+
const sessionRecordingsSnapshotsOperation = new Operation({
|
|
3523
|
+
id: "posthog.session-recordings-snapshots",
|
|
3524
|
+
name: "PostHog Session Recording Snapshots",
|
|
3525
|
+
description: "Fetch rrweb snapshot urls for a session recording",
|
|
3526
|
+
credentialSets: [posthogCredentialSet],
|
|
3527
|
+
input: z.object({
|
|
3528
|
+
...idInput$3,
|
|
3529
|
+
source: z.enum(["realtime", "blob"]).optional()
|
|
3530
|
+
}),
|
|
3531
|
+
output: z.record(z.string(), z.unknown()),
|
|
3532
|
+
run: async (input, context) => {
|
|
3533
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3534
|
+
const projectId = client.projectId(input.projectId);
|
|
3535
|
+
return client.request({
|
|
3536
|
+
method: "GET",
|
|
3537
|
+
path: `/api/projects/${projectId}/session_recordings/${input.id}/snapshots/`,
|
|
3538
|
+
query: { source: input.source }
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
});
|
|
3542
|
+
|
|
3543
|
+
//#endregion
|
|
3544
|
+
//#region src/operations/session-recordings-update.operation.ts
|
|
3545
|
+
const sessionRecordingsUpdateOperation = new Operation({
|
|
3546
|
+
id: "posthog.session-recordings-update",
|
|
3547
|
+
name: "PostHog Update Session Recording",
|
|
3548
|
+
description: "Mark a session recording as viewed or update summary metadata",
|
|
3549
|
+
credentialSets: [posthogCredentialSet],
|
|
3550
|
+
input: z.object({
|
|
3551
|
+
...idInput$3,
|
|
3552
|
+
viewed: z.boolean().optional(),
|
|
3553
|
+
analyzed: z.boolean().optional()
|
|
3554
|
+
}),
|
|
3555
|
+
output: sessionRecordingSchema,
|
|
3556
|
+
needsApproval: true,
|
|
3557
|
+
run: async (input, context) => {
|
|
3558
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3559
|
+
const projectId = client.projectId(input.projectId);
|
|
3560
|
+
return client.request({
|
|
3561
|
+
method: "PATCH",
|
|
3562
|
+
path: `/api/projects/${projectId}/session_recordings/${input.id}/`,
|
|
3563
|
+
body: {
|
|
3564
|
+
viewed: input.viewed,
|
|
3565
|
+
analyzed: input.analyzed
|
|
3566
|
+
}
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
});
|
|
3570
|
+
|
|
3571
|
+
//#endregion
|
|
3572
|
+
//#region src/operations/set-person-properties.operation.ts
|
|
3573
|
+
const setPersonPropertiesOperation = new Operation({
|
|
3574
|
+
id: "posthog.set-person-properties",
|
|
3575
|
+
name: "PostHog Set Person Properties",
|
|
3576
|
+
description: "Set (overwrite) properties on a person via a $set event",
|
|
3577
|
+
credentialSets: [posthogCredentialSet],
|
|
3578
|
+
input: z.object({
|
|
3579
|
+
distinctId: z.string().min(1),
|
|
3580
|
+
properties: propertiesBagSchema,
|
|
3581
|
+
timestamp: z.iso.datetime().optional()
|
|
3582
|
+
}),
|
|
3583
|
+
output: captureResponseSchema,
|
|
3584
|
+
needsApproval: true,
|
|
3585
|
+
run: async (input, context) => {
|
|
3586
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
3587
|
+
return client.request({
|
|
3588
|
+
method: "POST",
|
|
3589
|
+
path: "/capture/",
|
|
3590
|
+
body: {
|
|
3591
|
+
api_key: client.projectApiKey(),
|
|
3592
|
+
event: "$set",
|
|
3593
|
+
distinct_id: input.distinctId,
|
|
3594
|
+
properties: { $set: input.properties },
|
|
3595
|
+
...input.timestamp ? { timestamp: input.timestamp } : {}
|
|
3596
|
+
}
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
});
|
|
3600
|
+
|
|
3601
|
+
//#endregion
|
|
3602
|
+
//#region src/operations/set-person-properties-once.operation.ts
|
|
3603
|
+
const setPersonPropertiesOnceOperation = new Operation({
|
|
3604
|
+
id: "posthog.set-person-properties-once",
|
|
3605
|
+
name: "PostHog Set Person Properties Once",
|
|
3606
|
+
description: "Set properties on a person only if not already set ($set_once)",
|
|
3607
|
+
credentialSets: [posthogCredentialSet],
|
|
3608
|
+
input: z.object({
|
|
3609
|
+
distinctId: z.string().min(1),
|
|
3610
|
+
properties: propertiesBagSchema,
|
|
3611
|
+
timestamp: z.iso.datetime().optional()
|
|
3612
|
+
}),
|
|
3613
|
+
output: captureResponseSchema,
|
|
3614
|
+
needsApproval: true,
|
|
3615
|
+
run: async (input, context) => {
|
|
3616
|
+
const client = createPosthogIngestClient(context.credentials.posthog);
|
|
3617
|
+
return client.request({
|
|
3618
|
+
method: "POST",
|
|
3619
|
+
path: "/capture/",
|
|
3620
|
+
body: {
|
|
3621
|
+
api_key: client.projectApiKey(),
|
|
3622
|
+
event: "$set",
|
|
3623
|
+
distinct_id: input.distinctId,
|
|
3624
|
+
properties: { $set_once: input.properties },
|
|
3625
|
+
...input.timestamp ? { timestamp: input.timestamp } : {}
|
|
3626
|
+
}
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
});
|
|
3630
|
+
|
|
3631
|
+
//#endregion
|
|
3632
|
+
//#region src/operations/surveys-activity.operation.ts
|
|
3633
|
+
const surveysActivityOperation = new Operation({
|
|
3634
|
+
id: "posthog.surveys-activity",
|
|
3635
|
+
name: "PostHog Survey Activity",
|
|
3636
|
+
description: "Fetch activity log for a survey",
|
|
3637
|
+
credentialSets: [posthogCredentialSet],
|
|
3638
|
+
input: z.object({
|
|
3639
|
+
...idInput$3,
|
|
3640
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
3641
|
+
}),
|
|
3642
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
3643
|
+
run: async (input, context) => {
|
|
3644
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3645
|
+
const projectId = client.projectId(input.projectId);
|
|
3646
|
+
return client.request({
|
|
3647
|
+
method: "GET",
|
|
3648
|
+
path: `/api/projects/${projectId}/surveys/${input.id}/activity/`,
|
|
3649
|
+
query: { limit: input.limit }
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
});
|
|
3653
|
+
|
|
3654
|
+
//#endregion
|
|
3655
|
+
//#region src/operations/surveys-activity-feed.operation.ts
|
|
3656
|
+
const surveysActivityFeedOperation = new Operation({
|
|
3657
|
+
id: "posthog.surveys-activity-feed",
|
|
3658
|
+
name: "PostHog Surveys Activity Feed",
|
|
3659
|
+
description: "Fetch project-wide survey activity feed",
|
|
3660
|
+
credentialSets: [posthogCredentialSet],
|
|
3661
|
+
input: z.object({
|
|
3662
|
+
...projectIdInputShape,
|
|
3663
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
3664
|
+
}),
|
|
3665
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
3666
|
+
run: async (input, context) => {
|
|
3667
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3668
|
+
const projectId = client.projectId(input.projectId);
|
|
3669
|
+
return client.request({
|
|
3670
|
+
method: "GET",
|
|
3671
|
+
path: `/api/projects/${projectId}/surveys/activity/`,
|
|
3672
|
+
query: { limit: input.limit }
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
});
|
|
3676
|
+
|
|
3677
|
+
//#endregion
|
|
3678
|
+
//#region src/operations/surveys-create.operation.ts
|
|
3679
|
+
const surveysCreateOperation = new Operation({
|
|
3680
|
+
id: "posthog.surveys-create",
|
|
3681
|
+
name: "PostHog Create Survey",
|
|
3682
|
+
description: "Create a new survey",
|
|
3683
|
+
credentialSets: [posthogCredentialSet],
|
|
3684
|
+
input: z.object({
|
|
3685
|
+
...projectIdInputShape,
|
|
3686
|
+
...writeShape$1,
|
|
3687
|
+
name: z.string().min(1)
|
|
3688
|
+
}),
|
|
3689
|
+
output: surveySchema,
|
|
3690
|
+
needsApproval: true,
|
|
3691
|
+
run: async (input, context) => {
|
|
3692
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3693
|
+
const projectId = client.projectId(input.projectId);
|
|
3694
|
+
const { projectId: _pid, ...body } = input;
|
|
3695
|
+
return client.request({
|
|
3696
|
+
method: "POST",
|
|
3697
|
+
path: `/api/projects/${projectId}/surveys/`,
|
|
3698
|
+
body
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
3701
|
+
});
|
|
3702
|
+
|
|
3703
|
+
//#endregion
|
|
3704
|
+
//#region src/operations/surveys-delete.operation.ts
|
|
3705
|
+
const surveysDeleteOperation = new Operation({
|
|
3706
|
+
id: "posthog.surveys-delete",
|
|
3707
|
+
name: "PostHog Delete Survey",
|
|
3708
|
+
description: "Delete (archive) a survey",
|
|
3709
|
+
credentialSets: [posthogCredentialSet],
|
|
3710
|
+
input: z.object(idInput$3),
|
|
3711
|
+
output: z.object({ success: z.boolean() }),
|
|
3712
|
+
needsApproval: true,
|
|
3713
|
+
run: async (input, context) => {
|
|
3714
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3715
|
+
const projectId = client.projectId(input.projectId);
|
|
3716
|
+
await client.request({
|
|
3717
|
+
method: "DELETE",
|
|
3718
|
+
path: `/api/projects/${projectId}/surveys/${input.id}/`
|
|
3719
|
+
});
|
|
3720
|
+
return { success: true };
|
|
3721
|
+
}
|
|
3722
|
+
});
|
|
3723
|
+
|
|
3724
|
+
//#endregion
|
|
3725
|
+
//#region src/operations/surveys-get.operation.ts
|
|
3726
|
+
const surveysGetOperation = new Operation({
|
|
3727
|
+
id: "posthog.surveys-get",
|
|
3728
|
+
name: "PostHog Get Survey",
|
|
3729
|
+
description: "Retrieve a survey by id",
|
|
3730
|
+
credentialSets: [posthogCredentialSet],
|
|
3731
|
+
input: z.object(idInput$3),
|
|
3732
|
+
output: surveySchema,
|
|
3733
|
+
run: async (input, context) => {
|
|
3734
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3735
|
+
const projectId = client.projectId(input.projectId);
|
|
3736
|
+
return client.request({
|
|
3737
|
+
method: "GET",
|
|
3738
|
+
path: `/api/projects/${projectId}/surveys/${input.id}/`
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
});
|
|
3742
|
+
|
|
3743
|
+
//#endregion
|
|
3744
|
+
//#region src/operations/surveys-list.operation.ts
|
|
3745
|
+
const surveysListOperation = new Operation({
|
|
3746
|
+
id: "posthog.surveys-list",
|
|
3747
|
+
name: "PostHog List Surveys",
|
|
3748
|
+
description: "List surveys in a project",
|
|
3749
|
+
credentialSets: [posthogCredentialSet],
|
|
3750
|
+
input: z.object({
|
|
3751
|
+
...projectIdInputShape,
|
|
3752
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
3753
|
+
offset: z.number().int().min(0).optional(),
|
|
3754
|
+
search: z.string().optional()
|
|
3755
|
+
}),
|
|
3756
|
+
output: paginatedResponseSchema(surveySchema),
|
|
3757
|
+
run: async (input, context) => {
|
|
3758
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3759
|
+
const projectId = client.projectId(input.projectId);
|
|
3760
|
+
return client.request({
|
|
3761
|
+
method: "GET",
|
|
3762
|
+
path: `/api/projects/${projectId}/surveys/`,
|
|
3763
|
+
query: {
|
|
3764
|
+
limit: input.limit,
|
|
3765
|
+
offset: input.offset,
|
|
3766
|
+
search: input.search
|
|
3767
|
+
}
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
|
|
3772
|
+
//#endregion
|
|
3773
|
+
//#region src/operations/surveys-responses-count.operation.ts
|
|
3774
|
+
const surveysResponsesCountOperation = new Operation({
|
|
3775
|
+
id: "posthog.surveys-responses-count",
|
|
3776
|
+
name: "PostHog Survey Responses Count",
|
|
3777
|
+
description: "Fetch the responses count for all surveys",
|
|
3778
|
+
credentialSets: [posthogCredentialSet],
|
|
3779
|
+
input: z.object(projectIdInputShape),
|
|
3780
|
+
output: z.record(z.string(), z.unknown()),
|
|
3781
|
+
run: async (input, context) => {
|
|
3782
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3783
|
+
const projectId = client.projectId(input.projectId);
|
|
3784
|
+
return client.request({
|
|
3785
|
+
method: "GET",
|
|
3786
|
+
path: `/api/projects/${projectId}/surveys/responses_count/`
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
});
|
|
3790
|
+
|
|
3791
|
+
//#endregion
|
|
3792
|
+
//#region src/operations/surveys-stats.operation.ts
|
|
3793
|
+
const surveysStatsOperation = new Operation({
|
|
3794
|
+
id: "posthog.surveys-stats",
|
|
3795
|
+
name: "PostHog Survey Stats",
|
|
3796
|
+
description: "Fetch aggregate statistics for a survey",
|
|
3797
|
+
credentialSets: [posthogCredentialSet],
|
|
3798
|
+
input: z.object(idInput$3),
|
|
3799
|
+
output: z.record(z.string(), z.unknown()),
|
|
3800
|
+
run: async (input, context) => {
|
|
3801
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3802
|
+
const projectId = client.projectId(input.projectId);
|
|
3803
|
+
return client.request({
|
|
3804
|
+
method: "GET",
|
|
3805
|
+
path: `/api/projects/${projectId}/surveys/${input.id}/stats/`
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3808
|
+
});
|
|
3809
|
+
|
|
3810
|
+
//#endregion
|
|
3811
|
+
//#region src/operations/surveys-update.operation.ts
|
|
3812
|
+
const surveysUpdateOperation = new Operation({
|
|
3813
|
+
id: "posthog.surveys-update",
|
|
3814
|
+
name: "PostHog Update Survey",
|
|
3815
|
+
description: "Partial update to a survey",
|
|
3816
|
+
credentialSets: [posthogCredentialSet],
|
|
3817
|
+
input: z.object({
|
|
3818
|
+
...idInput$3,
|
|
3819
|
+
...writeShape$1
|
|
3820
|
+
}),
|
|
3821
|
+
output: surveySchema,
|
|
3822
|
+
needsApproval: true,
|
|
3823
|
+
run: async (input, context) => {
|
|
3824
|
+
const client = createPosthogManagementClient(context.credentials.posthog);
|
|
3825
|
+
const projectId = client.projectId(input.projectId);
|
|
3826
|
+
const { projectId: _pid, id, ...body } = input;
|
|
3827
|
+
return client.request({
|
|
3828
|
+
method: "PATCH",
|
|
3829
|
+
path: `/api/projects/${projectId}/surveys/${id}/`,
|
|
3830
|
+
body
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
});
|
|
3834
|
+
|
|
3835
|
+
//#endregion
|
|
3836
|
+
export { personsLifecycleOperation as $, eventDefinitionsUpdateOperation as $t, projectsResetTokenOperation as A, captureBatchEventsOperation as An, insightsCreateOperation as At, projectMembersListOperation as B, actionsDeleteOperation as Bn, featureFlagsRemoteConfigOperation as Bt, sessionRecordingPlaylistsDeleteOperation as C, cohortsListOperation as Cn, insightsRetentionOperation as Ct, propertyDefinitionsListOperation as D, cohortsCreateOperation as Dn, insightsGetOperation as Dt, propertyDefinitionsUpdateOperation as E, cohortsDeleteOperation as En, insightsListOperation as Et, projectsCreateOperation as F, annotationsCreateOperation as Fn, featureFlagsUpdateOperation as Ft, personsValuesOperation as G, featureFlagsDisableOperation as Gt, pipelineDestinationsListOperation as H, actionWebhooksListOperation as Hn, featureFlagsListOperation as Ht, projectsAddUserIntegrationOperation as I, aliasPersonOperation as In, featureFlagsStatusOperation as It, personsTrendsOperation as J, featureFlagsCreateOperation as Jt, personsUpdatePropertyOperation as K, featureFlagsDeleteOperation as Kt, projectsActivityOperation as L, actionsUpdateOperation as Ln, featureFlagsRoleAccessListOperation as Lt, projectsIsGenericEmailProviderOperation as M, annotationsListOperation as Mn, insightsActivityOperation as Mt, projectsGetOperation as N, annotationsGetOperation as Nn, identifyPersonOperation as Nt, propertyDefinitionsGetOperation as O, cohortsActivityOperation as On, insightsFunnelOperation as Ot, projectsDeleteOperation as P, annotationsDeleteOperation as Pn, groupIdentifyOperation as Pt, personsListOperation as Q, eventsGetOperation as Qt, projectMembersUpdateOperation as R, actionsListOperation as Rn, featureFlagsRoleAccessDeleteOperation as Rt, sessionRecordingPlaylistsGetOperation as S, cohortsPersonsOperation as Sn, insightsSharingGetOperation as St, sessionRecordingPlaylistsAddRecordingOperation as T, cohortsDuplicateAsStaticOperation as Tn, insightsMyInsightsOperation as Tt, pipelineDestinationsDeleteOperation as U, actionWebhooksDetachOperation as Un, featureFlagsGetOperation as Ut, projectMembersAddOperation as V, actionsCreateOperation as Vn, featureFlagsMyFlagsOperation as Vt, pipelineDestinationsCreateOperation as W, actionWebhooksAttachOperation as Wn, featureFlagsEnableOperation as Wt, personsResetNameOperation as X, eventsValuesOperation as Xt, personsSplitOperation as Y, featureFlagsActivityOperation as Yt, personsMergeOperation as Z, eventsListOperation as Zt, sessionRecordingsDeleteOperation as _, dashboardTemplatesListOperation as _n, insightsViewedOperation as _t, surveysGetOperation as a, dashboardsUpdateOperation as an, personsActivityOperation as at, sessionRecordingPlaylistsRecordingsListOperation as b, dashboardTemplatesCreateOperation as bn, insightsTrendOperation as bt, surveysActivityFeedOperation as c, dashboardsListOperation as cn, organizationsGetOperation as ct, setPersonPropertiesOperation as d, dashboardsCreateOperation as dn, organizationMembersUpdateOperation as dt, eventDefinitionsListOperation as en, personsGetOperation as et, sessionRecordingsUpdateOperation as f, dashboardsCollaboratorsRemoveOperation as fn, organizationMembersRemoveOperation as ft, sessionRecordingsGetOperation as g, dashboardTemplatesUpdateOperation as gn, organizationInvitesCreateOperation as gt, sessionRecordingsListOperation as h, dashboardsActivityOperation as hn, organizationInvitesDeleteOperation as ht, surveysListOperation as i, decideFeatureFlagsOperation as in, personsActivityFeedOperation as it, projectsListOperation as j, annotationsUpdateOperation as jn, insightsActivityFeedOperation as jt, projectsUpdateOperation as k, captureEventOperation as kn, insightsDeleteOperation as kt, surveysActivityOperation as l, dashboardsGetOperation as ln, organizationsDeleteOperation as lt, sessionRecordingsPropertiesOperation as m, dashboardsCollaboratorsAddOperation as mn, organizationInvitesListOperation as mt, surveysStatsOperation as n, eventDefinitionsDeleteOperation as nn, personsDeletePropertyOperation as nt, surveysDeleteOperation as o, dashboardsSharingUpdateOperation as on, organizationsUpdateOperation as ot, sessionRecordingsSnapshotsOperation as p, dashboardsCollaboratorsListOperation as pn, organizationMembersListOperation as pt, personsUpdateOperation as q, featureFlagsDashboardsOperation as qt, surveysResponsesCountOperation as r, decideFeatureFlagsLocalOperation as rn, personsDeleteOperation as rt, surveysCreateOperation as s, dashboardsSharingGetOperation as sn, organizationsListOperation as st, surveysUpdateOperation as t, eventDefinitionsGetOperation as tn, personsFunnelOperation as tt, setPersonPropertiesOnceOperation as u, dashboardsDeleteOperation as un, organizationsCreateOperation as ut, sessionRecordingPlaylistsUpdateOperation as v, dashboardTemplatesGetOperation as vn, insightsUpdateOperation as vt, sessionRecordingPlaylistsCreateOperation as w, cohortsGetOperation as wn, insightsPathOperation as wt, sessionRecordingPlaylistsListOperation as x, cohortsUpdateOperation as xn, insightsSharingUpdateOperation as xt, sessionRecordingPlaylistsRemoveRecordingOperation as y, dashboardTemplatesDeleteOperation as yn, insightsTrendChartOperation as yt, projectMembersRemoveOperation as z, actionsGetOperation as zn, featureFlagsRoleAccessCreateOperation as zt };
|