Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatwoot integration #1628

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
NEXT_PUBLIC_SENTRY_DNS=
NEXT_PUBLIC_SENTRY_DEBUG=false # true/false

# JITSU

Check warning on line 54 in apps/web/.env

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (JITSU)
JITSU_BROWSER_URL=

Check warning on line 55 in apps/web/.env

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (JITSU)
JITSU_BROWSER_WRITE_KEY=

Check warning on line 56 in apps/web/.env

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (JITSU)

# Github Integration
NEXT_PUBLIC_GITHUB_APP_NAME=ever-github

# Chatwoot

Check warning on line 61 in apps/web/.env

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (Chatwoot)
NEXT_PUBLIC_CHATWOOT_API_KEY=

Check warning on line 62 in apps/web/.env

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (CHATWOOT)
42 changes: 42 additions & 0 deletions apps/web/lib/features/integrations/chatwoot/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useEffect } from 'react';

declare global {
interface Window {
chatwootSettings: any;

Check warning on line 5 in apps/web/lib/features/integrations/chatwoot/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (chatwoot)
chatwootSDK: any;

Check warning on line 6 in apps/web/lib/features/integrations/chatwoot/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (chatwoot)
}
}

export default function ChatwootWidget() {

Check warning on line 10 in apps/web/lib/features/integrations/chatwoot/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (Chatwoot)
useEffect(() => {
const websiteToken = process.env.NEXT_PUBLIC_CHATWOOT_API_KEY;

Check warning on line 12 in apps/web/lib/features/integrations/chatwoot/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (CHATWOOT)
if (!websiteToken) {
return;
}

window.chatwootSettings = {

Check warning on line 17 in apps/web/lib/features/integrations/chatwoot/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (chatwoot)
hideMessageBubble: false,
position: 'right',
locale: 'en',
type: 'standard'
};

(function (d, t) {
const BASE_URL = 'https://app.chatwoot.com';
const g = d.createElement(t) as HTMLScriptElement;
const s = d.getElementsByTagName(t)[0];

g.src = BASE_URL + '/packs/js/sdk.js';
s.parentNode && s.parentNode.insertBefore(g, s);
g.async = !0;
g.onload = function () {
window.chatwootSDK.run({
websiteToken: websiteToken,
baseUrl: BASE_URL
});
};
})(document, 'script');
}, []);

return <></>;
}
13 changes: 5 additions & 8 deletions apps/web/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { JitsuProvider } from '@jitsu/jitsu-react';
import React from 'react';
import { JitsuAnalytics } from '../lib/components/services/jitsu-analytics';
import { jitsuConfiguration } from '@app/constants';
import ChatwootWidget from 'lib/features/integrations/chatwoot';

export default function MyApp({ Component, pageProps }: AppProps) {
const isJitsuEnvsPresent =
jitsuConfiguration.host && jitsuConfiguration.writeKey;
const isJitsuEnvsPresent = jitsuConfiguration.host && jitsuConfiguration.writeKey;
return (
<>
<Script
Expand All @@ -32,26 +32,23 @@ export default function MyApp({ Component, pageProps }: AppProps) {
</Script>
<Head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin=""
/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
</Head>
<JitsuProvider
options={
isJitsuEnvsPresent
? { ...jitsuConfiguration }
: {
disabled: true
}
}
}
>
<RecoilRoot>
<ThemeProvider attribute="class">
<SkeletonTheme baseColor="#F0F0F0" enableAnimation={false}>
<AppState />
<JitsuAnalytics user={pageProps?.user} />
<ChatwootWidget />
<Component {...pageProps} />
</SkeletonTheme>
</ThemeProvider>
Expand Down
Loading