From ce24b741b780dec9e559c27a8564de4c40265745 Mon Sep 17 00:00:00 2001 From: Sam Nesler Date: Fri, 15 Nov 2024 15:26:33 -0600 Subject: [PATCH] [feat] Integrate analytics as embedded page --- .github/workflows/firebase-hosting-merge-prod.yml | 1 + .github/workflows/firebase-hosting-merge-qa.yml | 1 + .github/workflows/firebase-hosting-pull-request.yml | 1 + README.md | 2 -- src/App.tsx | 12 +++++++++++- src/components/Navigation.tsx | 6 ++---- src/pages/StatsDashboard.tsx | 10 ++++++++++ 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge-prod.yml b/.github/workflows/firebase-hosting-merge-prod.yml index fd77681..9b42c73 100644 --- a/.github/workflows/firebase-hosting-merge-prod.yml +++ b/.github/workflows/firebase-hosting-merge-prod.yml @@ -10,6 +10,7 @@ env: VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID_PROD }} VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY_PROD }} VITE_STADIA_KEY: ${{ secrets.VITE_STADIA_KEY }} + VITE_ANALYTICS_URL: ${{ secrets.VITE_ANALYTICS_URL }} 'on': push: branches: diff --git a/.github/workflows/firebase-hosting-merge-qa.yml b/.github/workflows/firebase-hosting-merge-qa.yml index 439f239..19a2996 100644 --- a/.github/workflows/firebase-hosting-merge-qa.yml +++ b/.github/workflows/firebase-hosting-merge-qa.yml @@ -10,6 +10,7 @@ env: VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }} VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} VITE_STADIA_KEY: ${{ secrets.VITE_STADIA_KEY }} + VITE_ANALYTICS_URL: ${{ secrets.VITE_ANALYTICS_URL }} 'on': push: branches: diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index f683e12..36a7c44 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -10,6 +10,7 @@ env: VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }} VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} VITE_STADIA_KEY: ${{ secrets.VITE_STADIA_KEY }} + VITE_ANALYTICS_URL: ${{ secrets.VITE_ANALYTICS_URL }} 'on': pull_request jobs: build_and_preview: diff --git a/README.md b/README.md index 297f5a3..d3174b2 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ Interactive map of organized crime in South America. See the [Google Drive Folder](https://drive.google.com/drive/folders/1U2VPsuXm2Jfzjbf39y73rK3O6BKxV4Jy) for details. The Architecture document is most relevant. -Analytics for the web app can be viewed at https://net.tsuni.dev/redcoralmap.web.app. - ## Contributing Assign an issue to yourself, or work on one that has been assigned to you by cloning this repository, creating a new branch, pushing your changes, and creating a pull request into main. You'll get a preview link on the PR linked to the QA environment. Once you recieve an approval, feel free to merge into main! This will build deploy your code to production. diff --git a/src/App.tsx b/src/App.tsx index 59aa225..3f73fa5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -116,7 +116,7 @@ const App: React.FC = () => { function Layout() { return ( -
+
0} color={'#888888'} /> @@ -142,6 +142,15 @@ const App: React.FC = () => { ) } + function Analytics() { + const url = import.meta.env.VITE_ANALYTICS_URL + return ( + <> + + + ) + } + return ( <> @@ -155,6 +164,7 @@ const App: React.FC = () => { } /> } /> } /> + } /> diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index 783c4cc..a99240f 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -9,16 +9,14 @@ const Navigation = ({ isLoggedIn, auth }: { isLoggedIn: boolean; auth: Auth }) = ) return ( -
+
{isLoggedIn && ( <>
- - Analítica web - + )}
diff --git a/src/pages/StatsDashboard.tsx b/src/pages/StatsDashboard.tsx index e7292cf..13ed999 100644 --- a/src/pages/StatsDashboard.tsx +++ b/src/pages/StatsDashboard.tsx @@ -30,6 +30,16 @@ interface StatsDashboardProps { data: DB } +/** + * The idea is that the user can add and layer filters on top of each other to filter the incidents. + * Each filter has... + * - an id - a unique identifier for the filter used to remove or update it + * - a component that is displayed in the filter bar, displays the state of its filter, and can be clicked on to modify or remove the filter. + * - a state - some filters might need to store some state, maybe. + * - an operation - a function that takes an incident and returns a boolean. If the incident passes the filter, the function should return true. + * + * The filter bar is a horizontal bar that displays all the filters that have been added. It also has a button to add a new filter from a list. + */ const filterReducer = (state: filterState, action: filterDispatchType) => { let newState = state switch (action.type) {