Skip to content

Commit b216157

Browse files
authored
[AC-3808] feat: support test region in playground (#359)
## Changes - Internal changes ticket: [AC-3808] ## Additional Notes - ## Checklist Before requesting a code review, please check the following: - [x] **[Required]** CI has passed all checks. - [x] **[Required]** A self-review has been conducted to ensure there are no minor mistakes. - [x] **[Required]** Unnecessary comments/debugging code have been removed. - [x] **[Required]** All requirements specified in the ticket have been accurately implemented. - [ ] Ensure the ticket has been updated with the sprint, status, and story points. [AC-3808]: https://sendbird.atlassian.net/browse/AC-3808?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 5db7438 commit b216157

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/self-service/playground/index.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,24 @@
9494
<script type="text/babel">
9595
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
9696
const { ChatWindow } = window.ChatAiWidget;
97+
function getHost(region) {
98+
if (region && region.startsWith('no')) {
99+
return { apiHost: `https://api-${region}.sendbirdtest.com`, wsHost: `wss://ws-${region}.sendbirdtest.com` };
100+
}
101+
return {
102+
apiHost: region ? `https://api-cf-${region}.sendbird.com` : undefined,
103+
wsHost: undefined,
104+
};
105+
}
97106
const App = () => {
98107
const urlParams = new URLSearchParams(window.location.search);
99108
const appId = urlParams.get('app_id');
100109
const botId = urlParams.get('bot_id');
101110
const title = urlParams.get('title');
102111
const region = urlParams.get('region');
103112
const mode = urlParams.get('mode') ? urlParams.get('mode') : isMobile ? 'mobile' : 'desktop';
104-
const apiHost = region ? `https://api-cf-${region}.sendbird.com` : undefined;
113+
114+
const { apiHost, wsHost } = getHost(region);
105115

106116
if (title) document.title = title;
107117
if (!appId || !botId) {
@@ -116,6 +126,7 @@
116126
botId={botId}
117127
deviceType={mode}
118128
apiHost={apiHost}
129+
wsHost={wsHost}
119130
callbacks={{
120131
onWidgetSettingFailure() {
121132
window.document.getElementById('root').classList.add('hide');

0 commit comments

Comments
 (0)