mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: added project automation events
This commit is contained in:
parent
38fbf1f513
commit
604b9c7632
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProject, useUser } from "hooks/store";
|
import { useEventTracker, useProject, useUser } from "hooks/store";
|
||||||
// component
|
// component
|
||||||
import { CustomSelect, Loader, ToggleSwitch } from "@plane/ui";
|
import { CustomSelect, Loader, ToggleSwitch } from "@plane/ui";
|
||||||
import { SelectMonthModal } from "components/automation";
|
import { SelectMonthModal } from "components/automation";
|
||||||
@ -11,6 +11,7 @@ import { ArchiveRestore } from "lucide-react";
|
|||||||
import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "constants/project";
|
import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "constants/project";
|
||||||
// types
|
// types
|
||||||
import { IProject } from "@plane/types";
|
import { IProject } from "@plane/types";
|
||||||
|
import { AUTO_ARCHIVE_TOGGLED, AUTO_ARCHIVE_UPDATED } from "constants/event-tracker";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
handleChange: (formData: Partial<IProject>) => Promise<void>;
|
handleChange: (formData: Partial<IProject>) => Promise<void>;
|
||||||
@ -27,6 +28,7 @@ export const AutoArchiveAutomation: React.FC<Props> = observer((props) => {
|
|||||||
membership: { currentProjectRole },
|
membership: { currentProjectRole },
|
||||||
} = useUser();
|
} = useUser();
|
||||||
const { currentProjectDetails } = useProject();
|
const { currentProjectDetails } = useProject();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
|
||||||
const isAdmin = currentProjectRole === EUserProjectRoles.ADMIN;
|
const isAdmin = currentProjectRole === EUserProjectRoles.ADMIN;
|
||||||
|
|
||||||
@ -54,11 +56,16 @@ export const AutoArchiveAutomation: React.FC<Props> = observer((props) => {
|
|||||||
</div>
|
</div>
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
value={currentProjectDetails?.archive_in !== 0}
|
value={currentProjectDetails?.archive_in !== 0}
|
||||||
onChange={() =>
|
onChange={() => {
|
||||||
currentProjectDetails?.archive_in === 0
|
currentProjectDetails?.archive_in === 0
|
||||||
? handleChange({ archive_in: 1 })
|
? handleChange({ archive_in: 1 })
|
||||||
: handleChange({ archive_in: 0 })
|
: handleChange({ archive_in: 0 });
|
||||||
}
|
|
||||||
|
captureEvent(AUTO_ARCHIVE_TOGGLED, {
|
||||||
|
toggle: currentProjectDetails?.archive_in === 0 ? "true" : "false",
|
||||||
|
range: `${currentProjectDetails?.archive_in == 0 ? 1 : 0} month`,
|
||||||
|
});
|
||||||
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
disabled={!isAdmin}
|
disabled={!isAdmin}
|
||||||
/>
|
/>
|
||||||
@ -76,6 +83,9 @@ export const AutoArchiveAutomation: React.FC<Props> = observer((props) => {
|
|||||||
currentProjectDetails?.archive_in === 1 ? "month" : "months"
|
currentProjectDetails?.archive_in === 1 ? "month" : "months"
|
||||||
}`}
|
}`}
|
||||||
onChange={(val: number) => {
|
onChange={(val: number) => {
|
||||||
|
captureEvent(AUTO_ARCHIVE_UPDATED, {
|
||||||
|
range: val === 1 ? "1 month" : `${val} months`,
|
||||||
|
});
|
||||||
handleChange({ archive_in: val });
|
handleChange({ archive_in: val });
|
||||||
}}
|
}}
|
||||||
input
|
input
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProject, useProjectState, useUser } from "hooks/store";
|
import { useEventTracker, useProject, useProjectState, useUser } from "hooks/store";
|
||||||
// component
|
// component
|
||||||
import { SelectMonthModal } from "components/automation";
|
import { SelectMonthModal } from "components/automation";
|
||||||
import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui";
|
import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui";
|
||||||
@ -11,6 +11,7 @@ import { ArchiveX } from "lucide-react";
|
|||||||
import { IProject } from "@plane/types";
|
import { IProject } from "@plane/types";
|
||||||
// constants
|
// constants
|
||||||
import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "constants/project";
|
import { EUserProjectRoles, PROJECT_AUTOMATION_MONTHS } from "constants/project";
|
||||||
|
import { AUTO_CLOSE_Toggled, AUTO_CLOSE_UPDATED } from "constants/event-tracker";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
handleChange: (formData: Partial<IProject>) => Promise<void>;
|
handleChange: (formData: Partial<IProject>) => Promise<void>;
|
||||||
@ -26,6 +27,7 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
|
|||||||
} = useUser();
|
} = useUser();
|
||||||
const { currentProjectDetails } = useProject();
|
const { currentProjectDetails } = useProject();
|
||||||
const { projectStates } = useProjectState();
|
const { projectStates } = useProjectState();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
|
||||||
// const stateGroups = projectStateStore.groupedProjectStates ?? undefined;
|
// const stateGroups = projectStateStore.groupedProjectStates ?? undefined;
|
||||||
|
|
||||||
@ -80,11 +82,17 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
|
|||||||
</div>
|
</div>
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
value={currentProjectDetails?.close_in !== 0}
|
value={currentProjectDetails?.close_in !== 0}
|
||||||
onChange={() =>
|
onChange={() => {
|
||||||
currentProjectDetails?.close_in === 0
|
currentProjectDetails?.close_in === 0
|
||||||
? handleChange({ close_in: 1, default_state: defaultState })
|
? handleChange({ close_in: 1, default_state: defaultState })
|
||||||
: handleChange({ close_in: 0, default_state: null })
|
: handleChange({ close_in: 0, default_state: null });
|
||||||
}
|
|
||||||
|
captureEvent(AUTO_CLOSE_Toggled, {
|
||||||
|
toggle: currentProjectDetails?.close_in === 0 ? "true" : "false",
|
||||||
|
range: `${currentProjectDetails?.close_in == 0 ? 1 : 0} month`,
|
||||||
|
state: currentProjectDetails?.close_in === 0 ? undefined : defaultState,
|
||||||
|
});
|
||||||
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
disabled={!isAdmin}
|
disabled={!isAdmin}
|
||||||
/>
|
/>
|
||||||
@ -104,6 +112,10 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
|
|||||||
}`}
|
}`}
|
||||||
onChange={(val: number) => {
|
onChange={(val: number) => {
|
||||||
handleChange({ close_in: val });
|
handleChange({ close_in: val });
|
||||||
|
captureEvent(AUTO_CLOSE_UPDATED, {
|
||||||
|
range: val === 1 ? "1 month" : `${val} months`,
|
||||||
|
state: currentProjectDetails?.default_state,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
input
|
input
|
||||||
disabled={!isAdmin}
|
disabled={!isAdmin}
|
||||||
|
@ -237,6 +237,11 @@ export const LABEL_DELETED = "Label deleted";
|
|||||||
export const LABEL_GROUP_DELETED = "Label group deleted";
|
export const LABEL_GROUP_DELETED = "Label group deleted";
|
||||||
export const LABEL_ADDED_G = "Label added to group";
|
export const LABEL_ADDED_G = "Label added to group";
|
||||||
export const LABEL_REMOVED_G = "Label removed from group";
|
export const LABEL_REMOVED_G = "Label removed from group";
|
||||||
|
// Project Automation events
|
||||||
|
export const AUTO_ARCHIVE_TOGGLED = "Auto archive toggled";
|
||||||
|
export const AUTO_ARCHIVE_UPDATED = "Auto archive updated";
|
||||||
|
export const AUTO_CLOSE_Toggled = "Auto close toggled";
|
||||||
|
export const AUTO_CLOSE_UPDATED = "Auto close updated";
|
||||||
// Project Page Events
|
// Project Page Events
|
||||||
export const PAGE_CREATED = "Page created";
|
export const PAGE_CREATED = "Page created";
|
||||||
export const PAGE_UPDATED = "Page updated";
|
export const PAGE_UPDATED = "Page updated";
|
||||||
|
Loading…
Reference in New Issue
Block a user