Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: new analytic events #699

Merged
merged 6 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/app/components/core/board-view/single-issue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
TrashIcon,
XMarkIcon,
ArrowTopRightOnSquareIcon,

} from "@heroicons/react/24/outline";
// helpers
import { handleIssuesMutation } from "constants/issue";
Expand Down
19 changes: 18 additions & 1 deletion apps/app/components/core/issues-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DragDropContext, DropResult } from "react-beautiful-dnd";
import issuesService from "services/issues.service";
import stateService from "services/state.service";
import modulesService from "services/modules.service";
import trackEventServices from "services/track-event.service";
// hooks
import useToast from "hooks/use-toast";
import useIssuesView from "hooks/use-issues-view";
Expand Down Expand Up @@ -259,7 +260,22 @@ export const IssuesView: React.FC<Props> = ({
state: draggedItem.state,
sort_order: draggedItem.sort_order,
})
.then(() => {
.then((response) => {
const sourceStateBeforeDrag = states.find((state) => state.name === source.droppableId);

if (
sourceStateBeforeDrag?.group !== "completed" &&
response?.state_detail?.group === "completed"
)
trackEventServices.trackIssueMarkedAsDoneEvent({
workspaceSlug,
workspaceId: draggedItem.workspace_detail.id,
projectName: draggedItem.project_detail.name,
projectIdentifier: draggedItem.project_detail.identifier,
projectId,
issueId: draggedItem.id,
});

if (cycleId) {
mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params));
mutate(CYCLE_DETAILS(cycleId as string));
Expand All @@ -282,6 +298,7 @@ export const IssuesView: React.FC<Props> = ({
orderBy,
handleDeleteIssue,
params,
states,
]
);

Expand Down
13 changes: 13 additions & 0 deletions apps/app/components/issues/view-select/assignee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useSWR from "swr";

// services
import projectService from "services/project.service";
import trackEventServices from "services/track-event.service";
// ui
import { AssigneesList, Avatar, CustomSearchSelect, Tooltip } from "components/ui";
// icons
Expand Down Expand Up @@ -71,6 +72,18 @@ export const ViewAssigneeSelect: React.FC<Props> = ({
else newData.push(data);

partialUpdateIssue({ assignees_list: data });

trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_ASSIGNEE"
);
}}
options={options}
label={
Expand Down
19 changes: 16 additions & 3 deletions apps/app/components/issues/view-select/due-date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { CustomDatePicker, Tooltip } from "components/ui";
// helpers
import { findHowManyDaysLeft } from "helpers/date-time.helper";
// services
import trackEventServices from "services/track-event.service";
// types
import { IIssue } from "types";

Expand All @@ -25,13 +27,24 @@ export const ViewDueDateSelect: React.FC<Props> = ({ issue, partialUpdateIssue,
<CustomDatePicker
placeholder="N/A"
value={issue?.target_date}
onChange={(val) =>
onChange={(val) => {
partialUpdateIssue({
target_date: val,
priority: issue.priority,
state: issue.state,
})
}
});
trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_DUE_DATE"
);
}}
className={issue?.target_date ? "w-[6.5rem]" : "w-[3rem] text-center"}
disabled={isNotAllowed}
/>
Expand Down
19 changes: 16 additions & 3 deletions apps/app/components/issues/view-select/priority.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getPriorityIcon } from "components/icons/priority-icon";
import { IIssue } from "types";
// constants
import { PRIORITIES } from "constants/project";
// services
import trackEventServices from "services/track-event.service";

type Props = {
issue: IIssue;
Expand All @@ -26,9 +28,20 @@ export const ViewPrioritySelect: React.FC<Props> = ({
}) => (
<CustomSelect
value={issue.priority}
onChange={(data: string) =>
partialUpdateIssue({ priority: data, state: issue.state, target_date: issue.target_date })
}
onChange={(data: string) => {
partialUpdateIssue({ priority: data, state: issue.state, target_date: issue.target_date });
trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_PRIORITY"
);
}}
maxHeight="md"
customButton={
<button
Expand Down
32 changes: 29 additions & 3 deletions apps/app/components/issues/view-select/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useSWR from "swr";

// services
import stateService from "services/state.service";
import trackEventServices from "services/track-event.service";
// ui
import { CustomSearchSelect, Tooltip } from "components/ui";
// icons
Expand Down Expand Up @@ -58,13 +59,38 @@ export const ViewStateSelect: React.FC<Props> = ({
return (
<CustomSearchSelect
value={issue.state}
onChange={(data: string) =>
onChange={(data: string) => {
partialUpdateIssue({
state: data,
priority: issue.priority,
target_date: issue.target_date,
})
}
});
trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_STATE"
);

const oldState = states.find((s) => s.id === issue.state);
const newState = states.find((s) => s.id === data);

if (oldState?.group !== "completed" && newState?.group !== "completed") {
trackEventServices.trackIssueMarkedAsDoneEvent({
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
});
}
}}
options={options}
label={
<Tooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useSWR, { mutate } from "swr";

// services
import projectService from "services/project.service";
import trackEventServices from "services/track-event.service";
// lib
import { requiredAdmin } from "lib/auth";
// layouts
Expand Down Expand Up @@ -112,7 +113,19 @@ const FeaturesSettings: NextPage<UserAuth> = (props) => {
}`}
role="switch"
aria-checked={projectDetails?.cycle_view}
onClick={() => handleSubmit({ cycle_view: !projectDetails?.cycle_view })}
onClick={() => {
trackEventServices.trackMiscellaneousEvent(
{
workspaceId: (projectDetails?.workspace as any)?.id,
workspaceSlug,
projectId,
projectIdentifier: projectDetails?.identifier,
projectName: projectDetails?.name,
},
!projectDetails?.cycle_view ? "TOGGLE_CYCLE_ON" : "TOGGLE_CYCLE_OFF"
);
handleSubmit({ cycle_view: !projectDetails?.cycle_view });
}}
>
<span className="sr-only">Use cycles</span>
<span
Expand Down Expand Up @@ -141,7 +154,19 @@ const FeaturesSettings: NextPage<UserAuth> = (props) => {
}`}
role="switch"
aria-checked={projectDetails?.module_view}
onClick={() => handleSubmit({ module_view: !projectDetails?.module_view })}
onClick={() => {
trackEventServices.trackMiscellaneousEvent(
{
workspaceId: (projectDetails?.workspace as any)?.id,
workspaceSlug,
projectId,
projectIdentifier: projectDetails?.identifier,
projectName: projectDetails?.name,
},
!projectDetails?.module_view ? "TOGGLE_MODULE_ON" : "TOGGLE_MODULE_OFF"
);
handleSubmit({ module_view: !projectDetails?.module_view });
}}
>
<span className="sr-only">Use cycles</span>
<span
Expand Down Expand Up @@ -170,7 +195,19 @@ const FeaturesSettings: NextPage<UserAuth> = (props) => {
}`}
role="switch"
aria-checked={projectDetails?.issue_views_view}
onClick={() => handleSubmit({ issue_views_view: !projectDetails?.issue_views_view })}
onClick={() => {
trackEventServices.trackMiscellaneousEvent(
{
workspaceId: (projectDetails?.workspace as any)?.id,
workspaceSlug,
projectId,
projectIdentifier: projectDetails?.identifier,
projectName: projectDetails?.name,
},
!projectDetails?.issue_views_view ? "TOGGLE_VIEW_ON" : "TOGGLE_VIEW_OFF"
);
handleSubmit({ issue_views_view: !projectDetails?.issue_views_view });
}}
>
<span className="sr-only">Use views</span>
<span
Expand Down Expand Up @@ -199,7 +236,19 @@ const FeaturesSettings: NextPage<UserAuth> = (props) => {
}`}
role="switch"
aria-checked={projectDetails?.page_view}
onClick={() => handleSubmit({ page_view: !projectDetails?.page_view })}
onClick={() => {
trackEventServices.trackMiscellaneousEvent(
{
workspaceId: (projectDetails?.workspace as any)?.id,
workspaceSlug,
projectId,
projectIdentifier: projectDetails?.identifier,
projectName: projectDetails?.name,
},
!projectDetails?.page_view ? "TOGGLE_PAGES_ON" : "TOGGLE_PAGES_OFF"
);
handleSubmit({ page_view: !projectDetails?.page_view });
}}
>
<span className="sr-only">Use cycles</span>
<span
Expand Down
Loading