@kite-copilot/chat-panel 0.2.54 → 0.2.55
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/auto.cjs +67 -1
- package/dist/auto.js +1 -1
- package/dist/{chunk-TK7U64UR.js → chunk-AHIYBFU6.js} +67 -1
- package/dist/embed.global.js +25 -60
- package/dist/index.cjs +67 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/auto.cjs
CHANGED
|
@@ -1775,6 +1775,18 @@ function ChatPanel({
|
|
|
1775
1775
|
}
|
|
1776
1776
|
);
|
|
1777
1777
|
}
|
|
1778
|
+
if (supabaseRef.current && sessionId) {
|
|
1779
|
+
console.log("[KiteChat] resetSession - marking session as ended:", sessionId);
|
|
1780
|
+
supabaseRef.current.from("sessions").update({ session_status: "ended" }).eq("session_id", sessionId).then(
|
|
1781
|
+
() => console.log("[KiteChat] resetSession - session marked as ended successfully:", sessionId),
|
|
1782
|
+
(err) => console.error("[KiteChat] resetSession - failed to mark session as ended:", sessionId, err)
|
|
1783
|
+
);
|
|
1784
|
+
} else {
|
|
1785
|
+
console.log("[KiteChat] resetSession - skipped marking session as ended:", {
|
|
1786
|
+
hasSupabase: !!supabaseRef.current,
|
|
1787
|
+
sessionId
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1778
1790
|
setSessionUser(null);
|
|
1779
1791
|
setSessionId(crypto.randomUUID());
|
|
1780
1792
|
setIsEscalated(false);
|
|
@@ -1850,6 +1862,42 @@ function ChatPanel({
|
|
|
1850
1862
|
);
|
|
1851
1863
|
}
|
|
1852
1864
|
}, [isOpen, isEscalated, sessionId]);
|
|
1865
|
+
React6.useEffect(() => {
|
|
1866
|
+
if (!sessionId || !effectiveSupabaseUrl || !effectiveSupabaseAnonKey) {
|
|
1867
|
+
console.log("[KiteChat] Session end handler skipped - missing:", {
|
|
1868
|
+
sessionId: !!sessionId,
|
|
1869
|
+
supabaseUrl: !!effectiveSupabaseUrl,
|
|
1870
|
+
supabaseKey: !!effectiveSupabaseAnonKey
|
|
1871
|
+
});
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
const currentSessionId = sessionId;
|
|
1875
|
+
const sbUrl = effectiveSupabaseUrl;
|
|
1876
|
+
const sbKey = effectiveSupabaseAnonKey;
|
|
1877
|
+
console.log("[KiteChat] Registering session end handler for session:", currentSessionId);
|
|
1878
|
+
const markSessionEnded = () => {
|
|
1879
|
+
console.log("[KiteChat] Marking session as ended:", currentSessionId);
|
|
1880
|
+
const sessionsUrl = `${sbUrl}/rest/v1/sessions?session_id=eq.${currentSessionId}`;
|
|
1881
|
+
fetch(sessionsUrl, {
|
|
1882
|
+
method: "PATCH",
|
|
1883
|
+
headers: {
|
|
1884
|
+
"Content-Type": "application/json",
|
|
1885
|
+
"apikey": sbKey,
|
|
1886
|
+
"Authorization": `Bearer ${sbKey}`,
|
|
1887
|
+
"Prefer": "return=minimal"
|
|
1888
|
+
},
|
|
1889
|
+
body: JSON.stringify({ session_status: "ended" }),
|
|
1890
|
+
keepalive: true
|
|
1891
|
+
}).catch(() => {
|
|
1892
|
+
});
|
|
1893
|
+
};
|
|
1894
|
+
window.addEventListener("beforeunload", markSessionEnded);
|
|
1895
|
+
return () => {
|
|
1896
|
+
console.log("[KiteChat] Component unmounting - marking session as ended:", currentSessionId);
|
|
1897
|
+
window.removeEventListener("beforeunload", markSessionEnded);
|
|
1898
|
+
markSessionEnded();
|
|
1899
|
+
};
|
|
1900
|
+
}, [sessionId, effectiveSupabaseUrl, effectiveSupabaseAnonKey]);
|
|
1853
1901
|
const heartbeatIntervalRef = React6.useRef(null);
|
|
1854
1902
|
const updateCustomerStatus = React6.useCallback(async (status) => {
|
|
1855
1903
|
if (!supabaseRef.current || !sessionId) return;
|
|
@@ -1881,7 +1929,11 @@ function ChatPanel({
|
|
|
1881
1929
|
);
|
|
1882
1930
|
};
|
|
1883
1931
|
const markDisconnectedWithKeepalive = () => {
|
|
1884
|
-
|
|
1932
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive called for escalated session:", currentSessionId);
|
|
1933
|
+
if (!sbUrl || !sbKey) {
|
|
1934
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive skipped - missing credentials");
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1885
1937
|
const url = `${sbUrl}/rest/v1/escalations?session_id=eq.${currentSessionId}`;
|
|
1886
1938
|
fetch(url, {
|
|
1887
1939
|
method: "PATCH",
|
|
@@ -1898,6 +1950,20 @@ function ChatPanel({
|
|
|
1898
1950
|
keepalive: true
|
|
1899
1951
|
}).catch(() => {
|
|
1900
1952
|
});
|
|
1953
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive - also marking session as ended:", currentSessionId);
|
|
1954
|
+
const sessionsUrl = `${sbUrl}/rest/v1/sessions?session_id=eq.${currentSessionId}`;
|
|
1955
|
+
fetch(sessionsUrl, {
|
|
1956
|
+
method: "PATCH",
|
|
1957
|
+
headers: {
|
|
1958
|
+
"Content-Type": "application/json",
|
|
1959
|
+
"apikey": sbKey,
|
|
1960
|
+
"Authorization": `Bearer ${sbKey}`,
|
|
1961
|
+
"Prefer": "return=minimal"
|
|
1962
|
+
},
|
|
1963
|
+
body: JSON.stringify({ session_status: "ended" }),
|
|
1964
|
+
keepalive: true
|
|
1965
|
+
}).catch(() => {
|
|
1966
|
+
});
|
|
1901
1967
|
};
|
|
1902
1968
|
console.log("[KiteChat] Starting presence heartbeat for live chat");
|
|
1903
1969
|
markActive();
|
package/dist/auto.js
CHANGED
|
@@ -1776,6 +1776,18 @@ function ChatPanel({
|
|
|
1776
1776
|
}
|
|
1777
1777
|
);
|
|
1778
1778
|
}
|
|
1779
|
+
if (supabaseRef.current && sessionId) {
|
|
1780
|
+
console.log("[KiteChat] resetSession - marking session as ended:", sessionId);
|
|
1781
|
+
supabaseRef.current.from("sessions").update({ session_status: "ended" }).eq("session_id", sessionId).then(
|
|
1782
|
+
() => console.log("[KiteChat] resetSession - session marked as ended successfully:", sessionId),
|
|
1783
|
+
(err) => console.error("[KiteChat] resetSession - failed to mark session as ended:", sessionId, err)
|
|
1784
|
+
);
|
|
1785
|
+
} else {
|
|
1786
|
+
console.log("[KiteChat] resetSession - skipped marking session as ended:", {
|
|
1787
|
+
hasSupabase: !!supabaseRef.current,
|
|
1788
|
+
sessionId
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1779
1791
|
setSessionUser(null);
|
|
1780
1792
|
setSessionId(crypto.randomUUID());
|
|
1781
1793
|
setIsEscalated(false);
|
|
@@ -1851,6 +1863,42 @@ function ChatPanel({
|
|
|
1851
1863
|
);
|
|
1852
1864
|
}
|
|
1853
1865
|
}, [isOpen, isEscalated, sessionId]);
|
|
1866
|
+
React6.useEffect(() => {
|
|
1867
|
+
if (!sessionId || !effectiveSupabaseUrl || !effectiveSupabaseAnonKey) {
|
|
1868
|
+
console.log("[KiteChat] Session end handler skipped - missing:", {
|
|
1869
|
+
sessionId: !!sessionId,
|
|
1870
|
+
supabaseUrl: !!effectiveSupabaseUrl,
|
|
1871
|
+
supabaseKey: !!effectiveSupabaseAnonKey
|
|
1872
|
+
});
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
const currentSessionId = sessionId;
|
|
1876
|
+
const sbUrl = effectiveSupabaseUrl;
|
|
1877
|
+
const sbKey = effectiveSupabaseAnonKey;
|
|
1878
|
+
console.log("[KiteChat] Registering session end handler for session:", currentSessionId);
|
|
1879
|
+
const markSessionEnded = () => {
|
|
1880
|
+
console.log("[KiteChat] Marking session as ended:", currentSessionId);
|
|
1881
|
+
const sessionsUrl = `${sbUrl}/rest/v1/sessions?session_id=eq.${currentSessionId}`;
|
|
1882
|
+
fetch(sessionsUrl, {
|
|
1883
|
+
method: "PATCH",
|
|
1884
|
+
headers: {
|
|
1885
|
+
"Content-Type": "application/json",
|
|
1886
|
+
"apikey": sbKey,
|
|
1887
|
+
"Authorization": `Bearer ${sbKey}`,
|
|
1888
|
+
"Prefer": "return=minimal"
|
|
1889
|
+
},
|
|
1890
|
+
body: JSON.stringify({ session_status: "ended" }),
|
|
1891
|
+
keepalive: true
|
|
1892
|
+
}).catch(() => {
|
|
1893
|
+
});
|
|
1894
|
+
};
|
|
1895
|
+
window.addEventListener("beforeunload", markSessionEnded);
|
|
1896
|
+
return () => {
|
|
1897
|
+
console.log("[KiteChat] Component unmounting - marking session as ended:", currentSessionId);
|
|
1898
|
+
window.removeEventListener("beforeunload", markSessionEnded);
|
|
1899
|
+
markSessionEnded();
|
|
1900
|
+
};
|
|
1901
|
+
}, [sessionId, effectiveSupabaseUrl, effectiveSupabaseAnonKey]);
|
|
1854
1902
|
const heartbeatIntervalRef = React6.useRef(null);
|
|
1855
1903
|
const updateCustomerStatus = React6.useCallback(async (status) => {
|
|
1856
1904
|
if (!supabaseRef.current || !sessionId) return;
|
|
@@ -1882,7 +1930,11 @@ function ChatPanel({
|
|
|
1882
1930
|
);
|
|
1883
1931
|
};
|
|
1884
1932
|
const markDisconnectedWithKeepalive = () => {
|
|
1885
|
-
|
|
1933
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive called for escalated session:", currentSessionId);
|
|
1934
|
+
if (!sbUrl || !sbKey) {
|
|
1935
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive skipped - missing credentials");
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1886
1938
|
const url = `${sbUrl}/rest/v1/escalations?session_id=eq.${currentSessionId}`;
|
|
1887
1939
|
fetch(url, {
|
|
1888
1940
|
method: "PATCH",
|
|
@@ -1899,6 +1951,20 @@ function ChatPanel({
|
|
|
1899
1951
|
keepalive: true
|
|
1900
1952
|
}).catch(() => {
|
|
1901
1953
|
});
|
|
1954
|
+
console.log("[KiteChat] markDisconnectedWithKeepalive - also marking session as ended:", currentSessionId);
|
|
1955
|
+
const sessionsUrl = `${sbUrl}/rest/v1/sessions?session_id=eq.${currentSessionId}`;
|
|
1956
|
+
fetch(sessionsUrl, {
|
|
1957
|
+
method: "PATCH",
|
|
1958
|
+
headers: {
|
|
1959
|
+
"Content-Type": "application/json",
|
|
1960
|
+
"apikey": sbKey,
|
|
1961
|
+
"Authorization": `Bearer ${sbKey}`,
|
|
1962
|
+
"Prefer": "return=minimal"
|
|
1963
|
+
},
|
|
1964
|
+
body: JSON.stringify({ session_status: "ended" }),
|
|
1965
|
+
keepalive: true
|
|
1966
|
+
}).catch(() => {
|
|
1967
|
+
});
|
|
1902
1968
|
};
|
|
1903
1969
|
console.log("[KiteChat] Starting presence heartbeat for live chat");
|
|
1904
1970
|
markActive();
|