Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

FEAT: PostHog Custom Events (#311)

Tahier Hussaine2cb9992ef5e
diff --git a/frontend/src/components/agency/actions/Actions.jsx b/frontend/src/components/agency/actions/Actions.jsx
index 55c3ee3af..fe82adaca 100644
--- a/frontend/src/components/agency/actions/Actions.jsx
+++ b/frontend/src/components/agency/actions/Actions.jsx
@@ -26,6 +26,7 @@ import { EtlTaskDeploy } from "../../pipelines-or-deployments/etl-task-deploy/Et
import FileUpload from "../file-upload/FileUpload.jsx";
import "./Actions.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
const [executionId, setExecutionId] = useState("");
@@ -44,6 +45,7 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
const [deploymentType, setDeploymentType] = useState("");
const handleException = useExceptionHandler();
const {
+ projectName,
details,
isLoading,
loadingType,
@@ -55,6 +57,9 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
const { sessionDetails } = useSessionStore();
const { orgName } = sessionDetails;
const axiosPrivate = useAxiosPrivate();
+ const { posthogWfDeploymentEventText, setPostHogCustomEvent } =
+ usePostHogEvents();
+
useEffect(() => {
// Enable Deploy as API only when
// Source & Destination connection_type are selected as API
@@ -156,6 +161,19 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
isStepExecution,
executionAction
) => {
+ try {
+ if (isStepExecution) {
+ setPostHogCustomEvent("wf_step", {
+ info: `Clicked on '${wfExecutionTypes[executionAction]}' button (Step Execution)`,
+ });
+ } else {
+ setPostHogCustomEvent("wf_run_wf", {
+ info: "Clicked on 'Run Workflow' button (Normal Execution)",
+ });
+ }
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
const workflowId = details?.id;
if (!workflowId) {
@@ -373,6 +391,19 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
});
};
+ const handleDeployBtnClick = (deployType) => {
+ createDeployment(deployType);
+
+ try {
+ setPostHogCustomEvent(posthogWfDeploymentEventText[deployType], {
+ info: `Clicked on 'Deploy as ${deployType}' button`,
+ workflow_name: projectName,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
return (
<>
<div className="actions-container">
@@ -446,7 +477,7 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
<Tooltip title="Deploy as API">
<Button
disabled={isIncompleteWorkflow() || !apiOpsPresent}
- onClick={() => createDeployment("API")}
+ onClick={() => handleDeployBtnClick("API")}
>
<ApiOutlined />
</Button>
@@ -454,14 +485,14 @@ function Actions({ statusBarMsg, initializeWfComp, stepLoader }) {
<Tooltip title="Deploy as ETL Pipeline">
<Button
disabled={isIncompleteWorkflow() || !canAddETLPipeline}
- onClick={() => createDeployment("ETL")}
+ onClick={() => handleDeployBtnClick("ETL")}
>
<DeploymentUnitOutlined />
</Button>
</Tooltip>
<Tooltip title="Deploy as Task Pipeline">
<Button
- onClick={() => createDeployment("TASK")}
+ onClick={() => handleDeployBtnClick("TASK")}
disabled={isIncompleteWorkflow() || !canAddTaskPipeline}
>
<ApiOutlined />
diff --git a/frontend/src/components/agency/configure-connector-modal/ConfigureConnectorModal.jsx b/frontend/src/components/agency/configure-connector-modal/ConfigureConnectorModal.jsx
index ae8269be5..0b140754b 100644
--- a/frontend/src/components/agency/configure-connector-modal/ConfigureConnectorModal.jsx
+++ b/frontend/src/components/agency/configure-connector-modal/ConfigureConnectorModal.jsx
@@ -6,6 +6,7 @@ import { ListOfConnectors } from "../list-of-connectors/ListOfConnectors";
import "./ConfigureConnectorModal.css";
import { ConfigureFormsLayout } from "../configure-forms-layout/ConfigureFormsLayout";
import { ManageFiles } from "../../input-output/manage-files/ManageFiles";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
function ConfigureConnectorModal({
open,
@@ -23,8 +24,12 @@ function ConfigureConnectorModal({
isSpecConfigLoading,
connDetails,
connType,
+ selectedItemName,
+ setSelectedItemName,
}) {
const [activeKey, setActiveKey] = useState("1");
+ const { setPostHogCustomEvent, posthogConnectorEventText } =
+ usePostHogEvents();
const tabItems = [
{
key: "1",
@@ -44,6 +49,18 @@ function ConfigureConnectorModal({
const id = e.key;
setSelectedId(id?.toString());
setActiveKey("1");
+
+ const connectorData = [...filteredList].find((item) => item?.key === id);
+ setSelectedItemName(connectorData?.label);
+
+ try {
+ setPostHogCustomEvent(posthogConnectorEventText[`${connType}:${type}`], {
+ info: `Selected a connector`,
+ connector_name: connectorData?.label,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
};
const onTabChange = (key) => {
@@ -94,6 +111,8 @@ function ConfigureConnectorModal({
setFormDataConfig={setFormDataConfig}
isSpecConfigLoading={isSpecConfigLoading}
connDetails={connDetails}
+ connType={connType}
+ selectedItemName={selectedItemName}
/>
)}
{activeKey === "2" && <ManageFiles selectedItem={connectorId} />}
@@ -120,6 +139,8 @@ ConfigureConnectorModal.propTypes = {
isSpecConfigLoading: PropTypes.bool.isRequired,
connDetails: PropTypes.object,
connType: PropTypes.string.isRequired,
+ selectedItemName: PropTypes.string,
+ setSelectedItemName: PropTypes.func.isRequired,
};
export { ConfigureConnectorModal };
diff --git a/frontend/src/components/agency/configure-forms-layout/ConfigureFormsLayout.jsx b/frontend/src/components/agency/configure-forms-layout/ConfigureFormsLayout.jsx
index 648cc5cdb..74a9e916d 100644
--- a/frontend/src/components/agency/configure-forms-layout/ConfigureFormsLayout.jsx
+++ b/frontend/src/components/agency/configure-forms-layout/ConfigureFormsLayout.jsx
@@ -17,6 +17,8 @@ function ConfigureFormsLayout({
setFormDataConfig,
isSpecConfigLoading,
connDetails,
+ connType,
+ selectedItemName,
}) {
return (
<Row className="conn-modal-tab-body">
@@ -41,6 +43,8 @@ function ConfigureFormsLayout({
editItemId={editItemId}
handleUpdate={handleUpdate}
connDetails={connDetails}
+ connType={connType}
+ selectedSourceName={selectedItemName}
/>
)}
</div>
@@ -82,6 +86,8 @@ ConfigureFormsLayout.propTypes = {
setFormDataConfig: PropTypes.func.isRequired,
isSpecConfigLoading: PropTypes.bool.isRequired,
connDetails: PropTypes.object,
+ connType: PropTypes.string,
+ selectedItemName: PropTypes.string,
};
export { ConfigureFormsLayout };
diff --git a/frontend/src/components/agency/ds-settings-card/DsSettingsCard.jsx b/frontend/src/components/agency/ds-settings-card/DsSettingsCard.jsx
index e63dffbc4..1963dbe2c 100644
--- a/frontend/src/components/agency/ds-settings-card/DsSettingsCard.jsx
+++ b/frontend/src/components/agency/ds-settings-card/DsSettingsCard.jsx
@@ -77,6 +77,8 @@ function DsSettingsCard({ type, endpointDetails, message }) {
const [isSpecConfigLoading, setIsSpecConfigLoading] = useState(false);
const [formDataConfig, setFormDataConfig] = useState({});
const [selectedId, setSelectedId] = useState("");
+ const [selectedItemName, setSelectedItemName] = useState("");
+
const { sessionDetails } = useSessionStore();
const { updateWorkflow } = useWorkflowStore();
const { setAlertDetails } = useAlertStore();
@@ -431,6 +433,8 @@ function DsSettingsCard({ type, endpointDetails, message }) {
isSpecConfigLoading={isSpecConfigLoading}
connDetails={connDetails}
connType={connType}
+ selectedItemName={selectedItemName}
+ setSelectedItemName={setSelectedItemName}
/>
</>
);
diff --git a/frontend/src/components/agency/steps/Steps.jsx b/frontend/src/components/agency/steps/Steps.jsx
index 5a8cac5b6..9c2f926a5 100644
--- a/frontend/src/components/agency/steps/Steps.jsx
+++ b/frontend/src/components/agency/steps/Steps.jsx
@@ -14,6 +14,7 @@ import { DsSettingsCard } from "../ds-settings-card/DsSettingsCard.jsx";
import { StepCard } from "../step-card/StepCard.jsx";
import "./Steps.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function Steps({ setSteps, activeToolId, sourceMsg, destinationMsg }) {
const workflowStore = useWorkflowStore();
@@ -31,6 +32,7 @@ function Steps({ setSteps, activeToolId, sourceMsg, destinationMsg }) {
const axiosPrivate = useAxiosPrivate();
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
useEffect(() => {
getWfEndpointDetails();
@@ -60,6 +62,14 @@ function Steps({ setSteps, activeToolId, sourceMsg, destinationMsg }) {
const moveItem = (fromIndex, toIndex, funcName, dragging) => {
const toolInstance = details?.tool_instances || [];
if (fromIndex === undefined && funcName) {
+ try {
+ setPostHogCustomEvent("wf_tool_drag_dropped", {
+ info: `Tool dragged and dropped`,
+ tool_name: funcName,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
handleAddToolInstance(funcName)
.then((res) => {
const data = res?.data;
diff --git a/frontend/src/components/custom-tools/add-llm-profile/AddLlmProfile.jsx b/frontend/src/components/custom-tools/add-llm-profile/AddLlmProfile.jsx
index a21cad29c..e33b35c62 100644
--- a/frontend/src/components/custom-tools/add-llm-profile/AddLlmProfile.jsx
+++ b/frontend/src/components/custom-tools/add-llm-profile/AddLlmProfile.jsx
@@ -23,6 +23,7 @@ import { useSessionStore } from "../../../store/session-store";
import { CustomButton } from "../../widgets/custom-button/CustomButton";
import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper";
import "./AddLlmProfile.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
function AddLlmProfile({
editLlmProfileId,
@@ -50,6 +51,7 @@ function AddLlmProfile({
const axiosPrivate = useAxiosPrivate();
const { token } = theme.useToken();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const panelStyle = {
marginBottom: 16,
};
@@ -296,6 +298,14 @@ function AddLlmProfile({
method = "PUT";
url = `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/profile-manager/`;
url += `${editLlmProfileId}/`;
+ } else {
+ try {
+ setPostHogCustomEvent("intent_success_ps_new_llm_profile", {
+ info: "Clicked on 'Add' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
}
const requestOptions = {
diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
index 26da57682..5effd670c 100644
--- a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
+++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
@@ -15,6 +15,7 @@ import { DocumentViewer } from "../document-viewer/DocumentViewer";
import { ManageDocsModal } from "../manage-docs-modal/ManageDocsModal";
import { PdfViewer } from "../pdf-viewer/PdfViewer";
import { TextViewerPre } from "../text-viewer-pre/TextViewerPre";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
const items = [
{
@@ -71,6 +72,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
} = useCustomToolStore();
const { sessionDetails } = useSessionStore();
const axiosPrivate = useAxiosPrivate();
+ const { setPostHogCustomEvent } = usePostHogEvents();
useEffect(() => {
setFileUrl("");
@@ -167,6 +169,22 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
const handleActiveKeyChange = (key) => {
setActiveKey(key);
+
+ try {
+ if (key === "2") {
+ setPostHogCustomEvent("ps_raw_view_clicked", {
+ info: "Clicked on the 'Raw View' tab",
+ });
+ }
+
+ if (key === "3") {
+ setPostHogCustomEvent("ps_summary_view_clicked", {
+ info: "Clicked on the 'Summary View' tab",
+ });
+ }
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
};
const setErrorMessage = (viewType) => {
diff --git a/frontend/src/components/custom-tools/header/Header.jsx b/frontend/src/components/custom-tools/header/Header.jsx
index 259f1ede9..8cdf6bc56 100644
--- a/frontend/src/components/custom-tools/header/Header.jsx
+++ b/frontend/src/components/custom-tools/header/Header.jsx
@@ -17,6 +17,7 @@ import { useCustomToolStore } from "../../../store/custom-tool-store";
import { useSessionStore } from "../../../store/session-store";
import { CustomButton } from "../../widgets/custom-button/CustomButton";
import { ExportTool } from "../export-tool/ExportTool";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
let SinglePassToggleSwitch;
try {
@@ -35,6 +36,7 @@ function Header({ setOpenSettings, handleUpdateTool }) {
const handleException = useExceptionHandler();
const [userList, setUserList] = useState([]);
const [openExportToolModal, setOpenExportToolModal] = useState(false);
+ const { setPostHogCustomEvent } = usePostHogEvents();
const [toolDetails, setToolDetails] = useState(null);
@@ -70,6 +72,15 @@ function Header({ setOpenSettings, handleUpdateTool }) {
};
const handleShare = (isEdit) => {
+ try {
+ setPostHogCustomEvent("ps_exported_tool", {
+ info: `Clicked on the 'Export' button`,
+ tool_name: details?.tool_name,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
const requestOptions = {
method: "GET",
url: `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/export/${details?.tool_id}`,
diff --git a/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx b/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
index ed5dd4df8..f610b7b5d 100644
--- a/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
+++ b/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
@@ -11,6 +11,7 @@ import "./ListOfTools.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
import { SharePermission } from "../../widgets/share-permission/SharePermission";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
let OnboardMessagesModal;
let slides;
@@ -30,6 +31,7 @@ function ListOfTools() {
const [editItem, setEditItem] = useState(null);
const { sessionDetails } = useSessionStore();
const { loginOnboardingMessage } = sessionDetails;
+ const { setPostHogCustomEvent } = usePostHogEvents();
const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
@@ -181,12 +183,24 @@ function ListOfTools() {
setOpenAddTool(true);
};
+ const handleNewProjectBtnClick = () => {
+ showAddTool();
+
+ try {
+ setPostHogCustomEvent("intent_new_ps_project", {
+ info: "Clicked on '+ New Project' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
const CustomButtons = () => {
return (
<CustomButton
type="primary"
icon={<PlusOutlined />}
- onClick={showAddTool}
+ onClick={handleNewProjectBtnClick}
>
New Project
</CustomButton>
diff --git a/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx b/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx
index 72d1b3a5e..6b2765893 100644
--- a/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx
+++ b/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx
@@ -31,6 +31,7 @@ import { EmptyState } from "../../widgets/empty-state/EmptyState";
import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";
import "./ManageDocsModal.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
let SummarizeStatusTitle = null;
try {
@@ -78,6 +79,7 @@ function ManageDocsModal({
const { messages } = useSocketCustomToolStore();
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const successIndex = (
<Typography.Text>
@@ -338,6 +340,19 @@ function ManageDocsModal({
return instance?.isIndexed ? successIndex : failed;
};
+ const handleReIndexBtnClick = (item) => {
+ generateIndex(item);
+
+ try {
+ setPostHogCustomEvent("intent_ps_indexed_file", {
+ info: "Clicked on index button",
+ document_name: item?.document_name,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
useEffect(() => {
const newRows = listOfDocs.map((item) => {
return {
@@ -357,7 +372,7 @@ function ManageDocsModal({
<Button
size="small"
icon={<ReloadOutlined />}
- onClick={() => generateIndex(item)}
+ onClick={() => handleReIndexBtnClick(item)}
disabled={
disableLlmOrDocChange?.length > 0 ||
isSinglePassExtractLoading ||
@@ -419,6 +434,14 @@ function ManageDocsModal({
]);
const beforeUpload = (file) => {
+ try {
+ setPostHogCustomEvent("ps_uploaded_file", {
+ info: "Clicked on '+ Upload New File' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
diff --git a/frontend/src/components/custom-tools/manage-llm-profiles/ManageLlmProfiles.jsx b/frontend/src/components/custom-tools/manage-llm-profiles/ManageLlmProfiles.jsx
index 38ae68d74..c49b40c80 100644
--- a/frontend/src/components/custom-tools/manage-llm-profiles/ManageLlmProfiles.jsx
+++ b/frontend/src/components/custom-tools/manage-llm-profiles/ManageLlmProfiles.jsx
@@ -12,6 +12,7 @@ import { CustomButton } from "../../widgets/custom-button/CustomButton";
import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper";
import { AddLlmProfile } from "../add-llm-profile/AddLlmProfile";
import "./ManageLlmProfiles.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
const columns = [
{
@@ -68,8 +69,17 @@ function ManageLlmProfiles() {
useCustomToolStore();
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const handleDefaultLlm = (profileId) => {
+ try {
+ setPostHogCustomEvent("ps_profile_changed_per_prompt", {
+ info: "Selected default LLM profile",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
const body = {
default_profile: profileId,
};
@@ -140,6 +150,18 @@ function ManageLlmProfiles() {
setRows(modifiedRows);
}, [llmProfiles, defaultLlmProfile]);
+ const handleAddNewLlmProfileBtnClick = () => {
+ setIsAddLlm(true);
+
+ try {
+ setPostHogCustomEvent("intent_ps_new_llm_profile", {
+ info: "Clicked on 'Add New LLM Profile' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
const handleEdit = (id) => {
setEditLlmProfileId(id);
setIsAddLlm(true);
@@ -206,7 +228,7 @@ function ManageLlmProfiles() {
</div>
</SpaceWrapper>
<div className="display-flex-right">
- <CustomButton type="primary" onClick={() => setIsAddLlm(true)}>
+ <CustomButton type="primary" onClick={handleAddNewLlmProfileBtnClick}>
Add New LLM Profile
</CustomButton>
</div>
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
index bde939640..db444bacc 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
@@ -48,6 +48,7 @@ import { OutputForDocModal } from "../output-for-doc-modal/OutputForDocModal";
import "./PromptCard.css";
import { TokenCount } from "../token-count/TokenCount";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
const EvalBtn = null;
const EvalMetrics = null;
@@ -104,6 +105,7 @@ function PromptCard({
const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
useEffect(() => {
// Find the latest message that matches the criteria
@@ -282,6 +284,14 @@ function PromptCard({
// Generate the result for the currently selected document
const handleRun = () => {
+ try {
+ setPostHogCustomEvent("ps_prompt_run", {
+ info: "Click on 'Run Prompt' button (Multi Pass)",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
if (!promptDetails?.profile_manager?.length) {
setAlertDetails({
type: "error",
diff --git a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
index 30ea5a403..7ade1571c 100644
--- a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
+++ b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
@@ -15,6 +15,7 @@ import { LogsLabel } from "../logs-label/LogsLabel";
import { SettingsModal } from "../settings-modal/SettingsModal";
import { ToolsMain } from "../tools-main/ToolsMain";
import "./ToolIde.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
let OnboardMessagesModal;
let slides;
@@ -48,6 +49,7 @@ function ToolIde() {
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
const [loginModalOpen, setLoginModalOpen] = useState(true);
+ const { setPostHogCustomEvent } = usePostHogEvents();
const openLogsModal = () => {
setShowLogsModal(true);
@@ -115,6 +117,14 @@ function ToolIde() {
type: "success",
content: `${doc?.document_name} - Indexed successfully`,
});
+
+ try {
+ setPostHogCustomEvent("intent_success_ps_indexed_file", {
+ info: "Indexing completed",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
})
.catch((err) => {
setAlertDetails(
diff --git a/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx b/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx
index 9c6484ef4..caad513fe 100644
--- a/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx
+++ b/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx
@@ -13,6 +13,7 @@ import { CombinedOutput } from "../combined-output/CombinedOutput";
import { DocumentParser } from "../document-parser/DocumentParser";
import { Footer } from "../footer/Footer";
import "./ToolsMain.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
let RunSinglePassBtn;
try {
@@ -40,6 +41,7 @@ function ToolsMain() {
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
const navigate = useNavigate();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const items = [
{
@@ -105,6 +107,14 @@ function ToolsMain() {
};
const addPromptInstance = (type) => {
+ try {
+ setPostHogCustomEvent("ps_prompt_added", {
+ info: `Clicked on + ${type} button`,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
let body = {};
if (type === promptType.prompt) {
body = { ...defaultPromptInstance };
@@ -137,6 +147,18 @@ function ToolsMain() {
});
};
+ const handleOutputAnalyzerBtnClick = () => {
+ navigate("outputAnalyzer");
+
+ try {
+ setPostHogCustomEvent("ps_output_analyser_seen", {
+ info: "Clicked on 'Output Analyzer' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
return (
<div className="tools-main-layout">
<div className="doc-manager-header">
@@ -148,7 +170,7 @@ function ToolsMain() {
<Tooltip title="Output Analyzer">
<Button
icon={<BarChartOutlined />}
- onClick={() => navigate("outputAnalyzer")}
+ onClick={handleOutputAnalyzerBtnClick}
disabled={
disableLlmOrDocChange?.length > 0 ||
isSinglePassExtractLoading
diff --git a/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx b/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
index 53cb10999..d8f325700 100644
--- a/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
+++ b/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
@@ -6,6 +6,7 @@ import { useAlertStore } from "../../../store/alert-store";
import { apiDeploymentsService } from "../../deployments/api-deployment/api-deployments-service.js";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
import { useWorkflowStore } from "../../../store/workflow-store.js";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
const defaultFromDetails = {
display_name: "",
@@ -39,6 +40,8 @@ const CreateApiDeploymentModal = ({
const [form] = Form.useForm();
const [backendErrors, setBackendErrors] = useState(null);
const [isFormChanged, setIsFormChanged] = useState(false);
+ const { setPostHogCustomEvent } = usePostHogEvents();
+
const handleInputChange = (changedValues, allValues) => {
setIsFormChanged(true);
setFormDetails({ ...formDetails, ...allValues });
@@ -92,6 +95,19 @@ const CreateApiDeploymentModal = ({
};
const createApiDeployment = () => {
+ try {
+ const wf = workflowEndpointList.find(
+ (item) => item?.workflow === formDetails?.workflow
+ );
+ setPostHogCustomEvent("intent_success_api_deployment", {
+ info: "Clicked on 'Save' button",
+ deployment_name: formDetails?.api_name,
+ workflow_name: wf?.workflow_name,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
setIsLoading(true);
const body = formDetails;
apiDeploymentsApiService
diff --git a/frontend/src/components/deployments/header/Header.jsx b/frontend/src/components/deployments/header/Header.jsx
index efb28950d..c07419a07 100644
--- a/frontend/src/components/deployments/header/Header.jsx
+++ b/frontend/src/components/deployments/header/Header.jsx
@@ -4,14 +4,30 @@ import PropTypes from "prop-types";
import { CustomButton } from "../../widgets/custom-button/CustomButton";
import { deploymentsStaticContent } from "../../../helpers/GetStaticData";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
function Header({ type, openAddModal }) {
+ const { posthogDeploymentEventText, setPostHogCustomEvent } =
+ usePostHogEvents();
+
+ const handleOnClick = () => {
+ openAddModal(false);
+
+ try {
+ setPostHogCustomEvent(posthogDeploymentEventText[type], {
+ info: `Clicked on '+ ${deploymentsStaticContent[type].addBtn}' button`,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
const customButtons = () => {
return (
<CustomButton
type="primary"
icon={<PlusOutlined />}
- onClick={() => openAddModal(false)}
+ onClick={handleOnClick}
>
{deploymentsStaticContent[type].addBtn}
</CustomButton>
diff --git a/frontend/src/components/helpers/auth/RequireAuth.js b/frontend/src/components/helpers/auth/RequireAuth.js
index caaef86a5..ffc1afdcc 100644
--- a/frontend/src/components/helpers/auth/RequireAuth.js
+++ b/frontend/src/components/helpers/auth/RequireAuth.js
@@ -5,9 +5,12 @@ import {
onboardCompleted,
} from "../../../helpers/GetStaticData";
import { useSessionStore } from "../../../store/session-store";
+import { useEffect } from "react";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
const RequireAuth = () => {
const { sessionDetails } = useSessionStore();
+ const { setPostHogIdentity } = usePostHogEvents();
const location = useLocation();
const isLoggedIn = sessionDetails?.isLoggedIn;
const orgName = sessionDetails?.orgName;
@@ -15,6 +18,14 @@ const RequireAuth = () => {
const adapters = sessionDetails?.adapters;
const currOrgName = getOrgNameFromPathname(pathname);
+ useEffect(() => {
+ if (!sessionDetails?.isLoggedIn) {
+ return;
+ }
+
+ setPostHogIdentity();
+ }, [sessionDetails]);
+
let navigateTo = `/${orgName}/onboard`;
if (onboardCompleted(adapters)) {
navigateTo = `/${orgName}/tools`;
diff --git a/frontend/src/components/input-output/add-source-modal/AddSourceModal.jsx b/frontend/src/components/input-output/add-source-modal/AddSourceModal.jsx
index c85346381..6c197598d 100644
--- a/frontend/src/components/input-output/add-source-modal/AddSourceModal.jsx
+++ b/frontend/src/components/input-output/add-source-modal/AddSourceModal.jsx
@@ -22,6 +22,7 @@ function AddSourceModal({
const [selectedSourceId, setSelectedSourceId] = useState(null);
const [metadata, setMetadata] = useState({});
const [titles, setTitles] = useState({});
+ const [selectedSourceName, setSelectedSourceName] = useState("");
const { sessionDetails } = useSessionStore();
const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
@@ -65,6 +66,13 @@ function AddSourceModal({
}
}, [open]);
+ useEffect(() => {
+ const selectedSource = sourcesList.find(
+ (item) => item?.id === selectedSourceId
+ );
+ setSelectedSourceName(selectedSource?.name);
+ }, [selectedSourceId]);
+
const getSourceDetails = () => {
const isConnector = sourceTypes.connectors.includes(type);
let url = `/api/v1/unstract/${sessionDetails?.orgId}`;
@@ -153,6 +161,7 @@ function AddSourceModal({
{selectedSourceId ? (
<AddSource
selectedSourceId={selectedSourceId}
+ selectedSourceName={selectedSourceName}
setOpen={setOpen}
type={type}
addNewItem={addNewItem}
@@ -166,6 +175,7 @@ function AddSourceModal({
setSelectedSourceId={setSelectedSourceId}
open={open}
sourcesList={sourcesList}
+ type={type}
/>
)}
</Modal>
diff --git a/frontend/src/components/input-output/add-source/AddSource.jsx b/frontend/src/components/input-output/add-source/AddSource.jsx
index 10c607249..417936abb 100644
--- a/frontend/src/components/input-output/add-source/AddSource.jsx
+++ b/frontend/src/components/input-output/add-source/AddSource.jsx
@@ -12,6 +12,7 @@ import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
function AddSource({
selectedSourceId,
+ selectedSourceName,
setOpen,
type,
addNewItem,
@@ -19,6 +20,7 @@ function AddSource({
metadata,
handleUpdate,
connDetails,
+ connType,
}) {
const [spec, setSpec] = useState({});
const [formData, setFormData] = useState({});
@@ -106,12 +108,15 @@ function AddSource({
handleUpdate={handleUpdate}
connDetails={connDetails}
metadata={metadata}
+ selectedSourceName={selectedSourceName}
+ connType={connType}
/>
);
}
AddSource.propTypes = {
selectedSourceId: PropTypes.string.isRequired,
+ selectedSourceName: PropTypes.string,
setOpen: PropTypes.func,
type: PropTypes.string.isRequired,
addNewItem: PropTypes.func,
@@ -119,6 +124,7 @@ AddSource.propTypes = {
metadata: PropTypes.object,
handleUpdate: PropTypes.func,
connDetails: PropTypes.object,
+ connType: PropTypes.string,
};
export { AddSource };
diff --git a/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx b/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx
index 2b9f9fa5f..92f403962 100644
--- a/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx
+++ b/frontend/src/components/input-output/configure-ds/ConfigureDs.jsx
@@ -12,6 +12,7 @@ import { useSessionStore } from "../../../store/session-store";
import { OAuthDs } from "../../oauth-ds/oauth-ds/OAuthDs.jsx";
import { CustomButton } from "../../widgets/custom-button/CustomButton.jsx";
import "./ConfigureDs.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function ConfigureDs({
spec,
@@ -28,6 +29,8 @@ function ConfigureDs({
handleUpdate,
connDetails,
metadata,
+ selectedSourceName,
+ connType,
}) {
const formRef = createRef(null);
const axiosPrivate = useAxiosPrivate();
@@ -40,6 +43,12 @@ function ConfigureDs({
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
const { updateSessionDetails } = useSessionStore();
+ const {
+ posthogTcEventText,
+ posthogSubmitEventText,
+ posthogConnectorAddedEventText,
+ setPostHogCustomEvent,
+ } = usePostHogEvents();
const { id } = useParams();
@@ -104,6 +113,14 @@ function ConfigureDs({
adapter_type: type.toUpperCase(),
};
url += "test_adapters/";
+
+ try {
+ setPostHogCustomEvent(posthogTcEventText[type], {
+ info: `Test connection was triggered: ${selectedSourceName}`,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
}
if (oAuthProvider?.length > 0) {
@@ -175,6 +192,18 @@ function ConfigureDs({
connector_name: connectorName,
};
url += "connector/";
+
+ try {
+ setPostHogCustomEvent(
+ posthogConnectorAddedEventText[`${connType}:${type}`],
+ {
+ info: `Clicked on 'Submit' button`,
+ connector_name: selectedSourceName,
+ }
+ );
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
} else {
const adapterMetadata = { ...formData };
const adapterName = adapterMetadata?.adapter_name;
@@ -186,6 +215,15 @@ function ConfigureDs({
adapter_name: adapterName,
};
url += "adapter/";
+
+ try {
+ setPostHogCustomEvent(posthogSubmitEventText[type], {
+ info: "Clicked on 'Submit' button",
+ adpater_name: selectedSourceName,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
}
let method = "POST";
@@ -311,6 +349,8 @@ ConfigureDs.propTypes = {
handleUpdate: PropTypes.func,
connDetails: PropTypes.object,
metadata: PropTypes.object,
+ selectedSourceName: PropTypes.string.isRequired,
+ connType: PropTypes.string,
};
export { ConfigureDs };
diff --git a/frontend/src/components/input-output/data-source-card/DataSourceCard.jsx b/frontend/src/components/input-output/data-source-card/DataSourceCard.jsx
index 0f0c48ad6..b6ef89cda 100644
--- a/frontend/src/components/input-output/data-source-card/DataSourceCard.jsx
+++ b/frontend/src/components/input-output/data-source-card/DataSourceCard.jsx
@@ -2,8 +2,27 @@ import { Card, Image, Typography } from "antd";
import PropTypes from "prop-types";
import "./DataSourceCard.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
-function DataSourceCard({ srcDetails, setSelectedSourceId }) {
+function DataSourceCard({ srcDetails, setSelectedSourceId, type }) {
+ const { posthogEventText, setPostHogCustomEvent } = usePostHogEvents();
+
+ const handleSelectSource = () => {
+ if (srcDetails?.isDisabled) {
+ return;
+ }
+
+ setSelectedSourceId(srcDetails?.id);
+
+ try {
+ setPostHogCustomEvent(posthogEventText[type], {
+ info: "Clicked on the adapters card",
+ adapter_name: srcDetails?.name,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
return (
<Card
hoverable={!srcDetails?.isDisabled}
@@ -11,9 +30,7 @@ function DataSourceCard({ srcDetails, setSelectedSourceId }) {
type="inner"
bordered={true}
className={`ds-card ${srcDetails?.isDisabled ? "disabled" : ""}`}
- onClick={() =>
- !srcDetails?.isDisabled && setSelectedSourceId(srcDetails?.id)
- }
+ onClick={handleSelectSource}
>
<div className="cover-container">
{srcDetails?.isDisabled && (
@@ -40,6 +57,7 @@ function DataSourceCard({ srcDetails, setSelectedSourceId }) {
DataSourceCard.propTypes = {
srcDetails: PropTypes.object.isRequired,
setSelectedSourceId: PropTypes.func.isRequired,
+ type: PropTypes.string.isRequired,
};
export { DataSourceCard };
diff --git a/frontend/src/components/input-output/list-of-sources/ListOfSources.jsx b/frontend/src/components/input-output/list-of-sources/ListOfSources.jsx
index b359c0574..9a4e4d13a 100644
--- a/frontend/src/components/input-output/list-of-sources/ListOfSources.jsx
+++ b/frontend/src/components/input-output/list-of-sources/ListOfSources.jsx
@@ -7,7 +7,7 @@ import debounce from "lodash/debounce";
import { DataSourceCard } from "../data-source-card/DataSourceCard";
import "./ListOfSources.css";
-function ListOfSources({ setSelectedSourceId, open, sourcesList }) {
+function ListOfSources({ setSelectedSourceId, open, sourcesList, type }) {
const [filteredSourcesList, setFilteredSourcesList] = useState([]);
const [searchText, setSearchText] = useState("");
@@ -57,6 +57,7 @@ function ListOfSources({ setSelectedSourceId, open, sourcesList }) {
<DataSourceCard
srcDetails={srcDetails}
setSelectedSourceId={setSelectedSourceId}
+ type={type}
/>
</List.Item>
)}
@@ -70,6 +71,7 @@ ListOfSources.propTypes = {
setSelectedSourceId: PropTypes.func.isRequired,
open: PropTypes.bool,
sourcesList: PropTypes.array,
+ type: PropTypes.string.isRequired,
};
export { ListOfSources };
diff --git a/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx b/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
index 60bc8a609..a0383126f 100644
--- a/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
+++ b/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
@@ -13,6 +13,7 @@ import "./EtlTaskDeploy.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
import { useWorkflowStore } from "../../../store/workflow-store.js";
import { getBackendErrorDetail } from "../../../helpers/GetStaticData.js";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
const defaultFromDetails = {
pipeline_name: "",
@@ -49,6 +50,8 @@ const EtlTaskDeploy = ({
const [openCronGenerator, setOpenCronGenerator] = useState(false);
const [backendErrors, setBackendErrors] = useState(null);
const [summary, setSummary] = useState(null);
+ const { posthogDeploymentEventText, setPostHogCustomEvent } =
+ usePostHogEvents();
useEffect(() => {
if (workflowId) {
@@ -175,6 +178,19 @@ const EtlTaskDeploy = ({
};
const createPipeline = () => {
+ try {
+ const wf = workflowList.find(
+ (item) => item?.id === formDetails?.workflow
+ );
+ setPostHogCustomEvent(posthogDeploymentEventText[`${type}_success`], {
+ info: "Clicked on 'Save and Deploy' button",
+ deployment_name: formDetails?.pipeline_name,
+ workflow_name: wf?.workflow_name,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
const body = formDetails;
body["pipeline_type"] = type.toUpperCase();
@@ -306,7 +322,7 @@ const EtlTaskDeploy = ({
</div>
<div>
<Typography.Text className="summary-text">
- {summary ? summary : "Summary not available."}
+ {summary || "Summary not available."}
</Typography.Text>
</div>
</Space>
@@ -322,6 +338,7 @@ const EtlTaskDeploy = ({
</>
);
};
+
EtlTaskDeploy.propTypes = {
open: PropTypes.bool.isRequired,
setOpen: PropTypes.func.isRequired,
@@ -333,4 +350,5 @@ EtlTaskDeploy.propTypes = {
selectedRow: PropTypes.object,
setDeploymentName: PropTypes.func,
};
+
export { EtlTaskDeploy };
diff --git a/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx b/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
index 8258f6fa2..9eee85ab6 100644
--- a/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
+++ b/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
@@ -429,34 +429,32 @@ function Pipelines({ type }) {
];
return (
- <>
- <div className="p-or-d-layout">
- <Layout
+ <div className="p-or-d-layout">
+ <Layout
+ type={type}
+ columns={columns}
+ tableData={tableData}
+ isTableLoading={tableLoading}
+ openAddModal={openAddModal}
+ />
+ {openEtlOrTaskModal && (
+ <EtlTaskDeploy
+ open={openEtlOrTaskModal}
+ setOpen={setOpenEtlOrTaskModal}
+ setTableData={setTableData}
type={type}
- columns={columns}
- tableData={tableData}
- isTableLoading={tableLoading}
- openAddModal={openAddModal}
+ title={deploymentsStaticContent[type].modalTitle}
+ isEdit={isEdit}
+ selectedRow={selectedPorD}
+ setSelectedRow={setSelectedPorD}
/>
- {openEtlOrTaskModal && (
- <EtlTaskDeploy
- open={openEtlOrTaskModal}
- setOpen={setOpenEtlOrTaskModal}
- setTableData={setTableData}
- type={type}
- title={deploymentsStaticContent[type].modalTitle}
- isEdit={isEdit}
- selectedRow={selectedPorD}
- setSelectedRow={setSelectedPorD}
- />
- )}
- <DeleteModal
- open={openDeleteModal}
- setOpen={setOpenDeleteModal}
- deleteRecord={deletePipeline}
- />
- </div>
- </>
+ )}
+ <DeleteModal
+ open={openDeleteModal}
+ setOpen={setOpenDeleteModal}
+ deleteRecord={deletePipeline}
+ />
+ </div>
);
}
diff --git a/frontend/src/components/settings/default-triad/DefaultTriad.jsx b/frontend/src/components/settings/default-triad/DefaultTriad.jsx
index 7c83f668e..b360a897f 100644
--- a/frontend/src/components/settings/default-triad/DefaultTriad.jsx
+++ b/frontend/src/components/settings/default-triad/DefaultTriad.jsx
@@ -12,6 +12,7 @@ import { CustomButton } from "../../widgets/custom-button/CustomButton.jsx";
import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper.jsx";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader.jsx";
import "./DefaultTriad.css";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
const { Option } = Select;
@@ -21,6 +22,7 @@ function DefaultTriad() {
const axiosPrivate = useAxiosPrivate();
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const [adapterList, setAdapterList] = useState([]);
const [dropdownData, setDropdownData] = useState([]);
@@ -118,6 +120,15 @@ function DefaultTriad() {
[adapterType]: selectedValue,
}));
setIsSubmitEnabled(true);
+
+ try {
+ setPostHogCustomEvent("intent_success_select_default_triad", {
+ info: "Selected default triad",
+ adapter_name: adapterType,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
};
// Handler for form submission
diff --git a/frontend/src/components/settings/invite/InviteEditUser.jsx b/frontend/src/components/settings/invite/InviteEditUser.jsx
index 7a92b9c92..1afd4f352 100644
--- a/frontend/src/components/settings/invite/InviteEditUser.jsx
+++ b/frontend/src/components/settings/invite/InviteEditUser.jsx
@@ -11,6 +11,7 @@ import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader.jsx";
import { TopBar } from "../../widgets/top-bar/TopBar.jsx";
import "./InviteEditUser.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function InviteEditUser() {
const axiosPrivate = useAxiosPrivate();
@@ -23,6 +24,7 @@ function InviteEditUser() {
const [loading, setLoading] = useState(true);
const [submitLoading, setSubmitLoading] = useState(false);
const [initialRole, setInitialRole] = useState();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const isInvite = location.pathname.split("/").slice(-1)[0] === "invite";
const validateMessages = {
required: "required!",
@@ -32,6 +34,7 @@ function InviteEditUser() {
},
};
const USER_ROLE = "unstract_user";
+
const getUserRoles = async () => {
setLoading(true);
const requestOptions = {
@@ -121,6 +124,15 @@ function InviteEditUser() {
} else {
updateUserRole(values);
}
+
+ try {
+ const info = isInvite
+ ? "Clicked on 'Invite' button"
+ : "Clicked on 'Update' button";
+ setPostHogCustomEvent("intent_success_add_user", { info });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
};
const formatOptionLabel = (value) => {
diff --git a/frontend/src/components/settings/platform/PlatformSettings.jsx b/frontend/src/components/settings/platform/PlatformSettings.jsx
index e2313948c..89b929418 100644
--- a/frontend/src/components/settings/platform/PlatformSettings.jsx
+++ b/frontend/src/components/settings/platform/PlatformSettings.jsx
@@ -14,6 +14,7 @@ import { useSessionStore } from "../../../store/session-store";
import { ConfirmModal } from "../../widgets/confirm-modal/ConfirmModal.jsx";
import "./PlatformSettings.css";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
const defaultKeys = [
{
@@ -40,6 +41,7 @@ function PlatformSettings() {
const axiosPrivate = useAxiosPrivate();
const navigate = useNavigate();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
useEffect(() => {
const requestOptions = {
@@ -112,6 +114,20 @@ function PlatformSettings() {
body["is_active"] = activeKey === index;
}
+ try {
+ if (details?.id?.length > 0) {
+ setPostHogCustomEvent("intent_api_key_refreshed", {
+ info: "API Key has been refreshed",
+ });
+ } else {
+ setPostHogCustomEvent("intent_api_key_generation", {
+ info: "API Key has been generated",
+ });
+ }
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+
const requestOptions = {
method,
url,
diff --git a/frontend/src/components/settings/settings/Settings.jsx b/frontend/src/components/settings/settings/Settings.jsx
index 490d19a8f..bfee3963e 100644
--- a/frontend/src/components/settings/settings/Settings.jsx
+++ b/frontend/src/components/settings/settings/Settings.jsx
@@ -4,10 +4,24 @@ import "./Settings.css";
import { IslandLayout } from "../../../layouts/island-layout/IslandLayout.jsx";
import { useSessionStore } from "../../../store/session-store";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function Settings() {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
+ const { setPostHogCustomEvent } = usePostHogEvents();
+
+ const handleDefaultTriadClick = () => {
+ navigate("triad");
+
+ try {
+ setPostHogCustomEvent("intent_select_default_triad", {
+ info: "Clicked on 'Default Triad' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
return (
<div className="settings-bg-col">
@@ -40,7 +54,7 @@ function Settings() {
<Typography.Link
className="settings-plt-typo"
strong
- onClick={() => navigate("triad")}
+ onClick={handleDefaultTriadClick}
>
Default Triad
</Typography.Link>
diff --git a/frontend/src/components/settings/users/Users.jsx b/frontend/src/components/settings/users/Users.jsx
index af50c1f70..28db02ae0 100644
--- a/frontend/src/components/settings/users/Users.jsx
+++ b/frontend/src/components/settings/users/Users.jsx
@@ -18,12 +18,14 @@ import { CustomButton } from "../../widgets/custom-button/CustomButton.jsx";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader.jsx";
import { TopBar } from "../../widgets/top-bar/TopBar.jsx";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
function Users() {
const axiosPrivate = useAxiosPrivate();
const { sessionDetails } = useSessionStore();
const navigate = useNavigate();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const [userList, setUserList] = useState([]);
const [filteredUserList, setFilteredUserList] = useState(userList);
@@ -165,15 +167,26 @@ function Users() {
),
},
];
+
+ const handleInviteUsers = () => {
+ navigate(`/${sessionDetails?.orgName}/users/invite`);
+
+ try {
+ setPostHogCustomEvent("intent_add_user", {
+ info: "Clicked on '+ Invite User' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
const inviteUserButtons = () => {
return (
<>
<CustomButton
type="primary"
icon={<PlusOutlined />}
- onClick={() => {
- navigate(`/${sessionDetails?.orgName}/users/invite`);
- }}
+ onClick={handleInviteUsers}
>
Invite User
</CustomButton>
diff --git a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
index 61fac5924..3f633e4a0 100644
--- a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
+++ b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
@@ -14,6 +14,7 @@ import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
import { ViewTools } from "../../custom-tools/view-tools/ViewTools";
import { SharePermission } from "../../widgets/share-permission/SharePermission";
+import usePostHogEvents from "../../../hooks/usePostHogEvents";
const titles = {
llm: "LLMs",
@@ -46,6 +47,7 @@ function ToolSettings({ type }) {
const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
+ const { posthogEventText, setPostHogCustomEvent } = usePostHogEvents();
useEffect(() => {
setTableRows([]);
@@ -186,6 +188,18 @@ function ToolSettings({ type }) {
});
};
+ const handleOpenAddSourceModal = () => {
+ setOpenAddSourcesModal(true);
+
+ try {
+ setPostHogCustomEvent(posthogEventText[type], {
+ info: `Clicked on '+ ${btnText[type]}' button`,
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
return (
<div className="plt-tool-settings-layout">
<ToolNavBar
@@ -194,7 +208,7 @@ function ToolSettings({ type }) {
return (
<CustomButton
type="primary"
- onClick={() => setOpenAddSourcesModal(true)}
+ onClick={handleOpenAddSourceModal}
icon={<PlusOutlined />}
>
{btnText[type]}
diff --git a/frontend/src/components/workflows/workflow/Workflows.jsx b/frontend/src/components/workflows/workflow/Workflows.jsx
index ae11811e8..08839404f 100644
--- a/frontend/src/components/workflows/workflow/Workflows.jsx
+++ b/frontend/src/components/workflows/workflow/Workflows.jsx
@@ -17,6 +17,7 @@ import { workflowService } from "./workflow-service";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar.jsx";
import { ViewTools } from "../../custom-tools/view-tools/ViewTools.jsx";
+import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
const PROJECT_FILTER_OPTIONS = [
{ label: "My Workflows", value: "mine" },
@@ -30,6 +31,7 @@ function Workflows() {
const location = useLocation();
const projectApiService = workflowService();
const handleException = useExceptionHandler();
+ const { setPostHogCustomEvent } = usePostHogEvents();
const [projectList, setProjectList] = useState();
const [editingProject, setEditProject] = useState();
@@ -162,15 +164,25 @@ function Workflows() {
setEditProject();
}
+ const handleNewWorkflowBtnClick = () => {
+ showNewProject();
+ toggleModal(true);
+
+ try {
+ setPostHogCustomEvent("intent_new_wf_project", {
+ info: "Clicked on '+ New Workflow' button",
+ });
+ } catch (err) {
+ // If an error occurs while setting custom posthog event, ignore it and continue
+ }
+ };
+
const CustomButtons = () => {
return (
<CustomButton
type="primary"
icon={<PlusOutlined />}
- onClick={() => {
- showNewProject();
- toggleModal(true);
- }}
+ onClick={handleNewWorkflowBtnClick}
>
New Workflow
</CustomButton>
diff --git a/frontend/src/hooks/useLogout.js b/frontend/src/hooks/useLogout.js
index e8294db30..c653b71dd 100644
--- a/frontend/src/hooks/useLogout.js
+++ b/frontend/src/hooks/useLogout.js
@@ -1,12 +1,15 @@
+import { usePostHog } from "posthog-js/react";
import { getSessionData } from "../helpers/GetSessionData";
import { getBaseUrl } from "../helpers/GetStaticData";
import { useSessionStore } from "../store/session-store";
function useLogout() {
const setSessionDetails = useSessionStore((state) => state.setSessionDetails);
+ const posthog = usePostHog();
return () => {
setSessionDetails(getSessionData(null));
+ posthog.reset();
const baseUrl = getBaseUrl();
const newURL = baseUrl + "/api/v1/logout";
window.location.href = newURL;
diff --git a/frontend/src/hooks/usePostHogEvents.js b/frontend/src/hooks/usePostHogEvents.js
new file mode 100644
index 000000000..33a5ada0e
--- /dev/null
+++ b/frontend/src/hooks/usePostHogEvents.js
@@ -0,0 +1,100 @@
+import { usePostHog } from "posthog-js/react";
+import { useSessionStore } from "../store/session-store";
+
+const usePostHogEvents = () => {
+ const posthog = usePostHog();
+ const { sessionDetails } = useSessionStore();
+
+ const posthogEventText = {
+ llm: "intent_add_llm",
+ vector_db: "intent_add_vectordb",
+ embedding: "intent_add_embedding",
+ x2text: "intent_add_text_extractor",
+ ocr: null,
+ };
+
+ const posthogTcEventText = {
+ llm: "test_connection_llm",
+ vector_db: "test_connection_vectordb",
+ embedding: "test_connection_embedding",
+ x2text: "test_connection_text_extractor",
+ ocr: null,
+ };
+
+ const posthogSubmitEventText = {
+ llm: "intent_success_add_llm",
+ vector_db: "intent_success_add_vectordb",
+ embedding: "intent_success_add_embedding",
+ x2text: "intent_success_add_text_extractor",
+ ocr: null,
+ };
+
+ const posthogConnectorEventText = {
+ "FILESYSTEM:input": "intent_wf_fs_source",
+ "FILESYSTEM:output": "intent_wf_fs_dest",
+ "DATABASE:output": "intent_wf_db_dest",
+ };
+
+ const posthogConnectorAddedEventText = {
+ "FILESYSTEM:input": "intent_success_wf_fs_source",
+ "FILESYSTEM:output": "intent_success_wf_fs_dest",
+ "DATABASE:output": "intent_success_wf_db_dest",
+ };
+
+ const posthogWfDeploymentEventText = {
+ API: "wf_deploy_api",
+ ETL: "wf_deploy_etl",
+ TASK: "wf_deploy_task",
+ };
+
+ const posthogDeploymentEventText = {
+ api: "intent_api_deployment",
+ api_success: "intent_success_api_deployment",
+ etl: "intent_etl_deployment",
+ etl_success: "intent_success_etl_deployment",
+ task: "intent_task_deployment",
+ task_success: "intent_success_task_deployment",
+ };
+
+ const setPostHogIdentity = () => {
+ const distinctId = `${sessionDetails?.orgId}:${sessionDetails?.orgName}`;
+ const orgName = sessionDetails?.orgName;
+ const isOpenSource = orgName === "mock_org";
+
+ const name = `${sessionDetails?.name} ${sessionDetails?.family_name || ""}`;
+ const optionalParams = {
+ name,
+ org: orgName,
+ software: isOpenSource ? "OSS" : "SAAS",
+ };
+
+ const email = sessionDetails?.email;
+ const userId = sessionDetails?.id;
+
+ if (email) {
+ optionalParams["email"] = email;
+ } else {
+ optionalParams["userId"] = userId;
+ }
+
+ posthog.identify(distinctId, optionalParams);
+ };
+
+ const setPostHogCustomEvent = (distinctId, optionalParams) => {
+ posthog.capture(distinctId, optionalParams);
+ };
+
+ return {
+ posthogEventText,
+ posthogTcEventText,
+ posthogSubmitEventText,
+ posthogConnectorEventText,
+ posthogConnectorAddedEventText,
+ posthogWfDeploymentEventText,
+ posthogDeploymentEventText,
+ setPostHogIdentity,
+ setPostHogCustomEvent,
+ };
+};
+
+export default usePostHogEvents;