π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: disable x
Nevo David58b5fe1b5cd7
diff --git a/apps/frontend/src/app/(app)/layout.tsx b/apps/frontend/src/app/(app)/layout.tsxindex 5d044b793..ebcc5700b 100644--- a/apps/frontend/src/app/(app)/layout.tsx+++ b/apps/frontend/src/app/(app)/layout.tsx@@ -54,6 +54,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {neynarClientId={process.env.NEYNAR_CLIENT_ID!}isSecured={!process.env.NOT_SECURED}disableImageCompression={!!process.env.DISABLE_IMAGE_COMPRESSION}+ disableXAnalytics={!!process.env.DISABLE_X_ANALYTICS}language={allHeaders.get(headerName)}transloadit={process.env.TRANSLOADIT_AUTH && process.env.TRANSLOADIT_TEMPLATEdiff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsxindex aa45b6516..0e3f55953 100644--- a/apps/frontend/src/components/launches/calendar.tsx+++ b/apps/frontend/src/components/launches/calendar.tsx@@ -54,6 +54,7 @@ import { useT } from '@gitroom/react/translation/get.transation.service.client';import i18next from 'i18next';import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.modal';import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';+import { useVariables } from '@gitroom/react/helpers/variable.context';// Extend dayjs with necessary pluginsextend(isSameOrAfter);@@ -837,6 +838,7 @@ const CalendarItem: FC<{display,deletePost,} = props;+ const { disableXAnalytics } = useVariables();const preview = useCallback(() => {window.open(`/p/` + post.id + '?share=true', '_blank');}, [post]);@@ -896,15 +898,19 @@ const CalendarItem: FC<{><Preview /></div>{' '}- <div- className={clsx(- 'hidden group-hover:block hover:underline cursor-pointer',- post?.tags?.[0]?.tag?.color && 'mix-blend-difference'- )}- onClick={statistics}- >- <Statistics />- </div>{' '}+ {post.integration.providerIdentifier === 'x' && disableXAnalytics ? (+ <></>+ ) : (+ <div+ className={clsx(+ 'hidden group-hover:block hover:underline cursor-pointer',+ post?.tags?.[0]?.tag?.color && 'mix-blend-difference'+ )}+ onClick={statistics}+ >+ <Statistics />+ </div>+ )}{' '}<divclassName={clsx('hidden group-hover:block hover:underline cursor-pointer',diff --git a/apps/frontend/src/components/platform-analytics/platform.analytics.tsx b/apps/frontend/src/components/platform-analytics/platform.analytics.tsxindex fa8c7536a..0b68723ba 100644--- a/apps/frontend/src/components/platform-analytics/platform.analytics.tsx+++ b/apps/frontend/src/components/platform-analytics/platform.analytics.tsx@@ -13,6 +13,7 @@ import { Button } from '@gitroom/react/form/button';import { useRouter } from 'next/navigation';import { useToaster } from '@gitroom/react/toaster/toaster';import { useT } from '@gitroom/react/translation/get.transation.service.client';+import { useVariables } from '@gitroom/react/helpers/variable.context';const allowedIntegrations = ['facebook','instagram',@@ -28,12 +29,21 @@ export const PlatformAnalytics = () => {const fetch = useFetch();const t = useT();const router = useRouter();+ const { disableXAnalytics } = useVariables();+const [current, setCurrent] = useState(0);const [key, setKey] = useState(7);const [refresh, setRefresh] = useState(false);const toaster = useToaster();const load = useCallback(async () => {- const int = (await (await fetch('/integrations/list')).json()).integrations;+ const int = (+ await (await fetch('/integrations/list')).json()+ ).integrations.filter((f: any) => {+ if (f.identifier === 'x' && disableXAnalytics) {+ return false;+ }+ return true;+ });return int.filter((f: any) => allowedIntegrations.includes(f.identifier));}, []);const { data, isLoading } = useSWR('analytics-list', load, {diff --git a/libraries/helpers/src/decorators/plug.decorator.ts b/libraries/helpers/src/decorators/plug.decorator.tsindex 026bb4ef8..328c28707 100644--- a/libraries/helpers/src/decorators/plug.decorator.ts+++ b/libraries/helpers/src/decorators/plug.decorator.ts@@ -6,6 +6,7 @@ export function Plug(params: {description: string;runEveryMilliseconds: number;totalRuns: number;+ disabled?: boolean;fields: {name: string;description: string;diff --git a/libraries/helpers/src/decorators/post.plug.ts b/libraries/helpers/src/decorators/post.plug.tsindex da5ad6de1..67c641997 100644--- a/libraries/helpers/src/decorators/post.plug.ts+++ b/libraries/helpers/src/decorators/post.plug.ts@@ -3,6 +3,7 @@ import 'reflect-metadata';export function PostPlug(params: {identifier: string;title: string;+ disabled?: boolean;description: string;pickIntegration: string[];fields: {diff --git a/libraries/nestjs-libraries/src/integrations/integration.manager.ts b/libraries/nestjs-libraries/src/integrations/integration.manager.tsindex cb61de76d..ea821d2e2 100644--- a/libraries/nestjs-libraries/src/integrations/integration.manager.ts+++ b/libraries/nestjs-libraries/src/integrations/integration.manager.ts@@ -88,13 +88,15 @@ export class IntegrationManager {identifier: p.identifier,plugs: (Reflect.getMetadata('custom:plug', p.constructor.prototype) || []- ).map((p: any) => ({- ...p,- fields: p.fields.map((c: any) => ({- ...c,- validation: c?.validation?.toString(),+ )+ .filter((f) => !f.disabled)+ .map((p: any) => ({+ ...p,+ fields: p.fields.map((c: any) => ({+ ...c,+ validation: c?.validation?.toString(),+ })),})),- })),};}).filter((f) => f.plugs.length);@@ -104,8 +106,12 @@ export class IntegrationManager {const p = socialIntegrationList.find((p) => p.identifier === providerName)!;return {internalPlugs:- Reflect.getMetadata('custom:internal_plug', p.constructor.prototype) ||- [],+ (+ Reflect.getMetadata(+ 'custom:internal_plug',+ p.constructor.prototype+ ) || []+ ).filter((f) => !f.disabled) || [],};}diff --git a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts b/libraries/nestjs-libraries/src/integrations/social/x.provider.tsindex 63a77471d..d1ecc2842 100644--- a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts+++ b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts@@ -28,6 +28,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {@Plug({identifier: 'x-autoRepostPost',title: 'Auto Repost Posts',+ disabled: !!process.env.DISABLE_X_ANALYTICS,description:'When a post reached a certain number of likes, repost it to increase engagement (1 week old posts)',runEveryMilliseconds: 21600000,@@ -72,6 +73,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {@PostPlug({identifier: 'x-repost-post-users',title: 'Add Re-posters',+ disabled: !!process.env.DISABLE_X_ANALYTICS,description: 'Add accounts to repost your post',pickIntegration: ['x'],fields: [],@@ -104,6 +106,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {@Plug({identifier: 'x-autoPlugPost',title: 'Auto plug post',+ disabled: !!process.env.DISABLE_X_ANALYTICS,description:'When a post reached a certain number of likes, add another post to it so you followers get a notification about your promotion',runEveryMilliseconds: 21600000,@@ -175,7 +178,8 @@ export class XProvider extends SocialAbstract implements SocialProvider {});const { url, oauth_token, oauth_token_secret } =await client.generateAuthLink(- (process.env.X_URL || process.env.FRONTEND_URL) + `/integrations/social/x`,+ (process.env.X_URL || process.env.FRONTEND_URL) ++ `/integrations/social/x`,{authAccessType: 'write',linkMode: 'authenticate',@@ -409,6 +413,10 @@ export class XProvider extends SocialAbstract implements SocialProvider {accessToken: string,date: number): Promise<AnalyticsData[]> {+ if (process.env.DISABLE_X_ANALYTICS) {+ return [];+ }+const until = dayjs().endOf('day');const since = dayjs().subtract(date, 'day');diff --git a/libraries/react-shared-libraries/src/helpers/variable.context.tsx b/libraries/react-shared-libraries/src/helpers/variable.context.tsxindex 98a8ab847..968b50961 100644--- a/libraries/react-shared-libraries/src/helpers/variable.context.tsx+++ b/libraries/react-shared-libraries/src/helpers/variable.context.tsx@@ -18,6 +18,7 @@ interface VariableContextInterface {neynarClientId: string;isSecured: boolean;disableImageCompression: boolean;+ disableXAnalytics: boolean;language: string;tolt: string;transloadit: string[];@@ -39,6 +40,7 @@ const VariableContext = createContext({facebookPixel: '',neynarClientId: '',disableImageCompression: false,+ disableXAnalytics: false,language: '',tolt: '',transloadit: [],