Skip to content

Commit 9b26aec

Browse files
committed
feat(UI-1898): datadog screen session replays - mention pr comments
1 parent 0936a10 commit 9b26aec

File tree

6 files changed

+61
-28
lines changed

6 files changed

+61
-28
lines changed

src/components/organisms/topbar/project/buttons.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
useToastStore,
1818
useTourStore,
1919
} from "@src/store";
20-
import { validateEntitiesName, ClarityUtils, DatadogUtils } from "@src/utilities";
20+
import { validateEntitiesName, UserTrackingUtils } from "@src/utilities";
2121

2222
import { Button, IconSvg, Loader, Spinner } from "@components/atoms";
2323
import { DropdownButton } from "@components/molecules";
@@ -205,11 +205,7 @@ export const ProjectTopbarButtons = () => {
205205
LoggerService.info(namespaces.projectUI, t("topbar.buildProjectSuccessExtended", { buildId }));
206206

207207
if (buildId) {
208-
ClarityUtils.trackEvent("project_validated", {
209-
projectId,
210-
buildId,
211-
});
212-
DatadogUtils.trackEvent("project_validated", {
208+
UserTrackingUtils.trackEvent("project_validated", {
213209
projectId,
214210
buildId,
215211
});
@@ -265,11 +261,7 @@ export const ProjectTopbarButtons = () => {
265261
LoggerService.info(namespaces.projectUI, t("topbar.deployedProjectSuccessExtended", { deploymentId }));
266262

267263
if (deploymentId) {
268-
ClarityUtils.trackEvent("deployment_created", {
269-
deploymentId,
270-
projectId,
271-
});
272-
DatadogUtils.trackEvent("deployment_created", {
264+
UserTrackingUtils.trackEvent("deployment_created", {
273265
deploymentId,
274266
projectId,
275267
});

src/components/organisms/topbar/project/manualRun/manualRunButtons.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { namespaces, ProjectActions, tourStepsHTMLIds } from "@src/constants";
99
import { emptySelectItem } from "@src/constants/forms";
1010
import { DrawerName } from "@src/enums/components";
1111
import { useCacheStore, useDrawerStore, useManualRunStore, useProjectStore, useToastStore } from "@src/store/";
12-
import { ClarityUtils, DatadogUtils } from "@utilities";
12+
import { UserTrackingUtils } from "@utilities";
1313

1414
import { Button, IconSvg, Spinner } from "@components/atoms";
1515
import { ManualRunSuccessToastMessage } from "@components/organisms/topbar/project";
@@ -77,13 +77,7 @@ export const ManualRunButtons = () => {
7777
});
7878

7979
if (sessionId) {
80-
ClarityUtils.trackEvent("manual_run_executed", {
81-
sessionId,
82-
projectId,
83-
deploymentId: activeDeploymentStore?.deploymentId,
84-
entrypoint: entrypointFunction?.value,
85-
});
86-
DatadogUtils.trackEvent("manual_run_executed", {
80+
UserTrackingUtils.trackEvent("manual_run_executed", {
8781
sessionId,
8882
projectId,
8983
deploymentId: activeDeploymentStore?.deploymentId,

src/hooks/useProjectActions.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ModalName } from "@src/enums/components";
1616
import { fileOperations } from "@src/factories";
1717
import { Manifest } from "@src/interfaces/models";
1818
import { FileStructure } from "@src/interfaces/utilities";
19-
import { unpackFileZip, ClarityUtils, DatadogUtils } from "@src/utilities";
19+
import { unpackFileZip, UserTrackingUtils } from "@src/utilities";
2020

2121
import { useConnectionStore, useModalStore, useProjectStore, useToastStore } from "@store";
2222

@@ -65,11 +65,7 @@ export const useProjectActions = () => {
6565
const projectId = data?.projectId;
6666

6767
if (projectId) {
68-
ClarityUtils.trackEvent("project_created", {
69-
projectId,
70-
projectName: name,
71-
});
72-
DatadogUtils.trackEvent("project_created", {
68+
UserTrackingUtils.trackEvent("project_created", {
7369
projectId,
7470
projectName: name,
7571
});

src/main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import TimeAgo from "javascript-time-ago";
55
import en from "javascript-time-ago/locale/en";
66
import ReactDOM from "react-dom/client";
77

8-
import { appMode } from "@constants";
98
import {
9+
appMode,
1010
applicationId,
1111
clientToken,
1212
site,
@@ -16,15 +16,15 @@ import {
1616
sessionReplaySampleRate,
1717
allowedTracingUrls,
1818
defaultPrivacyLevel,
19-
} from "@constants/datadog.constants";
19+
} from "@constants";
2020
import { MainApp } from "@src/mainApp";
2121

2222
import "./assets/index.css";
2323
import "./i18n";
2424

2525
TimeAgo.addDefaultLocale(en);
2626

27-
if (!applicationId || !clientToken || !datadogVersion) {
27+
if (applicationId && clientToken && datadogVersion) {
2828
datadogRum.init({
2929
applicationId,
3030
clientToken,

src/utilities/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ export {
7373
export { getTextareaHeight } from "@utilities/htmlElements.utils";
7474
export { ClarityUtils } from "@utilities/clarity.utils";
7575
export { DatadogUtils } from "@utilities/datadog.utils";
76+
export { UserTrackingUtils } from "@utilities/userTracking.utils";
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Organization, Project, User } from "@src/types/models";
2+
import { ClarityUtils } from "@utilities/clarity.utils";
3+
import { DatadogUtils } from "@utilities/datadog.utils";
4+
5+
export const UserTrackingUtils = {
6+
setUser: (userId: string, userInfo: User) => {
7+
ClarityUtils.setUser(userId, userInfo);
8+
DatadogUtils.setUser(userId, userInfo);
9+
},
10+
11+
setOrg: (orgId: string, orgInfo: Organization) => {
12+
ClarityUtils.setOrg(orgId, orgInfo);
13+
DatadogUtils.setOrg(orgId, orgInfo);
14+
},
15+
16+
setProject: (projectId: string, projectInfo: Project) => {
17+
ClarityUtils.setProject(projectId, projectInfo);
18+
DatadogUtils.setProject(projectId, projectInfo);
19+
},
20+
21+
setUserRole: (role: string) => {
22+
ClarityUtils.setUserRole(role);
23+
DatadogUtils.setUserRole(role);
24+
},
25+
26+
setPlanType: (planType: string) => {
27+
ClarityUtils.setPlanType(planType);
28+
DatadogUtils.setPlanType(planType);
29+
},
30+
31+
setDeploymentId: (deploymentId: string) => {
32+
ClarityUtils.setDeploymentId(deploymentId);
33+
DatadogUtils.setDeploymentId(deploymentId);
34+
},
35+
36+
trackEvent: (eventName: string, properties?: Record<string, any>) => {
37+
ClarityUtils.trackEvent(eventName, properties);
38+
DatadogUtils.trackEvent(eventName, properties);
39+
},
40+
41+
setSessionId: (sessionId: string) => {
42+
ClarityUtils.setSessionId(sessionId);
43+
DatadogUtils.setSessionId(sessionId);
44+
},
45+
46+
setEventId: (eventId: string) => {
47+
ClarityUtils.setEventId(eventId);
48+
DatadogUtils.setEventId(eventId);
49+
},
50+
};

0 commit comments

Comments
 (0)