@posthog/ai 8.20.1 → 8.21.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.
Files changed (66) hide show
  1. package/README.md +20 -0
  2. package/dist/adk/index.cjs +125 -36
  3. package/dist/adk/index.cjs.map +1 -1
  4. package/dist/adk/index.d.ts +7 -0
  5. package/dist/adk/index.mjs +126 -37
  6. package/dist/adk/index.mjs.map +1 -1
  7. package/dist/anthropic/index.cjs +115 -22
  8. package/dist/anthropic/index.cjs.map +1 -1
  9. package/dist/anthropic/index.d.ts +7 -0
  10. package/dist/anthropic/index.mjs +116 -23
  11. package/dist/anthropic/index.mjs.map +1 -1
  12. package/dist/claude-agent-sdk/index.cjs +131 -35
  13. package/dist/claude-agent-sdk/index.cjs.map +1 -1
  14. package/dist/claude-agent-sdk/index.d.ts +6 -0
  15. package/dist/claude-agent-sdk/index.mjs +132 -36
  16. package/dist/claude-agent-sdk/index.mjs.map +1 -1
  17. package/dist/gemini/index.cjs +116 -23
  18. package/dist/gemini/index.cjs.map +1 -1
  19. package/dist/gemini/index.d.ts +7 -0
  20. package/dist/gemini/index.mjs +116 -23
  21. package/dist/gemini/index.mjs.map +1 -1
  22. package/dist/genkit/index.cjs +138 -43
  23. package/dist/genkit/index.cjs.map +1 -1
  24. package/dist/genkit/index.d.ts +7 -0
  25. package/dist/genkit/index.mjs +138 -43
  26. package/dist/genkit/index.mjs.map +1 -1
  27. package/dist/index.cjs +114 -21
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +11 -0
  30. package/dist/index.mjs +115 -22
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/langchain/index.cjs +99 -21
  33. package/dist/langchain/index.cjs.map +1 -1
  34. package/dist/langchain/index.d.ts +7 -0
  35. package/dist/langchain/index.mjs +99 -21
  36. package/dist/langchain/index.mjs.map +1 -1
  37. package/dist/langchain/middleware/index.cjs +99 -21
  38. package/dist/langchain/middleware/index.cjs.map +1 -1
  39. package/dist/langchain/middleware/index.d.ts +6 -0
  40. package/dist/langchain/middleware/index.mjs +99 -21
  41. package/dist/langchain/middleware/index.mjs.map +1 -1
  42. package/dist/openai/index.cjs +115 -22
  43. package/dist/openai/index.cjs.map +1 -1
  44. package/dist/openai/index.d.ts +7 -0
  45. package/dist/openai/index.mjs +116 -23
  46. package/dist/openai/index.mjs.map +1 -1
  47. package/dist/openai-agents/index.cjs +139 -60
  48. package/dist/openai-agents/index.cjs.map +1 -1
  49. package/dist/openai-agents/index.d.ts +7 -0
  50. package/dist/openai-agents/index.mjs +139 -60
  51. package/dist/openai-agents/index.mjs.map +1 -1
  52. package/dist/otel/index.browser.cjs +24 -14
  53. package/dist/otel/index.browser.cjs.map +1 -1
  54. package/dist/otel/index.browser.mjs +24 -14
  55. package/dist/otel/index.browser.mjs.map +1 -1
  56. package/dist/otel/index.cjs +24 -14
  57. package/dist/otel/index.cjs.map +1 -1
  58. package/dist/otel/index.d.ts +3 -3
  59. package/dist/otel/index.mjs +24 -14
  60. package/dist/otel/index.mjs.map +1 -1
  61. package/dist/vercel/index.cjs +114 -21
  62. package/dist/vercel/index.cjs.map +1 -1
  63. package/dist/vercel/index.d.ts +6 -0
  64. package/dist/vercel/index.mjs +115 -22
  65. package/dist/vercel/index.mjs.map +1 -1
  66. package/package.json +5 -5
@@ -1,13 +1,82 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("uuid");
3
+ let _posthog_core = require("@posthog/core");
3
4
  //#region src/captureAiEvent.ts
4
5
  /** @internal */
5
6
  function isFullAiCaptureEnabled(client) {
6
7
  return client?.enableFullAiCapture === true;
7
8
  }
9
+ /**
10
+ * The caller's distinct id as a string, or undefined when it is missing, empty or only whitespace.
11
+ *
12
+ * @internal
13
+ */
14
+ function userDistinctId(value) {
15
+ if (!value) return;
16
+ const id = String(value);
17
+ return id.trim() === "" ? void 0 : id;
18
+ }
19
+ /**
20
+ * The caller's per-event options when they are an object. A missing or `null` value means no
21
+ * options. An array or any other value is reported and ignored, so it is never spread.
22
+ *
23
+ * @internal
24
+ */
25
+ function readAiEventOptions(value) {
26
+ if (value === void 0 || value === null) return;
27
+ if (typeof value === "object" && !Array.isArray(value)) return value;
28
+ console.warn(`[PostHog AI] options must be an object, got ${Array.isArray(value) ? "array" : typeof value}; ignoring them`);
29
+ }
30
+ /**
31
+ * The `properties` and `options` for an AI event. `personless` (no user distinct id) turns person
32
+ * processing off and beats the caller's `process_person_profile`.
33
+ *
34
+ * posthog-node 6 takes the options as they are, so no option is written as a property.
35
+ * posthog-node 5 has no per-event options: each known option is sent as the property that version
36
+ * reads, and an unknown key is dropped.
37
+ *
38
+ * @internal
39
+ */
40
+ function eventOptionFields(client, properties, options, personless) {
41
+ const userOptions = readAiEventOptions(options);
42
+ if (isPostHogNode6(client)) {
43
+ const eventOptions = {
44
+ ...userOptions,
45
+ ...personless ? { process_person_profile: false } : {}
46
+ };
47
+ return Object.keys(eventOptions).length > 0 ? {
48
+ properties,
49
+ options: eventOptions
50
+ } : { properties };
51
+ }
52
+ const withOptionProperties = {
53
+ ...properties,
54
+ ...(0, _posthog_core.eventOptionsAsLegacyProperties)(userOptions)
55
+ };
56
+ if (personless) withOptionProperties.$process_person_profile = false;
57
+ return { properties: withOptionProperties };
58
+ }
59
+ /**
60
+ * Whether the client is posthog-node 6 or later, the first major with per-event options.
61
+ *
62
+ * @internal
63
+ */
64
+ function isPostHogNode6(client) {
65
+ return (0, _posthog_core.acceptsEventOptions)(client);
66
+ }
67
+ /**
68
+ * posthog-node 6 sends every AI event on its capture v1 AI lane; `enableFullAiCapture` then only
69
+ * controls truncation and media redaction. posthog-node 5 keeps the opt-in, so an `@posthog/ai`
70
+ * upgrade never changes how a 5.x client sends.
71
+ *
72
+ * @internal
73
+ */
74
+ function usesAiLane(client) {
75
+ return isPostHogNode6(client) || isFullAiCaptureEnabled(client);
76
+ }
8
77
  /** @internal */
9
78
  function captureAiEvent(client, event) {
10
- if (isFullAiCaptureEnabled(client) && typeof client.captureAi === "function") {
79
+ if (usesAiLane(client) && typeof client.captureAi === "function") {
11
80
  client.captureAi(event);
12
81
  return;
13
82
  }
@@ -155,13 +224,17 @@ var MediaTypeContext = class MediaTypeContext {
155
224
  //#region src/sanitization/binary_content_redactor.ts
156
225
  const STRONG_CONTEXT_MIN_LENGTH = 64;
157
226
  const WEAK_CONTEXT_MIN_LENGTH = 1024;
227
+ const MAX_NODES = 1e4;
228
+ const TRUNCATED = "[Truncated]";
158
229
  var BinaryContentRedactor = class {
159
230
  constructor(recognizer = new Base64Recognizer()) {
160
231
  this.recognizer = recognizer;
161
- this.visited = /* @__PURE__ */ new WeakSet();
232
+ this.ancestors = /* @__PURE__ */ new WeakSet();
233
+ this.remainingNodes = MAX_NODES;
162
234
  }
163
235
  redact(value, mediaType) {
164
- this.visited = /* @__PURE__ */ new WeakSet();
236
+ this.ancestors = /* @__PURE__ */ new WeakSet();
237
+ this.remainingNodes = MAX_NODES;
165
238
  return this.walk(value, mediaType ? new MediaTypeContext(void 0, void 0, mediaType) : MediaTypeContext.EMPTY);
166
239
  }
167
240
  /** Redact one leaf while a caller owns bounded, type-preserving traversal. @internal */
@@ -173,18 +246,24 @@ var BinaryContentRedactor = class {
173
246
  if (typeof value === "string") return this.redactLeaf(value, ctx);
174
247
  if (typeof value !== "object") return value;
175
248
  if (typeof Uint8Array !== "undefined" && value instanceof Uint8Array) return this.redactLeaf(value, ctx);
176
- if (this.visited.has(value)) return null;
177
- this.visited.add(value);
178
- if (Array.isArray(value)) return value.map((item) => this.walk(item, ctx));
179
- const obj = value;
180
- const out = {};
181
- for (const k of Object.keys(obj)) Object.defineProperty(out, k, {
182
- value: this.walk(obj[k], new MediaTypeContext(obj, k)),
183
- enumerable: true,
184
- writable: true,
185
- configurable: true
186
- });
187
- return out;
249
+ if (this.ancestors.has(value)) return null;
250
+ if (this.remainingNodes <= 0) return TRUNCATED;
251
+ this.remainingNodes--;
252
+ this.ancestors.add(value);
253
+ try {
254
+ if (Array.isArray(value)) return value.map((item) => this.walk(item, ctx));
255
+ const obj = value;
256
+ const out = {};
257
+ for (const k of Object.keys(obj)) Object.defineProperty(out, k, {
258
+ value: this.walk(obj[k], new MediaTypeContext(obj, k)),
259
+ enumerable: true,
260
+ writable: true,
261
+ configurable: true
262
+ });
263
+ return out;
264
+ } finally {
265
+ this.ancestors.delete(value);
266
+ }
188
267
  }
189
268
  redactString(value, ctx) {
190
269
  const hasDefiniteBinaryData = ctx.hasDefiniteBinaryData();
@@ -363,7 +442,7 @@ function summarizeErrorForPrivacy(error) {
363
442
  }
364
443
  //#endregion
365
444
  //#region package.json
366
- var version = "8.20.1";
445
+ var version = "8.21.0";
367
446
  //#endregion
368
447
  //#region src/gatewayWarning.ts
369
448
  const POSTHOG_AI_GATEWAY_HOSTS = [
@@ -487,16 +566,12 @@ var PostHogTracingProcessor = class {
487
566
  this._privacyMode = options.privacyMode ?? false;
488
567
  this._groups = options.groups ?? {};
489
568
  this._properties = options.properties ?? {};
569
+ this._eventOptions = options.options;
490
570
  this._onError = options.onError;
491
571
  }
492
572
  _getDistinctId(trace) {
493
- if (typeof this._distinctId === "function") {
494
- if (trace) {
495
- const result = this._distinctId(trace);
496
- if (result) return String(result);
497
- }
498
- return;
499
- } else if (this._distinctId) return String(this._distinctId);
573
+ if (typeof this._distinctId === "function") return trace ? userDistinctId(this._distinctId(trace)) : void 0;
574
+ return userDistinctId(this._distinctId);
500
575
  }
501
576
  _withPrivacyMode(value) {
502
577
  return withPrivacyMode(this._client, this._privacyMode, value);
@@ -524,7 +599,7 @@ var PostHogTracingProcessor = class {
524
599
  this._onError?.(error, context);
525
600
  } catch (handlerError) {}
526
601
  }
527
- _captureEvent(event, properties, distinctId) {
602
+ _captureEvent(event, properties, identity) {
528
603
  try {
529
604
  if (!this._client?.capture) return;
530
605
  const finalProperties = {
@@ -532,9 +607,9 @@ var PostHogTracingProcessor = class {
532
607
  ...properties
533
608
  };
534
609
  const eventMessage = {
535
- distinctId: distinctId || "unknown",
610
+ distinctId: identity.distinctId || "unknown",
536
611
  event,
537
- properties: finalProperties,
612
+ ...eventOptionFields(this._client, finalProperties, this._eventOptions, identity.personless),
538
613
  groups: Object.keys(this._groups).length > 0 ? this._groups : void 0
539
614
  };
540
615
  captureAiEvent(this._client, eventMessage);
@@ -619,8 +694,10 @@ var PostHogTracingProcessor = class {
619
694
  properties.$ai_group_id = groupId;
620
695
  }
621
696
  if (metadata && Object.keys(metadata).length > 0) properties.$ai_trace_metadata = this._prepareCapturedValue(metadata);
622
- if (distinctId == null) properties.$process_person_profile = false;
623
- this._captureEvent("$ai_trace", properties, distinctId ?? traceId);
697
+ this._captureEvent("$ai_trace", properties, {
698
+ distinctId: distinctId ?? traceId,
699
+ personless: distinctId == null
700
+ });
624
701
  } catch (error) {
625
702
  this._handleError(error, "onTraceEnd");
626
703
  }
@@ -652,39 +729,41 @@ var PostHogTracingProcessor = class {
652
729
  const userDistinctId = traceInfo?.distinctId ?? this._getDistinctId(null);
653
730
  const groupId = traceInfo?.groupId ?? null;
654
731
  const errorProperties = this._getErrorProperties(span.error);
655
- if (userDistinctId == null) errorProperties.$process_person_profile = false;
656
- const distinctId = userDistinctId ?? traceId;
732
+ const identity = {
733
+ distinctId: userDistinctId ?? traceId,
734
+ personless: userDistinctId == null
735
+ };
657
736
  switch (spanData.type) {
658
737
  case "generation":
659
- this._handleGenerationSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
738
+ this._handleGenerationSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
660
739
  break;
661
740
  case "response":
662
- this._handleResponseSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
741
+ this._handleResponseSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
663
742
  break;
664
743
  case "function":
665
- this._handleFunctionSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
744
+ this._handleFunctionSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
666
745
  break;
667
746
  case "agent":
668
- this._handleAgentSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
747
+ this._handleAgentSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
669
748
  break;
670
749
  case "handoff":
671
- this._handleHandoffSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
750
+ this._handleHandoffSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
672
751
  break;
673
752
  case "guardrail":
674
- this._handleGuardrailSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
753
+ this._handleGuardrailSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
675
754
  break;
676
755
  case "custom":
677
- this._handleCustomSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
756
+ this._handleCustomSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
678
757
  break;
679
758
  case "transcription":
680
759
  case "speech":
681
760
  case "speech_group":
682
- this._handleAudioSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
761
+ this._handleAudioSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
683
762
  break;
684
763
  case "mcp_tools":
685
- this._handleMcpSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
764
+ this._handleMcpSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
686
765
  break;
687
- default: this._handleGenericSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties);
766
+ default: this._handleGenericSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties);
688
767
  }
689
768
  } catch (error) {
690
769
  this._handleError(error, "onSpanEnd");
@@ -706,7 +785,7 @@ var PostHogTracingProcessor = class {
706
785
  this._handleError(error, "forceFlush");
707
786
  }
708
787
  }
709
- _handleGenerationSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
788
+ _handleGenerationSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
710
789
  const rawResponse = spanData.output?.[0];
711
790
  const rawResponseUsage = rawResponse?.usage;
712
791
  const usage = spanData.usage ?? rawResponseUsage ?? {};
@@ -750,9 +829,9 @@ var PostHogTracingProcessor = class {
750
829
  if (usage.reasoning_tokens) properties.$ai_reasoning_tokens = usage.reasoning_tokens;
751
830
  if (usage.cache_read_input_tokens) properties.$ai_cache_read_input_tokens = usage.cache_read_input_tokens;
752
831
  if (usage.cache_creation_input_tokens) properties.$ai_cache_creation_input_tokens = usage.cache_creation_input_tokens;
753
- this._captureEvent("$ai_generation", properties, distinctId);
832
+ this._captureEvent("$ai_generation", properties, identity);
754
833
  }
755
- _handleResponseSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
834
+ _handleResponseSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
756
835
  const responseSpanData = spanData;
757
836
  const response = responseSpanData._response;
758
837
  const responseId = spanData.response_id ?? response?.id;
@@ -776,9 +855,9 @@ var PostHogTracingProcessor = class {
776
855
  const outputTokenDetails = usage.output_tokens_details;
777
856
  if (outputTokenDetails?.reasoning_tokens) properties.$ai_reasoning_tokens = outputTokenDetails.reasoning_tokens;
778
857
  if (response?.output) properties.$ai_output_choices = this._prepareCapturedValue(response.output);
779
- this._captureEvent("$ai_generation", properties, distinctId);
858
+ this._captureEvent("$ai_generation", properties, identity);
780
859
  }
781
- _handleFunctionSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
860
+ _handleFunctionSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
782
861
  const properties = {
783
862
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
784
863
  $ai_span_name: spanData.name,
@@ -787,9 +866,9 @@ var PostHogTracingProcessor = class {
787
866
  $ai_output_state: this._prepareCapturedValue(spanData.output)
788
867
  };
789
868
  if (spanData.mcp_data) properties.$ai_mcp_data = this._prepareCapturedValue(spanData.mcp_data);
790
- this._captureEvent("$ai_span", properties, distinctId);
869
+ this._captureEvent("$ai_span", properties, identity);
791
870
  }
792
- _handleAgentSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
871
+ _handleAgentSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
793
872
  const properties = {
794
873
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
795
874
  $ai_span_name: spanData.name,
@@ -798,9 +877,9 @@ var PostHogTracingProcessor = class {
798
877
  if (spanData.handoffs) properties.$ai_agent_handoffs = spanData.handoffs;
799
878
  if (spanData.tools) properties.$ai_agent_tools = spanData.tools;
800
879
  if (spanData.output_type) properties.$ai_agent_output_type = spanData.output_type;
801
- this._captureEvent("$ai_span", properties, distinctId);
880
+ this._captureEvent("$ai_span", properties, identity);
802
881
  }
803
- _handleHandoffSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
882
+ _handleHandoffSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
804
883
  const properties = {
805
884
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
806
885
  $ai_span_name: `${spanData.from_agent} -> ${spanData.to_agent}`,
@@ -808,27 +887,27 @@ var PostHogTracingProcessor = class {
808
887
  $ai_handoff_from_agent: spanData.from_agent,
809
888
  $ai_handoff_to_agent: spanData.to_agent
810
889
  };
811
- this._captureEvent("$ai_span", properties, distinctId);
890
+ this._captureEvent("$ai_span", properties, identity);
812
891
  }
813
- _handleGuardrailSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
892
+ _handleGuardrailSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
814
893
  const properties = {
815
894
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
816
895
  $ai_span_name: spanData.name,
817
896
  $ai_span_type: "guardrail",
818
897
  $ai_guardrail_triggered: spanData.triggered
819
898
  };
820
- this._captureEvent("$ai_span", properties, distinctId);
899
+ this._captureEvent("$ai_span", properties, identity);
821
900
  }
822
- _handleCustomSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
901
+ _handleCustomSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
823
902
  const properties = {
824
903
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
825
904
  $ai_span_name: spanData.name,
826
905
  $ai_span_type: "custom",
827
906
  $ai_custom_data: this._prepareCapturedValue(spanData.data)
828
907
  };
829
- this._captureEvent("$ai_span", properties, distinctId);
908
+ this._captureEvent("$ai_span", properties, identity);
830
909
  }
831
- _handleAudioSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
910
+ _handleAudioSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
832
911
  const spanType = spanData.type;
833
912
  const properties = {
834
913
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
@@ -849,9 +928,9 @@ var PostHogTracingProcessor = class {
849
928
  const speechGroup = spanData;
850
929
  if (speechGroup.input) properties.$ai_input = this._prepareCapturedValue(speechGroup.input);
851
930
  }
852
- this._captureEvent("$ai_span", properties, distinctId);
931
+ this._captureEvent("$ai_span", properties, identity);
853
932
  }
854
- _handleMcpSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
933
+ _handleMcpSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
855
934
  const properties = {
856
935
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
857
936
  $ai_span_name: `mcp:${spanData.server}`,
@@ -859,16 +938,16 @@ var PostHogTracingProcessor = class {
859
938
  $ai_mcp_server: spanData.server,
860
939
  $ai_mcp_tools: this._prepareCapturedValue(spanData.result)
861
940
  };
862
- this._captureEvent("$ai_span", properties, distinctId);
941
+ this._captureEvent("$ai_span", properties, identity);
863
942
  }
864
- _handleGenericSpan(spanData, traceId, spanId, parentId, latency, distinctId, groupId, errorProperties) {
943
+ _handleGenericSpan(spanData, traceId, spanId, parentId, latency, identity, groupId, errorProperties) {
865
944
  const spanType = spanData.type || "unknown";
866
945
  const properties = {
867
946
  ...this._baseProperties(traceId, spanId, parentId, latency, groupId, errorProperties),
868
947
  $ai_span_name: spanType,
869
948
  $ai_span_type: spanType
870
949
  };
871
- this._captureEvent("$ai_span", properties, distinctId);
950
+ this._captureEvent("$ai_span", properties, identity);
872
951
  }
873
952
  };
874
953
  //#endregion