1import { getConfigValue } from './configs.js'; 2import { getCustomer } from './customer/api.js'; 3import { getAuthUserToken } from './helpers/user-utils.js'; 4 5const storeCode = await getConfigValue('commerce-store-view-code'); 6 7function getUserHash(sprinklrHash) { 8 const hash = Object.values(sprinklrHash).find((value) => value.startsWith(storeCode)); 9 return hash ? hash.split('-')[1] : null; 10} 11 12const lang = document.documentElement.lang || 'en'; 13const liveChatAppId = await getConfigValue(`live-chat-app-id-${lang}`); 14 15function isLoggedInUser() { 16 return !!getAuthUserToken(); 17} 18const isAuthenticated = await isLoggedInUser(); 19const redirectURL = window.location.href; 20if (isAuthenticated) { 21 const data = await getCustomer(); 22 const userData = (data.extension_attributes.sprinklr_user_data_fields); 23 const sprinklrHash = (data.extension_attributes.sprinklr_hash); 24 const userHash = getUserHash(sprinklrHash); 25 // const myAccountURL = `${window.location.origin}/${lang}/user/account`; 26 window.sprChatSettings = { 27 appId: liveChatAppId, 28 skin: 'MODERN', 29 user: { 30 id: userData.id, 31 firstName: userData.first_name, 32 lastName: userData.last_name, 33 profileImageUrl: userData.profile_image_url, 34 phoneNo: userData.phone_no, 35 email: userData.email, 36 hash: userHash, 37 }, 38 // isAuthenticated TRUE or FALSE 39 clientContext: { 40 _c_63bcf8d81e28737162edd703: ['True'], 41 _c_665ec05f18a11d6104ea05f0: [redirectURL], 42 }, 43 }; 44} else { 45 const loginURL = `${window.location.origin}/${lang}/user/login?redirect=${redirectURL}`; 46 window.sprChatSettings = { 47 appId: liveChatAppId, 48 skin: 'MODERN', 49 // loginURL 50 userContext: { _c_63b6a6587e86835dfdcc0ed9: [loginURL] }, 51 // isAuthenticated TRUE or FALSE 52 clientContext: { _c_63bcf8d81e28737162edd703: ['False'] }, 53 }; 54} 55/* eslint-disable */ 56(function(){var t=window,e=t.sprChat,a=e&&!!e.loaded,n=document,r=function(){r.m(arguments)};r.q=[],r.m=function(t){r.q.push(t)},t.sprChat=a?e:r;var e2=t.sprTeamChat,r2=function(){r2.m(arguments)};r2.q=[],r2.m=function(t){r2.q.push(t)},t.sprTeamChat=e2?e2:r2;var o=function(){var e=n.createElement("script"); e.type="text/javascript",e.async=!0,e.src="https://prod2-live-chat.sprinklr.com/api/livechat/handshake/widget/"+t.sprChatSettings.appId; e.onerror=function(){t.sprChat.loaded=!1},e.onload=function(){t.sprChat.loaded=!0};var a=n.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)};"function"==typeof e?a?e("update",t.sprChatSettings):o():"loading"!==n.readyState?o():n.addEventListener("DOMContentLoaded",o)})() 57/* eslint-enable */ 58 59if (isAuthenticated) { 60 await window.sprChat('updateConversationContext', { context: window.sprChatSettings.clientContext }); 61 await window.sprChat('openExistingConversation'); 62}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.