@theholocron/holocron-plugin-posthog 3.59.0 → 3.61.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/dist/index.d.mts CHANGED
@@ -13,7 +13,7 @@ declare class PostHogAnalytics implements Analytics {
13
13
  private readonly opts;
14
14
  readonly key: "analytics";
15
15
  readonly providerName = "posthog";
16
- constructor(client: PostHogClient$1, opts: PostHogAnalyticsOptions);
16
+ constructor(client: () => PostHogClient$1, opts: PostHogAnalyticsOptions);
17
17
  describe(): Promise<{
18
18
  provider: string;
19
19
  envKeys: string[];
@@ -60,7 +60,7 @@ interface PostHogPluginOptions extends ResolveTokenInput, PostHogAnalyticsOption
60
60
  }
61
61
  interface PluginContext {
62
62
  options: PostHogPluginOptions;
63
- client: PostHogClient$1;
63
+ client: () => PostHogClient$1;
64
64
  }
65
65
  declare function createContext(options?: PostHogPluginOptions): PluginContext;
66
66
  declare function analytics(ctx: PluginContext): Analytics;
package/dist/index.mjs CHANGED
@@ -25,17 +25,17 @@ var PostHogAnalytics = class {
25
25
  };
26
26
  }
27
27
  async whoami() {
28
- return { org: (await this.client.users.me()).organization.slug };
28
+ return { org: (await this.client().users.me()).organization.slug };
29
29
  }
30
30
  async ensureProject(name) {
31
- const { results } = await this.client.projects.list();
31
+ const { results } = await this.client().projects.list();
32
32
  const found = results.find((p) => p.name === name);
33
33
  if (found) return {
34
34
  token: found.api_token,
35
35
  alreadyExists: true
36
36
  };
37
37
  return {
38
- token: (await this.client.projects.create({ name })).api_token,
38
+ token: (await this.client().projects.create({ name })).api_token,
39
39
  alreadyExists: false
40
40
  };
41
41
  }
@@ -69,9 +69,10 @@ async function verifyToken(token, opts = {}) {
69
69
  //#endregion
70
70
  //#region src/index.ts
71
71
  function createContext(options = {}) {
72
+ let client;
72
73
  return {
73
74
  options,
74
- client: createPostHogClient$1({
75
+ client: () => client ??= createPostHogClient$1({
75
76
  token: resolveToken(options),
76
77
  host: options.host,
77
78
  baseUrl: options.baseUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-posthog",
3
- "version": "3.59.0",
3
+ "version": "3.61.0",
4
4
  "description": "Holocron plugin for PostHog. Implements the analytics capability — project provisioning and tracking token retrieval.",
5
5
  "keywords": [
6
6
  "analytics",
@@ -48,10 +48,10 @@
48
48
  "tsx": "4.23.12",
49
49
  "typescript": "^5.9.3",
50
50
  "vitest": "^4.1.11",
51
- "@theholocron/cli": "3.59.0"
51
+ "@theholocron/cli": "3.61.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@theholocron/cli": "3.59.0"
54
+ "@theholocron/cli": "3.61.0"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=22"