diff --git a/apps/frontend/src/app/layout.tsx b/apps/frontend/src/app/layout.tsx index df4509cd..f07744e0 100644 --- a/apps/frontend/src/app/layout.tsx +++ b/apps/frontend/src/app/layout.tsx @@ -10,10 +10,15 @@ import { Chakra_Petch } from 'next/font/google'; import PlausibleProvider from 'next-plausible'; import clsx from 'clsx'; import { VariableContextComponent } from '@gitroom/react/helpers/variable.context'; +import { Fragment } from 'react'; const chakra = Chakra_Petch({ weight: '400', subsets: ['latin'] }); export default async function AppLayout({ children }: { children: ReactNode }) { + const Plausible = !!process.env.STRIPE_PUBLISHABLE_KEY + ? PlausibleProvider + : Fragment; + return ( @@ -25,7 +30,9 @@ export default async function AppLayout({ children }: { children: ReactNode }) { - {children} - + diff --git a/apps/frontend/src/components/billing/main.billing.component.tsx b/apps/frontend/src/components/billing/main.billing.component.tsx index fc2f88d2..b2107c3a 100644 --- a/apps/frontend/src/components/billing/main.billing.component.tsx +++ b/apps/frontend/src/components/billing/main.billing.component.tsx @@ -24,6 +24,7 @@ import { useModals } from '@mantine/modals'; import { AddProviderComponent } from '@gitroom/frontend/components/launches/add.provider.component'; import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component'; import { Textarea } from '@gitroom/react/form/textarea'; +import { useFireEvents } from '@gitroom/helpers/utils/use.fire.events'; export interface Tiers { month: Array<{ @@ -156,9 +157,11 @@ export const Features: FC<{ const Info: FC<{ proceed: (feedback: string) => void }> = (props) => { const [feedback, setFeedback] = useState(''); const modal = useModals(); + const events = useFireEvents(); const cancel = useCallback(() => { props.proceed(feedback); + events('cancel_subscription'); modal.closeAll(); }, [modal, feedback]); diff --git a/libraries/helpers/src/utils/use.fire.events.ts b/libraries/helpers/src/utils/use.fire.events.ts index 46f880b1..07141295 100644 --- a/libraries/helpers/src/utils/use.fire.events.ts +++ b/libraries/helpers/src/utils/use.fire.events.ts @@ -1,9 +1,14 @@ -import {usePlausible} from 'next-plausible' -import {useCallback} from "react"; +import { usePlausible } from 'next-plausible'; +import { useCallback } from 'react'; +import { useVariables } from '@gitroom/react/helpers/variable.context'; export const useFireEvents = () => { - const plausible = usePlausible(); - return useCallback((name: string, props?: any) => { - plausible(name, {props}); - }, []); -} \ No newline at end of file + const { billingEnabled } = useVariables(); + const plausible = usePlausible(); + return useCallback((name: string, props?: any) => { + if (!billingEnabled) { + return; + } + plausible(name, { props }); + }, []); +}; diff --git a/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts b/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts index 85084600..1c60b026 100644 --- a/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts +++ b/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts @@ -149,7 +149,7 @@ export class OrganizationRepository { }); if ( - !process.env.STRIPE_PUBLISHABLE_KEY || + process.env.STRIPE_PUBLISHABLE_KEY && checkForSubscription?.subscription?.subscriptionTier !== SubscriptionTier.PRO ) { diff --git a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts index 0d8b4f40..d969d99b 100644 --- a/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts @@ -78,10 +78,10 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { `?client_key=${process.env.TIKTOK_CLIENT_ID}` + `&redirect_uri=${encodeURIComponent( `${ - process.env.NODE_ENV === 'development' || !process.env.NODE_ENV - ? `https://integration.git.sn/integrations/social/tiktok` - : `${process.env.FRONTEND_URL}/integrations/social/tiktok` - }` + process?.env?.FRONTEND_URL?.indexOf('https') === -1 + ? 'https://redirectmeto.com/' + : '' + }${process?.env?.FRONTEND_URL}/integrations/social/tiktok` )}` + `&state=${state}` + `&response_type=code` + @@ -199,7 +199,9 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { ? `https://www.tiktok.com/@${id}` : `https://www.tiktok.com/@${id}/video/` + publicaly_available_post_id, - id: !publicaly_available_post_id ? publishId : publicaly_available_post_id?.[0], + id: !publicaly_available_post_id + ? publishId + : publicaly_available_post_id?.[0], }; } @@ -210,7 +212,6 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider { }); } - await timer(3000); } } diff --git a/package-lock.json b/package-lock.json index 1130b5f1..480fe6a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22270,9 +22270,10 @@ } }, "node_modules/http-proxy-middleware": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-3.0.2.tgz", - "integrity": "sha512-fBLFpmvDzlxdckwZRjM0wWtwDZ4KBtQ8NFqhrFKoEtK4myzuiumBuNTxD+F4cVbXfOZljIbrynmvByofDzT7Ag==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-3.0.3.tgz", + "integrity": "sha512-usY0HG5nyDUwtqpiZdETNbmKtw3QQ1jwYFZ9wi5iHzX2BcILwQKtYDJPo7XHTsu5Z0B2Hj3W9NNnbd+AjFWjqg==", + "license": "MIT", "dependencies": { "@types/http-proxy": "^1.17.15", "debug": "^4.3.6", @@ -31760,9 +31761,9 @@ } }, "node_modules/polotno": { - "version": "2.14.3", - "resolved": "https://registry.npmjs.org/polotno/-/polotno-2.14.3.tgz", - "integrity": "sha512-CYf5BmK12wAYpnFnHpe8gSoYksPr5RmJQXHAib00Fx09FSG47jLzVC+R/v7CpDrcOW/1CpQqONz1po0D245xjA==", + "version": "2.14.4", + "resolved": "https://registry.npmjs.org/polotno/-/polotno-2.14.4.tgz", + "integrity": "sha512-Wq6j1BKkBWtSCILHAv04UnJp+F3MvriIo9N65wMRniPcNbwPY1IxhkEJ9co0AaPrQHmOiu25BOl5isYhH5jc4w==", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "@blueprintjs/core": "5.12.0", @@ -39011,9 +39012,10 @@ } }, "node_modules/webpack-dev-server/node_modules/http-proxy-middleware": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", - "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz", + "integrity": "sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==", + "license": "MIT", "dependencies": { "@types/http-proxy": "^1.17.8", "http-proxy": "^1.18.1",