fix: track events issue and env variables fixes (#2184)

* fix: track event fixes

* fix: adding env variables to trubo
This commit is contained in:
sriram veeraghanta 2023-09-14 16:05:31 +05:30 committed by GitHub
parent a53b428bbd
commit 6659cfc8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 903 additions and 971 deletions

View File

@ -15,17 +15,18 @@
"NEXT_PUBLIC_UNSPLASH_ACCESS",
"NEXT_PUBLIC_UNSPLASH_ENABLED",
"NEXT_PUBLIC_TRACK_EVENTS",
"TRACKER_ACCESS_KEY",
"NEXT_PUBLIC_PLAUSIBLE_DOMAIN",
"NEXT_PUBLIC_CRISP_ID",
"NEXT_PUBLIC_ENABLE_SESSION_RECORDER",
"NEXT_PUBLIC_SESSION_RECORDER_KEY",
"NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS",
"NEXT_PUBLIC_SLACK_CLIENT_ID",
"NEXT_PUBLIC_SLACK_CLIENT_SECRET",
"NEXT_PUBLIC_SUPABASE_URL",
"NEXT_PUBLIC_SUPABASE_ANON_KEY",
"NEXT_PUBLIC_PLAUSIBLE_DOMAIN",
"NEXT_PUBLIC_DEPLOY_WITH_NGINX"
"NEXT_PUBLIC_DEPLOY_WITH_NGINX",
"SLACK_OAUTH_URL",
"SLACK_CLIENT_ID",
"SLACK_CLIENT_SECRET",
"JITSU_TRACKER_ACCESS_KEY",
"JITSU_TRACKER_HOST",
"UNSPLASH_ACCESS_KEY"
],
"pipeline": {
"build": {

View File

@ -1,8 +1,6 @@
import { Fragment } from "react";
import { useRouter } from "next/router";
import Link from "next/link";
// headless ui
import { Menu, Transition } from "@headlessui/react";
// next-themes
@ -63,8 +61,6 @@ export const WorkspaceSidebarDropdown = () => {
const { user, mutateUser } = useUser();
const { collapsed: sidebarCollapse } = useThemeHook();
const { setTheme } = useTheme();
const { setToastAlert } = useToast();
@ -155,7 +151,7 @@ export const WorkspaceSidebarDropdown = () => {
{workspaces.length > 0 ? (
workspaces.map((workspace) => (
<Menu.Item key={workspace.id}>
{({ active }) => (
{() => (
<button
type="button"
onClick={() => handleWorkspaceNavigation(workspace)}

View File

@ -1,13 +1,10 @@
import React from "react";
import Link from "next/link";
import { useRouter } from "next/router";
// hooks
import useTheme from "hooks/use-theme";
// components
import { NotificationPopover } from "components/notifications";
// ui
import { Tooltip } from "components/ui";
// icons
import {

View File

@ -52,7 +52,7 @@ const SingleInvitation: React.FC<Props> = ({
? "bg-custom-background-80 text-custom-text-200"
: "bg-custom-primary text-white"
} text-sm px-4 py-2 border border-custom-border-200 rounded-3xl`}
onClick={(e) => {
onClick={() => {
handleInvitation(
invitation,
invitationsRespond.includes(invitation.id) ? "withdraw" : "accepted"

View File

@ -3,8 +3,6 @@ import { useEffect } from "react";
import { useTheme } from "next-themes";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// theme helpers
import { applyTheme, unsetCustomCssVariables } from "helpers/theme.helper";
const MobxStoreInit = () => {
const store: any = useMobxStore();

View File

@ -2,6 +2,7 @@ require("dotenv").config({ path: ".env" });
const { withSentryConfig } = require("@sentry/nextjs");
const path = require("path");
const extraImageDomains = (process.env.NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS ?? "")
.split(",")
.filter((domain) => domain.length > 0);

View File

@ -15,17 +15,14 @@ import { ICustomTheme } from "types";
import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// next themes
import { useTheme } from "next-themes";
const ProfilePreferences = observer(() => {
const { user: myProfile } = useUserAuth();
const store: any = useMobxStore();
const { theme } = useTheme();
console.log("store", store?.theme?.theme);
console.log("theme", theme);
// console.log("store", store?.theme?.theme);
// console.log("theme", theme);
const [customThemeSelectorOptions, setCustomThemeSelectorOptions] = useState(false);

View File

@ -1,23 +1,23 @@
// pages/api/slack/authorize.js
import axios from "axios";
import { NextApiRequest, NextApiResponse } from "next";
export default async function handleSlackAuthorize(req: NextApiRequest, res: NextApiResponse) {
try {
const { code } = req.body;
if (!code || code === "") return res.status(400).json({ message: "Code is required" });
const response = await axios({
method: "post",
url: "https://slack.com/api/oauth.v2.access",
url: process.env.SLACK_OAUTH_URL || "",
params: {
client_id: process.env.NEXT_PUBLIC_SLACK_CLIENT_ID,
client_secret: process.env.NEXT_PUBLIC_SLACK_CLIENT_SECRET,
client_id: process.env.SLACK_CLIENT_ID,
client_secret: process.env.SLACK_CLIENT_SECRET,
code,
},
});
// if (response?.data?.ok)
res.status(200).json(response.data);
// else res.status(404).json(response.data);
res.status(200).json(response?.data);
} catch (error) {
res.status(200).json({ message: "Internal Server Error" });
}
}

View File

@ -1,12 +1,10 @@
import type { NextApiRequest, NextApiResponse } from "next";
// jitsu
import { createClient } from "@jitsu/nextjs";
import { convertCookieStringToObject } from "lib/cookie";
const jitsu = createClient({
key: process.env.TRACKER_ACCESS_KEY || "",
tracking_host: "https://t.jitsu.com",
const jitsuClient = createClient({
key: process.env.JITSU_TRACKER_ACCESS_KEY || "",
tracking_host: process.env.JITSU_TRACKER_HOST || "",
});
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@ -18,18 +16,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (!user) return res.status(401).json({ message: "Unauthorized" });
// TODO: cache user info
jitsu
jitsuClient
.id({
id: user.id,
email: user.email,
first_name: user.first_name,
last_name: user.last_name,
id: user?.id,
email: user?.email,
first_name: user?.first_name,
last_name: user?.last_name,
display_name: user?.display_name,
})
.then(() => {
jitsu.track(eventName, {
jitsuClient.track(eventName, {
...extra,
});
});

View File

@ -1,7 +1,7 @@
import axios from "axios";
import type { NextApiRequest, NextApiResponse } from "next";
// TODO: remove NEXT_PUBLIC_ prefix from env variable
const unsplashKey = process.env.NEXT_PUBLIC_UNSPLASH_ACCESS;
const unsplashKey = process.env.UNSPLASH_ACCESS_KEY;
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { query, page, per_page = 20 } = req.query;
@ -10,14 +10,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
? `https://api.unsplash.com/search/photos/?client_id=${unsplashKey}&query=${query}&page=${page}&per_page=${per_page}`
: `https://api.unsplash.com/photos/?client_id=${unsplashKey}&page=${page}&per_page=${per_page}`;
const response = await fetch(url, {
const response = await axios({
method: "GET",
url,
headers: {
"Content-Type": "application/json",
},
});
const data = await response.json();
res.status(200).json(data);
res.status(200).json(response);
}

View File

@ -5,9 +5,6 @@ import { ICurrentUserResponse, IGptResponse } from "types";
// helpers
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class AiServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -21,7 +18,7 @@ class AiServices extends APIService {
): Promise<IGptResponse> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/ai-assistant/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackAskGptEvent(response?.data, "ASK_GPT", user);
trackEventServices.trackAskGptEvent(response?.data, "ASK_GPT", user);
return response?.data;
})
.catch((error) => {

View File

@ -5,9 +5,6 @@ import trackEventServices from "services/track-event.service";
import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IIssue } from "types";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ProjectCycleServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -21,7 +18,7 @@ class ProjectCycleServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackCycleEvent(response?.data, "CYCLE_CREATE", user);
trackEventServices.trackCycleEvent(response?.data, "CYCLE_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -99,7 +96,7 @@ class ProjectCycleServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackCycleEvent(response?.data, "CYCLE_UPDATE", user);
trackEventServices.trackCycleEvent(response?.data, "CYCLE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -119,7 +116,7 @@ class ProjectCycleServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackCycleEvent(response?.data, "CYCLE_UPDATE", user);
trackEventServices.trackCycleEvent(response?.data, "CYCLE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -135,7 +132,7 @@ class ProjectCycleServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/${cycleId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackCycleEvent(response?.data, "CYCLE_DELETE", user);
trackEventServices.trackCycleEvent(response?.data, "CYCLE_DELETE", user);
return response?.data;
})
.catch((error) => {

View File

@ -5,9 +5,6 @@ import type { ICurrentUserResponse, IEstimate, IEstimateFormData } from "types";
import trackEventServices from "services/track-event.service";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ProjectEstimateServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -21,7 +18,6 @@ class ProjectEstimateServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/estimates/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueEstimateEvent(response?.data, "ESTIMATE_CREATE", user);
return response?.data;
})
@ -42,7 +38,6 @@ class ProjectEstimateServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueEstimateEvent(response?.data, "ESTIMATE_UPDATE", user);
return response?.data;
})
@ -83,7 +78,6 @@ class ProjectEstimateServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/estimates/${estimateId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueEstimateEvent(response?.data, "ESTIMATE_DELETE", user);
return response?.data;
})

View File

@ -1,10 +1,6 @@
import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
// types
import type {
IInboxIssue,
@ -12,7 +8,6 @@ import type {
TInboxStatus,
IInboxIssueDetail,
ICurrentUserResponse,
IInboxFilterOptions,
IInboxQueryParams,
} from "types";
@ -95,7 +90,6 @@ class InboxServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/${inboxIssueId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackInboxEvent(response?.data, "INBOX_ISSUE_DELETE", user);
return response?.data;
})
@ -125,7 +119,7 @@ class InboxServices extends APIService {
: data.status === 1
? "INBOX_ISSUE_ACCEPTED"
: "INBOX_ISSUE_DUPLICATED";
if (trackEvent) trackEventServices.trackInboxEvent(response?.data, action, user);
trackEventServices.trackInboxEvent(response?.data, action, user);
return response?.data;
})
.catch((error) => {
@ -146,7 +140,6 @@ class InboxServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackInboxEvent(response?.data, "INBOX_ISSUE_UPDATE", user);
return response?.data;
})
@ -167,7 +160,6 @@ class InboxServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackInboxEvent(response?.data, "INBOX_ISSUE_CREATE", user);
return response?.data;
})

View File

@ -3,9 +3,6 @@ import trackEventServices from "services/track-event.service";
import { ICurrentUserResponse } from "types";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class CSVIntegrationService extends APIService {
constructor() {
super(API_BASE_URL);
@ -21,7 +18,6 @@ class CSVIntegrationService extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/export-issues/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackExporterEvent(
{
workspaceSlug,

View File

@ -4,11 +4,6 @@ import { API_BASE_URL } from "helpers/common.helper";
import { ICurrentUserResponse, IGithubRepoInfo, IGithubServiceImportFormData } from "types";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
const integrationServiceType: string = "github";
class GithubIntegrationService extends APIService {
constructor() {
@ -48,7 +43,6 @@ class GithubIntegrationService extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackImporterEvent(response?.data, "GITHUB_IMPORTER_CREATE", user);
return response?.data;
})

View File

@ -11,9 +11,6 @@ import {
} from "types";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class IntegrationService extends APIService {
constructor() {
super(API_BASE_URL);
@ -78,8 +75,7 @@ class IntegrationService extends APIService {
return this.delete(`/api/workspaces/${workspaceSlug}/importers/${service}/${importerId}/`)
.then((response) => {
const eventName = service === "github" ? "GITHUB_IMPORTER_DELETE" : "JIRA_IMPORTER_DELETE";
if (trackEvent) trackEventServices.trackImporterEvent(response?.data, eventName, user);
trackEventServices.trackImporterEvent(response?.data, eventName, user);
return response?.data;
})
.catch((error) => {

View File

@ -4,11 +4,6 @@ import { API_BASE_URL } from "helpers/common.helper";
// types
import { IJiraMetadata, IJiraResponse, IJiraImporterForm, ICurrentUserResponse } from "types";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class JiraImportedService extends APIService {
constructor() {
super(API_BASE_URL);
@ -31,7 +26,6 @@ class JiraImportedService extends APIService {
): Promise<IJiraResponse> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/importers/jira/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackImporterEvent(response?.data, "JIRA_IMPORTER_CREATE", user);
return response?.data;
})

View File

@ -12,9 +12,6 @@ import type {
} from "types";
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ProjectIssuesServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -28,7 +25,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent(response.data, "ISSUE_CREATE", user);
trackEventServices.trackIssueEvent(response.data, "ISSUE_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -112,7 +109,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueMovedToCycleOrModuleEvent(
{
workspaceSlug,
@ -165,7 +161,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_CREATE", user);
return response?.data;
})
@ -185,7 +180,6 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-relation/${relationId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_DELETE", user);
return response?.data;
})
@ -234,7 +228,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_CREATE", user);
return response?.data;
})
@ -256,7 +249,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_UPDATE", user);
return response?.data;
})
@ -276,7 +268,6 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/comments/${commentId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueCommentEvent(
{
issueId,
@ -316,7 +307,6 @@ class ProjectIssuesServices extends APIService {
): Promise<IIssueLabels> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/`, data)
.then((response: { data: IIssueLabels; [key: string]: any }) => {
if (trackEvent)
trackEventServices.trackIssueLabelEvent(
{
workSpaceId: response?.data?.workspace_detail?.id,
@ -350,7 +340,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueLabelEvent(
{
workSpaceId: response?.data?.workspace_detail?.id,
@ -382,7 +371,6 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/${labelId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueLabelEvent(
{
workspaceSlug,
@ -410,7 +398,7 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent(response.data, "ISSUE_UPDATE", user);
trackEventServices.trackIssueEvent(response.data, "ISSUE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -426,7 +414,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issuesId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent({ issuesId }, "ISSUE_DELETE", user);
trackEventServices.trackIssueEvent({ issuesId }, "ISSUE_DELETE", user);
return response?.data;
})
.catch((error) => {
@ -445,7 +433,7 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackIssueBulkDeleteEvent(data, user);
trackEventServices.trackIssueBulkDeleteEvent(data, user);
return response?.data;
})
.catch((error) => {

View File

@ -5,11 +5,6 @@ import trackEventServices from "./track-event.service";
import type { IModule, IIssue, ICurrentUserResponse } from "types";
import { API_BASE_URL } from "helpers/common.helper";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ProjectIssuesServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -31,7 +26,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_CREATE", user);
trackEventServices.trackModuleEvent(response?.data, "MODULE_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -51,7 +46,7 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -83,7 +78,7 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -101,7 +96,7 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/${moduleId}/`
)
.then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_DELETE", user);
trackEventServices.trackModuleEvent(response?.data, "MODULE_DELETE", user);
return response?.data;
})
.catch((error) => {
@ -156,7 +151,6 @@ class ProjectIssuesServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackIssueMovedToCycleOrModuleEvent(
{
workspaceSlug,

View File

@ -5,9 +5,6 @@ import trackEventServices from "services/track-event.service";
// types
import { IPage, IPageBlock, RecentPagesResponse, IIssue, ICurrentUserResponse } from "types";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class PageServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -21,7 +18,7 @@ class PageServices extends APIService {
): Promise<IPage> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackPageEvent(response?.data, "PAGE_CREATE", user);
trackEventServices.trackPageEvent(response?.data, "PAGE_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -41,7 +38,7 @@ class PageServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackPageEvent(response?.data, "PAGE_UPDATE", user);
trackEventServices.trackPageEvent(response?.data, "PAGE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -57,7 +54,7 @@ class PageServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackPageEvent(response?.data, "PAGE_DELETE", user);
trackEventServices.trackPageEvent(response?.data, "PAGE_DELETE", user);
return response?.data;
})
.catch((error) => {
@ -140,7 +137,6 @@ class PageServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackPageBlockEvent(response?.data, "PAGE_BLOCK_CREATE", user);
return response?.data;
})
@ -177,7 +173,6 @@ class PageServices extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackPageBlockEvent(response?.data, "PAGE_BLOCK_UPDATE", user);
return response?.data;
})
@ -197,7 +192,6 @@ class PageServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/page-blocks/${pageBlockId}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackPageBlockEvent(response?.data, "PAGE_BLOCK_DELETE", user);
return response?.data;
})
@ -231,7 +225,6 @@ class PageServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/page-blocks/${blockId}/issues/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackPageBlockEvent(
response?.data,
"PAGE_BLOCK_CONVERTED_TO_ISSUE",

View File

@ -6,9 +6,6 @@ import trackEventServices from "services/track-event.service";
import { ICurrentUserResponse } from "types";
import { IProjectPublishSettings } from "store/project-publish";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ProjectServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -23,13 +20,11 @@ class ProjectServices extends APIService {
`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/`
)
.then((response) => {
if (trackEvent) {
// trackEventServices.trackProjectPublishSettingsEvent(
// response.data,
// "GET_PROJECT_PUBLISH_SETTINGS",
// user
// );
}
return response?.data;
})
.catch((error) => {
@ -48,13 +43,12 @@ class ProjectServices extends APIService {
data
)
.then((response) => {
if (trackEvent) {
// trackEventServices.trackProjectPublishSettingsEvent(
// response.data,
// "CREATE_PROJECT_PUBLISH_SETTINGS",
// user
// );
}
return response?.data;
})
.catch((error) => {
@ -74,13 +68,11 @@ class ProjectServices extends APIService {
data
)
.then((response) => {
if (trackEvent) {
// trackEventServices.trackProjectPublishSettingsEvent(
// response.data,
// "UPDATE_PROJECT_PUBLISH_SETTINGS",
// user
// );
}
return response?.data;
})
.catch((error) => {
@ -98,13 +90,11 @@ class ProjectServices extends APIService {
`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/${project_publish_id}/`
)
.then((response) => {
if (trackEvent) {
// trackEventServices.trackProjectPublishSettingsEvent(
// response.data,
// "DELETE_PROJECT_PUBLISH_SETTINGS",
// user
// );
}
return response?.data;
})
.catch((error) => {

View File

@ -16,9 +16,6 @@ import type {
TProjectIssuesSearchParams,
} from "types";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
export class ProjectServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -31,7 +28,7 @@ export class ProjectServices extends APIService {
): Promise<IProject> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackProjectEvent(response.data, "CREATE_PROJECT", user);
trackEventServices.trackProjectEvent(response.data, "CREATE_PROJECT", user);
return response?.data;
})
.catch((error) => {
@ -82,7 +79,7 @@ export class ProjectServices extends APIService {
): Promise<IProject> {
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackProjectEvent(response.data, "UPDATE_PROJECT", user);
trackEventServices.trackProjectEvent(response.data, "UPDATE_PROJECT", user);
return response?.data;
})
.catch((error) => {
@ -97,7 +94,7 @@ export class ProjectServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackProjectEvent({ projectId }, "DELETE_PROJECT", user);
trackEventServices.trackProjectEvent({ projectId }, "DELETE_PROJECT", user);
return response?.data;
})
.catch((error) => {
@ -113,7 +110,6 @@ export class ProjectServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/members/add/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackProjectEvent(
{
workspaceId: response?.data?.workspace?.id,
@ -147,7 +143,6 @@ export class ProjectServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/members/leave/`)
.then((response) => {
if (trackEvent)
trackEventServices.trackProjectEvent(
"PROJECT_MEMBER_LEAVE",
{

View File

@ -11,9 +11,6 @@ import type {
IssueCommentReactionForm,
} from "types";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ReactionService extends APIService {
constructor() {
super(API_BASE_URL);
@ -31,7 +28,6 @@ class ReactionService extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackReactionEvent(response?.data, "ISSUE_REACTION_CREATE", user);
return response?.data;
})
@ -65,7 +61,6 @@ class ReactionService extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/reactions/${reaction}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackReactionEvent(response?.data, "ISSUE_REACTION_DELETE", user);
return response?.data;
})
@ -86,7 +81,6 @@ class ReactionService extends APIService {
data
)
.then((response) => {
if (trackEvent)
trackEventServices.trackReactionEvent(
response?.data,
"ISSUE_COMMENT_REACTION_CREATE",
@ -124,7 +118,6 @@ class ReactionService extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/comments/${commentId}/reactions/${reaction}/`
)
.then((response) => {
if (trackEvent)
trackEventServices.trackReactionEvent(
response?.data,
"ISSUE_COMMENT_REACTION_DELETE",

View File

@ -3,10 +3,6 @@ import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
// helpers
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
// types
import type { ICurrentUserResponse, IState, IStateResponse } from "types";
@ -23,7 +19,7 @@ class ProjectStateServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackStateEvent(response?.data, "STATE_CREATE", user);
trackEventServices.trackStateEvent(response?.data, "STATE_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -68,7 +64,7 @@ class ProjectStateServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackStateEvent(response?.data, "STATE_UPDATE", user);
trackEventServices.trackStateEvent(response?.data, "STATE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -88,7 +84,7 @@ class ProjectStateServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackStateEvent(response?.data, "STATE_UPDATE", user);
trackEventServices.trackStateEvent(response?.data, "STATE_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -104,7 +100,7 @@ class ProjectStateServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackStateEvent(response?.data, "STATE_DELETE", user);
trackEventServices.trackStateEvent(response?.data, "STATE_DELETE", user);
return response?.data;
})
.catch((error) => {

View File

@ -131,6 +131,8 @@ class TrackEventServices extends APIService {
eventName: WorkspaceEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (
eventName !== "DELETE_WORKSPACE" &&
@ -163,6 +165,8 @@ class TrackEventServices extends APIService {
eventName: ProjectEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (
eventName !== "DELETE_PROJECT" &&
@ -195,6 +199,8 @@ class TrackEventServices extends APIService {
data: any,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -212,6 +218,8 @@ class TrackEventServices extends APIService {
data: any,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -230,6 +238,8 @@ class TrackEventServices extends APIService {
eventName: IssueEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "ISSUE_DELETE")
payload = {
@ -303,6 +313,8 @@ class TrackEventServices extends APIService {
eventName: IssueCommentEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "ISSUE_COMMENT_DELETE")
payload = {
@ -333,6 +345,8 @@ class TrackEventServices extends APIService {
eventName: "ISSUE_RELATION_CREATE" | "ISSUE_RELATION_DELETE",
user: ICurrentUserResponse
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -353,6 +367,8 @@ class TrackEventServices extends APIService {
| "ISSUE_MOVED_TO_MODULE_IN_BULK",
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -367,6 +383,8 @@ class TrackEventServices extends APIService {
}
async trackIssueBulkDeleteEvent(data: any, user: ICurrentUserResponse | undefined): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -385,6 +403,8 @@ class TrackEventServices extends APIService {
eventName: IssueLabelEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -403,6 +423,8 @@ class TrackEventServices extends APIService {
eventName: StateEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "STATE_DELETE")
payload = {
@ -434,6 +456,8 @@ class TrackEventServices extends APIService {
eventName: CycleEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "CYCLE_DELETE")
payload = {
@ -465,6 +489,8 @@ class TrackEventServices extends APIService {
eventName: ModuleEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "MODULE_DELETE")
payload = {
@ -496,6 +522,8 @@ class TrackEventServices extends APIService {
eventName: PagesEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "PAGE_DELETE")
payload = {
@ -527,6 +555,8 @@ class TrackEventServices extends APIService {
eventName: PageBlocksEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "PAGE_BLOCK_DELETE" && eventName !== "PAGE_BLOCK_CONVERTED_TO_ISSUE")
payload = {
@ -569,6 +599,8 @@ class TrackEventServices extends APIService {
eventName: GptEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
const payload = {
workspaceId: data?.workspace_detail?.id,
workspaceName: data?.workspace_detail?.name,
@ -641,6 +673,8 @@ class TrackEventServices extends APIService {
eventName: ViewEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName === "VIEW_DELETE") payload = data;
else
@ -670,6 +704,8 @@ class TrackEventServices extends APIService {
eventName: MiscellaneousEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -688,6 +724,8 @@ class TrackEventServices extends APIService {
eventName: IntegrationEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -706,6 +744,8 @@ class TrackEventServices extends APIService {
eventName: GitHubSyncEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
return this.request({
url: "/api/track-event",
method: "POST",
@ -724,6 +764,8 @@ class TrackEventServices extends APIService {
eventName: IssueEstimateEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName === "ESTIMATE_DELETE") payload = data;
else
@ -755,6 +797,8 @@ class TrackEventServices extends APIService {
eventName: ImporterEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName === "GITHUB_IMPORTER_DELETE" || eventName === "JIRA_IMPORTER_DELETE")
payload = data;
@ -786,6 +830,8 @@ class TrackEventServices extends APIService {
eventName: AnalyticsEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
const payload = { ...data };
return this.request({
@ -799,12 +845,13 @@ class TrackEventServices extends APIService {
});
}
// track exporter function\
async trackExporterEvent(
data: any,
eventName: ExporterEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
const payload = { ...data };
return this.request({
@ -826,6 +873,8 @@ class TrackEventServices extends APIService {
eventName: InboxEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName !== "INBOX_DELETE")
payload = {
@ -857,6 +906,8 @@ class TrackEventServices extends APIService {
eventName: ReactionEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
let payload: any;
if (eventName === "ISSUE_REACTION_DELETE" || eventName === "ISSUE_COMMENT_REACTION_DELETE")
payload = data;
@ -878,12 +929,13 @@ class TrackEventServices extends APIService {
});
}
// project publish settings track events starts
async trackProjectPublishSettingsEvent(
data: any,
eventName: string,
user: ICurrentUserResponse | undefined
): Promise<any> {
if (!trackEvent) return;
const payload: any = data;
return this.request({
@ -896,8 +948,6 @@ class TrackEventServices extends APIService {
},
});
}
// project publish settings track events ends
}
const trackEventServices = new TrackEventServices();

View File

@ -14,9 +14,6 @@ import type {
import { API_BASE_URL } from "helpers/common.helper";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class UserService extends APIService {
constructor() {
super(API_BASE_URL);
@ -68,7 +65,6 @@ class UserService extends APIService {
is_onboarded: true,
})
.then((response) => {
if (trackEvent)
trackEventServices.trackUserOnboardingCompleteEvent(
{
user_role: userRole ?? "None",
@ -87,13 +83,7 @@ class UserService extends APIService {
is_tour_completed: true,
})
.then((response) => {
if (trackEvent)
trackEventServices.trackUserTourCompleteEvent(
{
user_role: user.role ?? "None",
},
user
);
trackEventServices.trackUserTourCompleteEvent({ user_role: user.role ?? "None" }, user);
return response?.data;
})
.catch((error) => {

View File

@ -1,18 +1,11 @@
// services
import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
import { ICurrentUserResponse } from "types";
// types
import { IView } from "types/views";
import { ICurrentUserResponse } from "types";
// helpers
import { API_BASE_URL } from "helpers/common.helper";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class ViewServices extends APIService {
constructor() {
super(API_BASE_URL);
@ -26,7 +19,7 @@ class ViewServices extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackViewEvent(response?.data, "VIEW_CREATE", user);
trackEventServices.trackViewEvent(response?.data, "VIEW_CREATE", user);
return response?.data;
})
.catch((error) => {
@ -43,7 +36,7 @@ class ViewServices extends APIService {
): Promise<any> {
return this.put(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/`, data)
.then((response) => {
if (trackEvent) trackEventServices.trackViewEvent(response?.data, "VIEW_UPDATE", user);
trackEventServices.trackViewEvent(response?.data, "VIEW_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -63,7 +56,7 @@ class ViewServices extends APIService {
data
)
.then((response) => {
if (trackEvent) trackEventServices.trackViewEvent(response?.data, "VIEW_UPDATE", user);
trackEventServices.trackViewEvent(response?.data, "VIEW_UPDATE", user);
return response?.data;
})
.catch((error) => {
@ -79,7 +72,7 @@ class ViewServices extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/`)
.then((response) => {
if (trackEvent) trackEventServices.trackViewEvent(response?.data, "VIEW_DELETE", user);
trackEventServices.trackViewEvent(response?.data, "VIEW_DELETE", user);
return response?.data;
})
.catch((error) => {

View File

@ -16,9 +16,6 @@ import {
IWorkspaceViewProps,
} from "types";
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class WorkspaceService extends APIService {
constructor() {
super(API_BASE_URL);
@ -46,7 +43,6 @@ class WorkspaceService extends APIService {
): Promise<IWorkspace> {
return this.post("/api/workspaces/", data)
.then((response) => {
if (trackEvent)
trackEventServices.trackWorkspaceEvent(response.data, "CREATE_WORKSPACE", user);
return response?.data;
})
@ -62,7 +58,6 @@ class WorkspaceService extends APIService {
): Promise<IWorkspace> {
return this.patch(`/api/workspaces/${workspaceSlug}/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackWorkspaceEvent(response.data, "UPDATE_WORKSPACE", user);
return response?.data;
})
@ -77,7 +72,6 @@ class WorkspaceService extends APIService {
): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/`)
.then((response) => {
if (trackEvent)
trackEventServices.trackWorkspaceEvent({ workspaceSlug }, "DELETE_WORKSPACE", user);
return response?.data;
})
@ -93,7 +87,6 @@ class WorkspaceService extends APIService {
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/invite/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackWorkspaceEvent(response.data, "WORKSPACE_USER_INVITE", user);
return response?.data;
})
@ -116,12 +109,7 @@ class WorkspaceService extends APIService {
}
)
.then((response) => {
if (trackEvent)
trackEventServices.trackWorkspaceEvent(
response.data,
"WORKSPACE_USER_INVITE_ACCEPT",
user
);
trackEventServices.trackWorkspaceEvent(response.data, "WORKSPACE_USER_INVITE_ACCEPT", user);
return response?.data;
})
.catch((error) => {

1209
yarn.lock

File diff suppressed because it is too large Load Diff