@posthog/ai 7.16.0 → 7.16.1

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.mjs CHANGED
@@ -5,7 +5,7 @@ import { uuidv7 } from '@posthog/core';
5
5
  import AnthropicOriginal from '@anthropic-ai/sdk';
6
6
  import { GoogleGenAI } from '@google/genai';
7
7
 
8
- var version = "7.16.0";
8
+ var version = "7.16.1";
9
9
 
10
10
  // Type guards for safer type checking
11
11
  const isString = value => {
@@ -4436,6 +4436,14 @@ class LangChainCallbackHandler extends BaseCallbackHandler {
4436
4436
 
4437
4437
  /// <reference lib="dom" />
4438
4438
  const DEFAULT_CACHE_TTL_SECONDS = 300; // 5 minutes
4439
+ const DEFAULT_PROMPTS_HOST = 'https://us.posthog.com';
4440
+ function normalizeApiKey(value) {
4441
+ return typeof value === 'string' ? value.trim() : '';
4442
+ }
4443
+ function normalizeHost(value) {
4444
+ const normalizedHost = typeof value === 'string' ? value.trim() : '';
4445
+ return (normalizedHost || DEFAULT_PROMPTS_HOST).replace(/\/+$/, '');
4446
+ }
4439
4447
  function isPromptApiResponse(data) {
4440
4448
  if (typeof data !== 'object' || data === null) {
4441
4449
  return false;
@@ -4486,13 +4494,13 @@ class Prompts {
4486
4494
  this.defaultCacheTtlSeconds = options.defaultCacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;
4487
4495
  if (isPromptsWithPostHog(options)) {
4488
4496
  this.personalApiKey = options.posthog.options.personalApiKey ?? '';
4489
- this.projectApiKey = options.posthog.apiKey ?? '';
4497
+ this.projectApiKey = options.posthog.apiKey;
4490
4498
  this.host = options.posthog.host;
4491
4499
  } else {
4492
4500
  // Direct options
4493
- this.personalApiKey = options.personalApiKey;
4494
- this.projectApiKey = options.projectApiKey;
4495
- this.host = options.host ?? 'https://us.posthog.com';
4501
+ this.personalApiKey = normalizeApiKey(options.personalApiKey);
4502
+ this.projectApiKey = normalizeApiKey(options.projectApiKey);
4503
+ this.host = normalizeHost(options.host);
4496
4504
  }
4497
4505
  }
4498
4506
  getPromptCache(name) {