@inkeep/cxkit-primitives 0.5.102 → 0.5.104

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),F=require("../../atoms/cmdk/index.cjs"),L=require("../../providers/search-events-provider.cjs"),P=require("../../providers/config-provider.cjs"),U=require("../../utils/graphql-client.cjs"),B=require("./search-query.graphql.cjs"),H=require("./search-provider.cjs"),O=250,j=()=>{const{setResultsList:o,setLoading:u,showSearchResults:a,setShowSearchResults:i}=H.useSearch(),{baseSettings:_,searchSettings:k}=P.useInkeepConfig(),{apiKey:y,aiApiBaseUrl:A,userAuthToken:l,filters:R}=_,{maxResults:m,debounceTimeMs:S,onQueryChange:M,filters:b}=k,{logEvent:g}=L.useSearchEvents(),s=r.useRef({}),h=r.useRef(null),f=r.useRef(null),T=`${A}/graphql`,q=r.useMemo(()=>({Authorization:`Bearer ${y}`,"Content-Type":"application/json",...l?{"User-Token":l}:{}}),[y,l]),w=r.useCallback(async e=>{const t=new AbortController;h.current=t;try{const E=(await U.graphqlRequest(T,B.default,{searchInput:e},q,t.signal))?.search.searchHits;s.current[e.searchQuery]=E,o(E)}catch(C){if(C.name==="AbortError")return}finally{u(!1)}},[T,q]),Q=r.useCallback(e=>{const t=s.current[e.searchQuery];g({eventName:"search_query_response_received",properties:{searchQuery:e.searchQuery,totalResults:t?.length}})},[]),p=()=>{h.current&&(h.current.abort(),u(!1))},v=r.useCallback(e=>{if(f.current&&window.clearTimeout(f.current),!e.searchQuery){p(),o([]);return}f.current=window.setTimeout(()=>{p(),g({eventName:"search_query_submitted",properties:{searchQuery:e.searchQuery}}),s.current[e.searchQuery]?(o(s.current[e.searchQuery]),Q(e)):(u(!0),w(e).then(()=>{Q(e)}))},S)},[S,w]),c=F.useCommandState(e=>e.search),d=r.useMemo(()=>({searchQuery:c,filters:{...R,...b,limit:m}}),[c,m,R,b]),n=r.useRef(null);r.useEffect(()=>{const e=()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},t=!!c;return t&&!a?(e(),n.current=window.setTimeout(()=>{i(!0)},O)):!t&&a&&(e(),i(!1)),e},[c,a,i]),r.useEffect(()=>{M?.(d.searchQuery),v(d)},[v,d])};exports.useSearchFetch=j;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),B=require("../../atoms/cmdk/index.cjs"),F=require("../../providers/search-events-provider.cjs"),L=require("../../providers/config-provider.cjs"),P=require("../../utils/graphql-client.cjs"),H=require("./search-query.graphql.cjs"),O=require("./search-provider.cjs"),j=250,x=()=>{const{setResultsList:o,setLoading:u,showSearchResults:a,setShowSearchResults:i}=O.useSearch(),{baseSettings:_,searchSettings:A}=L.useInkeepConfig(),{apiKey:y,aiApiBaseUrl:k,userAuthToken:l,filters:R}=_,{maxResults:m,searchApiBaseUrl:M,debounceTimeMs:S,onQueryChange:U,filters:b}=A,{logEvent:g}=F.useSearchEvents(),t=r.useRef({}),h=r.useRef(null),f=r.useRef(null),T=`${M||k}/graphql`,q=r.useMemo(()=>({Authorization:`Bearer ${y}`,"Content-Type":"application/json",...l?{"User-Token":l}:{}}),[y,l]),w=r.useCallback(async e=>{const s=new AbortController;h.current=s;try{const E=(await P.graphqlRequest(T,H.default,{searchInput:e},q,s.signal))?.search.searchHits;t.current[e.searchQuery]=E,o(E)}catch(C){if(C.name==="AbortError")return}finally{u(!1)}},[T,q]),Q=r.useCallback(e=>{const s=t.current[e.searchQuery];g({eventName:"search_query_response_received",properties:{searchQuery:e.searchQuery,totalResults:s?.length}})},[]),p=()=>{h.current&&(h.current.abort(),u(!1))},v=r.useCallback(e=>{if(f.current&&window.clearTimeout(f.current),!e.searchQuery){p(),o([]);return}f.current=window.setTimeout(()=>{p(),g({eventName:"search_query_submitted",properties:{searchQuery:e.searchQuery}}),t.current[e.searchQuery]?(o(t.current[e.searchQuery]),Q(e)):(u(!0),w(e).then(()=>{Q(e)}))},S)},[S,w]),c=B.useCommandState(e=>e.search),d=r.useMemo(()=>({searchQuery:c,filters:{...R,...b,limit:m}}),[c,m,R,b]),n=r.useRef(null);r.useEffect(()=>{const e=()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},s=!!c;return s&&!a?(e(),n.current=window.setTimeout(()=>{i(!0)},j)):!s&&a&&(e(),i(!1)),e},[c,a,i]),r.useEffect(()=>{U?.(d.searchQuery),v(d)},[v,d])};exports.useSearchFetch=x;
@@ -1,37 +1,37 @@
1
1
  "use client";
2
- import { useRef as n, useMemo as A, useCallback as y, useEffect as k } from "react";
3
- import { useCommandState as H } from "../../atoms/cmdk/index.js";
4
- import { useSearchEvents as M } from "../../providers/search-events-provider.js";
5
- import { useInkeepConfig as x } from "../../providers/config-provider.js";
6
- import { graphqlRequest as N } from "../../utils/graphql-client.js";
7
- import O from "./search-query.graphql.js";
8
- import { useSearch as $ } from "./search-provider.js";
9
- const j = 250, V = () => {
10
- const { setResultsList: c, setLoading: u, showSearchResults: a, setShowSearchResults: i } = $(), { baseSettings: L, searchSettings: U } = x(), { apiKey: R, aiApiBaseUrl: B, userAuthToken: l, filters: d } = L, { maxResults: p, debounceTimeMs: S, onQueryChange: F, filters: w } = U, { logEvent: T } = M(), t = n({}), h = n(null), m = n(null), Q = `${B}/graphql`, b = A(
2
+ import { useRef as n, useMemo as v, useCallback as y, useEffect as k } from "react";
3
+ import { useCommandState as M } from "../../atoms/cmdk/index.js";
4
+ import { useSearchEvents as x } from "../../providers/search-events-provider.js";
5
+ import { useInkeepConfig as N } from "../../providers/config-provider.js";
6
+ import { graphqlRequest as O } from "../../utils/graphql-client.js";
7
+ import $ from "./search-query.graphql.js";
8
+ import { useSearch as j } from "./search-provider.js";
9
+ const z = 250, X = () => {
10
+ const { setResultsList: c, setLoading: a, showSearchResults: u, setShowSearchResults: i } = j(), { baseSettings: U, searchSettings: B } = N(), { apiKey: p, aiApiBaseUrl: L, userAuthToken: l, filters: R } = U, { maxResults: d, searchApiBaseUrl: F, debounceTimeMs: S, onQueryChange: H, filters: w } = B, { logEvent: T } = x(), t = n({}), h = n(null), m = n(null), Q = `${F || L}/graphql`, b = v(
11
11
  () => ({
12
- Authorization: `Bearer ${R}`,
12
+ Authorization: `Bearer ${p}`,
13
13
  "Content-Type": "application/json",
14
14
  ...l ? { "User-Token": l } : {}
15
15
  }),
16
- [R, l]
16
+ [p, l]
17
17
  ), g = y(
18
18
  async (e) => {
19
19
  const r = new AbortController();
20
20
  h.current = r;
21
21
  try {
22
- const v = (await N(
22
+ const q = (await O(
23
23
  Q,
24
- O,
24
+ $,
25
25
  { searchInput: e },
26
26
  b,
27
27
  r.signal
28
28
  ))?.search.searchHits;
29
- t.current[e.searchQuery] = v, c(v);
30
- } catch (q) {
31
- if (q.name === "AbortError")
29
+ t.current[e.searchQuery] = q, c(q);
30
+ } catch (E) {
31
+ if (E.name === "AbortError")
32
32
  return;
33
33
  } finally {
34
- u(!1);
34
+ a(!1);
35
35
  }
36
36
  },
37
37
  [Q, b]
@@ -45,8 +45,8 @@ const j = 250, V = () => {
45
45
  }
46
46
  });
47
47
  }, []), _ = () => {
48
- h.current && (h.current.abort(), u(!1));
49
- }, E = y(
48
+ h.current && (h.current.abort(), a(!1));
49
+ }, A = y(
50
50
  (e) => {
51
51
  if (m.current && window.clearTimeout(m.current), !e.searchQuery) {
52
52
  _(), c([]);
@@ -58,34 +58,34 @@ const j = 250, V = () => {
58
58
  properties: {
59
59
  searchQuery: e.searchQuery
60
60
  }
61
- }), t.current[e.searchQuery] ? (c(t.current[e.searchQuery]), C(e)) : (u(!0), g(e).then(() => {
61
+ }), t.current[e.searchQuery] ? (c(t.current[e.searchQuery]), C(e)) : (a(!0), g(e).then(() => {
62
62
  C(e);
63
63
  }));
64
64
  }, S);
65
65
  },
66
66
  [S, g]
67
- ), s = H((e) => e.search), f = A(
67
+ ), s = M((e) => e.search), f = v(
68
68
  () => ({
69
69
  searchQuery: s,
70
70
  filters: {
71
- ...d,
71
+ ...R,
72
72
  ...w,
73
- limit: p
73
+ limit: d
74
74
  }
75
75
  }),
76
- [s, p, d, w]
76
+ [s, d, R, w]
77
77
  ), o = n(null);
78
78
  k(() => {
79
79
  const e = () => {
80
80
  o.current !== null && (window.clearTimeout(o.current), o.current = null);
81
81
  }, r = !!s;
82
- return r && !a ? (e(), o.current = window.setTimeout(() => {
82
+ return r && !u ? (e(), o.current = window.setTimeout(() => {
83
83
  i(!0);
84
- }, j)) : !r && a && (e(), i(!1)), e;
85
- }, [s, a, i]), k(() => {
86
- F?.(f.searchQuery), E(f);
87
- }, [E, f]);
84
+ }, z)) : !r && u && (e(), i(!1)), e;
85
+ }, [s, u, i]), k(() => {
86
+ H?.(f.searchQuery), A(f);
87
+ }, [A, f]);
88
88
  };
89
89
  export {
90
- V as useSearchFetch
90
+ X as useSearchFetch
91
91
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("openai"),t=require("react"),J=require("react-hook-form"),W=require("../../utils/form.cjs"),X=require("./actions/qa-model-response.cjs"),z=require("./actions/context-model-response.cjs"),Y=require("../../providers/config-provider.cjs"),Z=require("../../providers/conversation-provider.cjs"),ee=require("../../providers/chat-events-provider.cjs"),se=require("./actions/qa-model-messages.cjs"),re=require("../embedded-chat/use-captcha.cjs"),te="root.serverError",q=async(u,s)=>{if(s)return;const o=await re.fetchAndSolveChallenge(`${u}/v1/challenge`);if(o)return{"X-INKEEP-CHALLENGE-SOLUTION":btoa(JSON.stringify(o))}},oe=u=>{const{formSettings:s}=u,{baseSettings:o}=Y.useInkeepConfig(),{conversation:m}=Z.useInkeepConversation(),{logEvent:a}=ee.useChatEvents(),{aiApiBaseUrl:c,shouldBypassCaptcha:S}=o,v=t.useMemo(()=>new $({baseURL:`${c}/v1`,apiKey:o.apiKey,dangerouslyAllowBrowser:!0}),[o.apiKey,c]),[M,w]=t.useState(!1),[V,A]=t.useState(!1),[F,f]=t.useState(!1),[I,h]=t.useState({}),d=t.useMemo(()=>{const{primary:n,secondary:i}=s;return W.getFormDefaultValues([...n.fields,...i.fields])},[s]),{control:b,handleSubmit:N,formState:{errors:C,isSubmitting:_,isSubmitSuccessful:P},reset:E,trigger:O,setValue:k,setError:H}=J.useForm({defaultValues:d});t.useEffect(()=>{d&&E(d)},[E,d]);const L=async n=>{if(!_)try{await s.buttons.submit.onSubmit({values:n,conversation:m}),a({eventName:"intelligent_form_submitted",properties:{conversation:m,values:n}}),a({eventName:"user_escalation_indicated",properties:{escalationType:"intelligent_support_form",conversation:m}})}catch(i){H(te,{message:i instanceof Error?i.message:"Something went wrong."})}},x=async()=>{const n=s.primary.fields.map(e=>e.name);if(!await O(n))return;A(!0),w(!0);const B=b._formValues,R=s.primary.fields.reduce((e,l)=>(e[l.name]=B[l.name],e),{}),U=s.secondary.fields.filter(e=>e.shouldPrefillWithAI!==!1),g=se.getQAModelMessages(R);a({eventName:"intelligent_form_primary_section_submitted",properties:{}},g);try{const e=await q(c,S),l=await q(c,S),[r,p]=await Promise.all([X.generateQAModelResponse(g,v,e),z.generateContextModelResponse({primaryFieldValues:R,fieldsToGenerate:U},v,l)]);if(p.suggestedValues)for(const[G,Q]of Object.entries(p.suggestedValues))k(G,Q);const y=r.aiAnnotations?.answerConfidence,j=y&&["very_confident","somewhat_confident"].includes(y),D=r.recordsConsidered&&r.recordsConsidered.length>0;j&&D&&r.answer?(h({answer:r.answer,answerConfidence:y,recordsConsidered:r.recordsConsidered}),a({eventName:"intelligent_form_ai_response_provided",properties:{recordsConsidered:r.recordsConsidered}},[...g,{id:Date.now().toString(),role:"assistant",content:r.answer,links:[]}])):(f(!0),h({answer:null,recordsConsidered:r.recordsConsidered,suggestedValues:p.suggestedValues}))}catch(e){console.error(e),f(!0)}finally{w(!1)}},K=N(L),T=C?.root?.serverError;return{formSettings:s,control:b,errors:C,isSubmitSuccessful:P,isSubmitting:_,handleSubmit:K,loading:M,formError:T,submittedPrimaryForm:V,handleSubmitPrimaryForm:x,aiResponse:I,showSecondaryFields:F,setShowSecondaryFields:f}};exports.useInkeepIntelligentForm=oe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("openai"),t=require("react"),J=require("react-hook-form"),W=require("../../utils/form.cjs"),X=require("./actions/qa-model-response.cjs"),z=require("./actions/context-model-response.cjs"),Y=require("../../providers/config-provider.cjs"),Z=require("../../providers/conversation-provider.cjs"),ee=require("../../providers/chat-events-provider.cjs"),se=require("./actions/qa-model-messages.cjs"),re=require("../embedded-chat/use-captcha.cjs"),te="root.serverError",q=async(u,s)=>{if(s)return;const o=await re.fetchAndSolveChallenge(`${u}/v1/challenge`);if(o)return{"X-INKEEP-CHALLENGE-SOLUTION":btoa(JSON.stringify(o))}},oe=u=>{const{formSettings:s}=u,{baseSettings:o}=Y.useInkeepConfig(),{conversation:m}=Z.useInkeepConversation(),{logEvent:i}=ee.useChatEvents(),{aiApiBaseUrl:c,shouldBypassCaptcha:S}=o,v=t.useMemo(()=>new $({baseURL:`${c}/v1`,apiKey:o.apiKey,dangerouslyAllowBrowser:!0}),[o.apiKey,c]),[M,w]=t.useState(!1),[V,A]=t.useState(!1),[F,f]=t.useState(!1),[I,h]=t.useState({}),d=t.useMemo(()=>{const{primary:n,secondary:a}=s;return W.getFormDefaultValues([...n.fields,...a.fields])},[s]),{control:_,handleSubmit:N,formState:{errors:b,isSubmitting:C,isSubmitSuccessful:P},reset:E,trigger:O,setValue:k,setError:H}=J.useForm({defaultValues:d});t.useEffect(()=>{d&&E(d)},[E,d]);const L=async n=>{if(!C)try{await s.buttons.submit.onSubmit({values:n,conversation:m}),i({eventName:"intelligent_form_submitted",properties:{conversation:m,values:n}}),i({eventName:"user_escalation_indicated",properties:{escalationType:"intelligent_support_form",conversation:m}})}catch(a){H(te,{message:a instanceof Error?a.message:"Something went wrong."})}},x=async()=>{const n=s.primary.fields.map(e=>e.name);if(!await O(n))return;A(!0),w(!0);const B=_._formValues,R=s.primary.fields.reduce((e,l)=>(e[l.name]=B[l.name],e),{}),U=s.secondary.fields.filter(e=>e.shouldPrefillWithAI!==!1),p=se.getQAModelMessages(R);i({eventName:"intelligent_form_primary_section_submitted",properties:{}},p);try{const e=await q(c,S),l=await q(c,S),[r,g]=await Promise.all([X.generateQAModelResponse(p,v,e),z.generateContextModelResponse({primaryFieldValues:R,fieldsToGenerate:U},v,l)]);if(g.suggestedValues)for(const[G,Q]of Object.entries(g.suggestedValues))k(G,Q);const y=r.aiAnnotations?.answerConfidence,j=y&&["very_confident","somewhat_confident"].includes(y),D=r.recordsConsidered&&r.recordsConsidered.length>0;j&&D&&r.answer?(h({answer:r.answer,answerConfidence:y,recordsConsidered:r.recordsConsidered}),i({eventName:"intelligent_form_ai_response_provided",properties:{recordsConsidered:r.recordsConsidered}},[...p,{id:Date.now().toString(),role:"assistant",content:r.answer,links:[]}]),i({eventName:"assistant_answer_displayed",properties:{}})):(f(!0),h({answer:null,recordsConsidered:r.recordsConsidered,suggestedValues:g.suggestedValues}))}catch(e){console.error(e),f(!0)}finally{w(!1)}},K=N(L),T=b?.root?.serverError;return{formSettings:s,control:_,errors:b,isSubmitSuccessful:P,isSubmitting:C,handleSubmit:K,loading:M,formError:T,submittedPrimaryForm:V,handleSubmitPrimaryForm:x,aiResponse:I,showSecondaryFields:F,setShowSecondaryFields:f}};exports.useInkeepIntelligentForm=oe;
@@ -18,16 +18,16 @@ const ne = "root.serverError", A = async (m, s) => {
18
18
  "X-INKEEP-CHALLENGE-SOLUTION": btoa(JSON.stringify(t))
19
19
  };
20
20
  }, we = (m) => {
21
- const { formSettings: s } = m, { baseSettings: t } = ee(), { conversation: u } = se(), { logEvent: i } = re(), { aiApiBaseUrl: a, shouldBypassCaptcha: w } = t, S = V(
21
+ const { formSettings: s } = m, { baseSettings: t } = ee(), { conversation: u } = se(), { logEvent: n } = re(), { aiApiBaseUrl: a, shouldBypassCaptcha: w } = t, S = V(
22
22
  () => new J({
23
23
  baseURL: `${a}/v1`,
24
24
  apiKey: t.apiKey,
25
25
  dangerouslyAllowBrowser: !0
26
26
  }),
27
27
  [t.apiKey, a]
28
- ), [F, h] = c(!1), [N, I] = c(!1), [M, f] = c(!1), [O, _] = c({}), d = V(() => {
29
- const { primary: o, secondary: n } = s;
30
- return z([...o.fields, ...n.fields]);
28
+ ), [N, _] = c(!1), [F, I] = c(!1), [M, f] = c(!1), [O, h] = c({}), d = V(() => {
29
+ const { primary: o, secondary: i } = s;
30
+ return z([...o.fields, ...i.fields]);
31
31
  }, [s]), {
32
32
  control: C,
33
33
  handleSubmit: P,
@@ -48,35 +48,35 @@ const ne = "root.serverError", A = async (m, s) => {
48
48
  await s.buttons.submit.onSubmit({
49
49
  values: o,
50
50
  conversation: u
51
- }), i({
51
+ }), n({
52
52
  eventName: "intelligent_form_submitted",
53
53
  properties: {
54
54
  conversation: u,
55
55
  values: o
56
56
  }
57
- }), i({
57
+ }), n({
58
58
  eventName: "user_escalation_indicated",
59
59
  properties: {
60
60
  escalationType: "intelligent_support_form",
61
61
  conversation: u
62
62
  }
63
63
  });
64
- } catch (n) {
64
+ } catch (i) {
65
65
  H(ne, {
66
- message: n instanceof Error ? n.message : "Something went wrong."
66
+ message: i instanceof Error ? i.message : "Something went wrong."
67
67
  });
68
68
  }
69
69
  }, B = async () => {
70
70
  const o = s.primary.fields.map((e) => e.name);
71
71
  if (!await k(o)) return;
72
- I(!0), h(!0);
72
+ I(!0), _(!0);
73
73
  const q = C._formValues, R = s.primary.fields.reduce(
74
74
  (e, l) => (e[l.name] = q[l.name], e),
75
75
  {}
76
76
  ), D = s.secondary.fields.filter(
77
77
  (e) => e.shouldPrefillWithAI !== !1
78
78
  ), p = te(R);
79
- i(
79
+ n(
80
80
  {
81
81
  eventName: "intelligent_form_primary_section_submitted",
82
82
  properties: {}
@@ -96,11 +96,11 @@ const ne = "root.serverError", A = async (m, s) => {
96
96
  for (const [$, j] of Object.entries(g.suggestedValues))
97
97
  x($, j);
98
98
  const y = r.aiAnnotations?.answerConfidence, G = y && ["very_confident", "somewhat_confident"].includes(y), Q = r.recordsConsidered && r.recordsConsidered.length > 0;
99
- G && Q && r.answer ? (_({
99
+ G && Q && r.answer ? (h({
100
100
  answer: r.answer,
101
101
  answerConfidence: y,
102
102
  recordsConsidered: r.recordsConsidered
103
- }), i(
103
+ }), n(
104
104
  {
105
105
  eventName: "intelligent_form_ai_response_provided",
106
106
  properties: {
@@ -111,7 +111,12 @@ const ne = "root.serverError", A = async (m, s) => {
111
111
  ...p,
112
112
  { id: Date.now().toString(), role: "assistant", content: r.answer, links: [] }
113
113
  ]
114
- )) : (f(!0), _({
114
+ ), n(
115
+ {
116
+ eventName: "assistant_answer_displayed",
117
+ properties: {}
118
+ }
119
+ )) : (f(!0), h({
115
120
  answer: null,
116
121
  recordsConsidered: r.recordsConsidered,
117
122
  suggestedValues: g.suggestedValues
@@ -119,7 +124,7 @@ const ne = "root.serverError", A = async (m, s) => {
119
124
  } catch (e) {
120
125
  console.error(e), f(!0);
121
126
  } finally {
122
- h(!1);
127
+ _(!1);
123
128
  }
124
129
  }, T = P(K), U = b?.root?.serverError;
125
130
  return {
@@ -129,9 +134,9 @@ const ne = "root.serverError", A = async (m, s) => {
129
134
  isSubmitSuccessful: L,
130
135
  isSubmitting: v,
131
136
  handleSubmit: T,
132
- loading: F,
137
+ loading: N,
133
138
  formError: U,
134
- submittedPrimaryForm: N,
139
+ submittedPrimaryForm: F,
135
140
  handleSubmitPrimaryForm: B,
136
141
  aiResponse: O,
137
142
  showSecondaryFields: M,
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.102",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.104",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
7
7
  const u = B(void 0), $ = ({ children: e }) => {
8
8
  const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
9
9
  () => ({
10
- widgetLibraryVersion: "0.5.102",
10
+ widgetLibraryVersion: "0.5.104",
11
11
  componentType: s,
12
12
  tags: a
13
13
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.102",
3
+ "version": "0.5.104",
4
4
  "description": "",
5
5
  "license": "Inkeep, Inc. Customer License (IICL) v1.1",
6
6
  "homepage": "",
@@ -67,9 +67,9 @@
67
67
  "remark-gfm": "^4.0.1",
68
68
  "unist-util-visit": "^5.0.0",
69
69
  "use-sync-external-store": "^1.4.0",
70
- "@inkeep/cxkit-color-mode": "^0.5.102",
71
- "@inkeep/cxkit-theme": "0.5.102",
72
- "@inkeep/cxkit-types": "0.5.102"
70
+ "@inkeep/cxkit-color-mode": "^0.5.104",
71
+ "@inkeep/cxkit-theme": "0.5.104",
72
+ "@inkeep/cxkit-types": "0.5.104"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@biomejs/biome": "1.9.4",