Skip to content

Commit 98f36ec

Browse files
author
Nevo David
committed
feat: remove plausible
1 parent 8fb33ab commit 98f36ec

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

apps/frontend/src/app/layout.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import { Chakra_Petch } from 'next/font/google';
1010
import PlausibleProvider from 'next-plausible';
1111
import clsx from 'clsx';
1212
import { VariableContextComponent } from '@gitroom/react/helpers/variable.context';
13+
import { Fragment } from 'react';
1314

1415
const chakra = Chakra_Petch({ weight: '400', subsets: ['latin'] });
1516

1617
export default async function AppLayout({ children }: { children: ReactNode }) {
18+
const Plausible = !!process.env.STRIPE_PUBLISHABLE_KEY
19+
? PlausibleProvider
20+
: Fragment;
21+
1722
return (
1823
<html className={interClass}>
1924
<head>
@@ -25,7 +30,9 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
2530
</head>
2631
<body className={clsx(chakra.className, 'text-primary dark')}>
2732
<VariableContextComponent
28-
storageProvider={process.env.STORAGE_PROVIDER! as 'local' | 'cloudflare'}
33+
storageProvider={
34+
process.env.STORAGE_PROVIDER! as 'local' | 'cloudflare'
35+
}
2936
backendUrl={process.env.NEXT_PUBLIC_BACKEND_URL!}
3037
plontoKey={process.env.NEXT_PUBLIC_POLOTNO!}
3138
billingEnabled={!!process.env.STRIPE_PUBLISHABLE_KEY}
@@ -34,11 +41,11 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
3441
isGeneral={!!process.env.IS_GENERAL}
3542
uploadDirectory={process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY!}
3643
>
37-
<PlausibleProvider
44+
<Plausible
3845
domain={!!process.env.IS_GENERAL ? 'postiz.com' : 'gitroom.com'}
3946
>
4047
<LayoutContext>{children}</LayoutContext>
41-
</PlausibleProvider>
48+
</Plausible>
4249
</VariableContextComponent>
4350
</body>
4451
</html>

apps/frontend/src/components/billing/main.billing.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { useModals } from '@mantine/modals';
2424
import { AddProviderComponent } from '@gitroom/frontend/components/launches/add.provider.component';
2525
import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component';
2626
import { Textarea } from '@gitroom/react/form/textarea';
27+
import { useFireEvents } from '@gitroom/helpers/utils/use.fire.events';
2728

2829
export interface Tiers {
2930
month: Array<{
@@ -156,9 +157,11 @@ export const Features: FC<{
156157
const Info: FC<{ proceed: (feedback: string) => void }> = (props) => {
157158
const [feedback, setFeedback] = useState('');
158159
const modal = useModals();
160+
const events = useFireEvents();
159161

160162
const cancel = useCallback(() => {
161163
props.proceed(feedback);
164+
events('cancel_subscription');
162165
modal.closeAll();
163166
}, [modal, feedback]);
164167

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import {usePlausible} from 'next-plausible'
2-
import {useCallback} from "react";
1+
import { usePlausible } from 'next-plausible';
2+
import { useCallback } from 'react';
3+
import { useVariables } from '@gitroom/react/helpers/variable.context';
34

45
export const useFireEvents = () => {
5-
const plausible = usePlausible();
6-
return useCallback((name: string, props?: any) => {
7-
plausible(name, {props});
8-
}, []);
9-
}
6+
const { billingEnabled } = useVariables();
7+
const plausible = usePlausible();
8+
return useCallback((name: string, props?: any) => {
9+
if (!billingEnabled) {
10+
return;
11+
}
12+
plausible(name, { props });
13+
}, []);
14+
};

0 commit comments

Comments
 (0)