-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All - UI: add sbc web messenger (#450)
* sbc messenger draft * fix * fix * fix * working * switch to middleware * fix * fix * add msg config to all apps * fix * fix * add return if missing config * update vaults env
- Loading branch information
Showing
18 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
strr-base-web/app/middleware/enable-sbc-web-messenger.global.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
export default defineNuxtRouteMiddleware(async (to) => { | ||
const { ldClient, getStoredFlag } = useConnectLaunchdarklyStore() | ||
await ldClient?.waitUntilReady() | ||
const enableSbcWebMsg = getStoredFlag('enable-sbc-web-messenger') | ||
const msgConfig = useAppConfig().strrBaseLayer.sbcWebMsg | ||
|
||
if (ldClient && enableSbcWebMsg && msgConfig.enable) { | ||
const rtc = useRuntimeConfig().public | ||
const genesysUrl = rtc.genesysUrl as string | ||
const environmentKey = rtc.genesysEnvironmentKey as string | ||
const deploymentKey = rtc.genesysDeploymentKey as string | ||
|
||
const initWebMsg = () => { | ||
if (!genesysUrl || !environmentKey || !deploymentKey) { | ||
console.warn('Missing Sbc Web Messenger config, aborting setup.') | ||
return | ||
} | ||
|
||
window._genesysJs = 'Genesys' | ||
window.Genesys = window.Genesys || function (...args: any) { | ||
(window.Genesys.q = window.Genesys.q || []).push(args) | ||
} | ||
window.Genesys.t = new Date().getTime() | ||
window.Genesys.c = { | ||
environment: environmentKey, | ||
deploymentId: deploymentKey | ||
} | ||
|
||
const script = document.createElement('script') | ||
script.async = true | ||
script.src = genesysUrl | ||
document.head.appendChild(script) | ||
localStorage.removeItem('_actmu') | ||
} | ||
|
||
// TODO: how to remove ? | ||
// const removeWebMsg = () => { | ||
// const scripts = document.querySelectorAll('script[src^="https://apps.cac1.pure.cloud"]') | ||
// scripts.forEach(script => script.remove()) | ||
|
||
// const el1 = document.getElementById('genesys-thirdparty') | ||
// if (el1) { | ||
// el1.remove() | ||
// } | ||
|
||
// const el2 = document.getElementById('genesys-messenger') | ||
// if (el2) { | ||
// el2.remove() | ||
// } | ||
|
||
// delete window.Genesys | ||
// delete window._genesysJs | ||
// localStorage.removeItem('_actmu') | ||
// } | ||
|
||
const isRouteAllowed = (path: string): boolean => { | ||
if (msgConfig.allowedRoutes === undefined) { | ||
return true | ||
} | ||
return msgConfig.allowedRoutes.some(route => path.includes(route)) | ||
} | ||
|
||
if (isRouteAllowed(to.path)) { | ||
initWebMsg() | ||
} else { | ||
// TODO: how to remove ? | ||
// removeWebMsg() | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters