Skip to content

Commit

Permalink
Chores : Shifted Posthog event to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazi-pikachu committed Sep 4, 2023
1 parent d3b5878 commit deb1b96
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/frontend/src/app/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Space } from "antd";
import { useNavigate } from "react-router-dom";
import "app/styles/header.css";
import { Row, Col, Breadcrumb, Button } from "antd";

import Event from "app/constants/PosthogEvent";
import { NavLink, Link } from "react-router-dom";
import { usePostHog } from "posthog-js/react";

Expand Down Expand Up @@ -47,7 +47,7 @@ function Header({ name, subName, onPress }) {
useEffect(() => window.scrollTo(0, 0));

function logout() {
posthog.capture("User Signed Out",{user:local_info}); // capture the signed out events
posthog.capture(Event.SIGNED_OUT,{user:local_info}); // capture the signed out events
localStorage.clear();
navigate("/signup");
}
Expand Down
8 changes: 8 additions & 0 deletions apps/frontend/src/app/constants/PosthogEvent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Event = {
SIGNED_OUT:"User Signed Out",
SIGNED_IN :"User Signed In",
SIGNED_UP: "User signed Up",
BULK_LINK_CREATION :"Bulk Links Created",
LINK_CREATION :"Link Created",
}
export default Event;
3 changes: 2 additions & 1 deletion apps/frontend/src/app/pages/Auth/SignIn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Navbar from "app/components/Navbar";
import Footer from "app/components/Footer";
import { mockUser } from "app/constants/mockData"; // TODO: Remove this line
import { usePostHog } from "posthog-js/react";
import Event from "app/constants/PosthogEvent";
function onChange(checked) {
console.log(`switch to ${checked}`);
}
Expand Down Expand Up @@ -44,7 +45,7 @@ function SignIn() {
localStorage.setItem("user-info", JSON.stringify(result));
*/
// add telemetry for Sign In
posthog.capture("User Signed In", {
posthog.capture(Event.SIGNED_IN, {
// To DO: Add user info here after completing the api integration
email: email,
});
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/pages/Auth/SignUp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { Title } = Typography;
const { Content } = Layout;
import Footer from "app/components/Footer";
import { usePostHog } from "posthog-js/react";

import Event from "app/constants/PosthogEvent";
function SignUp() {
const history = useNavigate();
const posthog = usePostHog(); // posthog instance
Expand All @@ -40,7 +40,7 @@ function SignUp() {
});

// sent the signup event to posthog
posthog.capture('User signed Up', {
posthog.capture(Event.SIGNED_UP, {
name:name,
email:email
});
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/pages/CreateBulkLink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { nanoid } from "nanoid";
import { Excel } from "antd-table-saveas-excel";
import { Form, Button } from "antd";
import { usePostHog } from "posthog-js/react";

import Event from "app/constants/PosthogEvent";
function Bulk() {
const [form] = Form.useForm();
const baseUrl = " https://yaus.xyz";
Expand Down Expand Up @@ -50,7 +50,7 @@ function Bulk() {
console.log(data);
});
}
posthog.capture("Bulk Links Created" , {LinksData:bulkLinkData});
posthog.capture(Event.BULK_LINK_CREATION , {LinksData:bulkLinkData});
};

const onDownload = () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/app/pages/CreateLink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import FormRedirectPage from "app/pages/Form/LinkRedirectsForm";
import FormLinkDataPage from "app/pages/Form/LinkDataForm";
import FormTagsPage from "app/pages/Form/LinkTagsForm";
import { usePostHog } from "posthog-js/react";
import Event from "app/constants/PosthogEvent";
const { Footer } = Layout;
const { Step } = Steps;
const { Meta } = Card;
Expand Down Expand Up @@ -43,7 +44,7 @@ const FormDemo = () => {
Authorization: "JWT fefege...",
"Access-Control-Allow-Origin": "*",
};
posthog.capture("Link created",{userData:userData}); // capture the link creation events
posthog.capture(Event.LINK_CREATION,{userData:userData}); // capture the link creation events
console.log(userData);
axios
.post(`${baseUrl}/register`, userData, { headers: headers })
Expand Down

0 comments on commit deb1b96

Please sign in to comment.