@theholocron/holocron-plugin-posthog 3.28.0 → 3.29.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 CHANGED
@@ -21,6 +21,8 @@ Token resolution order:
21
21
  1. `--token <KEY>` flag on the holocron invocation
22
22
  2. `HOLOCRON_POSTHOG_TOKEN` env var
23
23
  3. `POSTHOG_PERSONAL_API_KEY` env var
24
+ 4. Keyring `posthog.<org>` — tried first when an org is active via `--org`, `HOLOCRON_ORG`, or `org` in `holocron.config.ts`
25
+ 5. Keyring `posthog` — unnamespaced fallback; set via `holocron auth set posthog <phx_key>`
24
26
 
25
27
  The token must be a **personal API key** (`phx_*`), found at
26
28
  **app.posthog.com → Settings → User → Personal API keys**. This is
package/dist/index.d.mts CHANGED
@@ -1,43 +1,8 @@
1
+ import { PostHogClient, PostHogClient as PostHogClient$1, PostHogClientOptions, PostHogProject, PostHogProjectsResponse, PostHogUser, createPostHogClient } from "@theholocron/posthog-client";
1
2
  import { Analytics, AuthError, ResolveTokenInput } from "@theholocron/cli";
2
3
  //#region src/auth.d.ts
3
4
  declare const resolveToken: (input?: ResolveTokenInput) => string;
4
5
  //#endregion
5
- //#region src/rest.d.ts
6
- interface PostHogClientOptions {
7
- token: string;
8
- /** PostHog instance host. Default: https://app.posthog.com */
9
- host?: string;
10
- /** Override base URL for tests (takes precedence over host). */
11
- baseUrl?: string;
12
- fetch?: typeof fetch;
13
- }
14
- interface PostHogProject {
15
- id: number;
16
- name: string;
17
- api_token: string;
18
- }
19
- interface PostHogUser {
20
- email: string;
21
- organization: {
22
- slug: string;
23
- name: string;
24
- };
25
- }
26
- interface PostHogClient {
27
- users: {
28
- me(): Promise<PostHogUser>;
29
- };
30
- projects: {
31
- list(): Promise<{
32
- results: PostHogProject[];
33
- }>;
34
- create(input: {
35
- name: string;
36
- }): Promise<PostHogProject>;
37
- };
38
- }
39
- declare function createPostHogClient({ token, host, baseUrl, fetch: fetchImpl }: PostHogClientOptions): PostHogClient;
40
- //#endregion
41
6
  //#region src/capabilities/analytics.d.ts
42
7
  interface PostHogAnalyticsOptions {
43
8
  /** PostHog instance host — pushed as NEXT_PUBLIC_POSTHOG_HOST. Default: https://app.posthog.com */
@@ -48,7 +13,7 @@ declare class PostHogAnalytics implements Analytics {
48
13
  private readonly opts;
49
14
  readonly key: "analytics";
50
15
  readonly providerName = "posthog";
51
- constructor(client: PostHogClient, opts: PostHogAnalyticsOptions);
16
+ constructor(client: PostHogClient$1, opts: PostHogAnalyticsOptions);
52
17
  describe(): Promise<{
53
18
  provider: string;
54
19
  envKeys: string[];
@@ -95,7 +60,7 @@ interface PostHogPluginOptions extends ResolveTokenInput, PostHogAnalyticsOption
95
60
  }
96
61
  interface PluginContext {
97
62
  options: PostHogPluginOptions;
98
- client: PostHogClient;
63
+ client: PostHogClient$1;
99
64
  }
100
65
  declare function createContext(options?: PostHogPluginOptions): PluginContext;
101
66
  declare function analytics(ctx: PluginContext): Analytics;
@@ -107,4 +72,4 @@ declare function createPlugin(options?: PostHogPluginOptions): {
107
72
  };
108
73
  declare const AUTH_HINT: string;
109
74
  //#endregion
110
- export { AUTH_HINT, AuthError, PluginContext, PostHogAnalytics, type PostHogAnalyticsOptions, type PostHogClient, type PostHogClientOptions, PostHogPluginOptions, type PostHogProject, type PostHogUser, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, analytics, createContext, createPlugin, createPostHogClient, resolveToken, verifyToken };
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 };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { AuthError, createResolveToken, createRestClient } from "@theholocron/cli";
1
+ import { createPostHogClient, createPostHogClient as createPostHogClient$1 } from "@theholocron/posthog-client";
2
+ import { AuthError, createResolveToken } from "@theholocron/cli";
2
3
  //#region src/auth.ts
3
4
  const resolveToken = createResolveToken({
4
5
  envName: "HOLOCRON_POSTHOG_TOKEN",
@@ -44,29 +45,9 @@ var PostHogAnalytics = class {
44
45
  }
45
46
  };
46
47
  //#endregion
47
- //#region src/rest.ts
48
- function createPostHogClient({ token, host, baseUrl, fetch: fetchImpl }) {
49
- const client = createRestClient({
50
- baseUrl: baseUrl ?? host ?? "https://app.posthog.com",
51
- token,
52
- vendor: "PostHog",
53
- fetch: fetchImpl
54
- });
55
- return {
56
- users: { me: () => client.request("/api/users/@me/") },
57
- projects: {
58
- list: () => client.request("/api/projects/"),
59
- create: (input) => client.request("/api/projects/", {
60
- method: "POST",
61
- body: input
62
- })
63
- }
64
- };
65
- }
66
- //#endregion
67
48
  //#region src/verify-token.ts
68
49
  async function verifyToken(token, opts = {}) {
69
- const client = createPostHogClient({
50
+ const client = createPostHogClient$1({
70
51
  token,
71
52
  host: opts.host,
72
53
  baseUrl: opts.baseUrl,
@@ -90,7 +71,7 @@ async function verifyToken(token, opts = {}) {
90
71
  function createContext(options = {}) {
91
72
  return {
92
73
  options,
93
- client: createPostHogClient({
74
+ client: createPostHogClient$1({
94
75
  token: resolveToken(options),
95
76
  host: options.host,
96
77
  baseUrl: options.baseUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-posthog",
3
- "version": "3.28.0",
3
+ "version": "3.29.0",
4
4
  "description": "Holocron plugin for PostHog. Implements the analytics capability — project provisioning and tracking token retrieval.",
5
5
  "homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-posthog#readme",
6
6
  "bugs": "https://github.com/theholocron/holocron/issues",
@@ -20,14 +20,17 @@
20
20
  "default": "./dist/index.mjs"
21
21
  }
22
22
  },
23
+ "dependencies": {
24
+ "@theholocron/posthog-client": "^1.9.0"
25
+ },
23
26
  "peerDependencies": {
24
- "@theholocron/cli": "3.28.0"
27
+ "@theholocron/cli": "3.29.0"
25
28
  },
26
29
  "devDependencies": {
27
- "@theholocron/eslint-config": "^7.19.1",
28
- "@theholocron/tsconfig": "^7.19.1",
29
- "@theholocron/tsdown-config": "^7.19.1",
30
- "@theholocron/vitest-config": "^7.19.1",
30
+ "@theholocron/eslint-config": "^7.20.0",
31
+ "@theholocron/tsconfig": "^7.20.0",
32
+ "@theholocron/tsdown-config": "^7.20.0",
33
+ "@theholocron/vitest-config": "^7.20.0",
31
34
  "@types/node": "^26",
32
35
  "@vitest/coverage-v8": "^4.1.10",
33
36
  "@vitest/eslint-plugin": "^1.6.27",
@@ -39,7 +42,7 @@
39
42
  "tsx": "4.22.4",
40
43
  "typescript": "^5.9.3",
41
44
  "vitest": "^4.1.10",
42
- "@theholocron/cli": "3.28.0"
45
+ "@theholocron/cli": "3.29.0"
43
46
  },
44
47
  "publishConfig": {
45
48
  "access": "public"