in src/components/Widget/index.js [662:699]
trySendTooltipPayload() {
const {
tooltipPayload,
socket,
customData,
connected,
isChatOpen,
dispatch,
tooltipSent
} = this.props;
if (connected && !isChatOpen && !tooltipSent.get(tooltipPayload)) {
const sessionId = this.getSessionId();
if (!sessionId) return;
// DIAGNOSTIC: Check token expiration before tooltip
if (customData?.auth_header) {
try {
const tokenPayload = customData.auth_header.split('.')[1];
const decoded = JSON.parse(atob(tokenPayload.replace(/-/g, '+').replace(/_/g, '/')));
const now = Date.now() / 1000;
const timeLeft = decoded.exp - now;
logger.info('🔍 TOOLTIP: Access token expires in:', Math.round(timeLeft / 60), 'minutes');
if (timeLeft < 0) {
logger.error('❌ TOOLTIP: Sending tooltip with EXPIRED access token! Expired', Math.round(-timeLeft / 60), 'minutes ago');
}
} catch (e) {
logger.error('❌ TOOLTIP: Failed to decode access token:', e);
}
}
socket.emit('user_uttered', { message: tooltipPayload, customData, session_id: sessionId });
dispatch(triggerTooltipSent(tooltipPayload));
dispatch(initialize());
}
}