chore: remove posthog events (#8465)
* chore: remove posthog events * chore: remove event tracking * chore: lint errors * chore: minor changes based on comments * fix: type errors
This commit is contained in:
parent
a37e5e2f6a
commit
d61b157929
144 changed files with 586 additions and 3397 deletions
|
|
@ -1,12 +1,9 @@
|
|||
import { useMemo } from "react";
|
||||
// plane imports
|
||||
import { IS_FAVORITE_MENU_OPEN, PROJECT_PAGE_TRACKER_EVENTS } from "@plane/constants";
|
||||
import type { EditorRefApi } from "@plane/editor";
|
||||
import { IS_FAVORITE_MENU_OPEN } from "@plane/constants";
|
||||
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
|
||||
import { EPageAccess } from "@plane/types";
|
||||
import { copyUrlToClipboard } from "@plane/utils";
|
||||
// helpers
|
||||
import { captureSuccess, captureError } from "@/helpers/event-tracker.helper";
|
||||
// hooks
|
||||
import { useCollaborativePageActions } from "@/hooks/use-collaborative-page-actions";
|
||||
// store types
|
||||
|
|
@ -57,35 +54,23 @@ export const usePageOperations = (
|
|||
const pageLink = getRedirectionLink();
|
||||
|
||||
return {
|
||||
copyLink: () => {
|
||||
copyUrlToClipboard(pageLink).then(() => {
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Link Copied!",
|
||||
message: "Page link copied to clipboard.",
|
||||
});
|
||||
copyLink: async () => {
|
||||
await copyUrlToClipboard(pageLink);
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Link Copied!",
|
||||
message: "Page link copied to clipboard.",
|
||||
});
|
||||
},
|
||||
duplicate: async () => {
|
||||
try {
|
||||
await duplicate();
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.duplicate,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page duplicated successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.duplicate,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -97,33 +82,16 @@ export const usePageOperations = (
|
|||
openInNewTab: () => window.open(pageLink, "_blank"),
|
||||
toggleAccess: async () => {
|
||||
const changedPageType = access === EPageAccess.PUBLIC ? "private" : "public";
|
||||
const eventName = PROJECT_PAGE_TRACKER_EVENTS.access_update;
|
||||
|
||||
try {
|
||||
if (access === EPageAccess.PUBLIC)
|
||||
await executeCollaborativeAction({ type: "sendMessageToServer", message: "make-private" });
|
||||
else await executeCollaborativeAction({ type: "sendMessageToServer", message: "make-public" });
|
||||
|
||||
captureSuccess({
|
||||
eventName,
|
||||
payload: {
|
||||
id: page.id,
|
||||
from_access: access === EPageAccess.PUBLIC ? "Public" : "Private",
|
||||
to_access: access === EPageAccess.PUBLIC ? "Private" : "Public",
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: `The page has been marked ${changedPageType} and moved to the ${changedPageType} section.`,
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -135,23 +103,12 @@ export const usePageOperations = (
|
|||
if (archived_at) {
|
||||
try {
|
||||
await executeCollaborativeAction({ type: "sendMessageToServer", message: "unarchive" });
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.restore,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page restored successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.restore,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -161,23 +118,12 @@ export const usePageOperations = (
|
|||
} else {
|
||||
try {
|
||||
await executeCollaborativeAction({ type: "sendMessageToServer", message: "archive" });
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.archive,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page archived successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.archive,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -186,75 +132,50 @@ export const usePageOperations = (
|
|||
}
|
||||
}
|
||||
},
|
||||
toggleFavorite: () => {
|
||||
toggleFavorite: async () => {
|
||||
if (is_favorite) {
|
||||
removePageFromFavorites()
|
||||
.then(() => {
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.unfavorite,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page removed from favorites.",
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.unfavorite,
|
||||
error,
|
||||
});
|
||||
try {
|
||||
await removePageFromFavorites();
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page removed from favorites.",
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
message: "Page could not be removed from favorites. Please try again later.",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
addToFavorites()
|
||||
.then(() => {
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.favorite,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
if (!isFavoriteMenuOpen) toggleFavoriteMenu(true);
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page added to favorites.",
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.favorite,
|
||||
error,
|
||||
});
|
||||
try {
|
||||
await addToFavorites();
|
||||
if (!isFavoriteMenuOpen) toggleFavoriteMenu(true);
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page added to favorites.",
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
message: "Page could not be added to favorites. Please try again later.",
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
toggleLock: async () => {
|
||||
if (is_locked) {
|
||||
try {
|
||||
await executeCollaborativeAction({ type: "sendMessageToServer", message: "unlock" });
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.unlock,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page unlocked successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.unlock,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -264,23 +185,12 @@ export const usePageOperations = (
|
|||
} else {
|
||||
try {
|
||||
await executeCollaborativeAction({ type: "sendMessageToServer", message: "lock" });
|
||||
captureSuccess({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.lock,
|
||||
payload: {
|
||||
id: page.id,
|
||||
state: "SUCCESS",
|
||||
},
|
||||
});
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: "Page locked successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
captureError({
|
||||
eventName: PROJECT_PAGE_TRACKER_EVENTS.lock,
|
||||
error,
|
||||
});
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
title: "Error!",
|
||||
|
|
@ -300,7 +210,6 @@ export const usePageOperations = (
|
|||
is_favorite,
|
||||
is_locked,
|
||||
isFavoriteMenuOpen,
|
||||
page.id,
|
||||
removePageFromFavorites,
|
||||
toggleFavoriteMenu,
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue