From 42dbe7de58777d73290930ed9178b76cb43212ab Mon Sep 17 00:00:00 2001 From: okorie2 Date: Wed, 4 Sep 2024 15:46:44 +0100 Subject: [PATCH] chore: use livesession sdk --- package.json | 1 + public/index.html | 4 ++-- src/app/Routes.tsx | 2 ++ src/app/hooks/useRouteListener.ts | 16 ++++++++++++++++ yarn.lock | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/app/hooks/useRouteListener.ts diff --git a/package.json b/package.json index d62f202a1..23717e610 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@draft-js-plugins/text-alignment": "^2.0.1", "@draft-js-plugins/undo": "^4.1.3", "@hookform/resolvers": "^3.3.0", + "@livesession/sdk": "^1.1.4", "@material-ui/core": "^4.11.3", "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.57", diff --git a/public/index.html b/public/index.html index 5c1f22bc8..e96acf79c 100644 --- a/public/index.html +++ b/public/index.html @@ -157,7 +157,7 @@ - --> diff --git a/src/app/Routes.tsx b/src/app/Routes.tsx index 634ee6df3..98f9741c6 100755 --- a/src/app/Routes.tsx +++ b/src/app/Routes.tsx @@ -5,6 +5,7 @@ import React, { Suspense, lazy } from "react"; import { socialAuth } from "app/utils/socialAuth"; import { useScrollToTop } from "app/hooks/useScrollToTop"; +import { useRouteListener } from "app/hooks/useRouteListener"; import { PageLoader } from "app/modules/common/page-loader"; import { RouteWithAppBar } from "app/utils/RouteWithAppBar"; import { Route, Switch, useHistory } from "react-router-dom"; @@ -218,6 +219,7 @@ const IntercomBootupComponent = () => { export function MainRoutes() { useScrollToTop(); + useRouteListener(); return ( { + const location = useLocation(); + + React.useEffect(() => { + if (window.location.hostname === "dataxplorer.org") { + ls.init(process.env.REACT_APP_LIVE_SESSION_ID as string); + ls.newPageView(); + } + }, [location.pathname]); + + return null; +}; diff --git a/yarn.lock b/yarn.lock index 6237027f1..2332158fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1729,6 +1729,11 @@ resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.4.0.tgz#08d6c5e20cf7e4cc02fd181c4b0c225cd31dbb60" integrity sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA== +"@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== + "@material-ui/core@^4.11.3": version "4.12.3" resolved "https://registry.npmjs.org/@material-ui/core/-/core-4.12.3.tgz"