Skip to content

Commit

Permalink
ci: sentry 초기 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
chysis committed Aug 6, 2024
1 parent dbeb7c4 commit b32adfb
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 12 deletions.
4 changes: 3 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
dist

yarn-error.log
.env
.env
# Sentry Config File
.env.sentry-build-plugin
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@sentry/react": "^8.23.0",
"@sentry/webpack-plugin": "^2.21.1",
"@tanstack/react-query": "^5.51.1",
"@tanstack/react-query-devtools": "^5.51.1",
"dotenv-webpack": "^8.1.0",
Expand Down
18 changes: 15 additions & 3 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Global, ThemeProvider } from '@emotion/react';
import * as Sentry from '@sentry/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';
import ReactDOM from 'react-dom/client';
Expand All @@ -17,6 +18,20 @@ import ReviewWritingCompletePage from './pages/ReviewWritingCompletePage';
import globalStyles from './styles/globalStyles';
import theme from './styles/theme';

const { hostname, port } = DEV_ENVIRONMENT;
const isDev = window?.location.hostname === hostname && window.location.port === port;
const baseUrlPattern = new RegExp(`^${process.env.API_BASE_URL?.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')}`);

Sentry.init({
dsn: `${process.env.SENTRY_DSN}`,
enabled: !isDev,
environment: 'production',
tracesSampleRate: 1.0,
tracePropagationTargets: [baseUrlPattern],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand Down Expand Up @@ -62,9 +77,6 @@ const router = createBrowserRouter([
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);

async function enableMocking() {
const { hostname, port } = DEV_ENVIRONMENT;
const isDev = window?.location.hostname === hostname && window.location.port === port;

if (isDev) {
const { worker } = await import('./mocks/browser');
return worker.start();
Expand Down
7 changes: 7 additions & 0 deletions frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');

module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
Expand Down Expand Up @@ -38,6 +39,7 @@ module.exports = (env, argv) => {
},
],
},
devtool: 'source-map',
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
Expand All @@ -54,6 +56,11 @@ module.exports = (env, argv) => {
systemvars: true,
path: './.env',
}),
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'review-me',
project: 'review-me',
}),
],
devtool: isProduction ? 'hidden-source-map' : 'eval',
devServer: {
Expand Down
Loading

0 comments on commit b32adfb

Please sign in to comment.