@elqnt/chat 1.0.12 → 1.0.14
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/hooks/use-websocket-chat-admin.js +13 -11
- package/dist/hooks/use-websocket-chat-admin.js.map +1 -1
- package/dist/hooks/use-websocket-chat-admin.mjs +13 -11
- package/dist/hooks/use-websocket-chat-admin.mjs.map +1 -1
- package/dist/hooks/use-websocket-chat-base.js +13 -11
- package/dist/hooks/use-websocket-chat-base.js.map +1 -1
- package/dist/hooks/use-websocket-chat-base.mjs +13 -11
- package/dist/hooks/use-websocket-chat-base.mjs.map +1 -1
- package/dist/hooks/use-websocket-chat-customer.js +13 -11
- package/dist/hooks/use-websocket-chat-customer.js.map +1 -1
- package/dist/hooks/use-websocket-chat-customer.mjs +13 -11
- package/dist/hooks/use-websocket-chat-customer.mjs.map +1 -1
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -737,6 +737,9 @@ var useWebSocketChatBase = ({
|
|
|
737
737
|
};
|
|
738
738
|
const handleSSEMessage = (event) => {
|
|
739
739
|
if (!mountedRef.current) return;
|
|
740
|
+
if (!event.data || event.data === "") {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
740
743
|
try {
|
|
741
744
|
const data = JSON.parse(event.data);
|
|
742
745
|
if (!isChatEvent(data)) {
|
|
@@ -793,7 +796,6 @@ var useWebSocketChatBase = ({
|
|
|
793
796
|
eventSource.addEventListener("chat_updated", handleSSEMessage);
|
|
794
797
|
eventSource.addEventListener("load_chat_response", handleSSEMessage);
|
|
795
798
|
eventSource.addEventListener("new_chat_created", handleSSEMessage);
|
|
796
|
-
eventSource.addEventListener("error", handleSSEMessage);
|
|
797
799
|
eventSource.addEventListener("show_csat_survey", handleSSEMessage);
|
|
798
800
|
eventSource.addEventListener("csat_response", handleSSEMessage);
|
|
799
801
|
eventSource.addEventListener("user_suggested_actions", handleSSEMessage);
|
|
@@ -1138,7 +1140,7 @@ var useWebSocketChatBase = ({
|
|
|
1138
1140
|
switch (fullEvent.type) {
|
|
1139
1141
|
case "message":
|
|
1140
1142
|
await sendRestMessage("send", {
|
|
1141
|
-
orgId: fullEvent.orgId,
|
|
1143
|
+
orgId: fullEvent.orgId || orgId,
|
|
1142
1144
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1143
1145
|
userId: fullEvent.userId,
|
|
1144
1146
|
message: fullEvent.message
|
|
@@ -1146,7 +1148,7 @@ var useWebSocketChatBase = ({
|
|
|
1146
1148
|
break;
|
|
1147
1149
|
case "typing":
|
|
1148
1150
|
await sendRestMessage("typing", {
|
|
1149
|
-
orgId: fullEvent.orgId,
|
|
1151
|
+
orgId: fullEvent.orgId || orgId,
|
|
1150
1152
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1151
1153
|
userId: fullEvent.userId,
|
|
1152
1154
|
typing: true
|
|
@@ -1154,7 +1156,7 @@ var useWebSocketChatBase = ({
|
|
|
1154
1156
|
break;
|
|
1155
1157
|
case "stopped_typing":
|
|
1156
1158
|
await sendRestMessage("typing", {
|
|
1157
|
-
orgId: fullEvent.orgId,
|
|
1159
|
+
orgId: fullEvent.orgId || orgId,
|
|
1158
1160
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1159
1161
|
userId: fullEvent.userId,
|
|
1160
1162
|
typing: false
|
|
@@ -1162,7 +1164,7 @@ var useWebSocketChatBase = ({
|
|
|
1162
1164
|
break;
|
|
1163
1165
|
case "load_chat":
|
|
1164
1166
|
const loadResponse = await sendRestMessage("load", {
|
|
1165
|
-
orgId: fullEvent.orgId,
|
|
1167
|
+
orgId: fullEvent.orgId || orgId,
|
|
1166
1168
|
chatKey: fullEvent.chatKey,
|
|
1167
1169
|
userId: fullEvent.userId
|
|
1168
1170
|
});
|
|
@@ -1184,7 +1186,7 @@ var useWebSocketChatBase = ({
|
|
|
1184
1186
|
break;
|
|
1185
1187
|
case "new_chat":
|
|
1186
1188
|
const createResponse = await sendRestMessage("create", {
|
|
1187
|
-
orgId: fullEvent.orgId,
|
|
1189
|
+
orgId: fullEvent.orgId || orgId,
|
|
1188
1190
|
userId: fullEvent.userId,
|
|
1189
1191
|
metadata: fullEvent.data
|
|
1190
1192
|
});
|
|
@@ -1210,7 +1212,7 @@ var useWebSocketChatBase = ({
|
|
|
1210
1212
|
break;
|
|
1211
1213
|
case "end_chat":
|
|
1212
1214
|
await sendRestMessage("end", {
|
|
1213
|
-
orgId: fullEvent.orgId,
|
|
1215
|
+
orgId: fullEvent.orgId || orgId,
|
|
1214
1216
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1215
1217
|
userId: fullEvent.userId,
|
|
1216
1218
|
data: fullEvent.data
|
|
@@ -1218,14 +1220,14 @@ var useWebSocketChatBase = ({
|
|
|
1218
1220
|
break;
|
|
1219
1221
|
case "human_agent_join":
|
|
1220
1222
|
await sendRestMessage("agent-join", {
|
|
1221
|
-
orgId: fullEvent.orgId,
|
|
1223
|
+
orgId: fullEvent.orgId || orgId,
|
|
1222
1224
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1223
1225
|
user: fullEvent.data?.user
|
|
1224
1226
|
});
|
|
1225
1227
|
break;
|
|
1226
1228
|
case "human_agent_leave":
|
|
1227
1229
|
await sendRestMessage("agent-leave", {
|
|
1228
|
-
orgId: fullEvent.orgId,
|
|
1230
|
+
orgId: fullEvent.orgId || orgId,
|
|
1229
1231
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1230
1232
|
user: fullEvent.data?.user
|
|
1231
1233
|
});
|
|
@@ -1239,7 +1241,7 @@ var useWebSocketChatBase = ({
|
|
|
1239
1241
|
case "plan_rejected":
|
|
1240
1242
|
await sendRestMessage("event", {
|
|
1241
1243
|
type: fullEvent.type,
|
|
1242
|
-
orgId: fullEvent.orgId,
|
|
1244
|
+
orgId: fullEvent.orgId || orgId,
|
|
1243
1245
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1244
1246
|
userId: fullEvent.userId,
|
|
1245
1247
|
data: fullEvent.data
|
|
@@ -1249,7 +1251,7 @@ var useWebSocketChatBase = ({
|
|
|
1249
1251
|
logger.warn("Sending unrecognized event type via generic endpoint:", fullEvent.type);
|
|
1250
1252
|
await sendRestMessage("event", {
|
|
1251
1253
|
type: fullEvent.type,
|
|
1252
|
-
orgId: fullEvent.orgId,
|
|
1254
|
+
orgId: fullEvent.orgId || orgId,
|
|
1253
1255
|
chatKey: fullEvent.chatKey || currentChatKeyRef.current,
|
|
1254
1256
|
userId: fullEvent.userId,
|
|
1255
1257
|
data: fullEvent.data
|