@posthog/ai 8.6.1 → 8.6.2

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.
@@ -537,7 +537,7 @@ function formatOpenAIResponsesInput(input, instructions) {
537
537
  return messages;
538
538
  }
539
539
 
540
- var version = "8.6.1";
540
+ var version = "8.6.2";
541
541
 
542
542
  const DEFAULT_MAX_DEPTH = 3;
543
543
  const MAX_STACK_LINES = 20;
@@ -656,8 +656,13 @@ const captureAiGeneration$1 = async (client, options) => {
656
656
  const eventType = options.eventType ?? AIEvent.Generation;
657
657
  const privacyMode = options.privacyMode ?? false;
658
658
  const usage = options.usage ?? {};
659
- const safeInput = sanitizeValues(options.input);
660
- const safeOutput = sanitizeValues(options.output);
659
+
660
+ // Check privacy before reading or traversing input/output. Besides avoiding
661
+ // needless work, this ensures hostile getters/proxies cannot observe a value
662
+ // that the caller explicitly requested us to redact.
663
+ const shouldRedact = withPrivacyMode(client, privacyMode, false) === null;
664
+ const safeInput = shouldRedact ? null : core.toJsonSafeValue(options.input);
665
+ const safeOutput = shouldRedact ? null : core.toJsonSafeValue(options.output);
661
666
  let httpStatus = options.httpStatus;
662
667
  let errorData = {};
663
668
  if (options.error) {
@@ -718,8 +723,8 @@ const captureAiGeneration$1 = async (client, options) => {
718
723
  $ai_provider: options.providerOverride ?? options.provider,
719
724
  $ai_model: options.modelOverride ?? options.model,
720
725
  $ai_model_parameters: options.modelParameters ?? {},
721
- $ai_input: withPrivacyMode(client, privacyMode, safeInput),
722
- $ai_output_choices: withPrivacyMode(client, privacyMode, safeOutput),
726
+ $ai_input: safeInput,
727
+ $ai_output_choices: safeOutput,
723
728
  $ai_http_status: httpStatus,
724
729
  $ai_input_tokens: usage.inputTokens ?? 0,
725
730
  ...(usage.outputTokens !== undefined ? {