@keystrokehq/posthog 0.0.1
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 +237 -0
- package/dist/_official/index.d.mts +2 -0
- package/dist/_official/index.mjs +3 -0
- package/dist/_runtime/index.d.mts +7 -0
- package/dist/_runtime/index.mjs +3 -0
- package/dist/actions.d.mts +244 -0
- package/dist/actions.mjs +129 -0
- package/dist/annotations.d.mts +185 -0
- package/dist/annotations.mjs +141 -0
- package/dist/capture.d.mts +177 -0
- package/dist/capture.mjs +241 -0
- package/dist/client.d.mts +51 -0
- package/dist/client.mjs +200 -0
- package/dist/cohorts.d.mts +229 -0
- package/dist/cohorts.mjs +185 -0
- package/dist/connection.d.mts +2 -0
- package/dist/connection.mjs +3 -0
- package/dist/dashboards.d.mts +434 -0
- package/dist/dashboards.mjs +356 -0
- package/dist/decide.d.mts +74 -0
- package/dist/decide.mjs +75 -0
- package/dist/errors.d.mts +58 -0
- package/dist/errors.mjs +120 -0
- package/dist/events-management.d.mts +294 -0
- package/dist/events-management.mjs +242 -0
- package/dist/factory-DYDvHOGb.mjs +8 -0
- package/dist/feature-flags.d.mts +416 -0
- package/dist/feature-flags.mjs +317 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/insights.d.mts +409 -0
- package/dist/insights.mjs +346 -0
- package/dist/integration-CsCBBu4d.d.mts +53 -0
- package/dist/integration-Doy2Dwli.mjs +30 -0
- package/dist/organizations.d.mts +257 -0
- package/dist/organizations.mjs +219 -0
- package/dist/persons.d.mts +369 -0
- package/dist/persons.mjs +345 -0
- package/dist/projects.d.mts +348 -0
- package/dist/projects.mjs +287 -0
- package/dist/schemas.d.mts +351 -0
- package/dist/schemas.mjs +302 -0
- package/dist/session-recordings.d.mts +391 -0
- package/dist/session-recordings.mjs +308 -0
- package/dist/surveys.d.mts +287 -0
- package/dist/surveys.mjs +208 -0
- package/dist/triggers.d.mts +115 -0
- package/dist/triggers.mjs +330 -0
- package/dist/webhook-management.d.mts +188 -0
- package/dist/webhook-management.mjs +152 -0
- package/package.json +147 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { createPosthogManagementClient } from "./client.mjs";
|
|
2
|
+
import { featureFlagFiltersSchema, featureFlagRoleAccessSchema, featureFlagSchema, paginatedResponseSchema, projectIdInputShape } from "./schemas.mjs";
|
|
3
|
+
import { t as posthogOperation } from "./factory-DYDvHOGb.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/feature-flags.ts
|
|
7
|
+
/**
|
|
8
|
+
* posthog/feature-flags.ts
|
|
9
|
+
*
|
|
10
|
+
* Feature-flag management — CRUD, status changes, role access, dashboards,
|
|
11
|
+
* remote config, and activity. Uses the management client (personal API key).
|
|
12
|
+
*
|
|
13
|
+
* Docs: https://posthog.com/docs/api/feature-flags
|
|
14
|
+
*/
|
|
15
|
+
const idInput = {
|
|
16
|
+
...projectIdInputShape,
|
|
17
|
+
id: z.number().int()
|
|
18
|
+
};
|
|
19
|
+
const flagWriteShape = {
|
|
20
|
+
key: z.string().min(1),
|
|
21
|
+
name: z.string().optional(),
|
|
22
|
+
filters: featureFlagFiltersSchema.optional(),
|
|
23
|
+
active: z.boolean().optional(),
|
|
24
|
+
deleted: z.boolean().optional(),
|
|
25
|
+
rollout_percentage: z.number().nullable().optional(),
|
|
26
|
+
ensure_experience_continuity: z.boolean().optional(),
|
|
27
|
+
tags: z.array(z.string()).optional()
|
|
28
|
+
};
|
|
29
|
+
const listInput = z.object({
|
|
30
|
+
...projectIdInputShape,
|
|
31
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
32
|
+
offset: z.number().int().min(0).optional(),
|
|
33
|
+
active: z.boolean().optional(),
|
|
34
|
+
search: z.string().optional(),
|
|
35
|
+
type: z.string().optional(),
|
|
36
|
+
created_by: z.number().int().optional()
|
|
37
|
+
});
|
|
38
|
+
const listOutput = paginatedResponseSchema(featureFlagSchema);
|
|
39
|
+
const listFeatureFlags = posthogOperation({
|
|
40
|
+
id: "posthog_feature_flags_list",
|
|
41
|
+
name: "PostHog List Feature Flags",
|
|
42
|
+
description: "List feature flags for a project",
|
|
43
|
+
input: listInput,
|
|
44
|
+
output: listOutput,
|
|
45
|
+
run: async (input, credentials) => {
|
|
46
|
+
const client = createPosthogManagementClient(credentials);
|
|
47
|
+
const projectId = client.projectId(input.projectId);
|
|
48
|
+
return client.request({
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: `/api/projects/${projectId}/feature_flags/`,
|
|
51
|
+
query: {
|
|
52
|
+
limit: input.limit,
|
|
53
|
+
offset: input.offset,
|
|
54
|
+
active: input.active,
|
|
55
|
+
search: input.search,
|
|
56
|
+
type: input.type,
|
|
57
|
+
created_by: input.created_by
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const getFeatureFlag = posthogOperation({
|
|
63
|
+
id: "posthog_feature_flags_get",
|
|
64
|
+
name: "PostHog Get Feature Flag",
|
|
65
|
+
description: "Retrieve a feature flag by numeric id",
|
|
66
|
+
input: z.object(idInput),
|
|
67
|
+
output: featureFlagSchema,
|
|
68
|
+
run: async (input, credentials) => {
|
|
69
|
+
const client = createPosthogManagementClient(credentials);
|
|
70
|
+
const projectId = client.projectId(input.projectId);
|
|
71
|
+
return client.request({
|
|
72
|
+
method: "GET",
|
|
73
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const createFeatureFlag = posthogOperation({
|
|
78
|
+
id: "posthog_feature_flags_create",
|
|
79
|
+
name: "PostHog Create Feature Flag",
|
|
80
|
+
description: "Create a new feature flag",
|
|
81
|
+
input: z.object({
|
|
82
|
+
...projectIdInputShape,
|
|
83
|
+
...flagWriteShape
|
|
84
|
+
}),
|
|
85
|
+
output: featureFlagSchema,
|
|
86
|
+
needsApproval: true,
|
|
87
|
+
run: async (input, credentials) => {
|
|
88
|
+
const client = createPosthogManagementClient(credentials);
|
|
89
|
+
const projectId = client.projectId(input.projectId);
|
|
90
|
+
const { projectId: _ignored, ...body } = input;
|
|
91
|
+
return client.request({
|
|
92
|
+
method: "POST",
|
|
93
|
+
path: `/api/projects/${projectId}/feature_flags/`,
|
|
94
|
+
body
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const updateFeatureFlag = posthogOperation({
|
|
99
|
+
id: "posthog_feature_flags_update",
|
|
100
|
+
name: "PostHog Update Feature Flag",
|
|
101
|
+
description: "Partially update a feature flag",
|
|
102
|
+
input: z.object({
|
|
103
|
+
...idInput,
|
|
104
|
+
key: z.string().min(1).optional(),
|
|
105
|
+
name: z.string().optional(),
|
|
106
|
+
filters: featureFlagFiltersSchema.optional(),
|
|
107
|
+
active: z.boolean().optional(),
|
|
108
|
+
deleted: z.boolean().optional(),
|
|
109
|
+
rollout_percentage: z.number().nullable().optional(),
|
|
110
|
+
ensure_experience_continuity: z.boolean().optional(),
|
|
111
|
+
tags: z.array(z.string()).optional()
|
|
112
|
+
}),
|
|
113
|
+
output: featureFlagSchema,
|
|
114
|
+
needsApproval: true,
|
|
115
|
+
run: async (input, credentials) => {
|
|
116
|
+
const client = createPosthogManagementClient(credentials);
|
|
117
|
+
const projectId = client.projectId(input.projectId);
|
|
118
|
+
const { projectId: _pid, id, ...body } = input;
|
|
119
|
+
return client.request({
|
|
120
|
+
method: "PATCH",
|
|
121
|
+
path: `/api/projects/${projectId}/feature_flags/${id}/`,
|
|
122
|
+
body
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const deleteFeatureFlag = posthogOperation({
|
|
127
|
+
id: "posthog_feature_flags_delete",
|
|
128
|
+
name: "PostHog Delete Feature Flag",
|
|
129
|
+
description: "Soft-delete a feature flag",
|
|
130
|
+
input: z.object(idInput),
|
|
131
|
+
output: featureFlagSchema,
|
|
132
|
+
needsApproval: true,
|
|
133
|
+
run: async (input, credentials) => {
|
|
134
|
+
const client = createPosthogManagementClient(credentials);
|
|
135
|
+
const projectId = client.projectId(input.projectId);
|
|
136
|
+
return client.request({
|
|
137
|
+
method: "PATCH",
|
|
138
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
139
|
+
body: { deleted: true }
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const enableFeatureFlag = posthogOperation({
|
|
144
|
+
id: "posthog_feature_flags_enable",
|
|
145
|
+
name: "PostHog Enable Feature Flag",
|
|
146
|
+
description: "Activate a feature flag",
|
|
147
|
+
input: z.object(idInput),
|
|
148
|
+
output: featureFlagSchema,
|
|
149
|
+
needsApproval: true,
|
|
150
|
+
run: async (input, credentials) => {
|
|
151
|
+
const client = createPosthogManagementClient(credentials);
|
|
152
|
+
const projectId = client.projectId(input.projectId);
|
|
153
|
+
return client.request({
|
|
154
|
+
method: "PATCH",
|
|
155
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
156
|
+
body: { active: true }
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const disableFeatureFlag = posthogOperation({
|
|
161
|
+
id: "posthog_feature_flags_disable",
|
|
162
|
+
name: "PostHog Disable Feature Flag",
|
|
163
|
+
description: "Deactivate a feature flag",
|
|
164
|
+
input: z.object(idInput),
|
|
165
|
+
output: featureFlagSchema,
|
|
166
|
+
needsApproval: true,
|
|
167
|
+
run: async (input, credentials) => {
|
|
168
|
+
const client = createPosthogManagementClient(credentials);
|
|
169
|
+
const projectId = client.projectId(input.projectId);
|
|
170
|
+
return client.request({
|
|
171
|
+
method: "PATCH",
|
|
172
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
173
|
+
body: { active: false }
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
const getFeatureFlagActivity = posthogOperation({
|
|
178
|
+
id: "posthog_feature_flags_activity",
|
|
179
|
+
name: "PostHog Feature Flag Activity",
|
|
180
|
+
description: "Fetch activity log for a feature flag",
|
|
181
|
+
input: z.object({
|
|
182
|
+
...idInput,
|
|
183
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
184
|
+
}),
|
|
185
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
186
|
+
run: async (input, credentials) => {
|
|
187
|
+
const client = createPosthogManagementClient(credentials);
|
|
188
|
+
const projectId = client.projectId(input.projectId);
|
|
189
|
+
return client.request({
|
|
190
|
+
method: "GET",
|
|
191
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/activity/`,
|
|
192
|
+
query: { limit: input.limit }
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
const getMyFeatureFlags = posthogOperation({
|
|
197
|
+
id: "posthog_feature_flags_my_flags",
|
|
198
|
+
name: "PostHog My Feature Flags",
|
|
199
|
+
description: "Fetch the feature flags evaluated for the calling user",
|
|
200
|
+
input: z.object(projectIdInputShape),
|
|
201
|
+
output: z.array(z.record(z.string(), z.unknown())),
|
|
202
|
+
run: async (input, credentials) => {
|
|
203
|
+
const client = createPosthogManagementClient(credentials);
|
|
204
|
+
const projectId = client.projectId(input.projectId);
|
|
205
|
+
return client.request({
|
|
206
|
+
method: "GET",
|
|
207
|
+
path: `/api/projects/${projectId}/feature_flags/my_flags/`
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
const getFeatureFlagRoleAccess = posthogOperation({
|
|
212
|
+
id: "posthog_feature_flags_role_access_list",
|
|
213
|
+
name: "PostHog List Feature Flag Role Access",
|
|
214
|
+
description: "List role access rules for a feature flag",
|
|
215
|
+
input: z.object(idInput),
|
|
216
|
+
output: paginatedResponseSchema(featureFlagRoleAccessSchema),
|
|
217
|
+
run: async (input, credentials) => {
|
|
218
|
+
const client = createPosthogManagementClient(credentials);
|
|
219
|
+
const projectId = client.projectId(input.projectId);
|
|
220
|
+
return client.request({
|
|
221
|
+
method: "GET",
|
|
222
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const createFeatureFlagRoleAccess = posthogOperation({
|
|
227
|
+
id: "posthog_feature_flags_role_access_create",
|
|
228
|
+
name: "PostHog Create Feature Flag Role Access",
|
|
229
|
+
description: "Grant a role access to a feature flag",
|
|
230
|
+
input: z.object({
|
|
231
|
+
...idInput,
|
|
232
|
+
role: z.number().int()
|
|
233
|
+
}),
|
|
234
|
+
output: featureFlagRoleAccessSchema,
|
|
235
|
+
needsApproval: true,
|
|
236
|
+
run: async (input, credentials) => {
|
|
237
|
+
const client = createPosthogManagementClient(credentials);
|
|
238
|
+
const projectId = client.projectId(input.projectId);
|
|
239
|
+
return client.request({
|
|
240
|
+
method: "POST",
|
|
241
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`,
|
|
242
|
+
body: { role: input.role }
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const deleteFeatureFlagRoleAccess = posthogOperation({
|
|
247
|
+
id: "posthog_feature_flags_role_access_delete",
|
|
248
|
+
name: "PostHog Delete Feature Flag Role Access",
|
|
249
|
+
description: "Revoke a role access rule for a feature flag",
|
|
250
|
+
input: z.object({
|
|
251
|
+
...idInput,
|
|
252
|
+
roleAccessId: z.number().int()
|
|
253
|
+
}),
|
|
254
|
+
output: z.object({ success: z.boolean() }),
|
|
255
|
+
needsApproval: true,
|
|
256
|
+
run: async (input, credentials) => {
|
|
257
|
+
const client = createPosthogManagementClient(credentials);
|
|
258
|
+
const projectId = client.projectId(input.projectId);
|
|
259
|
+
await client.request({
|
|
260
|
+
method: "DELETE",
|
|
261
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/${input.roleAccessId}/`
|
|
262
|
+
});
|
|
263
|
+
return { success: true };
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
const getFeatureFlagDashboards = posthogOperation({
|
|
267
|
+
id: "posthog_feature_flags_dashboards",
|
|
268
|
+
name: "PostHog Feature Flag Dashboards",
|
|
269
|
+
description: "Fetch dashboards linked to a feature flag",
|
|
270
|
+
input: z.object(idInput),
|
|
271
|
+
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
272
|
+
run: async (input, credentials) => {
|
|
273
|
+
const client = createPosthogManagementClient(credentials);
|
|
274
|
+
const projectId = client.projectId(input.projectId);
|
|
275
|
+
return client.request({
|
|
276
|
+
method: "GET",
|
|
277
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/dashboards/`
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
const getFeatureFlagRemoteConfig = posthogOperation({
|
|
282
|
+
id: "posthog_feature_flags_remote_config",
|
|
283
|
+
name: "PostHog Feature Flag Remote Config",
|
|
284
|
+
description: "Fetch the remote-config payload for a feature flag",
|
|
285
|
+
input: z.object({
|
|
286
|
+
...idInput,
|
|
287
|
+
distinctId: z.string().min(1)
|
|
288
|
+
}),
|
|
289
|
+
output: z.record(z.string(), z.unknown()),
|
|
290
|
+
run: async (input, credentials) => {
|
|
291
|
+
const client = createPosthogManagementClient(credentials);
|
|
292
|
+
const projectId = client.projectId(input.projectId);
|
|
293
|
+
return client.request({
|
|
294
|
+
method: "GET",
|
|
295
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/remote_config/`,
|
|
296
|
+
query: { distinct_id: input.distinctId }
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const getFeatureFlagStatus = posthogOperation({
|
|
301
|
+
id: "posthog_feature_flags_status",
|
|
302
|
+
name: "PostHog Feature Flag Status",
|
|
303
|
+
description: "Fetch computed status summary for a feature flag",
|
|
304
|
+
input: z.object(idInput),
|
|
305
|
+
output: z.record(z.string(), z.unknown()),
|
|
306
|
+
run: async (input, credentials) => {
|
|
307
|
+
const client = createPosthogManagementClient(credentials);
|
|
308
|
+
const projectId = client.projectId(input.projectId);
|
|
309
|
+
return client.request({
|
|
310
|
+
method: "GET",
|
|
311
|
+
path: `/api/projects/${projectId}/feature_flags/${input.id}/status/`
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
export { createFeatureFlag, createFeatureFlagRoleAccess, deleteFeatureFlag, deleteFeatureFlagRoleAccess, disableFeatureFlag, enableFeatureFlag, getFeatureFlag, getFeatureFlagActivity, getFeatureFlagDashboards, getFeatureFlagRemoteConfig, getFeatureFlagRoleAccess, getFeatureFlagStatus, getMyFeatureFlags, listFeatureFlags, updateFeatureFlag };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|