Skip to content

Commit 6c360e5

Browse files
committed
fix: update deployment files and sentry config
1 parent 2ee27d1 commit 6c360e5

10 files changed

+44
-35
lines changed

.github/workflows/deploy-dev.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ jobs:
2525
- name: Yarn build
2626
# Set environment variables required to perform the build. These are only available to this step
2727
env:
28-
VITE_API_HOST: ${{ secrets.REACT_APP_API_HOST_DEV }}
29-
VITE_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
28+
VITE_API_HOST: ${{ vars.VITE_API_HOST }}
29+
VITE_GRAASP_APP_KEY: ${{ secrets.VITE_GRAASP_APP_KEY }}
30+
VITE_SENTRY_ENV: development
3031
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
32+
VITE_VERSION: ${{ github.sha }}
3133
run: yarn build
3234
shell: bash
3335

.github/workflows/deploy-prod.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ jobs:
2424
- name: Yarn build
2525
# Set environment variables required to perform the build. These are only available to this step
2626
env:
27-
VITE_API_HOST: ${{ secrets.REACT_APP_API_HOST_PROD }}
28-
VITE_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
27+
VITE_API_HOST: ${{ vars.VITE_API_HOST }}
28+
VITE_GRAASP_APP_KEY: ${{ secrets.VITE_GRAASP_APP_KEY }}
29+
VITE_SENTRY_ENV: production
2930
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
31+
VITE_VERSION: ${{ github.event.client_payload.tag }}
3032
run: yarn build
3133
shell: bash
3234

.github/workflows/deploy-stage.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ jobs:
2424
- name: Yarn build
2525
# Set environment variables required to perform the build. These are only available to this step
2626
env:
27-
VITE_API_HOST: ${{ secrets.REACT_APP_API_HOST_STAGE }}
28-
VITE_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
27+
VITE_API_HOST: ${{ vars.VITE_API_HOST }}
28+
VITE_GRAASP_APP_KEY: ${{ secrets.VITE_GRAASP_APP_KEY }}
29+
VITE_SENTRY_ENV: staging
2930
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
31+
VITE_VERSION: ${{ github.event.client_payload.tag }}
3032
run: yarn build
3133
shell: bash
3234

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
PORT=3005
77
VITE_GRAASP_APP_KEY=<app KEY>
88
VITE_ENABLE_MOCK_API=true
9-
VITE_GRAASP_DOMAIN=localhost
109
VITE_API_HOST=<request address for the backend>
1110
```
1211

docs/Setup_Intructions.md

-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ jobs:
360360
uses: cypress-io/github-action@v2
361361
env:
362362
VITE_API_HOST: http://localhost:3636
363-
VITE_GRAASP_DOMAIN: localhost
364363
VITE_GRAASP_APP_KEY: id-1234567890
365364
VITE_ENABLE_MOCK_API: true
366365
NODE_ENV: test

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name="Text Analysis"
1111
content="A Graasp App created using a template."
1212
/>
13-
<meta name="version-info" content="%APP_VERSION%" />
13+
<meta name="version-info" content="%VITE_VERSION%" />
1414
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
1515
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
1616
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
@@ -48,6 +48,6 @@
4848
To begin the development, run `npm start` or `yarn start`.
4949
To create a production bundle, use `npm run build` or `yarn build`.
5050
-->
51-
<script type="module" src="./src/index.tsx"></script>
51+
<script type="module" src="src/index.tsx"></script>
5252
</body>
5353
</html>

src/config/env.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const GRAASP_APP_KEY = import.meta.env.VITE_GRAASP_APP_KEY;
2-
export const APP_VERSION = import.meta.env.VITE_VERSION;
3-
export const GOOGLE_ANALYTICS_ID = import.meta.env.VITE_GOOGLE_ANALYTICS_ID;
4-
export const ENABLE_MOCK_API =
5-
import.meta.env.VITE_ENABLE_MOCK_API === 'true' || false;
2+
export const APP_VERSION = import.meta.env.VITE_VERSION || 'latest';
3+
export const ENABLE_MOCK_API = import.meta.env.VITE_ENABLE_MOCK_API === 'true';
64
export const GRAASP_API_HOST =
75
import.meta.env.VITE_API_HOST || 'http://localhost:3000';
6+
export const SENTRY_DSN = import.meta.env.VITE_SENTRY_DSN;
7+
export const SENTRY_ENV = import.meta.env.VITE_SENTRY_ENV;

src/config/sentry.ts

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1+
import { APP_VERSION, SENTRY_DSN, SENTRY_ENV } from './env';
2+
13
type SentryConfigType = {
24
dsn: string;
35
environment: string;
46
tracesSampleRate: number;
57
release: string;
8+
replaysSessionSampleRate: number;
9+
replaysOnErrorSampleRate: number;
610
};
711

812
export const generateSentryConfig = (): SentryConfigType => {
9-
let SENTRY_ENVIRONMENT = 'development';
10-
let SENTRY_TRACE_SAMPLE_RATE = 1.0;
11-
switch (import.meta.env.MODE) {
12-
case 'production':
13-
SENTRY_ENVIRONMENT = 'production';
14-
SENTRY_TRACE_SAMPLE_RATE = 0.1;
15-
break;
16-
case 'test':
17-
SENTRY_TRACE_SAMPLE_RATE = 0.0;
18-
break;
19-
case 'development':
20-
SENTRY_TRACE_SAMPLE_RATE = 0.0;
21-
break;
22-
default:
23-
}
13+
// This sets the sample rate to be 10%. You may want this to be 100% while
14+
// in development and sample at a lower rate in production
15+
const DEV_TRACE_SAMPLE_RATE = 1.0;
16+
const DEV_REPLAY_SAMPLE_RATE = 0.1;
17+
const PROD_TRACE_SAMPLE_RATE = 0.1;
18+
const PROD_REPLAY_SAMPLE_RATE = 0.1;
2419

2520
return {
26-
dsn: (!window.Cypress && import.meta.env.SENTRY_DSN) || '',
27-
environment: SENTRY_ENVIRONMENT,
28-
tracesSampleRate: SENTRY_TRACE_SAMPLE_RATE,
29-
release: import.meta.env.APP_VERSION || '',
21+
// dsn is set only when not running inside cypress
22+
dsn: (!window.Cypress && SENTRY_DSN) || '',
23+
environment: SENTRY_ENV,
24+
tracesSampleRate: import.meta.env.PROD
25+
? PROD_TRACE_SAMPLE_RATE
26+
: DEV_TRACE_SAMPLE_RATE,
27+
// release is set only when building for production
28+
release: APP_VERSION,
29+
30+
replaysSessionSampleRate: import.meta.env.PROD
31+
? PROD_REPLAY_SAMPLE_RATE
32+
: DEV_REPLAY_SAMPLE_RATE,
33+
// If the entire session is not sampled, use the below sample rate to sample
34+
// sessions when an error occurs.
35+
replaysOnErrorSampleRate: 1.0,
3036
};
3137
};

src/env.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ interface ImportMetaEnv {
44
readonly VITE_PORT: number;
55
readonly VITE_VERSION: string;
66
readonly VITE_GRAASP_APP_KEY: string;
7-
readonly VITE_GOOGLE_ANALYTICS_ID?: string;
87
readonly VITE_ENABLE_MOCK_API: string;
98
readonly VITE_API_HOST?: string;
109
}

vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
1212
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
1313

1414
return defineConfig({
15-
base: '/',
15+
base: '',
1616
server: {
1717
port: parseInt(process.env.VITE_PORT || '3001', 10),
1818
// only auto open the app when in dev mode

0 commit comments

Comments
 (0)