diff --git a/apps/frontend/src/app/(app)/layout.tsx b/apps/frontend/src/app/(app)/layout.tsx
index 5d044b79..ebcc5700 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_TEMPLATE
diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx
index aa45b651..0e3f5595 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 plugins
extend(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<{
>
{' '}
-
{
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.ts
index 026bb4ef..328c2870 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.ts
index da5ad6de..67c64199 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.ts
index cb61de76..ea821d2e 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.ts
index 63a77471..d1ecc284 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
{
+ 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.tsx
index 98a8ab84..968b5096 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: [],