From fdc7008e621a48da3ca69735d3d6f61db9253d5e Mon Sep 17 00:00:00 2001 From: hrithikt Date: Thu, 29 Aug 2024 21:56:36 +0530 Subject: [PATCH 01/19] removed pirsch analytics from widget Signed-off-by: Rune Philosof --- widget/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/widget/index.html b/widget/index.html index c46ee54..521c00f 100644 --- a/widget/index.html +++ b/widget/index.html @@ -1364,9 +1364,7 @@

}); } - - + From 38323ed83c55d83ac652ab16cc1ab37cd5658f16 Mon Sep 17 00:00:00 2001 From: hrithikt Date: Sat, 31 Aug 2024 12:21:37 +0530 Subject: [PATCH 02/19] (fix): correct the client_url env variable Signed-off-by: Rune Philosof --- .env.docker | 2 +- .env.sample | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.docker b/.env.docker index 301f62a..ec90646 100644 --- a/.env.docker +++ b/.env.docker @@ -25,7 +25,7 @@ SENTRY_DSN= DEFAULT_SUBSCRIPTION=SELF_HOSTED ## FRONTEND URL ## -CLIENT_URL=https://webwhiz.ai +CLIENT_URL=https://app.webwhiz.ai ## EMAIL RELATED ## EMAIL_SENDER_EMAIL=hi@webwhiz.ai diff --git a/.env.sample b/.env.sample index 353a59b..a9f2cbc 100644 --- a/.env.sample +++ b/.env.sample @@ -26,7 +26,7 @@ SENDGRID_API_KEY=dummy SENTRY_DSN= ## FRONTEND URL ## -CLIENT_URL=https://webwhiz.ai +CLIENT_URL=https://app.webwhiz.ai ## EMAIL RELATED ## EMAIL_SENDER_EMAIL=hi@webwhiz.ai From 2bc7ffcb02dbf082335753c5e30cd09dda7a789a Mon Sep 17 00:00:00 2001 From: hrithikt Date: Fri, 30 Aug 2024 00:41:43 +0530 Subject: [PATCH 03/19] (fix)(widget): handle fetching-messages when no sessionId present Signed-off-by: Rune Philosof --- widget/index.html | 10 +++++----- widget/webwhiz-sdk.js | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/widget/index.html b/widget/index.html index 521c00f..134a363 100644 --- a/widget/index.html +++ b/widget/index.html @@ -402,6 +402,9 @@

async function getWidgetMessages() { + if (!sessionId) { + return; + } const url = `${baseURL}/chatbot/session/${sessionId}/messages`; try { const response = await fetch(url, { @@ -412,7 +415,6 @@

}, referrerPolicy: 'no-referrer', }); - if (response.status === 200) { const { messages: _messages } = await response.json(); @@ -441,13 +443,11 @@

const chatMessages = document.getElementById('chat-messages'); chatMessages.insertAdjacentHTML("beforeend", msgHTML); chatMessages.scrollTop = chatMessages.scrollHeight; + } else if (response.status === 404) { + resetChatHistory() } else { console.error('Failed to fetch messages: Status', response.status); } - - if (response.status === 404) { - resetChatHistory() - } } catch (error) { console.error('Error fetching messages:', error); } diff --git a/widget/webwhiz-sdk.js b/widget/webwhiz-sdk.js index c092f37..4921eb7 100644 --- a/widget/webwhiz-sdk.js +++ b/widget/webwhiz-sdk.js @@ -271,7 +271,6 @@ function __WEBWHIZ__getWidgetURL() { function __WEBWHIZ__getBaseURL() { const scriptEl = document.getElementById("__webwhizSdk__"); const baseURL = scriptEl.getAttribute('baseUrl') || scriptEl.getAttribute('data-base-url'); - console.log(baseURL); return baseURL || 'https://api.webwhiz.ai'; } From 730d890b8e138dc5afdca1b3cd7845df40aee809 Mon Sep 17 00:00:00 2001 From: hrithikt Date: Sat, 31 Aug 2024 17:12:55 +0530 Subject: [PATCH 04/19] configure widget url using env variable Signed-off-by: Rune Philosof --- frontend/.env.development | 8 +++++--- frontend/.env.docker | 2 ++ frontend/.env.sample | 5 +++++ frontend/src/config.ts | 3 ++- frontend/src/containers/EditChatbot/EditChatbot.tsx | 13 +++++++------ 5 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 frontend/.env.sample diff --git a/frontend/.env.development b/frontend/.env.development index 114cf09..21004d0 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,4 +1,6 @@ SKIP_PREFLIGHT_CHECK=true -REACT_APP_BASE_URL='https://api.webwhiz.ai' -REACT_APP_GOOGLE_AUTH_ID='158883259855-qn8g2bi77kqo0igt20pi6jb58797upm5.apps.googleusercontent.com' -PORT=3001 +REACT_APP_BASE_URL='http://localhost:3000' +REACT_APP_GOOGLE_AUTH_ID=dummy +PORT=3030 + +REACT_APP_WEBWHIZ_WIDGET_URL="https://widget.webwhiz.ai" diff --git a/frontend/.env.docker b/frontend/.env.docker index d61b035..16fdf62 100644 --- a/frontend/.env.docker +++ b/frontend/.env.docker @@ -1,3 +1,5 @@ SKIP_PREFLIGHT_CHECK=true REACT_APP_BASE_URL='/api' REACT_APP_GOOGLE_AUTH_ID='dummy' + +REACT_APP_WEBWHIZ_WIDGET_URL="https://widget.webwhiz.ai" \ No newline at end of file diff --git a/frontend/.env.sample b/frontend/.env.sample new file mode 100644 index 0000000..f4134dd --- /dev/null +++ b/frontend/.env.sample @@ -0,0 +1,5 @@ +SKIP_PREFLIGHT_CHECK=true +REACT_APP_BASE_URL='http://api.webwhiz.ai' +REACT_APP_GOOGLE_AUTH_ID=dummy + +REACT_APP_WEBWHIZ_WIDGET_URL="https://widget.webwhiz.ai" diff --git a/frontend/src/config.ts b/frontend/src/config.ts index 2578051..d73edf8 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -1,3 +1,4 @@ export const GOOGLE_AUTH_ID = process.env.REACT_APP_GOOGLE_AUTH_ID; export const baseURL = process.env.REACT_APP_BASE_URL; -export const SELF_HOST = process.env.REACT_APP_SELF_HOST; \ No newline at end of file +export const SELF_HOST = process.env.REACT_APP_SELF_HOST; +export const WEBWHIZ_WIDGET_URL = process.env.REACT_APP_WEBWHIZ_WIDGET_URL || 'https://widget.webwhiz.ai'; \ No newline at end of file diff --git a/frontend/src/containers/EditChatbot/EditChatbot.tsx b/frontend/src/containers/EditChatbot/EditChatbot.tsx index 99400b8..4a15e2f 100644 --- a/frontend/src/containers/EditChatbot/EditChatbot.tsx +++ b/frontend/src/containers/EditChatbot/EditChatbot.tsx @@ -46,6 +46,7 @@ import Integrations from "../Integrations/Integrations"; import Members from "../Members/Members"; import { OfflineMessagesNew } from "../OfflineMessages/OfflineMessagesNew"; import styles from "./EditChatbot.module.scss"; +import { WEBWHIZ_WIDGET_URL } from '../../config'; export function validateEmailAddress(email: string) { @@ -517,7 +518,7 @@ console.log(permissions.get(), 'permissionspermissions') <script id="__webwhizSdk__" data-chatbot-id="{chatBot._id}"

- src="https://widget.webwhiz.ai/webwhiz-sdk.js" + src="{WEBWHIZ_WIDGET_URL}/webwhiz-sdk.js" >


</script> @@ -531,7 +532,7 @@ console.log(permissions.get(), 'permissionspermissions') isDisabled={isSubmitting} onClick={() => { navigator.clipboard.writeText( - `` + `` ); toast({ title: `Copied to Clipboard`, @@ -553,7 +554,7 @@ console.log(permissions.get(), 'permissionspermissions') height="700px" frameborder="0"

- src="https://widget.webwhiz.ai/?kbId={chatBot._id}&embed=true&hide-chat-actions=true" + src="{WEBWHIZ_WIDGET_URL}/?kbId={chatBot._id}&embed=true&hide-chat-actions=true" >

</iframe> @@ -568,7 +569,7 @@ console.log(permissions.get(), 'permissionspermissions') onClick={() => { navigator.clipboard.writeText( `` ); toast({ @@ -588,7 +589,7 @@ console.log(permissions.get(), 'permissionspermissions') Share the chat interface with anyone with the below unique link. - https://widget.webwhiz.ai/?kbId={chatBot._id}&embed=true&hide-chat-actions=true + {WEBWHIZ_WIDGET_URL}/?kbId={chatBot._id}&embed=true&hide-chat-actions=true