feat: event tracking using posthog and created application provider to render multiple wrappers (#2757)
* fix: event tracker changes * fix: App provider implementation using wrappers * fix: updating packages * fix: handling warning * fix: wrapper fixes and minor optimization changes * fix: chore app-provider clearnup * fix: cleanup * fix: removing jitsu tracking * fix: minor updates * fix: adding event to posthog event tracker (#2802) * dev: posthog event tracker update intitiate * fix: adding events for posthog integration * fix: event payload --------- Co-authored-by: Ramesh Kumar Chandra <31303617+rameshkumarchandra@users.noreply.github.com>
This commit is contained in:
parent
33be52792f
commit
78fee22fec
114 changed files with 825 additions and 2768 deletions
|
|
@ -1,10 +1,6 @@
|
|||
import React from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import { mutate } from "swr";
|
||||
|
||||
// headless ui
|
||||
import { Dialog, Transition } from "@headlessui/react";
|
||||
// services
|
||||
import { PageService } from "services/page.service";
|
||||
|
|
@ -16,6 +12,7 @@ import { PageForm } from "./page-form";
|
|||
import { IUser, IPage } from "types";
|
||||
// fetch-keys
|
||||
import { ALL_PAGES_LIST, FAVORITE_PAGES_LIST, MY_PAGES_LIST, RECENT_PAGES_LIST } from "constants/fetch-keys";
|
||||
import { trackEvent } from "helpers/event-tracker.helper";
|
||||
|
||||
type Props = {
|
||||
isOpen: boolean;
|
||||
|
|
@ -30,7 +27,7 @@ type Props = {
|
|||
const pageService = new PageService();
|
||||
|
||||
export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
||||
const { isOpen, handleClose, data, user, workspaceSlug, projectId } = props;
|
||||
const { isOpen, handleClose, data, workspaceSlug, projectId } = props;
|
||||
// router
|
||||
const router = useRouter();
|
||||
|
||||
|
|
@ -42,7 +39,7 @@ export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
|||
|
||||
const createPage = async (payload: IPage) => {
|
||||
await pageService
|
||||
.createPage(workspaceSlug as string, projectId as string, payload, user)
|
||||
.createPage(workspaceSlug as string, projectId as string, payload)
|
||||
.then((res) => {
|
||||
mutate(RECENT_PAGES_LIST(projectId as string));
|
||||
mutate<IPage[]>(
|
||||
|
|
@ -64,14 +61,19 @@ export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
|||
false
|
||||
);
|
||||
onClose();
|
||||
|
||||
router.push(`/${workspaceSlug}/projects/${projectId}/pages/${res.id}`);
|
||||
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Success!",
|
||||
message: "Page created successfully.",
|
||||
});
|
||||
trackEvent(
|
||||
'PAGE_CREATE',
|
||||
{
|
||||
...res,
|
||||
caase: "SUCCES"
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(() => {
|
||||
setToastAlert({
|
||||
|
|
@ -79,12 +81,18 @@ export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
|||
title: "Error!",
|
||||
message: "Page could not be created. Please try again.",
|
||||
});
|
||||
trackEvent(
|
||||
'PAGE_CREATE',
|
||||
{
|
||||
case: "FAILED"
|
||||
}
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
const updatePage = async (payload: IPage) => {
|
||||
await pageService
|
||||
.patchPage(workspaceSlug as string, projectId as string, data?.id ?? "", payload, user)
|
||||
.patchPage(workspaceSlug as string, projectId as string, data?.id ?? "", payload)
|
||||
.then((res) => {
|
||||
mutate(RECENT_PAGES_LIST(projectId as string));
|
||||
mutate<IPage[]>(
|
||||
|
|
@ -124,6 +132,13 @@ export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
|||
title: "Success!",
|
||||
message: "Page updated successfully.",
|
||||
});
|
||||
trackEvent(
|
||||
'PAGE_UPDATE',
|
||||
{
|
||||
...res,
|
||||
case: "SUCCESS"
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(() => {
|
||||
setToastAlert({
|
||||
|
|
@ -131,6 +146,12 @@ export const CreateUpdatePageModal: React.FC<Props> = (props) => {
|
|||
title: "Error!",
|
||||
message: "Page could not be updated. Please try again.",
|
||||
});
|
||||
trackEvent(
|
||||
'PAGE_UPDATE',
|
||||
{
|
||||
case: "FAILED"
|
||||
}
|
||||
)
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue