@inkeep/cxkit-primitives 0.5.94 → 0.5.96

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,69 +1,75 @@
1
1
  "use client";
2
2
  import { jsx as I } from "react/jsx-runtime";
3
- import { createContext as U, useContext as M, useState as k, useCallback as u } from "react";
4
- import { submitFeedback as N } from "../atoms/api/analytics/feedback.js";
3
+ import { createContext as N, useContext as U, useState as f, useCallback as p } from "react";
4
+ import { submitFeedback as M } from "../atoms/api/analytics/feedback.js";
5
5
  import { useChat as S } from "../components/embedded-chat/chat-provider.js";
6
- import { getMessageContent as f } from "../utils/misc.js";
6
+ import { getMessageContent as v } from "../utils/misc.js";
7
7
  import { useInkeepConfig as j } from "./config-provider.js";
8
8
  import { useInkeepConversation as q } from "./conversation-provider.js";
9
9
  import { useChatEvents as A } from "./chat-events-provider.js";
10
10
  import { useUser as B } from "./user-provider.js";
11
- const v = U(void 0);
11
+ const l = N(void 0);
12
12
  function K() {
13
- const { baseSettings: e } = j(), { apiKey: s, analyticsApiBaseUrl: o, analyticsProperties: b } = e, [l, F] = k(null), [g, C] = k({}), { conversation: m } = q(), { messages: n, selectedWorkflow: h } = S(), { userProperties: w } = B(), { logEvent: y } = A(), r = u(
14
- async (t, i, c = []) => {
15
- const a = await N({
16
- type: i,
13
+ const { baseSettings: e } = j(), { apiKey: s, analyticsApiBaseUrl: o, analyticsProperties: m } = e, [F, g] = f(null), [C, w] = f({}), { conversation: c } = q(), { messages: r, selectedWorkflow: h } = S(), { userProperties: y } = B(), { logEvent: b } = A(), i = p(
14
+ async (t, n, a = []) => {
15
+ const d = await M({
16
+ type: n,
17
17
  messageId: t,
18
- reasons: c,
18
+ reasons: a,
19
19
  apiKey: s,
20
20
  apiUrl: o,
21
- userProperties: w,
22
- properties: b
21
+ userProperties: y,
22
+ properties: m
23
23
  });
24
- a && C((d) => ({
25
- ...d,
26
- [t]: { type: a.type, reasons: a.reasons }
24
+ d && w((u) => ({
25
+ ...u,
26
+ [t]: { type: d.type, reasons: d.reasons }
27
27
  }));
28
- const p = n.findIndex((d) => d.id === t), _ = n[p], E = {
29
- conversationId: m.id,
30
- question: f(n[p - 1]),
31
- answer: f(_),
28
+ const k = r.findIndex((u) => u.id === t), P = r[k], E = {
29
+ conversationId: c.id,
30
+ question: v(r[k - 1]),
31
+ answer: v(P),
32
32
  messageId: t,
33
- reasons: c,
33
+ reasons: a,
34
34
  workflowId: h?.id
35
35
  };
36
- y({
37
- eventName: i === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
36
+ b({
37
+ eventName: n === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
38
38
  properties: E
39
+ }), n === "negative" && b({
40
+ eventName: "user_escalation_indicated",
41
+ properties: {
42
+ escalationType: "downvote",
43
+ conversation: c
44
+ }
39
45
  });
40
46
  },
41
- [n, m]
42
- ), x = u(
47
+ [r, c]
48
+ ), _ = p(
43
49
  async (t) => {
44
- r(t, "positive");
50
+ i(t, "positive");
45
51
  },
46
- [r]
47
- ), P = u(
48
- async (t, i) => {
49
- const c = R(i);
50
- r(t, "negative", c);
52
+ [i]
53
+ ), x = p(
54
+ async (t, n) => {
55
+ const a = R(n);
56
+ i(t, "negative", a);
51
57
  },
52
- [r]
58
+ [i]
53
59
  );
54
60
  return {
55
- feedback: g,
56
- currentFeedback: l,
57
- setCurrentFeedback: F,
58
- submitPositiveFeedback: x,
59
- submitNegativeFeedback: P
61
+ feedback: C,
62
+ currentFeedback: F,
63
+ setCurrentFeedback: g,
64
+ submitPositiveFeedback: _,
65
+ submitNegativeFeedback: x
60
66
  };
61
67
  }
62
- const Q = ({ children: e }) => {
68
+ const O = ({ children: e }) => {
63
69
  const s = K();
64
- return /* @__PURE__ */ I(v.Provider, { value: s, children: e });
65
- }, T = () => {
66
- const e = M(v);
70
+ return /* @__PURE__ */ I(l.Provider, { value: s, children: e });
71
+ }, Q = () => {
72
+ const e = U(l);
67
73
  if (!e)
68
74
  throw new Error("useFeedback must be used within a FeedbackProvider");
69
75
  return e;
@@ -78,6 +84,6 @@ function R(e) {
78
84
  return s.length > 0 ? s : [];
79
85
  }
80
86
  export {
81
- Q as FeedbackProvider,
82
- T as useMessageFeedback
87
+ O as FeedbackProvider,
88
+ Q as useMessageFeedback
83
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.94",
3
+ "version": "0.5.96",
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.94",
71
- "@inkeep/cxkit-theme": "0.5.94",
72
- "@inkeep/cxkit-types": "0.5.94"
70
+ "@inkeep/cxkit-color-mode": "^0.5.96",
71
+ "@inkeep/cxkit-theme": "0.5.96",
72
+ "@inkeep/cxkit-types": "0.5.96"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@biomejs/biome": "1.9.4",