Skip to content

Commit

Permalink
[AC-3808] feat: support test region in playground (#359)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
bang9 authored Sep 12, 2024
1 parent 5db7438 commit b216157
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 b216157

Please sign in to comment.