@keystrokehq/posthog 0.0.9 → 0.0.15
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/dist/_official/index.d.mts +1 -1
- package/dist/_official/index.mjs +1 -1
- package/dist/_runtime/index.d.mts +2 -1
- package/dist/_runtime/index.mjs +1 -1
- package/dist/actions.d.mts +18 -49
- package/dist/actions.mjs +1 -1
- package/dist/annotations.d.mts +11 -42
- package/dist/annotations.mjs +1 -1
- package/dist/capture.d.mts +15 -58
- package/dist/capture.mjs +1 -1
- package/dist/client.d.mts +2 -1
- package/dist/client.mjs +1 -1
- package/dist/cohorts.d.mts +17 -66
- package/dist/cohorts.mjs +1 -1
- package/dist/connection.d.mts +1 -1
- package/dist/connection.mjs +1 -1
- package/dist/dashboards.d.mts +33 -130
- package/dist/dashboards.mjs +1 -1
- package/dist/decide.d.mts +5 -18
- package/dist/decide.mjs +1 -1
- package/dist/events-management.d.mts +21 -82
- package/dist/events-management.mjs +1 -1
- package/dist/factory-D4Ve2fJ-.mjs +8 -0
- package/dist/feature-flags.d.mts +31 -122
- package/dist/feature-flags.mjs +1 -1
- package/dist/insights.d.mts +33 -130
- package/dist/insights.mjs +1 -1
- package/dist/integration-BHWIx2Lw.mjs +31 -0
- package/dist/{integration-BN7xcpga.d.mts → integration-Dv7fVIxG.d.mts} +7 -23
- package/dist/organizations.d.mts +23 -90
- package/dist/organizations.mjs +1 -1
- package/dist/persons.d.mts +31 -122
- package/dist/persons.mjs +1 -1
- package/dist/projects.d.mts +27 -106
- package/dist/projects.mjs +1 -1
- package/dist/schemas.d.mts +3 -3
- package/dist/session-recordings.d.mts +29 -114
- package/dist/session-recordings.mjs +1 -1
- package/dist/surveys.d.mts +25 -80
- package/dist/surveys.mjs +1 -1
- package/dist/triggers.d.mts +3 -5
- package/dist/triggers.mjs +3 -52
- package/dist/webhook-management.d.mts +16 -53
- package/dist/webhook-management.mjs +1 -1
- package/package.json +5 -5
- package/dist/factory-C3ssyfSy.mjs +0 -7
- package/dist/http-BYcjqxPi.mjs +0 -84
- package/dist/integration-D0HdrI0T.mjs +0 -120
package/dist/http-BYcjqxPi.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/integration-authoring/dist/http.mjs
|
|
2
|
-
/**
|
|
3
|
-
* Typed error thrown by `createJsonRestClient` for non-2xx responses.
|
|
4
|
-
*
|
|
5
|
-
* Includes the full HTTP status, status text, response headers, raw body
|
|
6
|
-
* string, and request URL/method so callers can make structured decisions
|
|
7
|
-
* (retry on 5xx, map 401/403 to `CredentialRevokedError`, read
|
|
8
|
-
* `Retry-After`, etc.) instead of parsing error messages.
|
|
9
|
-
*/
|
|
10
|
-
var JsonRestError = class extends Error {
|
|
11
|
-
name = "JsonRestError";
|
|
12
|
-
status;
|
|
13
|
-
statusText;
|
|
14
|
-
body;
|
|
15
|
-
headers;
|
|
16
|
-
url;
|
|
17
|
-
method;
|
|
18
|
-
constructor(init) {
|
|
19
|
-
super(`${init.errorPrefix}: ${init.status} ${init.statusText}${init.body ? ` — ${init.body}` : ""}`);
|
|
20
|
-
this.status = init.status;
|
|
21
|
-
this.statusText = init.statusText;
|
|
22
|
-
this.body = init.body;
|
|
23
|
-
this.headers = init.headers;
|
|
24
|
-
this.url = init.url;
|
|
25
|
-
this.method = init.method;
|
|
26
|
-
}
|
|
27
|
-
/** True for 401 and 403 responses (auth / permission failures). */
|
|
28
|
-
static isAuthError(error) {
|
|
29
|
-
return isJsonRestError(error) && (error.status === 401 || error.status === 403);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Structural type guard for `JsonRestError`. Tolerates cross-realm errors by
|
|
34
|
-
* checking the `name` property instead of relying on `instanceof`.
|
|
35
|
-
*/
|
|
36
|
-
function isJsonRestError(error) {
|
|
37
|
-
if (!error || typeof error !== "object") return false;
|
|
38
|
-
const candidate = error;
|
|
39
|
-
return candidate.name === "JsonRestError" && typeof candidate.status === "number" && typeof candidate.body === "string";
|
|
40
|
-
}
|
|
41
|
-
function buildQueryString(query) {
|
|
42
|
-
if (!query) return "";
|
|
43
|
-
const params = new URLSearchParams();
|
|
44
|
-
for (const [key, value] of Object.entries(query)) if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
45
|
-
const qs = params.toString();
|
|
46
|
-
return qs ? `?${qs}` : "";
|
|
47
|
-
}
|
|
48
|
-
function createJsonRestClient(config) {
|
|
49
|
-
const fetchImpl = config.fetchImpl ?? fetch;
|
|
50
|
-
const request = async (options) => {
|
|
51
|
-
const { method, path, body, query, headers: requestHeaders } = options;
|
|
52
|
-
const url = `${config.baseUrl}${path}${buildQueryString(query)}`;
|
|
53
|
-
const headers = {
|
|
54
|
-
Accept: "application/json",
|
|
55
|
-
...config.defaultHeaders,
|
|
56
|
-
...config.authHeaders(),
|
|
57
|
-
...requestHeaders
|
|
58
|
-
};
|
|
59
|
-
if (body !== void 0) headers["Content-Type"] ??= "application/json";
|
|
60
|
-
const response = await fetchImpl(url, {
|
|
61
|
-
method,
|
|
62
|
-
headers,
|
|
63
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
64
|
-
});
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
const errorBody = await response.text().catch(() => "");
|
|
67
|
-
throw new JsonRestError({
|
|
68
|
-
errorPrefix: config.errorPrefix,
|
|
69
|
-
status: response.status,
|
|
70
|
-
statusText: response.statusText,
|
|
71
|
-
body: errorBody,
|
|
72
|
-
headers: response.headers,
|
|
73
|
-
url,
|
|
74
|
-
method
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (response.status === 204) return;
|
|
78
|
-
return await response.json();
|
|
79
|
-
};
|
|
80
|
-
return { request };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { isJsonRestError as n, createJsonRestClient as t };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { CredentialSet, Operation } from "@keystrokehq/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/integration-authoring/dist/official/runtime.mjs
|
|
5
|
-
const REGISTRY_KEY = "__ks_official_integration_metadata_registry";
|
|
6
|
-
function getRegistry() {
|
|
7
|
-
const globalStore = globalThis;
|
|
8
|
-
if (!globalStore[REGISTRY_KEY]) globalStore[REGISTRY_KEY] = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
return globalStore[REGISTRY_KEY];
|
|
10
|
-
}
|
|
11
|
-
function registerOfficialOperation(operation, metadata) {
|
|
12
|
-
getRegistry().set(operation, Object.freeze({ ...metadata }));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region ../../packages/integration-authoring/dist/official/index.mjs
|
|
17
|
-
const OFFICIAL_CREDENTIAL_SET_ID_PREFIX = "keystroke:";
|
|
18
|
-
function stripOfficialCredentialSetIdPrefix(id) {
|
|
19
|
-
return id.startsWith(OFFICIAL_CREDENTIAL_SET_ID_PREFIX) ? id.slice(10) : id;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Creates a factory for Keystroke-official integration operations.
|
|
23
|
-
*
|
|
24
|
-
* It keeps the same flat `run(input, credentials)` ergonomics as the generic
|
|
25
|
-
* operation factory, while registering official metadata for builder/runtime
|
|
26
|
-
* operation metadata.
|
|
27
|
-
*/
|
|
28
|
-
function createOfficialOperationFactory(credentialSet) {
|
|
29
|
-
const integrationId = stripOfficialCredentialSetIdPrefix(credentialSet.id);
|
|
30
|
-
return (config) => {
|
|
31
|
-
const wrappedRun = async (input, ctx) => {
|
|
32
|
-
const creds = ctx.credentials[credentialSet.id];
|
|
33
|
-
return config.run(input, creds);
|
|
34
|
-
};
|
|
35
|
-
const operation = new Operation({
|
|
36
|
-
id: config.id,
|
|
37
|
-
name: config.name,
|
|
38
|
-
description: config.description,
|
|
39
|
-
input: config.input,
|
|
40
|
-
output: config.output,
|
|
41
|
-
credentialSets: [credentialSet],
|
|
42
|
-
...config.tags !== void 0 ? { tags: config.tags } : {},
|
|
43
|
-
...config.needsApproval !== void 0 ? { needsApproval: config.needsApproval } : {},
|
|
44
|
-
...config.requiredOAuthScopes !== void 0 ? { requiredOAuthScopes: config.requiredOAuthScopes } : {},
|
|
45
|
-
...config.retries !== void 0 ? { retries: config.retries } : {},
|
|
46
|
-
...config.timeout !== void 0 ? { timeout: config.timeout } : {},
|
|
47
|
-
...config.maxDurationMs !== void 0 ? { maxDurationMs: config.maxDurationMs } : {},
|
|
48
|
-
run: wrappedRun
|
|
49
|
-
});
|
|
50
|
-
registerOfficialOperation(operation, { integrationId });
|
|
51
|
-
return operation;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Creates an official integration bundle from a single config object.
|
|
56
|
-
*
|
|
57
|
-
* - Creates the public `CredentialSet` internally.
|
|
58
|
-
* - Accepts optional `internal` fields for Keystroke-owned platform credentials.
|
|
59
|
-
*/
|
|
60
|
-
function defineOfficialIntegration(config) {
|
|
61
|
-
const internalCredentialSets = config.internal ?? {};
|
|
62
|
-
const allInternalCredentialSets = [
|
|
63
|
-
...internalCredentialSets.providerApp ? [internalCredentialSets.providerApp] : [],
|
|
64
|
-
...internalCredentialSets.providerAppVariants ?? [],
|
|
65
|
-
...internalCredentialSets.webhookVerification ? [internalCredentialSets.webhookVerification] : [],
|
|
66
|
-
...internalCredentialSets.other ?? []
|
|
67
|
-
];
|
|
68
|
-
const credentialSet = new CredentialSet({
|
|
69
|
-
id: config.id,
|
|
70
|
-
name: config.name,
|
|
71
|
-
description: config.description,
|
|
72
|
-
auth: config.auth,
|
|
73
|
-
...config.connections ? { connections: config.connections } : {},
|
|
74
|
-
...config.proxy ? { proxy: config.proxy } : {},
|
|
75
|
-
...config.needsRawSecret === true ? { needsRawSecret: true } : {}
|
|
76
|
-
});
|
|
77
|
-
return Object.freeze({
|
|
78
|
-
integration: {
|
|
79
|
-
id: config.id,
|
|
80
|
-
name: config.name,
|
|
81
|
-
...config.description !== void 0 ? { description: config.description } : {},
|
|
82
|
-
auth: config.auth,
|
|
83
|
-
...config.proxy ? { proxy: config.proxy } : {},
|
|
84
|
-
...config.needsRawSecret === true ? { needsRawSecret: true } : {},
|
|
85
|
-
...config.connections ? { connections: config.connections } : {}
|
|
86
|
-
},
|
|
87
|
-
credentialSet,
|
|
88
|
-
internalCredentialSets,
|
|
89
|
-
allInternalCredentialSets
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/integration.ts
|
|
95
|
-
const posthogAuthSchema = z.object({
|
|
96
|
-
POSTHOG_PERSONAL_API_KEY: z.string().min(1),
|
|
97
|
-
POSTHOG_PROJECT_API_KEY: z.string().min(1).optional(),
|
|
98
|
-
POSTHOG_HOST: z.url().default("https://us.posthog.com"),
|
|
99
|
-
POSTHOG_PROJECT_ID: z.string().min(1).optional(),
|
|
100
|
-
POSTHOG_SCOPES: z.array(z.string()).optional()
|
|
101
|
-
});
|
|
102
|
-
/**
|
|
103
|
-
* PostHog integration — product analytics, feature flags, experiments,
|
|
104
|
-
* session replay, surveys, and data-platform management.
|
|
105
|
-
*
|
|
106
|
-
* The personal API key is injected as `Authorization: Bearer` for every
|
|
107
|
-
* management request (see `./client.ts`). The optional project API key
|
|
108
|
-
* is required only for capture/decide operations.
|
|
109
|
-
*/
|
|
110
|
-
const posthogOfficialIntegration = {
|
|
111
|
-
id: "posthog",
|
|
112
|
-
name: "PostHog",
|
|
113
|
-
description: "PostHog product analytics, feature flags, experiments, session replay, surveys, and data-platform management",
|
|
114
|
-
auth: posthogAuthSchema
|
|
115
|
-
};
|
|
116
|
-
const posthogBundle = defineOfficialIntegration(posthogOfficialIntegration);
|
|
117
|
-
const posthog = posthogBundle.credentialSet;
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
export { createOfficialOperationFactory as i, posthogBundle as n, posthogOfficialIntegration as r, posthog as t };
|