[WEB-4407] chore: add project page creation event tracking #7378
This commit is contained in:
parent
6d01622663
commit
db2f783d33
1 changed files with 24 additions and 4 deletions
|
|
@ -4,11 +4,18 @@ import { useState } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { useParams, useRouter, useSearchParams } from "next/navigation";
|
import { useParams, useRouter, useSearchParams } from "next/navigation";
|
||||||
// constants
|
// constants
|
||||||
import { EPageAccess, EProjectFeatureKey, PROJECT_TRACKER_ELEMENTS } from "@plane/constants";
|
import {
|
||||||
|
EPageAccess,
|
||||||
|
EProjectFeatureKey,
|
||||||
|
PROJECT_PAGE_TRACKER_EVENTS,
|
||||||
|
PROJECT_TRACKER_ELEMENTS,
|
||||||
|
} from "@plane/constants";
|
||||||
// plane types
|
// plane types
|
||||||
import { TPage } from "@plane/types";
|
import { TPage } from "@plane/types";
|
||||||
// plane ui
|
// plane ui
|
||||||
import { Breadcrumbs, Button, Header, setToast, TOAST_TYPE } from "@plane/ui";
|
import { Breadcrumbs, Button, Header, setToast, TOAST_TYPE } from "@plane/ui";
|
||||||
|
// helpers
|
||||||
|
import { captureError, captureSuccess } from "@/helpers/event-tracker.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProject } from "@/hooks/store";
|
import { useProject } from "@/hooks/store";
|
||||||
// plane web
|
// plane web
|
||||||
|
|
@ -37,16 +44,29 @@ export const PagesListHeader = observer(() => {
|
||||||
|
|
||||||
await createPage(payload)
|
await createPage(payload)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
captureSuccess({
|
||||||
|
eventName: PROJECT_PAGE_TRACKER_EVENTS.create,
|
||||||
|
payload: {
|
||||||
|
id: res?.id,
|
||||||
|
state: "SUCCESS",
|
||||||
|
},
|
||||||
|
});
|
||||||
const pageId = `/${workspaceSlug}/projects/${currentProjectDetails?.id}/pages/${res?.id}`;
|
const pageId = `/${workspaceSlug}/projects/${currentProjectDetails?.id}/pages/${res?.id}`;
|
||||||
router.push(pageId);
|
router.push(pageId);
|
||||||
})
|
})
|
||||||
.catch((err) =>
|
.catch((err) => {
|
||||||
|
captureError({
|
||||||
|
eventName: PROJECT_PAGE_TRACKER_EVENTS.create,
|
||||||
|
payload: {
|
||||||
|
state: "ERROR",
|
||||||
|
},
|
||||||
|
});
|
||||||
setToast({
|
setToast({
|
||||||
type: TOAST_TYPE.ERROR,
|
type: TOAST_TYPE.ERROR,
|
||||||
title: "Error!",
|
title: "Error!",
|
||||||
message: err?.data?.error || "Page could not be created. Please try again.",
|
message: err?.data?.error || "Page could not be created. Please try again.",
|
||||||
|
});
|
||||||
})
|
})
|
||||||
)
|
|
||||||
.finally(() => setIsCreatingPage(false));
|
.finally(() => setIsCreatingPage(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue