Skip to content

Commit

Permalink
Merge pull request #74 from lontonggg/staging
Browse files Browse the repository at this point in the history
fix: re-enable mixpanel
  • Loading branch information
Veivel authored Aug 6, 2024
2 parents 5baf026 + 0da783b commit 7929fbb
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 78 deletions.
5 changes: 2 additions & 3 deletions src/containers/BuildSchedule/CourseClass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styled from "styled-components";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { useSelector, useDispatch } from "react-redux";
import { addSchedule, removeSchedule } from "redux/modules/schedules";
import { useColorModeValue } from "@chakra-ui/react";
Expand Down Expand Up @@ -100,8 +100,7 @@ function CourseClass({ course, courseClass }) {
dispatch(removeSchedule(item));
} else {
dispatch(addSchedule(item));
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("select_course");
useMixpanel.track("select_course");
}
};

Expand Down
8 changes: 3 additions & 5 deletions src/containers/BuildSchedule/SelectMajor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { Flex } from "@chakra-ui/react";
import FACULTIES from "utils/faculty-base-additional-info.json";
import { useForm } from "react-hook-form";
Expand Down Expand Up @@ -29,13 +29,11 @@ function SelectMajor({ theme, isMobile, setMajorSelected, show }) {
}

useEffect(() => {
// TODO: Re-enable mixpanel or change to other analytics
// if (selectedFaculty) useMixpanel.track("select_faculty");
if (selectedFaculty) useMixpanel.track("select_faculty");
}, [selectedFaculty]);

useEffect(() => {
// TODO: Re-enable mixpanel or change to other analytics
// if (selectedMajorName) useMixpanel.track("select_prodi");/
if (selectedMajorName) useMixpanel.track("select_prodi");
}, [selectedMajorName]);

return (
Expand Down
12 changes: 5 additions & 7 deletions src/containers/BuildSchedule/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useCallback, useRef } from "react";
import { useSelector, useDispatch } from "react-redux";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import {
Button,
useColorModeValue,
Expand Down Expand Up @@ -97,15 +97,13 @@ function BuildSchedule() {
}
});

// TODO: Re-enable mixpanel or change to other analytics
// useEffect(() => {
// useMixpanel.track("open_buat_jadwal");
// }, []);
useEffect(() => {
useMixpanel.track("open_buat_jadwal");
}, []);

useEffect(() => {
if (isInitialMount.current) isInitialMount.current = false;
// TODO: Re-enable mixpanel or change to other analytics
// else useMixpanel.track("search_course");
else useMixpanel.track("search_course");
}, [value]);

return (
Expand Down
11 changes: 4 additions & 7 deletions src/containers/Contributors/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from "react";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { Text, Box, Button, Flex, useColorModeValue } from "@chakra-ui/react";
import { ChevronLeftIcon } from "@chakra-ui/icons";
import { Link } from "react-router-dom";
Expand Down Expand Up @@ -36,8 +36,7 @@ const Contributors = () => {
}, [fetchContributors]);

useEffect(() => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("open_contributors");
useMixpanel.track("open_contributors");
}, []);

const MergeContributors = (contributors, otherContributors) => {
Expand Down Expand Up @@ -91,8 +90,7 @@ const Contributors = () => {
avatar={user.avatar_url}
github={user.html_url}
contributions={user.contributions}
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("see_contributor_detail")}
onClick={() => useMixpanel.track("see_contributor_detail")}
/>
));

Expand Down Expand Up @@ -139,8 +137,7 @@ const Contributors = () => {
<a
href="https://ristek.link/oss-discord"
rel="noopener noreferrer"
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("gabung_discord")}
onClick={() => useMixpanel.track("gabung_discord")}
target="_blank"
>
<Button
Expand Down
7 changes: 3 additions & 4 deletions src/containers/Header/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link, useLocation } from "react-router-dom";
import { useSelector } from "react-redux";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import React from "react";

import {
Expand Down Expand Up @@ -93,9 +93,8 @@ function Header() {
type="checkbox"
onClick={() => {
toggleColorMode();
// TODO: Re-enable mixpanel or change to other analytics
// if (theme === "light") useMixpanel.track("dark_mode");
// else useMixpanel.track("light_mode");
if (theme === "light") useMixpanel.track("dark_mode");
else useMixpanel.track("light_mode");
}}
checked={theme === "light" ? false : true}
/>
Expand Down
8 changes: 3 additions & 5 deletions src/containers/Login/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSelector, useDispatch } from "react-redux";
import { Fade, Button, Box, useColorModeValue } from "@chakra-ui/react";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import React, { useEffect, useState, useMemo, useRef } from "react";
import { Link } from "react-router-dom";
import { parse } from "query-string";
Expand Down Expand Up @@ -399,8 +399,7 @@ function Login({ history, location }) {
href="https://ristek.link/oss-discord"
rel="noopener noreferrer"
target="_blank"
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("gabung_discord")}
onClick={() => useMixpanel.track("gabung_discord")}
>
<DiscordButton _hover={{ background: "primary.Purple" }}>
Join Discord
Expand All @@ -409,8 +408,7 @@ function Login({ history, location }) {
<div style={{ minWidth: "16px", minHeight: "16px" }}></div>
<Link
to="/kontributor"
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("see_contributor_detail")}
onClick={() => useMixpanel.track("see_contributor_detail")}
>
<DiscordButton variant="outline">Lihat Kontributor</DiscordButton>
</Link>
Expand Down
6 changes: 2 additions & 4 deletions src/containers/ScheduleList/ScheduleDetail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef } from "react";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { Link } from "react-router-dom";
import { useSelector } from "react-redux";
import styled from "styled-components";
Expand Down Expand Up @@ -67,9 +67,7 @@ const ScheduleDetail = ({
return (
<>
<Link
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("open_jadwal")}
onClick={null}
onClick={() => useMixpanel.track("open_jadwal")}
to={`/jadwal/${schedule.id}`}
>
<Card key={`${schedule.name}-${idx}`} mode={theme}>
Expand Down
11 changes: 4 additions & 7 deletions src/containers/ScheduleList/SortByTermButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { useSelector } from "react-redux";
import {
Menu,
Expand Down Expand Up @@ -50,8 +50,7 @@ const SortByTermButton = ({ isSortByLatest, setSortByLatest }) => {
display="flex"
justifyContent="center"
alignItems="center"
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("sort_daftar_jadwal")}
onClick={() => useMixpanel.track("sort_daftar_jadwal")}
/>
<MenuList>
<MenuOptionGroup
Expand All @@ -62,8 +61,7 @@ const SortByTermButton = ({ isSortByLatest, setSortByLatest }) => {
<MenuItemOption
onClick={() => {
setSortByLatest(true);
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("sort_semester_terbaru");
useMixpanel.track("sort_semester_terbaru");
}}
value="desc"
>
Expand All @@ -72,8 +70,7 @@ const SortByTermButton = ({ isSortByLatest, setSortByLatest }) => {
<MenuItemOption
onClick={() => {
setSortByLatest(false);
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("sort_semester_terlama");
useMixpanel.track("sort_semester_terlama");
}}
value="asc"
>
Expand Down
11 changes: 4 additions & 7 deletions src/containers/ScheduleList/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useRef } from "react";
import ReactGA from "react-ga";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { useHistory } from "react-router";
import {
Button,
Expand Down Expand Up @@ -118,14 +118,12 @@ const ScheduleList = () => {
}, [filteredSchedules, isSortByLatest]);

useEffect(() => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("open_daftar_jadwal");
useMixpanel.track("open_daftar_jadwal");
}, []);

useEffect(() => {
if (isInitialMount.current) isInitialMount.current = false;
// TODO: Re-enable mixpanel or change to other analytics
// else useMixpanel.track("search_daftar_jadwal");
else useMixpanel.track("search_daftar_jadwal");
}, [query]);

const performDeleteSchedule = async (userId, scheduleId) => {
Expand Down Expand Up @@ -325,8 +323,7 @@ const ScheduleList = () => {
}
onMouseDown={() => {
setQuery(document.getElementById("input").value);
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("search_daftar_jadwal");
useMixpanel.track("search_daftar_jadwal");
}}
fontSize={isMobile && "14px"}
px={isMobile && "4px"}
Expand Down
11 changes: 4 additions & 7 deletions src/containers/SelectedCourses/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import ReactGA from "react-ga";
import styled from "styled-components";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import { withRouter } from "react-router";

import { useSelector, useDispatch } from "react-redux";
Expand Down Expand Up @@ -161,8 +161,7 @@ function SelectedCourses({ history, scheduleId, isEditing }) {
<Button
onClick={() => {
onClose();
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("cancel");
useMixpanel.track("cancel");
}}
variant="outline"
borderColor={
Expand All @@ -180,8 +179,7 @@ function SelectedCourses({ history, scheduleId, isEditing }) {
? handleDeleteSchedule()
: updateSchedule();

// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("simpan_jadwal");
useMixpanel.track("simpan_jadwal");
}}
variant="solid"
bg={theme === "light" ? "primary.Purple" : "dark.LightPurple"}
Expand Down Expand Up @@ -245,8 +243,7 @@ function SelectedCourses({ history, scheduleId, isEditing }) {

<Button
onClick={() => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("open_simpan_modal");
useMixpanel.track("open_simpan_modal");
onOpen();
}}
disabled={isConflict || totalCredits > 24 || schedules.length === 0}
Expand Down
14 changes: 5 additions & 9 deletions src/containers/UpdateCourses/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from "react";
import ReactGA from "react-ga";
import Helmet from "react-helmet";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
import styled from "styled-components";
import { useForm } from "react-hook-form";
import { useSelector } from "react-redux";
Expand Down Expand Up @@ -42,22 +42,19 @@ const UpdateCourses = () => {
const password = watch("password");

useEffect(() => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("open_update_matkul");
useMixpanel.track("open_update_matkul");
}, []);

useEffect(() => {
if (username && !isUsernameChanged) {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("update_matkul_fill_username");
useMixpanel.track("update_matkul_fill_username");
setIsUsernameChanged(true);
}
}, [username, isUsernameChanged]);

useEffect(() => {
if (password && !isPasswordChanged) {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("update_matkul_fill_password");
useMixpanel.track("update_matkul_fill_password");
setIsPasswordChanged(true);
}
}, [password, isPasswordChanged]);
Expand Down Expand Up @@ -136,8 +133,7 @@ const UpdateCourses = () => {
w={{ sm: "100%", lg: "unset" }}
bg={theme === "light" ? "primary.Purple" : "dark.LightPurple"}
color={theme === "light" ? "white" : "dark.White"}
// TODO: Re-enable mixpanel or change to other analytics
// onClick={() => useMixpanel.track("update_matkul")}
onClick={() => useMixpanel.track("update_matkul")}
>
Update Jadwal
</Button>
Expand Down
8 changes: 3 additions & 5 deletions src/containers/ViewSchedule/Schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useSelector } from "react-redux";
import { useColorModeValue } from "@chakra-ui/react";
import { useDisclosure } from "@chakra-ui/react";
import DetailsModal from "./DetailsModal";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";
const DAYS = ["Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"];

const pad = (val) => {
Expand Down Expand Up @@ -63,15 +63,13 @@ function Schedule({
);

const handleClickedCourse = (course) => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("open_course_detail");
useMixpanel.track("open_course_detail");
setSelectedCourse(course);
onOpen();
};

const handleCloseModal = () => {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("close_course_detail");
useMixpanel.track("close_course_detail");
onClose();
};

Expand Down
8 changes: 3 additions & 5 deletions src/services/sso.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import config from "config";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";

const { SSO_UI_URL, DOMAIN, BASE_URL } = config;

const loginUrl = `${SSO_UI_URL}/login?service=${DOMAIN}${BASE_URL}`;
const logoutUrl = `${SSO_UI_URL}/logout?url=${DOMAIN}${BASE_URL}`;

export function redirectToSSOLogin() {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("login");
useMixpanel.track("login");
window.location.replace(loginUrl);
}

export function redirectToSSOLogout() {
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("logout");
useMixpanel.track("logout");
window.location.replace(logoutUrl);
}
5 changes: 2 additions & 3 deletions src/utils/auth.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { setupAxiosInstance, validateToken } from "services/api";
// import { useMixpanel } from "hooks/useMixpanel";
import { useMixpanel } from "hooks/useMixpanel";

export function persistAuth(auth) {
if (!auth) {
localStorage.clear();
} else {
setupAxiosInstance(auth.token);
localStorage.setItem("auth", JSON.stringify(auth));
// TODO: Re-enable mixpanel or change to other analytics
// useMixpanel.track("login_successful");
useMixpanel.track("login_successful");
}
}

Expand Down

0 comments on commit 7929fbb

Please sign in to comment.