@posthog/ai 7.8.11 → 7.8.12

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.
@@ -10,7 +10,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var AnthropicOriginal__default = /*#__PURE__*/_interopDefault(AnthropicOriginal);
12
12
 
13
- var version = "7.8.11";
13
+ var version = "7.8.12";
14
14
 
15
15
  // Type guards for safer type checking
16
16
 
@@ -2,7 +2,7 @@ import AnthropicOriginal from '@anthropic-ai/sdk';
2
2
  import { v4 } from 'uuid';
3
3
  import { uuidv7 } from '@posthog/core';
4
4
 
5
- var version = "7.8.11";
5
+ var version = "7.8.12";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
@@ -6,7 +6,7 @@ var genai = require('@google/genai');
6
6
  var uuid = require('uuid');
7
7
  var core = require('@posthog/core');
8
8
 
9
- var version = "7.8.11";
9
+ var version = "7.8.12";
10
10
 
11
11
  // Type guards for safer type checking
12
12
 
@@ -2,7 +2,7 @@ import { GoogleGenAI } from '@google/genai';
2
2
  import { v4 } from 'uuid';
3
3
  import { uuidv7 } from '@posthog/core';
4
4
 
5
- var version = "7.8.11";
5
+ var version = "7.8.12";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
package/dist/index.cjs CHANGED
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
29
29
  var uuid__namespace = /*#__PURE__*/_interopNamespace(uuid);
30
30
  var AnthropicOriginal__default = /*#__PURE__*/_interopDefault(AnthropicOriginal);
31
31
 
32
- var version = "7.8.11";
32
+ var version = "7.8.12";
33
33
 
34
34
  // Type guards for safer type checking
35
35
  const isString = value => {
@@ -4399,6 +4399,7 @@ function isPromptsWithPostHog(options) {
4399
4399
  * // Or with direct options (no PostHog client needed)
4400
4400
  * const prompts = new Prompts({
4401
4401
  * personalApiKey: 'phx_xxx',
4402
+ * projectApiKey: 'phc_xxx',
4402
4403
  * host: 'https://us.posthog.com',
4403
4404
  * })
4404
4405
  *
@@ -4421,10 +4422,12 @@ class Prompts {
4421
4422
  this.defaultCacheTtlSeconds = options.defaultCacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;
4422
4423
  if (isPromptsWithPostHog(options)) {
4423
4424
  this.personalApiKey = options.posthog.options.personalApiKey ?? '';
4425
+ this.projectApiKey = options.posthog.apiKey ?? '';
4424
4426
  this.host = options.posthog.host;
4425
4427
  } else {
4426
4428
  // Direct options
4427
4429
  this.personalApiKey = options.personalApiKey;
4430
+ this.projectApiKey = options.projectApiKey;
4428
4431
  this.host = options.host ?? 'https://us.posthog.com';
4429
4432
  }
4430
4433
  }
@@ -4508,7 +4511,12 @@ class Prompts {
4508
4511
  if (!this.personalApiKey) {
4509
4512
  throw new Error('[PostHog Prompts] personalApiKey is required to fetch prompts. ' + 'Please provide it when initializing the Prompts instance.');
4510
4513
  }
4511
- const url = `${this.host}/api/environments/@current/llm_prompts/name/${encodeURIComponent(name)}/`;
4514
+ if (!this.projectApiKey) {
4515
+ throw new Error('[PostHog Prompts] projectApiKey is required to fetch prompts. ' + 'Please provide it when initializing the Prompts instance.');
4516
+ }
4517
+ const encodedPromptName = encodeURIComponent(name);
4518
+ const encodedProjectApiKey = encodeURIComponent(this.projectApiKey);
4519
+ const url = `${this.host}/api/environments/@current/llm_prompts/name/${encodedPromptName}/?token=${encodedProjectApiKey}`;
4512
4520
  const response = await fetch(url, {
4513
4521
  method: 'GET',
4514
4522
  headers: {