Skip to content

Commit

Permalink
analytics react
Browse files Browse the repository at this point in the history
  • Loading branch information
saphal-upreti committed Jul 10, 2024
1 parent cd50f51 commit 395d6a1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
42 changes: 0 additions & 42 deletions nepalingo-web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import React from "react";
import Header from "./components/Header";
import ReactGA from 'react-ga4';

function App() {
import React, { useState, useEffect } from "react";
import {
BrowserRouter as Router,
Expand Down Expand Up @@ -43,43 +38,6 @@ const App: React.FC = () => {
return () => subscription.unsubscribe();
}, []);

=======
import React, { useState, useEffect } from "react";
import {
BrowserRouter as Router,
Route,
Routes,
Navigate,
} from "react-router-dom";
import User_auth from "./components/userAuth/UserAuth";
import Home from "./pages/Home/Home";
import supabase from "./components/userAuth/supabaseClient";

const App: React.FC = () => {
const [isAuthenticated, setIsAuthenticated] = useState(false);

// useEffect to check the current session and subscribe to authentication state changes
useEffect(() => {
// Function to fetch the current session
const fetchSession = async () => {
const {
data: { session },
} = await supabase.auth.getSession();
setIsAuthenticated(!!session); // Update authentication state
};

fetchSession(); // Initial session fetch

// Subscribe to authentication state changes
const {
data: { subscription },
} = supabase.auth.onAuthStateChange((_event, session) => {
setIsAuthenticated(!!session); // Update authentication state on changes
});

// Cleanup subscription on component unmount
return () => subscription.unsubscribe();
}, []);
return (
<Router>
<Routes>
Expand Down
3 changes: 1 addition & 2 deletions nepalingo-web/src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from "react";
import { useLocation } from "react-router-dom";
import logo from "../../assets/logo.png";
import ReactGA from 'react-ga4';

Check failure on line 4 in nepalingo-web/src/pages/Home/Home.tsx

View workflow job for this annotation

GitHub Actions / test_build

'ReactGA' is defined but never used
const Home: React.FC = () => {
ReactGA.send({ hitType: "pageview", page: "/", title: "home" });

const Home: React.FC = () => {
const location = useLocation();
const username = location.state?.username;
Expand Down

0 comments on commit 395d6a1

Please sign in to comment.