mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
refactor: requiredProperties getter name
This commit is contained in:
parent
379a4de533
commit
dac046cb05
@ -2,10 +2,10 @@ import { action, computed, makeObservable, observable } from "mobx";
|
|||||||
import posthog from "posthog-js";
|
import posthog from "posthog-js";
|
||||||
// stores
|
// stores
|
||||||
import {
|
import {
|
||||||
GROUP_WORKSPACE,
|
//types
|
||||||
WORKSPACE_CREATED,
|
|
||||||
EventProps,
|
EventProps,
|
||||||
IssueEventProps,
|
IssueEventProps,
|
||||||
|
// payload helpers
|
||||||
getCycleEventPayload,
|
getCycleEventPayload,
|
||||||
getIssueEventPayload,
|
getIssueEventPayload,
|
||||||
getModuleEventPayload,
|
getModuleEventPayload,
|
||||||
@ -13,6 +13,11 @@ import {
|
|||||||
getProjectStateEventPayload,
|
getProjectStateEventPayload,
|
||||||
getWorkspaceEventPayload,
|
getWorkspaceEventPayload,
|
||||||
getPageEventPayload,
|
getPageEventPayload,
|
||||||
|
getIssuesListOpenedPayload,
|
||||||
|
// event constants
|
||||||
|
ISSUES_LIST_OPENED,
|
||||||
|
GROUP_WORKSPACE,
|
||||||
|
WORKSPACE_CREATED,
|
||||||
} from "@/constants/event-tracker";
|
} from "@/constants/event-tracker";
|
||||||
import { RootStore } from "./root.store";
|
import { RootStore } from "./root.store";
|
||||||
|
|
||||||
@ -20,7 +25,7 @@ export interface IEventTrackerStore {
|
|||||||
// properties
|
// properties
|
||||||
trackElement: string | undefined;
|
trackElement: string | undefined;
|
||||||
// computed
|
// computed
|
||||||
getRequiredProperties: any;
|
requiredProperties: any;
|
||||||
// actions
|
// actions
|
||||||
resetSession: () => void;
|
resetSession: () => void;
|
||||||
setTrackElement: (element: string) => void;
|
setTrackElement: (element: string) => void;
|
||||||
@ -33,6 +38,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: (routePath: string, filters: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EventTrackerStore implements IEventTrackerStore {
|
export class EventTrackerStore implements IEventTrackerStore {
|
||||||
@ -43,7 +49,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
// properties
|
// properties
|
||||||
trackElement: observable,
|
trackElement: observable,
|
||||||
// computed
|
// computed
|
||||||
getRequiredProperties: computed,
|
requiredProperties: computed,
|
||||||
// actions
|
// actions
|
||||||
resetSession: action,
|
resetSession: action,
|
||||||
setTrackElement: action,
|
setTrackElement: action,
|
||||||
@ -58,7 +64,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
/**
|
/**
|
||||||
* @description: Returns the necessary property for the event tracking
|
* @description: Returns the necessary property for the event tracking
|
||||||
*/
|
*/
|
||||||
get getRequiredProperties() {
|
get requiredProperties() {
|
||||||
const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace;
|
const currentWorkspaceDetails = this.rootStore.workspaceRoot.currentWorkspace;
|
||||||
const currentProjectDetails = this.rootStore.projectRoot.project.currentProjectDetails;
|
const currentProjectDetails = this.rootStore.projectRoot.project.currentProjectDetails;
|
||||||
return {
|
return {
|
||||||
@ -102,7 +108,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
*/
|
*/
|
||||||
captureEvent = (eventName: string, payload?: any) => {
|
captureEvent = (eventName: string, payload?: any) => {
|
||||||
posthog?.capture(eventName, {
|
posthog?.capture(eventName, {
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload?.element ?? this.trackElement,
|
element: payload?.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
@ -133,7 +139,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
captureProjectEvent = (props: EventProps) => {
|
captureProjectEvent = (props: EventProps) => {
|
||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = getProjectEventPayload({
|
const eventPayload: any = getProjectEventPayload({
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
@ -148,7 +154,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
captureCycleEvent = (props: EventProps) => {
|
captureCycleEvent = (props: EventProps) => {
|
||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = getCycleEventPayload({
|
const eventPayload: any = getCycleEventPayload({
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
@ -163,7 +169,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
captureModuleEvent = (props: EventProps) => {
|
captureModuleEvent = (props: EventProps) => {
|
||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = getModuleEventPayload({
|
const eventPayload: any = getModuleEventPayload({
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
@ -178,7 +184,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
capturePageEvent = (props: EventProps) => {
|
capturePageEvent = (props: EventProps) => {
|
||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = getPageEventPayload({
|
const eventPayload: any = getPageEventPayload({
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
@ -194,7 +200,7 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = {
|
const eventPayload: any = {
|
||||||
...getIssueEventPayload(props),
|
...getIssueEventPayload(props),
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
state_group: this.rootStore.state.getStateById(payload.state_id)?.group ?? "",
|
state_group: this.rootStore.state.getStateById(payload.state_id)?.group ?? "",
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
};
|
};
|
||||||
@ -209,11 +215,28 @@ export class EventTrackerStore implements IEventTrackerStore {
|
|||||||
captureProjectStateEvent = (props: EventProps) => {
|
captureProjectStateEvent = (props: EventProps) => {
|
||||||
const { eventName, payload } = props;
|
const { eventName, payload } = props;
|
||||||
const eventPayload: any = getProjectStateEventPayload({
|
const eventPayload: any = getProjectStateEventPayload({
|
||||||
...this.getRequiredProperties,
|
...this.requiredProperties,
|
||||||
...payload,
|
...payload,
|
||||||
element: payload.element ?? this.trackElement,
|
element: payload.element ?? this.trackElement,
|
||||||
});
|
});
|
||||||
posthog?.capture(eventName, eventPayload);
|
posthog?.capture(eventName, eventPayload);
|
||||||
this.setTrackElement(undefined);
|
this.setTrackElement(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Captures the event whenever the issues list is opened.
|
||||||
|
* @param {string} path
|
||||||
|
* @param {any} filters
|
||||||
|
*/
|
||||||
|
captureIssuesListOpenedEvent = (routePath: string, filters: any) => {
|
||||||
|
const eventPayload = {
|
||||||
|
...getIssuesListOpenedPayload({
|
||||||
|
routePath: routePath,
|
||||||
|
filters: filters,
|
||||||
|
}),
|
||||||
|
...this.requiredProperties,
|
||||||
|
};
|
||||||
|
posthog?.capture(ISSUES_LIST_OPENED, eventPayload);
|
||||||
|
this.setTrackElement(undefined);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user