From 6e82eaf78f04b713589e0aa91f0ec9e195f43183 Mon Sep 17 00:00:00 2001 From: aaronshiel Date: Wed, 7 Feb 2024 16:51:58 -0800 Subject: [PATCH 1/3] pass data to get client data --- client/Makefile | 2 +- client/src/api.ts | 8 ++++++-- client/src/local-constants.ts | 1 + client/src/pages/index.tsx | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/Makefile b/client/Makefile index 9ba3713c..308b6fc4 100644 --- a/client/Makefile +++ b/client/Makefile @@ -14,7 +14,7 @@ clean: .PHONY: develop develop: .env.development node_modules/gatsby - npx gatsby develop -p 8000 + npx gatsby develop -p 80 .PHONY: format format: diff --git a/client/src/api.ts b/client/src/api.ts index 787ab97d..91fe3d04 100644 --- a/client/src/api.ts +++ b/client/src/api.ts @@ -5,6 +5,7 @@ Permission to use, copy, modify, and distribute this software and its documentat The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license. */ import axios, { AxiosResponse } from "axios"; +import { LS_LEFT_HOME_PAGE } from "local-constants"; import { Utterance, Config, @@ -21,6 +22,7 @@ import { UtteranceGQL, convertUtteranceGQL, } from "types-gql"; +import { getLocalStorage } from "utils"; export const GATSBY_GRAPHQL_ENDPOINT = process.env.GATSBY_GRAPHQL_ENDPOINT || "/graphql"; @@ -170,12 +172,13 @@ export async function fetchMentor( accessToken: string, subjectId?: string ): Promise { + const leftHomePageData = getLocalStorage(LS_LEFT_HOME_PAGE); const gqlRes = await axios.post>( GATSBY_GRAPHQL_ENDPOINT, { query: ` - query FetchMentor($mentor: ID!, $subject: ID) { - mentorClientData(mentor: $mentor, subject: $subject) { + query FetchMentor($mentor: ID!, $subject: ID, $leftHomePageData: String!) { + mentorClientData(mentor: $mentor, subject: $subject, leftHomePageData: $leftHomePageData) { _id name title @@ -218,6 +221,7 @@ export async function fetchMentor( variables: { mentor: mentorId, subject: subjectId, + leftHomePageData: leftHomePageData, }, }, { diff --git a/client/src/local-constants.ts b/client/src/local-constants.ts index dd53c789..89cf081b 100644 --- a/client/src/local-constants.ts +++ b/client/src/local-constants.ts @@ -18,6 +18,7 @@ export const LS_X_API_EMAIL_KEY = "xapiUserEmail"; // Other export const REFERRER_KEY = "referrer"; export const EVENTS_KEY = "events"; +export const LS_LEFT_HOME_PAGE = "leftHomePage"; // Survey Popup export const TIMER_TEXT_KEY = "timertext"; diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index 5612da34..ab116014 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -535,7 +535,7 @@ function IndexPage(props: { }); updateLocalStorageUserData(newUserData); } - + console.log(document.referrer); return (
Date: Wed, 7 Feb 2024 17:27:55 -0800 Subject: [PATCH 2/3] small fix --- client/src/pages/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index ab116014..06897cfe 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -535,7 +535,9 @@ function IndexPage(props: { }); updateLocalStorageUserData(newUserData); } - console.log(document.referrer); + if (typeof window !== "undefined") { + console.log(document.referrer); + } return (
Date: Sun, 11 Feb 2024 20:59:30 -0800 Subject: [PATCH 3/3] remove old deployments (#231) --- Makefile | 8 -------- cicd/deployspec-dev.yml | 5 ----- cicd/deployspec-prod.yml | 7 +------ cicd/deployspec-qa.yml | 7 +------ client/src/utils.ts | 2 +- 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index cc51e645..71a1d846 100644 --- a/Makefile +++ b/Makefile @@ -98,11 +98,3 @@ test-e2e-exec: test-e2e-up: $(TEST_E2E_DOCKER_COMPOSE) up -d -.PHONY: deploy -deploy: - cd client && \ - export GATSBY_GRAPHQL_ENDPOINT=https://api.devmentorpal.org/graphql/graphql && \ - export GATSBY_STAGE=dev && \ - npm run build && \ - aws s3 sync ./public/ s3://mentorpal-us-east-1-newdev-mentorpal-origin/chat && \ - aws cloudfront create-invalidation --distribution-id E6VOL8BYUVNWS --paths "/chat*" diff --git a/cicd/deployspec-dev.yml b/cicd/deployspec-dev.yml index 804cefc0..94e2fd10 100644 --- a/cicd/deployspec-dev.yml +++ b/cicd/deployspec-dev.yml @@ -7,8 +7,6 @@ env: GATSBY_STAGE: 'dev' GATSBY_IS_SENTRY_ENABLED: false parameter-store: - S3_DEPLOY_BUCKET_NEWDEV: "/mentorpal/newdev/s3-websites/NAME" - CDN_ID_NEWDEV: "/mentorpal/newdev/CLOUDFRONT_DISTRIBUTION_ID" S3_DEPLOY_BUCKET_DEV: "/devmentorpal/s3-websites/NAME" CDN_ID_DEV: "/devmentorpal/CLOUDFRONT_DISTRIBUTION_ID" @@ -22,9 +20,6 @@ phases: build: commands: - cd client && npm run build - - echo Deploying to $S3_DEPLOY_BUCKET_NEWDEV - - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET_NEWDEV/chat - - aws cloudfront create-invalidation --distribution-id $CDN_ID_NEWDEV --paths "/chat*" - echo Deploying to $S3_DEPLOY_BUCKET_DEV - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET_DEV/chat - aws cloudfront create-invalidation --distribution-id $CDN_ID_DEV --paths "/chat*" diff --git a/cicd/deployspec-prod.yml b/cicd/deployspec-prod.yml index 64c51e63..dabf61b7 100644 --- a/cicd/deployspec-prod.yml +++ b/cicd/deployspec-prod.yml @@ -4,11 +4,9 @@ env: variables: GATSBY_GRAPHQL_ENDPOINT: 'https://api.mentorpal.org/graphql/graphql' GATSBY_NPCEDITOR_ENDPOINT: 'https://api.mentorpal.org/npceditor' - GATSBY_STAGE: 'cf' + GATSBY_STAGE: 'prod' GATSBY_IS_SENTRY_ENABLED: true parameter-store: - S3_DEPLOY_BUCKET_CF: "/mentorpal/cf/s3-websites/NAME" - CDN_ID_CF: "/mentorpal/cf/CLOUDFRONT_DISTRIBUTION_ID" S3_DEPLOY_BUCKET: "/mentorpal/s3-websites/NAME" CDN_ID: "/mentorpal/CLOUDFRONT_DISTRIBUTION_ID" @@ -22,9 +20,6 @@ phases: build: commands: - cd client && npm run build - - echo Deploying to $S3_DEPLOY_BUCKET_CF - - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET_CF/chat - - aws cloudfront create-invalidation --distribution-id $CDN_ID_CF --paths "/chat*" - echo Deploying to $S3_DEPLOY_BUCKET - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET/chat - aws cloudfront create-invalidation --distribution-id $CDN_ID --paths "/chat*" diff --git a/cicd/deployspec-qa.yml b/cicd/deployspec-qa.yml index 9866d6db..6dd0725a 100644 --- a/cicd/deployspec-qa.yml +++ b/cicd/deployspec-qa.yml @@ -4,11 +4,9 @@ env: variables: GATSBY_GRAPHQL_ENDPOINT: 'https://api.qamentorpal.org/graphql/graphql' GATSBY_NPCEDITOR_ENDPOINT: 'https://api.qamentorpal.org/npceditor' - GATSBY_STAGE: 'v2' + GATSBY_STAGE: 'qa' GATSBY_IS_SENTRY_ENABLED: true parameter-store: - S3_DEPLOY_BUCKET_V2: "/mentorpal/v2/s3-websites/NAME" - CDN_ID_V2: "/mentorpal/v2/CLOUDFRONT_DISTRIBUTION_ID" S3_DEPLOY_BUCKET_QA: "/qamentorpal/s3-websites/NAME" CDN_ID_QA: "/qamentorpal/CLOUDFRONT_DISTRIBUTION_ID" @@ -22,9 +20,6 @@ phases: build: commands: - cd client && npm run build - - echo Deploying to $S3_DEPLOY_BUCKET_V2 - - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET_V2/chat - - aws cloudfront create-invalidation --distribution-id $CDN_ID_V2 --paths "/chat*" - echo Deploying to $S3_DEPLOY_BUCKET_QA - aws s3 sync ./public s3://$S3_DEPLOY_BUCKET_QA/chat - aws cloudfront create-invalidation --distribution-id $CDN_ID_QA --paths "/chat*" diff --git a/client/src/utils.ts b/client/src/utils.ts index 4c54229e..e09e1d61 100644 --- a/client/src/utils.ts +++ b/client/src/utils.ts @@ -136,7 +136,7 @@ export function loadSentry(): void { Sentry.init({ dsn: "https://75accb4ecbef4766ae3bf62ecfb56658@o1081855.ingest.sentry.io/6439056", integrations: [new BrowserTracing()], - tracesSampleRate: process.env.GATSBY_STAGE == "cf" ? 0.2 : 0.0, + tracesSampleRate: process.env.GATSBY_STAGE == "prod" ? 0.2 : 0.0, environment: process.env.GATSBY_STAGE, }); }