diff --git a/.env.example b/.env.example index e99df4b8..73a5365d 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,12 @@ VITE_WARD_API_BASE_URL=https://wardanalyticsapi.com -VITE_WARD_API_KEY= \ No newline at end of file +VITE_WARD_API_KEY= + +# Firebase config +VITE_FIREBASE_API_KEY= +VITE_FIREBASE_AUTH_DOMAIN= +VITE_FIREBASE_PROJECT_ID= +VITE_FIREBASE_STORAGE_BUCKET= +VITE_FIREBASE_MESSAGING_SENDER_ID= +VITE_FIREBASE_APP_ID= +# For Google Analytics +VITE_FIREBASE_MEASUREMENT_ID= \ No newline at end of file diff --git a/.github/workflows/firebase-dev-hosting-merge.yml b/.github/workflows/firebase-dev-hosting-merge.yml new file mode 100644 index 00000000..1c88a3e7 --- /dev/null +++ b/.github/workflows/firebase-dev-hosting-merge.yml @@ -0,0 +1,33 @@ +# Configuration for deploying to production on merge to development +# For more information, see https://github.com/marketplace/actions/deploy-to-firebase-hosting#options + +name: Deploy to Firebase Dev Hosting on merge +"on": + push: + branches: + - development + +env: + VITE_WARD_API_BASE_URL: "https://wardanalyticsapi.com" + VITE_WARD_API_KEY: ${{ secrets.WARD_API_KEY }} + VITE_FIREBASE_API_KEY: "AIzaSyBZCnEQus6G42SodGNRf6o2zmBnGN0nXes" + VITE_FIREBASE_AUTH_DOMAIN: "graphapp-dev.firebaseapp.com" + VITE_FIREBASE_PROJECT_ID: "graphapp-dev" + VITE_FIREBASE_STORAGE_BUCKET: "graphapp-dev.appspot.com" + VITE_FIREBASE_MESSAGING_SENDER_ID: "897485812844" + VITE_FIREBASE_APP_ID: "1:897485812844:web:039de3b976c1559fded449" + # For Google Analytics + VITE_FIREBASE_MEASUREMENT_ID: "G-V2S9JPMH7S" + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: yarn install && yarn build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRAPHAPP_DEV }}" + channelId: live + projectId: graphapp-dev diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 2cce8761..6b8edeff 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -1,11 +1,24 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools +# Configuration for deploying to production on merge to main +# For more information, see https://github.com/marketplace/actions/deploy-to-firebase-hosting#options name: Deploy to Firebase Hosting on merge -'on': +"on": push: branches: - main + +env: + VITE_WARD_API_BASE_URL: https://wardanalyticsapi.com + VITE_WARD_API_KEY: ${{ secrets.WARD_API_KEY }} + VITE_FIREBASE_API_KEY: AIzaSyD1LUGU2RM-bhxKgeYdnzItbwBC0VSTOV0 + VITE_FIREBASE_AUTH_DOMAIN: graphapp-bca04.firebaseapp.com + VITE_FIREBASE_PROJECT_ID: graphapp-bca04 + VITE_FIREBASE_STORAGE_BUCKET: graphapp-bca04.appspot.com + VITE_FIREBASE_MESSAGING_SENDER_ID: "1030502540585" + VITE_FIREBASE_APP_ID: "1:1030502540585:web:cfe727695aad44d0494338" + # For Google Analytics + VITE_FIREBASE_MEASUREMENT_ID: G-RYB03B2Q13 + jobs: build_and_deploy: runs-on: ubuntu-latest @@ -14,7 +27,7 @@ jobs: - run: yarn install && yarn build - uses: FirebaseExtended/action-hosting-deploy@v0 with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRAPHAPP_BCA04 }}' + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRAPHAPP_BCA04 }}" channelId: live projectId: graphapp-bca04 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 0fcd0aa9..282f5328 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -1,8 +1,24 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools +# Configuration for deploy a preview of the PR to a temporary url +# The goal is to be able to test the PR before merging it +# This action is triggered on every PR, regardless of the branch +# The preview url has a lifetime of 7 days +# For more information, see https://github.com/marketplace/actions/deploy-to-firebase-hosting#options name: Deploy to Firebase Hosting on PR "on": pull_request + +env: + VITE_WARD_API_BASE_URL: "https://wardanalyticsapi.com" + VITE_WARD_API_KEY: ${{ secrets.WARD_API_KEY }} + VITE_FIREBASE_API_KEY: "AIzaSyD1LUGU2RM-bhxKgeYdnzItbwBC0VSTOV0" + VITE_FIREBASE_AUTH_DOMAIN: "graphapp-bca04.firebaseapp.com" + VITE_FIREBASE_PROJECT_ID: "graphapp-bca04" + VITE_FIREBASE_STORAGE_BUCKET: "graphapp-bca04.appspot.com" + VITE_FIREBASE_MESSAGING_SENDER_ID: "1030502540585" + VITE_FIREBASE_APP_ID: "1:1030502540585:web:cfe727695aad44d0494338" + # For Google Analytics + VITE_FIREBASE_MEASUREMENT_ID: "G-RYB03B2Q13" + jobs: build_and_preview: if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}" @@ -14,4 +30,5 @@ jobs: with: repoToken: "${{ secrets.GITHUB_TOKEN }}" firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRAPHAPP_BCA04 }}" + expires: 7d projectId: graphapp-bca04 diff --git a/.gitignore b/.gitignore index b63cb8f3..ed96b29a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,13 +14,15 @@ dist-ssr build *.local .env +.env.development +.env.test +.env.production # Yarn installation state file .yarn/install-state.gz # Firebase .firebase/* -firebase.json .firebaserc # Editor directories and files diff --git a/firebase.json b/firebase.json new file mode 100644 index 00000000..340ed5b7 --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "build", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/src/App.tsx b/src/App.tsx index dcd44725..3fcfa0c3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,6 +3,7 @@ import { QueryClientProvider } from 'react-query' import Routes from './Routes'; import useCustomQueryClient from './hooks/useCustomQueryClient'; +import './firebase/firebase' function App() { const queryClient = useCustomQueryClient() diff --git a/src/components/Graph/Graph.tsx b/src/components/Graph/Graph.tsx index 40a3a247..d05c1224 100644 --- a/src/components/Graph/Graph.tsx +++ b/src/components/Graph/Graph.tsx @@ -49,6 +49,8 @@ import Legend from "./Legend"; import TransactionTooltip, { TransactionTooltipProps, } from "./TransactionTooltip"; +import { default as firebase } from "../../firebase/firebase" +import { logEvent } from "firebase/analytics"; /* Pan on drag settings */ const panOnDrag = [1, 2]; @@ -531,6 +533,17 @@ const Graph: FC = () => { } }, []); + const onSetSearchedAddress = (newAddress: string) => { + setSearchedAddresses([newAddress]); + + logEvent(firebase.analytics, "search_address", { + address: newAddress, + }); + + console.log("Searched address: ", newAddress); + console.log(firebase.analytics) + } + return (