forked from github/plane
fix: transmitting selective data for analytics (#578)
This commit is contained in:
parent
2138ddf1f5
commit
06daf68753
@ -38,7 +38,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
jitsu
|
||||
.id({
|
||||
...user,
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
first_name: user.first_name,
|
||||
last_name: user.last_name,
|
||||
})
|
||||
.then(() => {
|
||||
jitsu.track(eventName, {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// services
|
||||
import APIService from "services/api.service";
|
||||
// types
|
||||
import type { IWorkspace } from "types";
|
||||
import type { ICycle, IIssue, IModule, IProject, IState, IWorkspace } from "types";
|
||||
|
||||
// TODO: as we add more events, we can refactor this to be divided into different classes
|
||||
class TrackEventServices extends APIService {
|
||||
@ -10,26 +10,36 @@ class TrackEventServices extends APIService {
|
||||
}
|
||||
|
||||
async trackCreateWorkspaceEvent(data: IWorkspace): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data.id,
|
||||
workspaceSlug: data.slug,
|
||||
workspaceName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "CREATE_WORKSPACE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackUpdateWorkspaceEvent(data: IWorkspace): Promise<any> {
|
||||
async trackUpdateWorkspaceEvent(data: Partial<IWorkspace>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data.id,
|
||||
workspaceSlug: data.slug,
|
||||
workspaceName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "UPDATE_WORKSPACE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -48,27 +58,41 @@ class TrackEventServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async trackCreateProjectEvent(data: any): Promise<any> {
|
||||
async trackCreateProjectEvent(data: IProject): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data.workspace_detail.id,
|
||||
workspaceName: data.workspace_detail.name,
|
||||
workspaceSlug: data.workspace_detail.slug,
|
||||
projectId: data.id,
|
||||
projectName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "CREATE_PROJECT",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackUpdateProjectEvent(data: any): Promise<any> {
|
||||
async trackUpdateProjectEvent(data: Partial<IProject>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data.id,
|
||||
projectName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "UPDATE_PROJECT",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -139,27 +163,47 @@ class TrackEventServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async trackIssueCreateEvent(data: any): Promise<any> {
|
||||
async trackIssueCreateEvent(data: IIssue): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data.workspace_detail.id,
|
||||
workspaceName: data.workspace_detail.name,
|
||||
workspaceSlug: data.workspace_detail.slug,
|
||||
projectId: data.project_detail.id,
|
||||
projectName: data.project_detail.name,
|
||||
projectIdentifier: data.project_detail.identifier,
|
||||
issueId: data.id,
|
||||
issueTitle: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "ISSUE_CREATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackIssueUpdateEvent(data: any): Promise<any> {
|
||||
async trackIssueUpdateEvent(data: Partial<IIssue>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data?.project_detail?.name,
|
||||
projectIdentifier: data?.project_detail?.identifier,
|
||||
issueId: data.id,
|
||||
issueTitle: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "ISSUE_UPDATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -191,27 +235,47 @@ class TrackEventServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async trackStateCreateEvent(data: any): Promise<any> {
|
||||
async trackStateCreateEvent(data: IState): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data?.project_detail?.name,
|
||||
projectIdentifier: data?.project_detail?.identifier,
|
||||
stateId: data.id,
|
||||
stateName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "STATE_CREATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackStateUpdateEvent(data: any): Promise<any> {
|
||||
async trackStateUpdateEvent(data: Partial<IState>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data?.project_detail?.name,
|
||||
projectIdentifier: data?.project_detail?.identifier,
|
||||
stateId: data.id,
|
||||
stateName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "STATE_UPDATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -230,27 +294,47 @@ class TrackEventServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async trackCycleCreateEvent(data: any): Promise<any> {
|
||||
async trackCycleCreateEvent(data: ICycle): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data?.project_detail?.name,
|
||||
projectIdentifier: data?.project_detail?.identifier,
|
||||
cycleId: data.id,
|
||||
cycleName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "CYCLE_CREATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackCycleUpdateEvent(data: any): Promise<any> {
|
||||
async trackCycleUpdateEvent(data: Partial<ICycle>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data?.project_detail?.name,
|
||||
projectIdentifier: data?.project_detail?.identifier,
|
||||
cycleId: data.id,
|
||||
cycleName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "CYCLE_UPDATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -269,27 +353,45 @@ class TrackEventServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async trackModuleCreateEvent(data: any): Promise<any> {
|
||||
async trackModuleCreateEvent(data: IModule): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail.id,
|
||||
workspaceName: data?.workspace_detail.name,
|
||||
workspaceSlug: data?.workspace_detail.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data.project_detail?.name,
|
||||
moduleId: data.id,
|
||||
moduleName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "MODULE_CREATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async trackModuleUpdateEvent(data: any): Promise<any> {
|
||||
async trackModuleUpdateEvent(data: Partial<IModule>): Promise<any> {
|
||||
const payload = {
|
||||
workspaceId: data?.workspace_detail?.id,
|
||||
workspaceName: data?.workspace_detail?.name,
|
||||
workspaceSlug: data?.workspace_detail?.slug,
|
||||
projectId: data?.project_detail?.id,
|
||||
projectName: data.project_detail?.name,
|
||||
moduleId: data.id,
|
||||
moduleName: data.name,
|
||||
};
|
||||
return this.request({
|
||||
url: "/api/track-event",
|
||||
method: "POST",
|
||||
data: {
|
||||
eventName: "MODULE_UPDATE",
|
||||
extra: {
|
||||
...data,
|
||||
...payload,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
4
apps/app/types/cycles.d.ts
vendored
4
apps/app/types/cycles.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import type { IUser, IIssue } from ".";
|
||||
import type { IUser, IIssue, IProject, IProjectLite, IWorkspace, IWorkspaceLite } from "types";
|
||||
|
||||
export interface ICycle {
|
||||
backlog_issues: number;
|
||||
@ -14,6 +14,7 @@ export interface ICycle {
|
||||
name: string;
|
||||
owned_by: IUser;
|
||||
project: string;
|
||||
project_detail: IProjectLite;
|
||||
start_date: string | null;
|
||||
started_issues: number;
|
||||
total_issues: number;
|
||||
@ -21,6 +22,7 @@ export interface ICycle {
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface CurrentAndUpcomingCyclesResponse {
|
||||
|
14
apps/app/types/issues.d.ts
vendored
14
apps/app/types/issues.d.ts
vendored
@ -1,4 +1,13 @@
|
||||
import type { IState, IUser, IProject, ICycle, IModule, IUserLite } from "./";
|
||||
import type {
|
||||
IState,
|
||||
IUser,
|
||||
IProject,
|
||||
ICycle,
|
||||
IModule,
|
||||
IUserLite,
|
||||
IProjectLite,
|
||||
IWorkspaceLite,
|
||||
} from "types";
|
||||
|
||||
export interface IIssueCycle {
|
||||
id: string;
|
||||
@ -96,7 +105,7 @@ export interface IIssue {
|
||||
parent_detail: IIssueParent | null;
|
||||
priority: string | null;
|
||||
project: string;
|
||||
project_detail: IProject;
|
||||
project_detail: IProjectLite;
|
||||
sequence_id: number;
|
||||
sort_order: number;
|
||||
sprints: string | null;
|
||||
@ -108,6 +117,7 @@ export interface IIssue {
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
labels: any[];
|
||||
labels_list: string[];
|
||||
}
|
||||
|
13
apps/app/types/modules.d.ts
vendored
13
apps/app/types/modules.d.ts
vendored
@ -1,4 +1,12 @@
|
||||
import type { IUser, IUserLite, IIssue, IProject } from ".";
|
||||
import type {
|
||||
IUser,
|
||||
IUserLite,
|
||||
IIssue,
|
||||
IProject,
|
||||
IWorkspace,
|
||||
IWorkspaceLite,
|
||||
IProjectLite,
|
||||
} from "types";
|
||||
|
||||
export interface IModule {
|
||||
backlog_issues: number;
|
||||
@ -28,7 +36,7 @@ export interface IModule {
|
||||
is_favorite: boolean;
|
||||
name: string;
|
||||
project: string;
|
||||
project_detail: IProject;
|
||||
project_detail: IProjectLite;
|
||||
start_date: string | null;
|
||||
started_issues: number;
|
||||
status: "backlog" | "planned" | "in-progress" | "paused" | "completed" | "cancelled" | null;
|
||||
@ -38,6 +46,7 @@ export interface IModule {
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface ModuleIssueResponse {
|
||||
|
10
apps/app/types/projects.d.ts
vendored
10
apps/app/types/projects.d.ts
vendored
@ -2,9 +2,10 @@ import type {
|
||||
IIssueFilterOptions,
|
||||
IUserLite,
|
||||
IWorkspace,
|
||||
IWorkspaceLite,
|
||||
TIssueGroupByOptions,
|
||||
TIssueOrderByOptions,
|
||||
} from "./";
|
||||
} from "types";
|
||||
|
||||
export interface IProject {
|
||||
cover_image: string | null;
|
||||
@ -26,6 +27,13 @@ export interface IProject {
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: IWorkspace | string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface IProjectLite {
|
||||
id: string;
|
||||
name: string;
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
export interface IFavoriteProject {
|
||||
|
4
apps/app/types/state.d.ts
vendored
4
apps/app/types/state.d.ts
vendored
@ -1,3 +1,5 @@
|
||||
import { IProject, IProjectLite, IWorkspaceLite } from "types";
|
||||
|
||||
export interface IState {
|
||||
readonly id: string;
|
||||
color: string;
|
||||
@ -8,11 +10,13 @@ export interface IState {
|
||||
group: "backlog" | "unstarted" | "started" | "completed" | "cancelled";
|
||||
name: string;
|
||||
project: string;
|
||||
readonly project_detail: IProjectLite;
|
||||
sequence: number;
|
||||
readonly slug: string;
|
||||
readonly updated_at: Date;
|
||||
readonly updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface StateResponse {
|
||||
|
8
apps/app/types/workspace.d.ts
vendored
8
apps/app/types/workspace.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import type { IProjectMember, IUser, IUserLite } from "./";
|
||||
import type { IProjectMember, IUser, IUserLite } from "types";
|
||||
|
||||
export interface IWorkspace {
|
||||
readonly id: string;
|
||||
@ -16,6 +16,12 @@ export interface IWorkspace {
|
||||
company_size: number | null;
|
||||
}
|
||||
|
||||
export interface IWorkspaceLite {
|
||||
readonly id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
}
|
||||
|
||||
export interface IWorkspaceMemberInvitation {
|
||||
readonly id: string;
|
||||
email: string;
|
||||
|
Loading…
Reference in New Issue
Block a user