Skip to content

Commit

Permalink
feat(client): add sentry (#144)
Browse files Browse the repository at this point in the history
* feat(client): add sentry

* refactor(client): index.tsx setup imports
  • Loading branch information
Jozwiaczek authored Mar 19, 2021
1 parent d60fc2e commit 69a0c3c
Show file tree
Hide file tree
Showing 9 changed files with 1,644 additions and 1,402 deletions.
6 changes: 6 additions & 0 deletions packages/client/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ PORT=8080

# API
REACT_APP_API_URL=http://localhost:3030

# Sentry
REACT_APP_SENTRY_DSN=dns_url
REACT_APP_SENTRY_DEBUG=false
REACT_APP_SENTRY_ENABLED=false
REACT_APP_SENTRY_ENVIRONMENT=development
2 changes: 2 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@sentry/react": "^6.2.3",
"@sentry/tracing": "^6.2.3",
"animejs": "^3.2.1",
"axios": "^0.21.1",
"i18next": "^19.9.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { fireEvent, render, screen } from '../../../utils/testing-library-instance';
import { fireEvent, render, screen } from '../../../utils/testingLibraryInstance';
import TextField from '.';

describe('TextField', () => {
Expand Down
13 changes: 4 additions & 9 deletions packages/client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import './loadSentry';
import './loadPolyfills';

import React from 'react';
import ReactDOM from 'react-dom';

import Providers from './providers';
import Routes from './routes';
import * as serviceWorkerRegistration from './serviceWorker/serviceWorkerRegistration';
import reportWebVitals from './utils/reportWebVitals';

// Load Polyfills
(async () => {
if (typeof window.IntersectionObserver === 'undefined') {
await import('intersection-observer');
}
})();

ReactDOM.render(
<React.StrictMode>
Expand All @@ -24,4 +19,4 @@ ReactDOM.render(

serviceWorkerRegistration.register();

reportWebVitals();
// reportWebVitals(); TODO: setup analytics: https://github.com/Jozwiaczek/smart-gate/issues/145
7 changes: 7 additions & 0 deletions packages/client/src/loadPolyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(async () => {
if (typeof window.IntersectionObserver === 'undefined') {
await import('intersection-observer');
}
})();

export {};
21 changes: 21 additions & 0 deletions packages/client/src/loadSentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as Sentry from '@sentry/react';
import { Integrations } from '@sentry/tracing';

import { onlyOnDevEnv } from './utils';

const {
REACT_APP_SENTRY_DEBUG,
REACT_APP_SENTRY_ENABLED,
REACT_APP_SENTRY_ENVIRONMENT,
REACT_APP_SENTRY_DSN,
} = process.env;

onlyOnDevEnv(() => console.log('Initializing sentry'));

Sentry.init({
dsn: REACT_APP_SENTRY_DSN,
integrations: [new Integrations.BrowserTracing()],
debug: Boolean(REACT_APP_SENTRY_DEBUG),
environment: REACT_APP_SENTRY_ENVIRONMENT || 'production',
enabled: Boolean(REACT_APP_SENTRY_ENABLED),
});
File renamed without changes.
2,995 changes: 1,603 additions & 1,392 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 69a0c3c

Please sign in to comment.