Salesforcewebchat Changes
This commit is contained in:
parent
5445512816
commit
defd461145
4 changed files with 7 additions and 27 deletions
|
|
@ -7,7 +7,7 @@ function setupCustomSettings(
|
|||
onWebchatCloseCallback
|
||||
) {
|
||||
modifyEmbeddedSvcCallback();
|
||||
window.addEventListener("onEmbeddedMessagingReady", finishedLoadingCallback);
|
||||
window.addEventListener("onEmbeddedMessagingButtonCreated", finishedLoadingCallback);
|
||||
window.addEventListener("onEmbeddedMessagingWindowMaximized", onWebchatOpenCallback);
|
||||
window.addEventListener("onEmbeddedMessagingWindowClosed", onWebchatCloseCallback);
|
||||
}
|
||||
|
|
@ -43,7 +43,6 @@ export function initializeSalesforceWebchatForDev(
|
|||
);
|
||||
|
||||
try {
|
||||
console.log("initializing embeddedservice_bootstrap");
|
||||
embeddedservice_bootstrap.settings.language = "en_US"; // For example, enter 'en' or 'en-US'
|
||||
|
||||
embeddedservice_bootstrap.init(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export default {
|
|||
mixins: [analyticsMixin],
|
||||
data() {
|
||||
return {
|
||||
isAgentAvailable: false,
|
||||
isWebchatLoaded: false,
|
||||
isWebchatOpen: false,
|
||||
};
|
||||
},
|
||||
|
|
@ -37,25 +37,9 @@ export default {
|
|||
"https://safelite2--dev.sandbox.my.site.com/ESWSalesCentralTFN1755660094477/assets/js/bootstrap.min.js";
|
||||
script.onload = this.initializeSalesforceWebchat;
|
||||
document.body.appendChild(script);
|
||||
|
||||
// Notify funnel-header about Salesforce chat open/close state
|
||||
this._salesforceChatOpenObserver = new MutationObserver(() => {
|
||||
const isOpen = !!document.querySelector(".embeddedServiceSidebar");
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("salesforce-chat-visibility", { detail: { open: isOpen } })
|
||||
);
|
||||
});
|
||||
this._salesforceChatOpenObserver.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
},
|
||||
beforeUnmount() {
|
||||
// Clean up event listeners and observers
|
||||
window.removeEventListener(
|
||||
"salesforce-chat-visibility",
|
||||
this._handleSalesforceChatVisibility
|
||||
);
|
||||
window.removeEventListener("sierra-chat-transfer", this._handleSierraToSalesforceTransfer);
|
||||
if (this._salesforceChatOpenObserver) {
|
||||
this._salesforceChatOpenObserver.disconnect();
|
||||
|
|
@ -93,16 +77,13 @@ export default {
|
|||
}
|
||||
},
|
||||
modifyEmbeddedSvcCallback() {
|
||||
window.embeddedservice_bootstrap.settings.avatarImgURL = require("@/assets/img/salesforce-webchat/avatar_webchat.png");
|
||||
window.embeddedservice_bootstrap.settings.prechatBackgroundImgURL = require("@/assets/img/salesforce-webchat/safelite_logo_webchat.png");
|
||||
window.embeddedservice_bootstrap.settings.smallCompanyLogoImgURL = require("@/assets/img/salesforce-webchat/minimized_chat_bubble_webchat.png");
|
||||
window.embeddedservice_bootstrap.settings.displayHelpButton = false;
|
||||
window.embeddedservice_bootstrap.settings.hideChatButtonOnLoad = true;
|
||||
window.addEventListener("onEmbeddedMessagingConversationStarted", () => {
|
||||
this.pushEventForChatsToGA("support_chat", "chat_opened", "Live Agent", true);
|
||||
});
|
||||
},
|
||||
finishedLoadingCallback(data) {
|
||||
this.isAgentAvailable = data.isAgentAvailable;
|
||||
this.isWebchatLoaded = true;
|
||||
this.updateShouldShowWebchatButton();
|
||||
},
|
||||
onWebchatOpenCallback() {
|
||||
|
|
@ -118,7 +99,7 @@ export default {
|
|||
updateShouldShowWebchatButton() {
|
||||
this.webchatGlobalNonpersistedState.showWebchatButton =
|
||||
!this.hideSalesforceWebchatLaunchButton &&
|
||||
this.isAgentAvailable &&
|
||||
this.isWebchatLoaded &&
|
||||
!this.isWebchatOpen;
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ export default {
|
|||
return;
|
||||
}
|
||||
}
|
||||
window.embeddedservice_bootstrap.bootstrapEmbeddedService();
|
||||
window.embeddedservice_bootstrap.utilAPI.launchChat();
|
||||
}
|
||||
};
|
||||
window.addEventListener("sierra-chat-transfer", this._handleSierraTransfer);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const webchatHelper = () => {
|
|||
if (webchatGlobalNonpersistedState.shouldLaunchSierra) {
|
||||
window.dispatchEvent(new CustomEvent("launch-sierra-webchat")); // launches the sierra chat
|
||||
} else {
|
||||
window.embeddedservice_bootstrap.bootstrapEmbeddedService(); // launches the salesForce prechat form
|
||||
window.embeddedservice_bootstrap.utilAPI.launchChat(); // launches the salesForce prechat form
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue