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_ACCESS",
"NEXT_PUBLIC_UNSPLASH_ENABLED", "NEXT_PUBLIC_UNSPLASH_ENABLED",
"NEXT_PUBLIC_TRACK_EVENTS", "NEXT_PUBLIC_TRACK_EVENTS",
"TRACKER_ACCESS_KEY", "NEXT_PUBLIC_PLAUSIBLE_DOMAIN",
"NEXT_PUBLIC_CRISP_ID", "NEXT_PUBLIC_CRISP_ID",
"NEXT_PUBLIC_ENABLE_SESSION_RECORDER", "NEXT_PUBLIC_ENABLE_SESSION_RECORDER",
"NEXT_PUBLIC_SESSION_RECORDER_KEY", "NEXT_PUBLIC_SESSION_RECORDER_KEY",
"NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS", "NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS",
"NEXT_PUBLIC_SLACK_CLIENT_ID", "NEXT_PUBLIC_DEPLOY_WITH_NGINX",
"NEXT_PUBLIC_SLACK_CLIENT_SECRET", "SLACK_OAUTH_URL",
"NEXT_PUBLIC_SUPABASE_URL", "SLACK_CLIENT_ID",
"NEXT_PUBLIC_SUPABASE_ANON_KEY", "SLACK_CLIENT_SECRET",
"NEXT_PUBLIC_PLAUSIBLE_DOMAIN", "JITSU_TRACKER_ACCESS_KEY",
"NEXT_PUBLIC_DEPLOY_WITH_NGINX" "JITSU_TRACKER_HOST",
"UNSPLASH_ACCESS_KEY"
], ],
"pipeline": { "pipeline": {
"build": { "build": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import axios from "axios";
import type { NextApiRequest, NextApiResponse } from "next"; import type { NextApiRequest, NextApiResponse } from "next";
// TODO: remove NEXT_PUBLIC_ prefix from env variable const unsplashKey = process.env.UNSPLASH_ACCESS_KEY;
const unsplashKey = process.env.NEXT_PUBLIC_UNSPLASH_ACCESS;
export default async function handler(req: NextApiRequest, res: NextApiResponse) { export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { query, page, per_page = 20 } = req.query; 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/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}`; : `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", method: "GET",
url,
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
const data = await response.json(); res.status(200).json(response);
res.status(200).json(data);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,6 @@ import trackEventServices from "services/track-event.service";
import { ICurrentUserResponse } from "types"; import { ICurrentUserResponse } from "types";
import { API_BASE_URL } from "helpers/common.helper"; 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 { class CSVIntegrationService extends APIService {
constructor() { constructor() {
super(API_BASE_URL); super(API_BASE_URL);
@ -21,14 +18,13 @@ class CSVIntegrationService extends APIService {
): Promise<any> { ): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/export-issues/`, data) return this.post(`/api/workspaces/${workspaceSlug}/export-issues/`, data)
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackExporterEvent(
trackEventServices.trackExporterEvent( {
{ workspaceSlug,
workspaceSlug, },
}, "CSV_EXPORTER_CREATE",
"CSV_EXPORTER_CREATE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {

View File

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

View File

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

View File

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

View File

@ -12,9 +12,6 @@ import type {
} from "types"; } from "types";
import { API_BASE_URL } from "helpers/common.helper"; 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 { class ProjectIssuesServices extends APIService {
constructor() { constructor() {
super(API_BASE_URL); super(API_BASE_URL);
@ -28,7 +25,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> { ): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/`, data) return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/`, data)
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent(response.data, "ISSUE_CREATE", user); trackEventServices.trackIssueEvent(response.data, "ISSUE_CREATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -112,20 +109,19 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueMovedToCycleOrModuleEvent(
trackEventServices.trackIssueMovedToCycleOrModuleEvent( {
{ workspaceSlug,
workspaceSlug, workspaceName: response?.data?.[0]?.issue_detail?.workspace_detail?.name,
workspaceName: response?.data?.[0]?.issue_detail?.workspace_detail?.name, projectId,
projectId, projectIdentifier: response?.data?.[0]?.issue_detail?.project_detail?.identifier,
projectIdentifier: response?.data?.[0]?.issue_detail?.project_detail?.identifier, projectName: response?.data?.[0]?.issue_detail?.project_detail?.name,
projectName: response?.data?.[0]?.issue_detail?.project_detail?.name, issueId: response?.data?.[0]?.issue_detail?.id,
issueId: response?.data?.[0]?.issue_detail?.id, cycleId,
cycleId, },
}, response.data.length > 1 ? "ISSUE_MOVED_TO_CYCLE_IN_BULK" : "ISSUE_MOVED_TO_CYCLE",
response.data.length > 1 ? "ISSUE_MOVED_TO_CYCLE_IN_BULK" : "ISSUE_MOVED_TO_CYCLE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -165,8 +161,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_CREATE", user);
trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_CREATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -185,8 +180,7 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-relation/${relationId}/` `/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-relation/${relationId}/`
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_DELETE", user);
trackEventServices.trackIssueRelationEvent(response.data, "ISSUE_RELATION_DELETE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -234,8 +228,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_CREATE", user);
trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_CREATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -256,8 +249,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_UPDATE", user);
trackEventServices.trackIssueCommentEvent(response.data, "ISSUE_COMMENT_UPDATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -276,15 +268,14 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/comments/${commentId}/` `/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/comments/${commentId}/`
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueCommentEvent(
trackEventServices.trackIssueCommentEvent( {
{ issueId,
issueId, commentId,
commentId, },
}, "ISSUE_COMMENT_DELETE",
"ISSUE_COMMENT_DELETE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -316,21 +307,20 @@ class ProjectIssuesServices extends APIService {
): Promise<IIssueLabels> { ): Promise<IIssueLabels> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/`, data) return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/`, data)
.then((response: { data: IIssueLabels; [key: string]: any }) => { .then((response: { data: IIssueLabels; [key: string]: any }) => {
if (trackEvent) trackEventServices.trackIssueLabelEvent(
trackEventServices.trackIssueLabelEvent( {
{ workSpaceId: response?.data?.workspace_detail?.id,
workSpaceId: response?.data?.workspace_detail?.id, workSpaceName: response?.data?.workspace_detail?.name,
workSpaceName: response?.data?.workspace_detail?.name, workspaceSlug,
workspaceSlug, projectId,
projectId, projectIdentifier: response?.data?.project_detail?.identifier,
projectIdentifier: response?.data?.project_detail?.identifier, projectName: response?.data?.project_detail?.name,
projectName: response?.data?.project_detail?.name, labelId: response?.data?.id,
labelId: response?.data?.id, color: response?.data?.color,
color: response?.data?.color, },
}, "ISSUE_LABEL_CREATE",
"ISSUE_LABEL_CREATE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -350,21 +340,20 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueLabelEvent(
trackEventServices.trackIssueLabelEvent( {
{ workSpaceId: response?.data?.workspace_detail?.id,
workSpaceId: response?.data?.workspace_detail?.id, workSpaceName: response?.data?.workspace_detail?.name,
workSpaceName: response?.data?.workspace_detail?.name, workspaceSlug,
workspaceSlug, projectId,
projectId, projectIdentifier: response?.data?.project_detail?.identifier,
projectIdentifier: response?.data?.project_detail?.identifier, projectName: response?.data?.project_detail?.name,
projectName: response?.data?.project_detail?.name, labelId: response?.data?.id,
labelId: response?.data?.id, color: response?.data?.color,
color: response?.data?.color, },
}, "ISSUE_LABEL_UPDATE",
"ISSUE_LABEL_UPDATE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -382,15 +371,14 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/${labelId}/` `/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-labels/${labelId}/`
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueLabelEvent(
trackEventServices.trackIssueLabelEvent( {
{ workspaceSlug,
workspaceSlug, projectId,
projectId, },
}, "ISSUE_LABEL_DELETE",
"ISSUE_LABEL_DELETE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -410,7 +398,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent(response.data, "ISSUE_UPDATE", user); trackEventServices.trackIssueEvent(response.data, "ISSUE_UPDATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -426,7 +414,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> { ): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issuesId}/`) return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issuesId}/`)
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueEvent({ issuesId }, "ISSUE_DELETE", user); trackEventServices.trackIssueEvent({ issuesId }, "ISSUE_DELETE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -445,7 +433,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueBulkDeleteEvent(data, user); trackEventServices.trackIssueBulkDeleteEvent(data, user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {

View File

@ -5,11 +5,6 @@ import trackEventServices from "./track-event.service";
import type { IModule, IIssue, ICurrentUserResponse } from "types"; import type { IModule, IIssue, ICurrentUserResponse } from "types";
import { API_BASE_URL } from "helpers/common.helper"; 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 { class ProjectIssuesServices extends APIService {
constructor() { constructor() {
super(API_BASE_URL); super(API_BASE_URL);
@ -31,7 +26,7 @@ class ProjectIssuesServices extends APIService {
): Promise<any> { ): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/`, data) return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/`, data)
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_CREATE", user); trackEventServices.trackModuleEvent(response?.data, "MODULE_CREATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -51,7 +46,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user); trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -83,7 +78,7 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user); trackEventServices.trackModuleEvent(response?.data, "MODULE_UPDATE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -101,7 +96,7 @@ class ProjectIssuesServices extends APIService {
`/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/${moduleId}/` `/api/workspaces/${workspaceSlug}/projects/${projectId}/modules/${moduleId}/`
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackModuleEvent(response?.data, "MODULE_DELETE", user); trackEventServices.trackModuleEvent(response?.data, "MODULE_DELETE", user);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {
@ -156,20 +151,19 @@ class ProjectIssuesServices extends APIService {
data data
) )
.then((response) => { .then((response) => {
if (trackEvent) trackEventServices.trackIssueMovedToCycleOrModuleEvent(
trackEventServices.trackIssueMovedToCycleOrModuleEvent( {
{ workspaceSlug,
workspaceSlug, workspaceName: response?.data?.[0]?.issue_detail?.workspace_detail?.name,
workspaceName: response?.data?.[0]?.issue_detail?.workspace_detail?.name, projectId,
projectId, projectIdentifier: response?.data?.[0]?.issue_detail?.project_detail?.identifier,
projectIdentifier: response?.data?.[0]?.issue_detail?.project_detail?.identifier, projectName: response?.data?.[0]?.issue_detail?.project_detail?.name,
projectName: response?.data?.[0]?.issue_detail?.project_detail?.name, issueId: response?.data?.[0]?.issue_detail?.id,
issueId: response?.data?.[0]?.issue_detail?.id, moduleId,
moduleId, },
}, response?.data?.length > 1 ? "ISSUE_MOVED_TO_MODULE_IN_BULK" : "ISSUE_MOVED_TO_MODULE",
response?.data?.length > 1 ? "ISSUE_MOVED_TO_MODULE_IN_BULK" : "ISSUE_MOVED_TO_MODULE", user
user );
);
return response?.data; return response?.data;
}) })
.catch((error) => { .catch((error) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

1209
yarn.lock

File diff suppressed because it is too large Load Diff