Skip to content

Commit

Permalink
Remove GA (#1122)
Browse files Browse the repository at this point in the history
remove GA
  • Loading branch information
mipyykko committed Feb 27, 2023
1 parent 650b895 commit cda68ba
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 152 deletions.
111 changes: 51 additions & 60 deletions frontend/components/Home/CourseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import ReactGA from "react-ga"

import { Chip, Grid, Skeleton } from "@mui/material"
import { styled } from "@mui/material/styles"

Expand Down Expand Up @@ -62,9 +60,6 @@ const TextArea = styled("div")`
}
`

const CardLinkWithGA = styled(ReactGA.OutboundLink)`
text-decoration: none;
`
interface CourseCardProps {
course?: CourseFieldsFragment
}
Expand All @@ -74,67 +69,63 @@ function CourseCard({ course }: CourseCardProps) {

return (
<Grid item xs={12} sm={12} md={6} lg={4} xl={3}>
<CardLinkWithGA
eventLabel={`coursesite: ${course?.name ?? ""}`}
<Background
focusRipple
to={course?.link ?? ""}
target="_blank"
disabled={
!course?.link ||
(course?.status === "Upcoming" && !course?.upcoming_active_link)
}
component="div"
role="none"
>
<Background
focusRipple
disabled={
!course?.link ||
(course?.status === "Upcoming" && !course?.upcoming_active_link)
}
component="div"
role="none"
>
<ResponsiveCourseImageBase>
{course ? (
<CourseImage
photo={course.photo}
style={{ opacity: course.status === "Upcoming" ? 0.6 : 1 }}
<ResponsiveCourseImageBase>
{course ? (
<CourseImage
photo={course.photo}
style={{ opacity: course.status === "Upcoming" ? 0.6 : 1 }}
/>
) : (
<Skeleton variant="rectangular" height="100%" />
)}
{course?.link &&
course?.status === "Upcoming" &&
course?.upcoming_active_link && (
<Chip
variant="outlined"
style={{
position: "absolute",
top: "10px",
right: "10px",
backgroundColor: "white",
}}
clickable
label={t("coursePageAvailable")}
/>
) : (
<Skeleton variant="rectangular" height="100%" />
)}
{course?.link &&
course?.status === "Upcoming" &&
course?.upcoming_active_link && (
<Chip
variant="outlined"
style={{
position: "absolute",
top: "10px",
right: "10px",
backgroundColor: "white",
}}
clickable
label={t("coursePageAvailable")}
/>
)}
</ResponsiveCourseImageBase>
<TextArea>
{course ? (
<>
<CardTitle component="h3" variant="h3">
{course.name}
</CardTitle>
<CardText component="p" variant="body1" paragraph align="left">
{course.description}
</CardText>
</>
) : (
<>
<h3>
<Skeleton variant="text" width="100%" />
</h3>
</ResponsiveCourseImageBase>
<TextArea>
{course ? (
<>
<CardTitle component="h3" variant="h3">
{course.name}
</CardTitle>
<CardText component="p" variant="body1" paragraph align="left">
{course.description}
</CardText>
</>
) : (
<>
<h3>
<Skeleton variant="text" width="100%" />
<Skeleton variant="text" width="100%" />
</>
)}
</TextArea>
</Background>
</CardLinkWithGA>
</h3>
<Skeleton variant="text" width="100%" />
<Skeleton variant="text" width="100%" />
</>
)}
</TextArea>
</Background>
</Grid>
)
}
Expand Down
70 changes: 32 additions & 38 deletions frontend/components/Home/ModuleSmallCourseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import ReactGA from "react-ga"

import { Grid, Skeleton, Typography } from "@mui/material"
import { styled } from "@mui/material/styles"

Expand Down Expand Up @@ -110,42 +108,38 @@ function ModuleSmallCourseCard({

return (
<Grid item xs={12} sm={6} md={12} lg={6} xl={4}>
<Background focusRipple component="div" role="none">
{course ? (
<ReactGA.OutboundLink
eventLabel={`modulecoursesite: ${course ? course.name : ""}`}
to={course.link ?? ""}
target="_blank"
style={{ textDecoration: "none", width: "100%" }}
onClick={(e) => (course.link === "" ? e.preventDefault() : null)}
aria-label={`To the course homepage of ${course.name}`}
>
{showHeader &&
(course.study_module_start_point ||
course.status === CourseStatus.Upcoming) && (
<Header
startPoint={course.study_module_start_point}
upcoming={course.status === CourseStatus.Upcoming}
>
<Typography variant="body1">
{course.status === CourseStatus.Upcoming
? t("upcomingShort")
: t("moduleCourseStartPoint")}
</Typography>
</Header>
)}
<ContentArea>
<ModuleCardTitle>{course.name}</ModuleCardTitle>
<ModuleCardText>{course.description}</ModuleCardText>
</ContentArea>
</ReactGA.OutboundLink>
) : (
<>
<SkeletonTitle />
<SkeletonText />
</>
)}
</Background>
{course ? (
<Background
focusRipple
href={course.link ?? ""}
target="_blank"
aria-label={`To the course homepage of ${course.name}`}
>
{showHeader &&
(course.study_module_start_point ||
course.status === CourseStatus.Upcoming) && (
<Header
startPoint={course.study_module_start_point}
upcoming={course.status === CourseStatus.Upcoming}
>
<Typography variant="body1">
{course.status === CourseStatus.Upcoming
? t("upcomingShort")
: t("moduleCourseStartPoint")}
</Typography>
</Header>
)}
<ContentArea>
<ModuleCardTitle>{course.name}</ModuleCardTitle>
<ModuleCardText>{course.description}</ModuleCardText>
</ContentArea>
</Background>
) : (
<Background focusRipple component="div" role="none">
<SkeletonTitle />
<SkeletonText />
</Background>
)}
</Grid>
)
}
Expand Down
7 changes: 2 additions & 5 deletions frontend/components/Home/UkraineInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,15 @@ function UkraineInfo() {
<CardTitle component="h3" variant="h3" style={{ marginTop: 0 }}>
{t("ukraineText")}
</CardTitle>
<OutboundLink eventLabel="custom: ukraina" to={t("ukraineLink")}>
<OutboundLink href={t("ukraineLink")}>
{t("ukraineLinkText")}
</OutboundLink>
</InfoContainer>
<InfoContainer>
<CardTitle component="h3" variant="h3" style={{ marginTop: 0 }}>
{t("ukraineHyText")}
</CardTitle>
<OutboundLink
eventLabel="custom: ukrainaHy"
to={t("ukraineHyLink")}
>
<OutboundLink href={t("ukraineHyLink")}>
{t("ukraineHyLinkText")}
</OutboundLink>
</InfoContainer>
Expand Down
6 changes: 2 additions & 4 deletions frontend/components/NewLayout/Courses/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const StyledTooltip = styled(Tooltip)`
const Link = styled(OutboundLink)`
justify-self: right;
margin: 1rem;
`
` as typeof OutboundLink

const Tags = styled("div")``

Expand Down Expand Up @@ -339,9 +339,7 @@ function CourseCard({ course }: CourseCardProps) {
</DifficultyTagContainer>
))}
</DifficultyTags>
<Link eventLabel="to_course_material" to="https://www.mooc.fi">
{t("showCourse")}
</Link>
<Link href="https://www.mooc.fi">{t("showCourse")}</Link>
</RightContentContainer>
{/* <SponsorContainer>
<Sponsor src={sponsorLogo.src} alt="Sponsor logo" fill />
Expand Down
17 changes: 4 additions & 13 deletions frontend/components/OutboundLink.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import React, { PropsWithChildren } from "react"

import ReactGA from "react-ga"

import upRightFromSquareSvg from "@fortawesome/fontawesome-free/svgs/solid/up-right-from-square.svg"
import { Link, LinkProps } from "@mui/material"
import { styled } from "@mui/material/styles"

interface OutboundLinkProps {
label?: string
}

const StyledOutboundLink = styled(ReactGA.OutboundLink)`
const StyledOutboundLink = styled(Link)`
padding-right: 0.5rem;
::after {
content: "";
Expand All @@ -20,17 +15,13 @@ const StyledOutboundLink = styled(ReactGA.OutboundLink)`
height: 0.75rem;
margin-left: 0.5rem;
}
` as React.FC<ReactGA.OutboundLinkProps & React.HTMLProps<HTMLAnchorElement>>
` as Link

function OutboundLink({
label,
children,
...props
}: PropsWithChildren<
ReactGA.OutboundLinkProps &
React.HTMLProps<HTMLAnchorElement> &
OutboundLinkProps
>) {
}: PropsWithChildren<LinkProps>) {
return (
<StyledOutboundLink target="_blank" aria-label={label} {...props}>
{children}
Expand Down
14 changes: 0 additions & 14 deletions frontend/lib/gtag.ts

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-ga": "^3.3.1",
"react-hook-form": "^7.43.2",
"sharp": "^0.31.3",
"styled-jsx": "^5.1.2",
Expand Down
12 changes: 1 addition & 11 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { BreadcrumbProvider } from "/contexts/BreadcrumbContext"
import { LoginStateProvider } from "/contexts/LoginStateContext"
import { useScrollToHash } from "/hooks/useScrollToHash"
import { isAdmin, isSignedIn } from "/lib/authentication"
import { initGA, logPageView } from "/lib/gtag"
import withApolloClient from "/lib/with-apollo-client"
import { createEmotionSsr } from "/src/createEmotionSsr"
import newTheme from "/src/newTheme"
Expand All @@ -37,20 +36,11 @@ export function MyApp({ Component, pageProps }: AppProps) {
const isNew = router.pathname?.includes("_new")

useEffect(() => {
initGA()
logPageView()

router.events.on("routeChangeComplete", logPageView)

const jssStyles = document?.querySelector("#jss-server-side")
if (jssStyles?.parentElement) {
jssStyles.parentElement.removeChild(jssStyles)
}

return () => {
router.events.off("routeChangeComplete", logPageView)
}
}, [router])
}, [])

useScrollToHash()

Expand Down
2 changes: 1 addition & 1 deletion frontend/public/md_pages/lut_module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LUT-yliopisto tarjoaa ohjelmistotuotannon opintoja joustavina etäopintoina. Opi
* Ilmoittautuminen: 29.11. klo 8.00 &mdash; 12.12.2022
</CustomModuleCourse>

<OutboundLink eventLabel="custom: lut-ohjelmistotuotanto" to="https://www.lut.fi/fi/opiskelu/avoin-yliopisto/avoimen-yliopiston-opintotarjonta/ohjelmistotuotannon-opintokokonaisuus">Lue lisää kursseista ja ilmoittautumisesta LUTin sivuilta.</OutboundLink>
<OutboundLink href="https://www.lut.fi/fi/opiskelu/avoin-yliopisto/avoimen-yliopiston-opintotarjonta/ohjelmistotuotannon-opintokokonaisuus">Lue lisää kursseista ja ilmoittautumisesta LUTin sivuilta.</OutboundLink>

</CustomModuleContent>
export default ({ children }) => (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/theme/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { openSansCondensedDeclaration } from "/src/fonts"
const LinkBehavior = React.forwardRef<HTMLAnchorElement, NextLinkProps>(
(props, ref) => {
const { href, ...other } = props

return <Link ref={ref} href={href} {...other} />
},
)
Expand Down

0 comments on commit cda68ba

Please sign in to comment.