Skip to content

Commit

Permalink
Merge pull request #266 from AppQuality/develop
Browse files Browse the repository at this point in the history
Sentry setup
  • Loading branch information
d-beezee authored Dec 11, 2023
2 parents 7fd6fdd + f8b38eb commit 20c0c89
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 125 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
# be deployed to ECS.
docker build \
--build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ cypress/videos
cypress/screenshots
cypress/reports
cypress/downloads

# Sentry Config File
.sentryclirc
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:16.19-alpine3.17 as base

COPY package.json ./
COPY yarn.lock ./
ARG SENTRY_AUTH_TOKEN
ARG NPM_TOKEN
RUN echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
RUN ["yarn", "install", "--frozen-lockfile", "--ignore-scripts"]
Expand All @@ -11,6 +12,7 @@ RUN rm -f .npmrc
COPY . .

RUN ["yarn", "build"]
RUN ["yarn", "sentry:sourcemaps"]

FROM alpine:3.14 as web

Expand Down
1 change: 1 addition & 0 deletions deployment/after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ services:
PORT: 80
NODE_ENV: ${ENVIRONMENT}
REACT_APP_ENVIRONMENT: ${ENVIRONMENT}
REACT_APP_VERSION: ${DOCKER_IMAGE}
logging:
driver: awslogs
options:
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rm -rf $CONFIG_FILE_PATH
touch $CONFIG_FILE_PATH

# Add assignment
echo "window._env_ = {" > $CONFIG_FILE_PATH
echo "window.react_env = {" > $CONFIG_FILE_PATH

VARIABLES=$(printenv | grep REACT_APP)

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@appquality/craft-blocks": "^0.1.27",
"@datadog/browser-logs": "^3.4.1",
"@reduxjs/toolkit": "^1.8.2",
"@sentry/react": "^7.83.0",
"formik": "^2.2.6",
"i18n-iso-countries": "^6.7.0",
"i18next": "^20.2.2",
Expand Down Expand Up @@ -57,7 +58,8 @@
"translate": "i18next-scanner",
"generate-schema": ". ./.env.development; npx openapi-typescript $REACT_APP_API_URL/reference/ --output src/utils/schema.ts ",
"generate-api": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/ npx @rtk-query/codegen-openapi src/services/tryberApi/config.ts",
"generate-fixtures": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/; npx @appquality/fixture-generator -u $API_URL && npx prettier --write 'cypress/fixtures/**/*.json'"
"generate-fixtures": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/; npx @appquality/fixture-generator -u $API_URL && npx prettier --write 'cypress/fixtures/**/*.json'",
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org appquality-srl --project tryber-react ./build && sentry-cli sourcemaps upload --org appquality-srl --project tryber-react ./build"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -94,6 +96,7 @@
"@craco/craco": "^6.4.2",
"@redux-devtools/core": "^3.11.0",
"@rtk-query/codegen-openapi": "^1.0.0-alpha.1",
"@sentry/cli": "^2.23.0",
"@types/node": "^14.14.41",
"@types/react": "17.0.9",
"@types/react-dom": "17.0.9",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDy8e6_8uv8JnNZFRXng6HfbhnhvobWyac&libraries=places"
></script>
<script src="%PUBLIC_URL%/static/iframeResizer.contentWindow.min.js"></script>
<script type="text/javascript" src="/static/env-config.js"></script>
<script type="text/javascript" src="/static/env-config.js?v=0.2.0"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
3 changes: 2 additions & 1 deletion public/static/env-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window._env_ = {
window.react_env = {
REACT_APP_ENVIRONMENT: "local",
REACT_APP_VERSION: "local",
};
241 changes: 127 additions & 114 deletions src/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import "./i18n";
import { datadogLogs } from "@datadog/browser-logs";
import { Location } from "history";
import { Location, createBrowserHistory } from "history";
import queryString from "query-string";
import { useEffect } from "react";
import TagManager from "react-gtm-module";
import { useDispatch } from "react-redux";
import { Redirect, Route, Switch, useLocation } from "react-router-dom";
import { Redirect, Route, Router, Switch, useLocation } from "react-router-dom";

import GenericModal from "./features/GenericModal";
import SiteWideMessages from "./features/SiteWideMessages";
Expand All @@ -27,6 +26,12 @@ import { refreshUser } from "./redux/user/actions/refreshUser";
import BugForm from "./pages/BugForm";
import ThankYouPage from "./pages/ThankYou";
import VdpPage from "./pages/VDP";
import * as Sentry from "@sentry/react";
import SentryWrapper from "./features/SentryWrapper";

// Create Custom Sentry Route component
const SentryRoute = Sentry.withSentryRouting(Route);
const history = createBrowserHistory();

if (process.env.REACT_APP_DATADOG_CLIENT_TOKEN) {
datadogLogs.init({
Expand All @@ -36,13 +41,6 @@ if (process.env.REACT_APP_DATADOG_CLIENT_TOKEN) {
sampleRate: 100,
});
}
if (process.env.REACT_APP_GTM_ID) {
const tagManagerArgs = {
gtmId: process.env.REACT_APP_GTM_ID,
};

TagManager.initialize(tagManagerArgs);
}
const base = "/:locale(en|it|es)?";

function Page() {
Expand All @@ -59,117 +57,132 @@ function Page() {
}, []);

return (
<div>
<SentryWrapper history={history}>
<SiteWideMessages />
<GenericModal />
<Switch>
<Route path={`${base}/getting-started`} component={GettingStarted} />
<Route path={`/it/getting-started-2`}>
<Redirect to="/it/getting-started" />
</Route>
<Router history={history}>
<Switch>
<SentryRoute
path={`${base}/getting-started`}
component={GettingStarted}
/>
<SentryRoute path={`/it/getting-started-2`}>
<Redirect to="/it/getting-started" />
</SentryRoute>

<Route path={`${base}/my-dashboard`} component={Dashboard} />
<SentryRoute path={`${base}/my-dashboard`} component={Dashboard} />

<Route path={`${base}/personal-equipment`} component={Devices} />
<Route
path={`/it/i-miei-device`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/personal-equipment",
}}
/>
)}
/>
<Route
path={`/es/dispositivos`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/personal-equipment",
}}
/>
)}
/>
<SentryRoute
path={`${base}/personal-equipment`}
component={Devices}
/>
<SentryRoute
path={`/it/i-miei-device`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/personal-equipment",
}}
/>
)}
/>
<SentryRoute
path={`/es/dispositivos`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/personal-equipment",
}}
/>
)}
/>

<Route path={`/it/la-mia-dashboard`}>
<Redirect to="/it/my-dashboard" />
</Route>
<Route path={`/es/tablero`}>
<Redirect to="/es/my-dashboard" />
</Route>
<SentryRoute path={`/it/la-mia-dashboard`}>
<Redirect to="/it/my-dashboard" />
</SentryRoute>
<SentryRoute path={`/es/tablero`}>
<Redirect to="/es/my-dashboard" />
</SentryRoute>

<Route path={`${base}/my-bugs`} component={MyBugs} />
<Route path={`${base}/vdp/:id/:token`} component={VdpPage} />
<Route
path={`${base}/experience-points`}
component={ExperiencePoints}
/>
<Route
path={`${base}/it/punti-esperienza`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/experience-points",
}}
/>
)}
/>
<Route
path={`${base}/es/puntos-de-experiencia`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/experience-points",
}}
/>
)}
/>
<Route
path={`${base}/it/i-miei-bug`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/my-bugs",
}}
/>
)}
/>
<Route
path={`${base}/es/errores-cargados`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/my-bugs",
}}
/>
)}
/>
<SentryRoute path={`${base}/my-bugs`} component={MyBugs} />
<SentryRoute path={`${base}/vdp/:id/:token`} component={VdpPage} />
<SentryRoute
path={`${base}/experience-points`}
component={ExperiencePoints}
/>
<SentryRoute
path={`${base}/it/punti-esperienza`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/experience-points",
}}
/>
)}
/>
<SentryRoute
path={`${base}/es/puntos-de-experiencia`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/experience-points",
}}
/>
)}
/>
<SentryRoute
path={`${base}/it/i-miei-bug`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/it/my-bugs",
}}
/>
)}
/>
<SentryRoute
path={`${base}/es/errores-cargados`}
component={({ location }: { location: Location }) => (
<Redirect
to={{
...location,
pathname: "/es/my-bugs",
}}
/>
)}
/>

<Route path={`${base}/my-account`} component={Profile} />
<Route path={`${base}/payments`} component={Wallet} />
<Route path={`${base}/leaderboard`} component={Ranking} />
<Route path={`${base}/campaign/:id/bugform`} component={BugForm} />
<Route path={`${base}/thank-you`} component={ThankYouPage} />
{/* TODO Temporary route */}
<Route
path={`${base}/campaign/:id/preview-selection-form`}
component={PreviewSelectionForm}
/>
<Route
path={["/goodbye", "/it/goodbye", "/es/goodbye"]}
exact
component={GoodbyePage}
/>
<Route path={["/", "/it", "/es"]} exact component={() => <Home />} />
</Switch>
</div>
<SentryRoute path={`${base}/my-account`} component={Profile} />
<SentryRoute path={`${base}/payments`} component={Wallet} />
<SentryRoute path={`${base}/leaderboard`} component={Ranking} />
<SentryRoute
path={`${base}/campaign/:id/bugform`}
component={BugForm}
/>
<SentryRoute path={`${base}/thank-you`} component={ThankYouPage} />
{/* TODO Temporary route */}
<SentryRoute
path={`${base}/campaign/:id/preview-selection-form`}
component={PreviewSelectionForm}
/>
<SentryRoute
path={["/goodbye", "/it/goodbye", "/es/goodbye"]}
exact
component={GoodbyePage}
/>
<SentryRoute
path={["/", "/it", "/es"]}
exact
component={() => <Home />}
/>
</Switch>
</Router>
</SentryWrapper>
);
}

Expand Down
Loading

0 comments on commit 20c0c89

Please sign in to comment.