Skip to content

Commit 32810e6

Browse files
kilraujackstar12michael1011
authored
feat: add Chatwoot (#745)
* feat: add chatwoot, replace discord as main help link * chore: linting and tsc * chore: address review * chore: check chatwoot env variable in build script --------- Co-authored-by: jackstar12 <[email protected]> Co-authored-by: jackstar12 <[email protected]> Co-authored-by: michael1011 <[email protected]>
1 parent ca8059f commit 32810e6

File tree

8 files changed

+71
-18
lines changed

8 files changed

+71
-18
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We encourage our technical users to check the code and run the web app locally f
88

99
## Resources
1010

11-
* Get Help: [Discord](https://discord.gg/QBvZGcW) | [Telegram](https://t.me/boltzhq)
11+
* Get Help: [Support Center](https://support.boltz.exchange/hc/center/) | [Discord](https://discord.gg/QBvZGcW) | [Telegram](https://t.me/boltzhq)
1212
* Read the Docs: [Docs Home](https://docs.boltz.exchange/)
1313
* Read our Blog: [Substack](https://blog.boltz.exchange/)
1414
* Follow us: [X/Twitter](https://twitter.com/Boltzhq) | [Nostr](https://snort.social/p/npub1psm37hke2pmxzdzraqe3cjmqs28dv77da74pdx8mtn5a0vegtlas9q8970)

build.py

+4
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ def handle_coop_disabled():
3535
if var not in data:
3636
print(f"{var} not in .env file")
3737
sys.exit(1)
38+
39+
for var in ["VITE_CHATWOOT_TOKEN"]:
40+
if var not in data:
41+
print(f"WARN: {var} not in .env file")

src/chatwoot.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import log from "loglevel";
2+
import { onMount } from "solid-js";
3+
4+
import { config } from "./config";
5+
6+
declare global {
7+
interface Window {
8+
chatwootSettings: {
9+
darkMode: string;
10+
};
11+
chatwootSDK: {
12+
run: (config: { websiteToken: string; baseUrl: string }) => void;
13+
};
14+
$chatwoot: {
15+
setCustomAttributes: (attributes: { swapId: string }) => void;
16+
};
17+
}
18+
}
19+
20+
const Chatwoot = () => {
21+
onMount(() => {
22+
const token = import.meta.env.VITE_CHATWOOT_TOKEN;
23+
const url = config.chatwootUrl;
24+
25+
if (token === undefined || url === undefined) {
26+
log.warn("Chatwoot URL or token not set");
27+
return;
28+
}
29+
30+
const tag = "script";
31+
const script = document.createElement(tag);
32+
const parent = document.getElementsByTagName(tag)[0];
33+
script.src = url + "/packs/js/sdk.js";
34+
script.defer = true;
35+
script.async = true;
36+
parent.parentNode.insertBefore(script, parent);
37+
script.onload = function () {
38+
window.chatwootSettings = {
39+
darkMode: "auto",
40+
};
41+
window.chatwootSDK.run({
42+
websiteToken: token,
43+
baseUrl: url,
44+
});
45+
};
46+
});
47+
48+
return "";
49+
};
50+
51+
export default Chatwoot;

src/components/Footer.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ const Footer = () => {
1717

1818
return (
1919
<footer>
20-
<h4>
21-
{t("feedback")}{" "}
22-
<a
23-
title="Discord"
24-
class="discord"
25-
target="_blank"
26-
href={config.discordUrl}>
27-
Discord
28-
</a>
29-
</h4>
3020
<div class="socials">
3121
<a
3222
title="Github"
@@ -79,6 +69,10 @@ const Footer = () => {
7969
</a>
8070
</div>
8171
<p class="footer-nav">
72+
<a target="_blank" href={config.supportUrl}>
73+
{t("support")}
74+
</a>{" "}
75+
|{" "}
8276
<a target="_blank" href={config.blogUrl}>
8377
{t("blog")}
8478
</a>{" "}

src/components/Nav.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const Nav = (props: { network: string }) => {
8080
<a
8181
class="external"
8282
target="_blank"
83-
href={config.discordUrl}>
83+
href={config.supportUrl}>
8484
{t("help")}
8585
<OcLinkexternal2 size={23} />
8686
</a>

src/config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const defaults = {
88

99
loglevel: "info" as log.LogLevelDesc,
1010
defaultLanguage: "en",
11+
supportUrl: "https://support.boltz.exchange/hc/center",
1112
discordUrl: "https://discord.gg/QBvZGcW",
1213
twitterUrl: "https://twitter.com/boltzhq",
1314
githubUrl: "https://github.com/BoltzExchange",
@@ -24,6 +25,7 @@ const defaults = {
2425
telegramUrl: "https://t.me/boltzhq",
2526
2627
dnsOverHttps: "https://1.1.1.1/dns-query",
28+
chatwootUrl: "https://support.boltz.exchange",
2729
preimageValidation: "https://validate-payment.com",
2830
};
2931

src/i18n/i18n.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const dict = {
22
en: {
33
language: "English",
44
status: "Status",
5-
feedback: "Got Feedback? Join our",
65
fast: "Fast",
76
l2: "Built on Layer 2",
87
l2_sub: "Boltz utilizes Layer 2 scaling technologies like the Lightning Network",
@@ -21,6 +20,7 @@ const dict = {
2120
channel: "Channel",
2221
refund: "Refund",
2322
blog: "Blog",
23+
support: "Support",
2424
documentation: "Docs",
2525
onion: "Onion",
2626
blockexplorer: "open {{ typeLabel }}",
@@ -229,7 +229,6 @@ const dict = {
229229
de: {
230230
language: "Deutsch",
231231
status: "Status",
232-
feedback: "Feedback? Schreib uns auf",
233232
fast: "Schnell",
234233
l2: "Auf Layer-2 gebaut",
235234
l2_sub: "Boltz nutzt Layer-2 Skalierungstechnologien wie das Lightning-Netzwerk",
@@ -249,6 +248,7 @@ const dict = {
249248
channel: "Kanal",
250249
refund: "Rückerstattung",
251250
blog: "Blog",
251+
support: "Hilfe",
252252
documentation: "Docs",
253253
onion: "Onion",
254254
blockexplorer: "{{ typeLabel }} anzeigen",
@@ -466,7 +466,6 @@ const dict = {
466466
es: {
467467
language: "Español",
468468
status: "Estado",
469-
feedback: "¿Tienes comentarios? Únete a nuestro",
470469
fast: "Rápido",
471470
l2: "Construido en la Capa 2",
472471
l2_sub: "Boltz utiliza tecnologías de segunda capa como la red de Lightning",
@@ -485,6 +484,7 @@ const dict = {
485484
channel: "Canal",
486485
refund: "Reembolso",
487486
blog: "Blog",
487+
support: "Ayuda",
488488
documentation: "Docs",
489489
onion: "Onion",
490490
blockexplorer: "Ver en {{ typeLabel }}",
@@ -700,7 +700,6 @@ const dict = {
700700
zh: {
701701
language: "中文",
702702
status: "状态",
703-
feedback: "有反馈?加入我们的",
704703
fast: "快速",
705704
l2: "建立在二层网络之上",
706705
l2_sub: "Boltz利用像闪电网络这样的二层网络扩展技术",
@@ -719,14 +718,15 @@ const dict = {
719718
channel: "通道",
720719
refund: "退款",
721720
blog: "博客",
721+
support: "支持",
722722
documentation: "文档",
723723
onion: "洋葱",
724724
blockexplorer: "打开{{ typeLabel }}",
725725
blockexplorer_lockup_address: "锁仓地址",
726726
blockexplorer_lockup_tx: "锁仓交易",
727727
blockexplorer_claim_tx: "索赔交易",
728728
blockexplorer_refund_tx: "退款交易",
729-
help: "帮助",
729+
help: "支持",
730730
network_fee: "网络费",
731731
fee: "Boltz费",
732732
denomination: "面额",
@@ -907,7 +907,6 @@ const dict = {
907907
ja: {
908908
language: "日本語",
909909
status: "ステータス",
910-
feedback: "フィードバックはこちらへ",
911910
fast: "高速",
912911
l2: "L2技術を活用",
913912
l2_sub: "Boltzは、LiquidネットワークやLightningネットワークなどのL2スケーリング技術を利用しています",
@@ -926,6 +925,7 @@ const dict = {
926925
channel: "チャネル",
927926
refund: "返金",
928927
blog: "ブログ",
928+
support: "ヘルプ",
929929
documentation: "ドキュメント",
930930
onion: "Onion",
931931
blockexplorer: "ブロックエクスプローラーで表示{{ typeLabel }}",

src/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import log from "loglevel";
77
import { Match, Show, Switch, createSignal, onMount } from "solid-js";
88
import { render } from "solid-js/web";
99

10+
import Chatwoot from "./chatwoot";
1011
import Footer from "./components/Footer";
1112
import Nav from "./components/Nav";
1213
import Notification from "./components/Notification";
@@ -67,6 +68,7 @@ const App = (props: RouteSectionProps) => {
6768
<CreateProvider>
6869
<PayProvider>
6970
<SwapChecker />
71+
<Chatwoot />
7072
<Show when={!isEmbedded()}>
7173
<Nav network={config.network} />
7274
</Show>

0 commit comments

Comments
 (0)