This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IR-2721: Zendesk integration (#10416)
* feat: zendesk integration * chore: license * chore: added zendesk key to docker images and build scripts --------- Co-authored-by: Hanzla Mateen <[email protected]>
- Loading branch information
1 parent
9ff957c
commit c826939
Showing
12 changed files
with
151 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import config from '@etherealengine/common/src/config' | ||
import { getMutableState, useHookstate } from '@etherealengine/hyperflux' | ||
import { useEffect } from 'react' | ||
import { AuthState } from '../user/services/AuthService' | ||
|
||
declare global { | ||
interface Window { | ||
zE: (...args: any) => void | ||
} | ||
} | ||
|
||
export const useZendesk = () => { | ||
const user = getMutableState(AuthState).user | ||
const initalized = useHookstate(() => { | ||
const zendeskScript = document.getElementById(`ze-snippet`) as HTMLScriptElement | ||
return !!zendeskScript | ||
}) | ||
|
||
const initalize = () => { | ||
if (initalized.value || !config.client.zendeskKey) return | ||
const script = document.createElement('script') | ||
script.id = 'ze-snippet' | ||
script.async = true | ||
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${config.client.zendeskKey}` | ||
document.body.appendChild(script) | ||
initalized.set(true) | ||
} | ||
|
||
useEffect(() => { | ||
if (config.client.zendeskEnabled !== 'true') return | ||
|
||
if (!user.isGuest.value && !initalized.value) { | ||
initalize() | ||
} else if (!user.isGuest.value && initalized.value) { | ||
showWidget() | ||
} else if (user.isGuest.value && initalized.value) { | ||
hideWidget() | ||
} | ||
}, [user.value]) | ||
|
||
const hideWidget = () => { | ||
if (initalized.value) return | ||
window.zE('messenger', 'hide') | ||
} | ||
const showWidget = () => { | ||
if (initalized.value) return | ||
window.zE('messenger', 'show') | ||
} | ||
const openChat = () => { | ||
if (initalized.value) return | ||
window.zE('messenger', 'open') | ||
} | ||
|
||
return { | ||
initialized: initalized.value, | ||
hideWidget, | ||
showWidget, | ||
openChat | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,3 +213,7 @@ vite-error-overlay { | |
height: 100%; | ||
} | ||
} | ||
|
||
iframe#launcher { | ||
pointer-events: all; | ||
} |
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