Skip to content

Commit

Permalink
chore: add livesession integration
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Jul 15, 2024
1 parent 4bb2e67 commit e9a41f7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@livesession/sdk": "^1.1.4",
"@mui/icons-material": "^5.14.0",
"@mui/material": "^5.14.0",
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest",
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { Header } from "app/components/header";
import { Footer } from "app/components/footer";
import Container from "@mui/material/Container";
import { useUrlFilters } from "app/hooks/useUrlFilters";
import { useRouteListener } from "app/hooks/useRouteListener";
import { useScrollToAnchor } from "app/hooks/useScrollToAnchor";

export const Page: React.FC = () => {
useUrlFilters();
useRouteListener();
useScrollToAnchor();

return (
Expand Down
16 changes: 16 additions & 0 deletions src/app/hooks/useRouteListener.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import ls from "@livesession/sdk";
import { useLocation } from "react-router-dom";

export const useRouteListener = () => {
const location = useLocation();

React.useEffect(() => {
if (window.location.hostname === "data.theglobalfund.org") {
ls.init(process.env.REACT_APP_LIVE_SESSION_ID as string);
ls.newPageView();
}
}, [location.pathname]);

return null;
};
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,11 @@
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1"
integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==

"@livesession/sdk@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@livesession/sdk/-/sdk-1.1.4.tgz#e8c020faffe4b51308a6b0bf404a1871f246a595"
integrity sha512-xyiDd3M9wx5k586BIQRcVxSJP5/2XWF9Ca1seLGRSaFoV8o270p5Mn5kpceZFN4STzlYubiMcrPZFFSNWEceVw==

"@mdx-js/react@^3.0.0":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-3.0.1.tgz#997a19b3a5b783d936c75ae7c47cfe62f967f746"
Expand Down

0 comments on commit e9a41f7

Please sign in to comment.