feat: disable x
This commit is contained in:
parent
7c70bc7c79
commit
58b5fe1b5c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<{
|
|||
>
|
||||
<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>
|
||||
)}{' '}
|
||||
<div
|
||||
className={clsx(
|
||||
'hidden group-hover:block hover:underline cursor-pointer',
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export function Plug(params: {
|
|||
description: string;
|
||||
runEveryMilliseconds: number;
|
||||
totalRuns: number;
|
||||
disabled?: boolean;
|
||||
fields: {
|
||||
name: string;
|
||||
description: string;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'reflect-metadata';
|
|||
export function PostPlug(params: {
|
||||
identifier: string;
|
||||
title: string;
|
||||
disabled?: boolean;
|
||||
description: string;
|
||||
pickIntegration: string[];
|
||||
fields: {
|
||||
|
|
|
|||
|
|
@ -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) || [],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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: [],
|
||||
|
|
|
|||
Loading…
Reference in New Issue