[spotify-api] VINYLIFY : μ€ν¬ν°νμ΄ apiνμ©ν κ²μ + μ¬μ νλ‘μ νΈ(6)
[μ΄μ κΈ] 2024.08.09 - [π©π»π» dev] - [spotify-api] VINYLIFY : μ€ν¬ν°νμ΄ apiνμ©ν κ²μ + μ¬μ νλ‘μ νΈ(5) react router μ€μ [spotify-api] VINYLIFY : μ€ν¬ν°νμ΄ apiνμ©ν κ²μ + μ¬μ νλ‘μ νΈ(5) react router
pyotato-dev.tistory.com
sentry can't fix this μ νλΈ κ΄κ³ λ‘ μ’ μ’ λ΄€λ sentry! μ€λμ sentry μ μ©μ λν΄ μ 리λ₯Ό νκ³ μ νλ€.
sentryμ λν΄ μκ² λ κ² νλ‘μ νΈ λ§λ¬΄λ¦¬ μμ μ΄λΌ, κ²½νμ ν΄λ³΄κ³ μΆμ΄μ μμ¬μ΄λλ‘ μ μ©μ ν΄λ΄€λ€.
β οΈ μκ°μ λ§μ§λ§ λ¨κ³μ νμ§λ§, μ€μ κ΄λ ¨ νκ³ λ€μ κ°μ΄ λͺ¨μλκ³ μΆμ΄μ sentry μ€μ μ λν΄ λ¨Όμ λ€λ£¨κ² λμμ΅λλ€! yarn, reactλ₯Ό κΈ°μ€μΌλ‘ μμ±λμμ΅λλ€!
sentryλ κ°λ°μλ€μ΄ μλΉμ€μ μμ€ν μ λ°μ κ±Έμ³ μ±λ₯ μ΄μλ μλ¬λ€μ λ°κ²¬νκ³ λλ²κΉ νλλ° λμμ£Όλ λꡬλ€.
λΏλ§ μλλΌ μ¬λ¬ μλΉμ€λ μ ν리μΌμ΄μ κ°μ μνΈμμ©μ λͺ¨λν°λ§ν μ μλ€λ μ₯μ μ΄ μλ€.
μλμ²λΌ μ΄λ€ κ²½λ‘λ‘ μμ²μ΄ λ§μ΄ κ°κ³ μ΄μκ° μμ λ λ‘κ·Έλ₯Ό νμΈν μ μκ³ , κ°μ νλ μ΄λ©μΌλ‘ μλ¬ λ°μ μ μ΄λ©μΌμ΄ μ¨λ€.
μλ¬κ° λ°μν κ²½μ° dom 리νλ μ΄λ κ°λ₯νλ€.
μ΄λ κ² μκ°μ μΌλ‘ μλ¬κ° μ΄λ»κ² μ΄λμ λ°μνλ μ§ μλ €μ£Όλ κ² μ λ°ν κ±° κ°λ€.
κ·ΈλΌ λ³Έκ²©μ μΌλ‘ μ€μ μ ν΄λ³΄μ! (κ³μ κ°μ ν κ³Όμ μ λ€λ£Ήλλ€.)
μ€μ λ°©λ²μΌλ‘λ ν¨ν€μ§ λ§€λμ / loader/ cdn λ°©λ²μ΄ μλλ°, κ·Έ μ€ ν¨ν€μ§ λ§€λμ λ‘ μ€μΉλ₯Ό ν κ²μ΄λ€.
μ€μΉ
yarn add @sentry/react
μ€μ
sentryλ react router λ²μ μ μ¬λ¬κ° μ§μνλ€.
κ°λ₯ν μ±μ μ΅μλ¨μ sentry μ΄κΈ°νλ₯Ό ν΄μ€μΌνλ€. λ€μκ³Ό κ°μ΄ μ΄κΈ°ν μ½λλ₯Ό μ ν리μΌμ΄μ μ΅μλ¨μ νλλ‘ νμ.
vinylifyμ μ± μ§μ νμΌμ main.tsxλ€. (viteμμ index.htmlμμ <script type="module" src="/src/main.tsx"></script>λ‘ μ€μ λμ΄ μκΈ° λλ¬Έ)
https://docs.sentry.io/platforms/javascript/#configureμ μλ μ½λλ₯Ό 볡μ¬ν΄μ€λ©΄ λλ€.
- main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: 'https://λλ€μΌλ ¨λ²νΈ.ingest.us.sentry.io/λλ€μΌλ ¨λ²νΈ2',
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
'localhost',
/^https:\/\/yourserver\.io\/api/,
/^https:\/\/vinylify-express.vercel.app/, //λ‘κ·ΈμΈ νμ΄μ§μμ μνΈμμ©μ μκΈ° μν΄ λ±λ‘
// /^https:\/\/api.spotify.com/,
],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
κ·Έ ν vite.config.tsμ νλ¬κ·ΈμΈ μ€μ μ μΆκ°ν΄μ£Όμ.
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import type { UserConfig } from 'vite';
import type { InlineConfig } from 'vitest';
type ViteConfig = UserConfig & { test: InlineConfig };
const config: ViteConfig = {
plugins: [
react(),
tsconfigPaths(),
//////////////////////////////////////////////// π μΆκ° ////////////////////////////////////////////////////////////////
sentryVitePlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'pyotato',
project: 'javascript-react',
}),
//////////////////////////////////////////////// π μΆκ° ////////////////////////////////////////////////////////////////
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
test: {
globals: true,
environment: 'jsdom',
},
build: {
sourcemap: true, // Source map generation must be turned on
},
};
export default defineConfig(config);
κΉνλΈμ sentry token λ λ±λ‘ν΄μ£Όμ.
π References
https://docs.sentry.io/platforms/javascript/guides/react/
React | Sentry for React
Learn about Sentry's React SDK and how it automatically reports errors and exceptions in your application.
docs.sentry.io