From 7c5a3ab8ce110fb8a3c60257b328bc9d3cda220e Mon Sep 17 00:00:00 2001 From: LWangllix Date: Fri, 13 Oct 2023 12:47:00 +0300 Subject: [PATCH 1/3] setup --- .github/workflows/deploy-development.yml | 7 ++- .github/workflows/deploy-production.yml | 7 ++- .github/workflows/deploy-staging.yml | 7 ++- package.json | 1 + src/index.tsx | 33 +++++++++++- yarn.lock | 69 ++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-development.yml b/.github/workflows/deploy-development.yml index fef6ba2..2b7cfe6 100644 --- a/.github/workflows/deploy-development.yml +++ b/.github/workflows/deploy-development.yml @@ -13,4 +13,9 @@ jobs: packages: write with: environment: Development - docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web \ No newline at end of file + docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web + enable-sentry: true + build-args: | + NODE_ENV=development + REACT_APP_SENTRY_DSN=https://0385edf7f78f4ad4a511abae516ae3e8@sentry.biip.lt/7 + REACT_APP_MAPS_HOST=https://dev.maps.biip.lt \ No newline at end of file diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 0abc74a..108733e 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -14,4 +14,9 @@ jobs: packages: write with: environment: Production - docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web \ No newline at end of file + docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web + enable-sentry: true + build-args: | + NODE_ENV=production + REACT_APP_SENTRY_DSN=https://0385edf7f78f4ad4a511abae516ae3e8@sentry.biip.lt/7 + REACT_APP_MAPS_HOST=https://maps.biip.lt \ No newline at end of file diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 75ea68f..70e8432 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -14,4 +14,9 @@ jobs: packages: write with: environment: Staging - docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web \ No newline at end of file + docker-image: ghcr.io/AplinkosMinisterija/biip-zuvinimas-web + enable-sentry: true + build-args: | + NODE_ENV=production + REACT_APP_SENTRY_DSN=https://0385edf7f78f4ad4a511abae516ae3e8@sentry.biip.lt/7 + REACT_APP_MAPS_HOST=https://staging.maps.biip.lt diff --git a/package.json b/package.json index ce19214..52fe45c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dependencies": { "@material-ui/core": "^4.12.4", "@reduxjs/toolkit": "^1.9.3", + "@sentry/react": "^7.73.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", diff --git a/src/index.tsx b/src/index.tsx index 027a7ca..24272aa 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,14 @@ import ReactDOM from "react-dom/client"; +import * as Sentry from "@sentry/react"; import { QueryClient, QueryClientProvider } from "react-query"; import { Provider } from "react-redux"; -import { BrowserRouter } from "react-router-dom"; +import { + BrowserRouter, + createRoutesFromChildren, + matchRoutes, + useLocation, + useNavigationType +} from "react-router-dom"; import { PersistGate } from "redux-persist/integration/react"; import { ThemeProvider } from "styled-components"; import App from "./App"; @@ -10,12 +17,34 @@ import reportWebVitals from "./reportWebVitals"; import * as serviceWorkerRegistration from "./serviceWorkerRegistration"; import redux from "./state/store"; import { GlobalStyle, theme } from "./styles/index"; +import { useEffect } from "react"; const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement ); const { store, persistor } = redux; - const queryClient = new QueryClient(); +const env = process.env; + +if (env.REACT_APP_SENTRY_DSN) { + Sentry.init({ + environment: env.REACT_APP_ENVIRONMENT, + dsn: env.REACT_APP_SENTRY_DSN, + integrations: [ + new Sentry.BrowserTracing({ + routingInstrumentation: Sentry.reactRouterV6Instrumentation( + useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes + ) + }) + ], + tracesSampleRate: 1, + release: env.REACT_APP_VERSION, + tracePropagationTargets: [env.REACT_APP_MAPS_HOST!] + }); +} root.render( <> diff --git a/yarn.lock b/yarn.lock index 8212ef8..a3d434b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1767,6 +1767,70 @@ resolved "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz" integrity sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg== +"@sentry-internal/tracing@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.73.0.tgz#4838f31e41d23a6041ef4520519b80f788bf1cac" + integrity sha512-ig3WL/Nqp8nRQ52P205NaypGKNfIl/G+cIqge9xPW6zfRb5kJdM1YParw9GSJ1SPjEZBkBORGAML0on5H2FILw== + dependencies: + "@sentry/core" "7.73.0" + "@sentry/types" "7.73.0" + "@sentry/utils" "7.73.0" + tslib "^2.4.1 || ^1.9.3" + +"@sentry/browser@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.73.0.tgz#a8eaeb50cf16ca32f0039a81719c503d7045495f" + integrity sha512-e301hUixcJ5+HNKCJwajFF5smF4opXEFSclyWsJuFNufv5J/1C1SDhbwG2JjBt5zzdSoKWJKT1ewR6vpICyoDw== + dependencies: + "@sentry-internal/tracing" "7.73.0" + "@sentry/core" "7.73.0" + "@sentry/replay" "7.73.0" + "@sentry/types" "7.73.0" + "@sentry/utils" "7.73.0" + tslib "^2.4.1 || ^1.9.3" + +"@sentry/core@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.73.0.tgz#1caeeec44f42c4d58c06cc05dec39e5497b65aa3" + integrity sha512-9FEz4Gq848LOgVN2OxJGYuQqxv7cIVw69VlAzWHEm3njt8mjvlTq+7UiFsGRo84+59V2FQuHxzA7vVjl90WfSg== + dependencies: + "@sentry/types" "7.73.0" + "@sentry/utils" "7.73.0" + tslib "^2.4.1 || ^1.9.3" + +"@sentry/react@^7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.73.0.tgz#8591bb70ac683b43fbe41736c2c321a4661ce22d" + integrity sha512-RCGlxW0Xp5vsC38LGxUO0Xf11LBzfg75VN+KS3D2FS5GXl0R0JwgUyPNVlod7YMCfwytsKGhfP+YpQvHGQAVwg== + dependencies: + "@sentry/browser" "7.73.0" + "@sentry/types" "7.73.0" + "@sentry/utils" "7.73.0" + hoist-non-react-statics "^3.3.2" + tslib "^2.4.1 || ^1.9.3" + +"@sentry/replay@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.73.0.tgz#4e6c522bac5c12f596ef76afe15ecb3807407669" + integrity sha512-a8IC9SowBisLYD2IdLkXzx7gN4iVwHDJhQvLp2B8ARs1PyPjJ7gCxSMHeGrYp94V0gOXtorNYkrxvuX8ayPROA== + dependencies: + "@sentry/core" "7.73.0" + "@sentry/types" "7.73.0" + "@sentry/utils" "7.73.0" + +"@sentry/types@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.73.0.tgz#6d811bbe413d319df0a592a672d6d72a94a8e716" + integrity sha512-/v8++bly8jW7r4cP2wswYiiVpn7eLLcqwnfPUMeCQze4zj3F3nTRIKc9BGHzU0V+fhHa3RwRC2ksqTGq1oJMDg== + +"@sentry/utils@7.73.0": + version "7.73.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.73.0.tgz#530cf023f7c395aa7708cd3824e5a45948449c10" + integrity sha512-h3ZK/qpf4k76FhJV9uiSbvMz3V/0Ovy94C+5/9UgPMVCJXFmVsdw8n/dwANJ7LupVPfYP23xFGgebDMFlK1/2w== + dependencies: + "@sentry/types" "7.73.0" + tslib "^2.4.1 || ^1.9.3" + "@sinclair/typebox@^0.24.1": version "0.24.51" resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz" @@ -9275,6 +9339,11 @@ tslib@^2.0.3: resolved "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz" integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== +"tslib@^2.4.1 || ^1.9.3": + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz" From 3622ffff358cc299c8022a1b63bc1d53edc06c35 Mon Sep 17 00:00:00 2001 From: LWangllix Date: Fri, 13 Oct 2023 12:48:16 +0300 Subject: [PATCH 2/3] map geolocation fix --- src/components/other/RegistrationMap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/other/RegistrationMap.tsx b/src/components/other/RegistrationMap.tsx index 67be17b..a6ce504 100644 --- a/src/components/other/RegistrationMap.tsx +++ b/src/components/other/RegistrationMap.tsx @@ -66,7 +66,6 @@ const Map = ({ [locationMutationMutateAsync] ); - const handleSaveGeom = useCallback( (event: any) => { if (!event?.data?.mapIframeMsg) return; @@ -151,6 +150,7 @@ const Map = ({ )} Date: Fri, 13 Oct 2023 12:58:13 +0300 Subject: [PATCH 3/3] docker updated --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4530e37..81cb1d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,17 @@ RUN yarn install --frozen-lockfile # Copy source COPY . . +# Docker build args and environment variables +ARG ENVIRONMENT +ARG VERSION +ARG REACT_APP_ENVIRONMENT=${ENVIRONMENT} +ARG REACT_APP_VERSION=${VERSION} + +# Set env variables +ARG REACT_APP_MAPS_HOST= +ARG REACT_APP_SENTRY_DSN= +ARG NODE_ENV=production + # Build and cleanup RUN yarn build