@theholocron/holocron-plugin-posthog 5.0.0-alpha.27 → 5.0.0-alpha.270
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 +1 -1
- package/dist/index.d.mts +14 -28
- package/dist/index.mjs +18 -10
- package/package.json +20 -18
package/README.md
CHANGED
|
@@ -53,6 +53,6 @@ runtime — the personal key is for management only.
|
|
|
53
53
|
| `whoami` | Calls `/api/users/@me/` to verify the token and return the org slug. |
|
|
54
54
|
| `ensureProject` | Lists projects and returns the existing one if found by name; creates it via `POST /api/projects/` otherwise. Returns the project's `api_token` (`phc_*`) and `alreadyExists`. |
|
|
55
55
|
|
|
56
|
-
`holocron setup` calls `ensureProject` and pushes `NEXT_PUBLIC_POSTHOG_KEY`
|
|
56
|
+
`holocron repo setup` calls `ensureProject` and pushes `NEXT_PUBLIC_POSTHOG_KEY`
|
|
57
57
|
(the project `api_token`) and `NEXT_PUBLIC_POSTHOG_HOST` (the resolved
|
|
58
58
|
`host` value) to GitHub Secrets.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
import { Analytics, AuthError, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
1
2
|
import { PostHogClient, PostHogClient as PostHogClient$1, PostHogClientOptions, PostHogProject, PostHogProjectsResponse, PostHogUser, createPostHogClient } from "@theholocron/posthog-client";
|
|
2
|
-
|
|
3
|
-
//#region src/auth.d.ts
|
|
4
|
-
declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/capabilities/analytics.d.ts
|
|
3
|
+
export declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
7
4
|
interface PostHogAnalyticsOptions {
|
|
8
5
|
/** PostHog instance host — pushed as NEXT_PUBLIC_POSTHOG_HOST. Default: https://app.posthog.com */
|
|
9
6
|
host?: string;
|
|
10
7
|
}
|
|
11
|
-
declare class PostHogAnalytics implements Analytics {
|
|
8
|
+
export declare class PostHogAnalytics implements Analytics {
|
|
12
9
|
private readonly client;
|
|
13
10
|
private readonly opts;
|
|
14
11
|
readonly key: "analytics";
|
|
@@ -28,26 +25,13 @@ declare class PostHogAnalytics implements Analytics {
|
|
|
28
25
|
/** The host value to push as NEXT_PUBLIC_POSTHOG_HOST. */
|
|
29
26
|
get resolvedHost(): string;
|
|
30
27
|
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/verify-token.d.ts
|
|
33
|
-
interface VerifyTokenSuccess {
|
|
34
|
-
ok: true;
|
|
35
|
-
subject: string;
|
|
36
|
-
}
|
|
37
|
-
interface VerifyTokenFailure {
|
|
38
|
-
ok: false;
|
|
39
|
-
message: string;
|
|
40
|
-
}
|
|
41
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
42
28
|
interface VerifyTokenOptions {
|
|
43
29
|
host?: string;
|
|
44
30
|
baseUrl?: string;
|
|
45
31
|
fetch?: typeof fetch;
|
|
46
32
|
}
|
|
47
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
48
|
-
|
|
49
|
-
//#region src/index.d.ts
|
|
50
|
-
interface PostHogPluginOptions extends ResolveTokenInput, PostHogAnalyticsOptions {
|
|
33
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
34
|
+
export interface PostHogPluginOptions extends ResolveTokenInput, PostHogAnalyticsOptions {
|
|
51
35
|
/**
|
|
52
36
|
* PostHog instance host. Defaults to US cloud.
|
|
53
37
|
* EU cloud: "https://eu.posthog.com"
|
|
@@ -58,18 +42,20 @@ interface PostHogPluginOptions extends ResolveTokenInput, PostHogAnalyticsOption
|
|
|
58
42
|
baseUrl?: string;
|
|
59
43
|
fetch?: typeof fetch;
|
|
60
44
|
}
|
|
61
|
-
interface PluginContext {
|
|
45
|
+
export interface PluginContext {
|
|
62
46
|
options: PostHogPluginOptions;
|
|
63
47
|
client: () => PostHogClient$1;
|
|
64
48
|
}
|
|
65
|
-
declare function createContext(options?: PostHogPluginOptions): PluginContext;
|
|
66
|
-
declare function analytics(ctx: PluginContext): Analytics;
|
|
67
|
-
declare function createPlugin(options?: PostHogPluginOptions): {
|
|
49
|
+
export declare function createContext(options?: PostHogPluginOptions): PluginContext;
|
|
50
|
+
export declare function analytics(ctx: PluginContext): Analytics;
|
|
51
|
+
export declare function createPlugin(options?: PostHogPluginOptions): {
|
|
68
52
|
name: string;
|
|
53
|
+
probes: {
|
|
54
|
+
connection: import("@theholocron/cli").Probe;
|
|
55
|
+
};
|
|
69
56
|
capabilities: {
|
|
70
57
|
analytics: () => Analytics;
|
|
71
58
|
};
|
|
72
59
|
};
|
|
73
|
-
declare const AUTH_HINT: string;
|
|
74
|
-
|
|
75
|
-
export { AUTH_HINT, AuthError, PluginContext, PostHogAnalytics, type PostHogAnalyticsOptions, type PostHogClient, type PostHogClientOptions, PostHogPluginOptions, type PostHogProject, type PostHogProjectsResponse, type PostHogUser, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, analytics, createContext, createPlugin, createPostHogClient, resolveToken, verifyToken };
|
|
60
|
+
export declare const AUTH_HINT: string;
|
|
61
|
+
export { AuthError, type PostHogAnalyticsOptions, type PostHogClient, type PostHogClientOptions, type PostHogProject, type PostHogProjectsResponse, type PostHogUser, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createPostHogClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { AuthError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
1
2
|
import { createPostHogClient, createPostHogClient as createPostHogClient$1 } from "@theholocron/posthog-client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
// src/auth.ts
|
|
4
5
|
const resolveToken = createResolveToken({
|
|
5
6
|
envName: "HOLOCRON_POSTHOG_TOKEN",
|
|
6
7
|
vendorEnvName: "POSTHOG_PERSONAL_API_KEY",
|
|
7
8
|
keyringService: "posthog",
|
|
8
9
|
errorMessage: "no PostHog personal API key found. Pass --token <KEY>, set HOLOCRON_POSTHOG_TOKEN / POSTHOG_PERSONAL_API_KEY, or run: holocron auth set posthog <phx_KEY>"
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
//#region src/capabilities/analytics.ts
|
|
11
|
+
// src/capabilities/analytics.ts
|
|
12
12
|
var PostHogAnalytics = class {
|
|
13
13
|
client;
|
|
14
14
|
opts;
|
|
@@ -44,8 +44,7 @@ var PostHogAnalytics = class {
|
|
|
44
44
|
return this.opts.host ?? "https://app.posthog.com";
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
//#region src/verify-token.ts
|
|
47
|
+
// src/verify-token.ts
|
|
49
48
|
async function verifyToken(token, opts = {}) {
|
|
50
49
|
const client = createPostHogClient$1({
|
|
51
50
|
token,
|
|
@@ -62,12 +61,11 @@ async function verifyToken(token, opts = {}) {
|
|
|
62
61
|
} catch (err) {
|
|
63
62
|
return {
|
|
64
63
|
ok: false,
|
|
65
|
-
message:
|
|
64
|
+
message: errorMessage(err)
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/index.ts
|
|
68
|
+
// src/index.ts
|
|
71
69
|
function createContext(options = {}) {
|
|
72
70
|
let client;
|
|
73
71
|
return {
|
|
@@ -87,9 +85,19 @@ function createPlugin(options = {}) {
|
|
|
87
85
|
const ctx = createContext(options);
|
|
88
86
|
return {
|
|
89
87
|
name: "@theholocron/holocron-plugin-posthog",
|
|
88
|
+
probes: { connection: connectionProbe({
|
|
89
|
+
provider: "PostHog",
|
|
90
|
+
url: options.baseUrl ?? options.host ?? "https://app.posthog.com",
|
|
91
|
+
fetch: options.fetch,
|
|
92
|
+
token: () => resolveToken(options),
|
|
93
|
+
verify: (token) => verifyToken(token, {
|
|
94
|
+
host: options.host,
|
|
95
|
+
baseUrl: options.baseUrl,
|
|
96
|
+
fetch: options.fetch
|
|
97
|
+
})
|
|
98
|
+
}) },
|
|
90
99
|
capabilities: { analytics: () => analytics(ctx) }
|
|
91
100
|
};
|
|
92
101
|
}
|
|
93
102
|
const AUTH_HINT = "create a personal API key at https://app.posthog.com/settings/user/api-keys (not the project API key — that is the client-side phc_* tracking token), then run: holocron auth set posthog <phx_KEY>";
|
|
94
|
-
//#endregion
|
|
95
103
|
export { AUTH_HINT, AuthError, PostHogAnalytics, analytics, createContext, createPlugin, createPostHogClient, resolveToken, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-posthog",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.270",
|
|
4
4
|
"description": "Holocron plugin for PostHog. Implements the analytics capability — project provisioning and tracking token retrieval.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"posthog"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/posthog/",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-posthog"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,29 +30,31 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@theholocron/posthog-client": "^1.
|
|
33
|
+
"@theholocron/posthog-client": "^1.58.0-alpha.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
37
|
-
"@theholocron/http-client": "^1.23.0",
|
|
38
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
39
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
40
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
41
36
|
"@types/node": "^26",
|
|
42
|
-
"@vitest/coverage-v8": "^
|
|
37
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
43
38
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
44
39
|
"chalk": "^6.0.0",
|
|
45
40
|
"eslint": "^10.8.1",
|
|
46
41
|
"eslint-plugin-n": "^18.3.0",
|
|
47
42
|
"globals": "^17.11.0",
|
|
48
|
-
"tsdown": "^0.
|
|
49
|
-
"tsx": "4.23.
|
|
43
|
+
"tsdown": "^0.23.3",
|
|
44
|
+
"tsx": "4.23.15",
|
|
50
45
|
"typescript": "^5.9.3",
|
|
51
|
-
"vitest": "^
|
|
52
|
-
"@theholocron/
|
|
46
|
+
"vitest": "^5.0.5",
|
|
47
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
48
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
49
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.270",
|
|
51
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.3",
|
|
52
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
53
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@theholocron/
|
|
56
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
57
|
+
"@theholocron/cli": "5.0.0-alpha.270"
|
|
56
58
|
},
|
|
57
59
|
"engines": {
|
|
58
60
|
"node": ">=22"
|
|
@@ -62,10 +64,10 @@
|
|
|
62
64
|
},
|
|
63
65
|
"scripts": {
|
|
64
66
|
"delivery.build": "tsdown",
|
|
65
|
-
"sourceQuality.staticAnalysis": "
|
|
67
|
+
"sourceQuality.staticAnalysis": "eslint .",
|
|
66
68
|
"test:watch": "vitest",
|
|
67
69
|
"validate": "tsx scripts/validate.mjs",
|
|
68
|
-
"verification.typeSafety": "
|
|
69
|
-
"verification.unitTests": "
|
|
70
|
+
"verification.typeSafety": "tsc --noEmit",
|
|
71
|
+
"verification.unitTests": "vitest run"
|
|
70
72
|
}
|
|
71
73
|
}
|