Skip to content

Commit

Permalink
Fix events dependencies (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes authored Dec 20, 2023
1 parent 3d8e9ff commit 615d7d0
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 23 deletions.
7 changes: 0 additions & 7 deletions components/course/CourseHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Button } from '@mui/material';
import { ISbRichtext } from '@storyblok/react';
import { useTranslations } from 'next-intl';
import { useEffect } from 'react';
import { PROGRESS_STATUS } from '../../constants/enums';
import { COURSE_OVERVIEW_VIEWED } from '../../constants/events';
import logEvent from '../../utils/logEvent';
import Link from '../common/Link';
import Header from '../layout/Header';

Expand All @@ -18,10 +15,6 @@ export interface CourseHeaderProps {
const CourseHeader = (props: CourseHeaderProps) => {
const { name, description, image_with_background, courseProgress, eventData } = props;

useEffect(() => {
logEvent(COURSE_OVERVIEW_VIEWED, eventData);
});

const headerProps = {
title: name,
introduction: description,
Expand Down
2 changes: 1 addition & 1 deletion components/crisp/CrispScript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CrispScript = () => {
logEvent(CHAT_STARTED, eventUserData);
},
]);
});
}, []);

useEffect(() => {
const hasLiveAccess =
Expand Down
2 changes: 1 addition & 1 deletion components/storyblok/StoryblokCoursePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const StoryblokCoursePage = (props: StoryblokCoursePageProps) => {

useEffect(() => {
logEvent(COURSE_OVERVIEW_VIEWED, eventData);
});
}, []);

const eventUserData = getEventUserData(userCreatedAt, partnerAccesses, partnerAdmin);

Expand Down
2 changes: 1 addition & 1 deletion components/storyblok/StoryblokMeetTheTeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const StoryblokMeetTheTeamPage = (props: StoryblokMeetTheTeamPageProps) => {

useEffect(() => {
logEvent(MEET_THE_TEAM_VIEWED, eventUserData);
});
}, []);

const headerProps = {
title: title,
Expand Down
2 changes: 1 addition & 1 deletion components/storyblok/StoryblokSessionIbaPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const StoryblokSessionIbaPage = (props: StoryblokSessionIbaPageProps) => {

useEffect(() => {
logEvent(SESSION_VIEWED, eventData);
});
}, []);

const eventUserData = getEventUserData(userCreatedAt, partnerAccesses, partnerAdmin);

Expand Down
2 changes: 1 addition & 1 deletion components/storyblok/StoryblokSessionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const StoryblokSessionPage = (props: StoryblokSessionPageProps) => {

useEffect(() => {
logEvent(SESSION_VIEWED, eventData);
});
}, []);

const eventUserData = getEventUserData(userCreatedAt, partnerAccesses, partnerAdmin);
const eventData = {
Expand Down
4 changes: 2 additions & 2 deletions guards/authGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function AuthGuard({ children }: { children: JSX.Element }) {
});

return () => unsubscribe();
});
}, []);

// 2. Add ongoing event listener to check for token changes
useEffect(() => {
Expand All @@ -67,7 +67,7 @@ export function AuthGuard({ children }: { children: JSX.Element }) {
await dispatch(setUserToken(token));
}
});
});
}, []);

// Function to get User details from the backend api
async function callGetUser() {
Expand Down
2 changes: 1 addition & 1 deletion guards/publicPageDataWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function PublicPageDataWrapper({ children }: { children: JSX.Element }) {
dispatch(setAuthStateLoading(false));
});
return () => unsubscribe();
});
}, []);

useEffect(() => {
async function callGetUser() {
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function AppReduxWrapper({ Component, ...rest }: MyAppProps) {
(window as any).store = store;
}
}
});
}, []);

return (
<Provider store={store}>
Expand Down
2 changes: 1 addition & 1 deletion pages/about-our-courses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CourseAbout: NextPage<Props> = ({ story }) => {

useEffect(() => {
logEvent(ABOUT_COURSES_VIEWED, eventUserData);
});
}, []);

if (!story) {
return <NoDataAvailable />;
Expand Down
2 changes: 1 addition & 1 deletion pages/account/about-you.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const AboutYou: NextPage = () => {

useEffect(() => {
logEvent(ABOUT_YOU_VIEWED, eventUserData);
});
}, []);

const headerProps = {
partnerLogoSrc: welcomeToBloom,
Expand Down
2 changes: 1 addition & 1 deletion pages/account/apply-a-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ApplyACode: NextPage = () => {
const eventUserData = getEventUserData(userCreatedAt, partnerAccesses, partnerAdmin);

logEvent(ASSIGN_NEW_PARTNER_VIEWED, eventUserData);
});
}, []);

const headerProps = {
title: t('applyCode.title'),
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Dashboard: NextPage = () => {

useEffect(() => {
logEvent(CREATE_PARTNER_ACCESS_VIEWED, eventUserData);
});
}, []);

return (
<Box>
Expand Down
2 changes: 1 addition & 1 deletion pages/partner-admin/create-access-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CreateAccessCode: NextPage = () => {

useEffect(() => {
logEvent(CREATE_PARTNER_ACCESS_VIEWED, { ...eventUserData });
});
}, []);

return (
<Box>
Expand Down
2 changes: 1 addition & 1 deletion pages/therapy/book-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const BookSession: NextPage = () => {

useEffect(() => {
logEvent(THERAPY_BOOKING_VIEWED, eventUserData);
});
}, []);

const headerProps = {
title: t('title'),
Expand Down
2 changes: 1 addition & 1 deletion pages/therapy/confirmed-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ConfirmedSession: NextPage = () => {

useEffect(() => {
logEvent(THERAPY_CONFIRMATION_VIEWED, eventUserData);
});
}, []);

const headerProps = {
title: t('confirmation.title'),
Expand Down

0 comments on commit 615d7d0

Please sign in to comment.