chore: posthog event for workspace invite (#2989)

* chore: posthog event for workspace invite

* chore: updated event names, added all the existing events to workspace metrics group

* chore: seperated workspace invite

* fix: workspace invite accept event updated

---------

Co-authored-by: Ramesh Kumar Chandra <rameshkumar2299@gmail.com>
This commit is contained in:
Bavisetti Narayan 2023-12-06 17:15:14 +05:30 committed by sriram veeraghanta
parent 37c03ff239
commit b35874e294
25 changed files with 441 additions and 120 deletions

View file

@ -9,8 +9,6 @@ import { PageForm } from "./page-form";
import { IPage } from "types";
// store
import { useMobxStore } from "lib/mobx/store-provider";
// helpers
import { trackEvent } from "helpers/event-tracker.helper";
type Props = {
data?: IPage | null;
@ -27,6 +25,8 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
// store
const {
page: { createPage, updatePage },
trackEvent: { postHogEventTracker },
workspace: { currentWorkspace }
} = useMobxStore();
const { setToastAlert } = useToast();
@ -47,10 +47,18 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Success!",
message: "Page created successfully.",
});
trackEvent("PAGE_CREATE", {
...res,
case: "SUCCESS",
});
postHogEventTracker(
"PAGE_CREATED",
{
...res,
state: "SUCCESS",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
}
);
})
.catch(() => {
setToastAlert({
@ -58,9 +66,16 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Error!",
message: "Page could not be created. Please try again.",
});
trackEvent("PAGE_CREATE", {
case: "FAILED",
});
postHogEventTracker("PAGE_CREATED",
{
state: "FAILED",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
}
);
});
};
@ -75,10 +90,17 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Success!",
message: "Page updated successfully.",
});
trackEvent("PAGE_UPDATE", {
...res,
case: "SUCCESS",
});
postHogEventTracker("PAGE_UPDATED",
{
...res,
state: "SUCCESS",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
}
);
})
.catch(() => {
setToastAlert({
@ -86,9 +108,16 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Error!",
message: "Page could not be updated. Please try again.",
});
trackEvent("PAGE_UPDATE", {
case: "FAILED",
});
postHogEventTracker("PAGE_UPDATED",
{
state: "FAILED",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
}
);
});
};