chore: issues-list open event refactored

This commit is contained in:
LAKHAN BAHETI 2024-02-22 15:42:01 +05:30
parent 8886aface1
commit 238d437692
8 changed files with 47 additions and 12 deletions

View File

@ -28,7 +28,11 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => {
async () => { async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: projectId,
});
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -40,7 +40,11 @@ export const CycleLayoutRoot: React.FC = observer(() => {
async () => { async () => {
if (workspaceSlug && projectId && cycleId) { if (workspaceSlug && projectId && cycleId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: cycleId,
});
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -28,7 +28,11 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => {
async () => { async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: projectId,
});
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -37,7 +37,11 @@ export const ModuleLayoutRoot: React.FC = observer(() => {
async () => { async () => {
if (workspaceSlug && projectId && moduleId) { if (workspaceSlug && projectId && moduleId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: moduleId,
})
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -33,7 +33,11 @@ export const ProjectLayoutRoot: FC = observer(() => {
useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_${workspaceSlug}_${projectId}` : null, async () => { useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_${workspaceSlug}_${projectId}` : null, async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: projectId,
});
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -35,7 +35,11 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => {
async () => { async () => {
if (workspaceSlug && projectId && viewId) { if (workspaceSlug && projectId && viewId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString()); await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString());
captureIssuesListOpenedEvent(router.asPath, issuesFilter?.issueFilters?.filters); captureIssuesListOpenedEvent({
path: router.asPath,
filters: issuesFilter?.issueFilters?.filters,
element_id: viewId,
});
await issues?.fetchIssues( await issues?.fetchIssues(
workspaceSlug.toString(), workspaceSlug.toString(),
projectId.toString(), projectId.toString(),

View File

@ -123,6 +123,16 @@ export const getProjectStateEventPayload = (payload: any) => {
export const getIssuesListOpenedPayload = (payload: any) => ({ export const getIssuesListOpenedPayload = (payload: any) => ({
element: elementFromPath(payload.path), element: elementFromPath(payload.path),
element_id: payload.element_id,
type: payload.project_id ? "Project" : "Workspace",
layout: payload?.displayFilters?.layout,
filters: payload?.filters,
display_properties: payload?.displayProperties,
});
export const getIssuesFilterEventPayload = (payload: any) => ({
element: elementFromPath(payload.path),
element_id: payload.element_id,
type: payload.project_id ? "Project" : "Workspace", type: payload.project_id ? "Project" : "Workspace",
layout: payload?.displayFilters?.layout, layout: payload?.displayFilters?.layout,
filters: payload?.filters, filters: payload?.filters,
@ -176,6 +186,10 @@ export const ISSUE_DELETED = "Issue deleted";
// Issue Checkout Events // Issue Checkout Events
export const ISSUES_LIST_OPENED = "Issues list opened"; export const ISSUES_LIST_OPENED = "Issues list opened";
export const ISSUE_OPENED = "Issue opened"; export const ISSUE_OPENED = "Issue opened";
// Issues Filter Events
export const FILTER_APPLIED = "Filter applied";
export const FILTER_REMOVED = "Filter removed";
export const FILTER_SEARCHED = "Filter searched";
// Project State Events // Project State Events
export const STATE_CREATED = "State created"; export const STATE_CREATED = "State created";
export const STATE_UPDATED = "State updated"; export const STATE_UPDATED = "State updated";

View File

@ -39,7 +39,7 @@ export interface IEventTrackerStore {
capturePageEvent: (props: EventProps) => void; capturePageEvent: (props: EventProps) => void;
captureIssueEvent: (props: IssueEventProps) => void; captureIssueEvent: (props: IssueEventProps) => void;
captureProjectStateEvent: (props: EventProps) => void; captureProjectStateEvent: (props: EventProps) => void;
captureIssuesListOpenedEvent: (path: string, filters: any) => void; captureIssuesListOpenedEvent: (payload: any) => void;
} }
export class EventTrackerStore implements IEventTrackerStore { export class EventTrackerStore implements IEventTrackerStore {
@ -248,12 +248,9 @@ export class EventTrackerStore implements IEventTrackerStore {
* @param {string} path * @param {string} path
* @param {any} filters * @param {any} filters
*/ */
captureIssuesListOpenedEvent = (path: string, filters: any) => { captureIssuesListOpenedEvent = (payload: any) => {
const eventPayload = { const eventPayload = {
...getIssuesListOpenedPayload({ ...getIssuesListOpenedPayload(payload),
path: path,
filters: filters,
}),
...this.getRequiredProperties, ...this.getRequiredProperties,
}; };
posthog?.capture(ISSUES_LIST_OPENED, eventPayload); posthog?.capture(ISSUES_LIST_OPENED, eventPayload);