Skip to content

Commit

Permalink
feat: support test region in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Sep 12, 2024
1 parent 8181ba9 commit 8a6580f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/self-service/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,24 @@
<script type="text/babel">
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
const { ChatWindow } = window.ChatAiWidget;
function getHost(region) {
if (region && region.startsWith('no')) {
return { apiHost: `https://api-${region}.sendbirdtest.com`, wsHost: `wss://ws-${region}.sendbirdtest.com` };
}
return {
apiHost: region ? `https://api-cf-${region}.sendbird.com` : undefined,
wsHost: undefined,
};
}
const App = () => {
const urlParams = new URLSearchParams(window.location.search);
const appId = urlParams.get('app_id');
const botId = urlParams.get('bot_id');
const title = urlParams.get('title');
const region = urlParams.get('region');
const mode = urlParams.get('mode') ? urlParams.get('mode') : isMobile ? 'mobile' : 'desktop';
const apiHost = region ? `https://api-cf-${region}.sendbird.com` : undefined;

const { apiHost, wsHost } = getHost(region);

if (title) document.title = title;
if (!appId || !botId) {
Expand All @@ -116,6 +126,7 @@
botId={botId}
deviceType={mode}
apiHost={apiHost}
wsHost={wsHost}
callbacks={{
onWidgetSettingFailure() {
window.document.getElementById('root').classList.add('hide');
Expand Down

0 comments on commit 8a6580f

Please sign in to comment.