Added Sentry for error tracking

no refs

- adds sentry setup if Sentry DSN is available via Ghost config for better error tracking
This commit is contained in:
Rishabh 2021-06-21 19:45:42 +05:30
parent 4db821f9ee
commit 0535fab865
3 changed files with 107 additions and 7 deletions

View File

@ -18,6 +18,8 @@
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@sentry/react": "^6.7.2",
"@sentry/tracing": "^6.7.2",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "11.2.7",
"@testing-library/user-event": "13.1.9",

View File

@ -1,3 +1,4 @@
import * as Sentry from '@sentry/react';
import TriggerButton from './components/TriggerButton';
import Notification from './components/Notification';
import PopupModal from './components/PopupModal';
@ -365,6 +366,7 @@ export default class App extends React.Component {
}
this.setupFirstPromoter({site, member});
this.setupSentry({site});
return {site, member};
} catch (e) {
if (hasMode(['dev', 'test'])) {
@ -374,6 +376,18 @@ export default class App extends React.Component {
}
}
/** Setup Sentry */
setupSentry({site}) {
const {portal_sentry: portalSentry, portal_version: portalVersion, version: ghostVersion} = site;
if (portalSentry && portalSentry.dsn) {
Sentry.init({
dsn: portalSentry.dsn,
environment: portalSentry.env || 'development',
release: `portal@${portalVersion}|ghost@${ghostVersion}`
});
}
}
/** Setup Firstpromoter script */
setupFirstPromoter({site, member}) {
const firstPromoterId = getFirstpromoterId({site});
@ -591,11 +605,13 @@ export default class App extends React.Component {
render() {
if (this.state.initStatus === 'success') {
return (
<AppContext.Provider value={this.getContextFromState()}>
<PopupModal />
<TriggerButton />
<Notification />
</AppContext.Provider>
<Sentry.ErrorBoundary>
<AppContext.Provider value={this.getContextFromState()}>
<PopupModal />
<TriggerButton />
<Notification />
</AppContext.Provider>
</Sentry.ErrorBoundary>
);
}
return null;

View File

@ -1536,6 +1536,81 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"
"@sentry/browser@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.7.2.tgz#cfbe060de5a9694617f175a6bde469e5e266792e"
integrity sha512-Lv0Ne1QcesyGAhVcQDfQa3hDPR/MhPSDTMg3xFi+LxqztchVc4w/ynzR0wCZFb8KIHpTj5SpJHfxpDhXYMtS9g==
dependencies:
"@sentry/core" "6.7.2"
"@sentry/types" "6.7.2"
"@sentry/utils" "6.7.2"
tslib "^1.9.3"
"@sentry/core@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.7.2.tgz#1d294fac6e62744bce3b9dfbcd90b14e93620480"
integrity sha512-NTZqwN5nR94yrXmSfekoPs1mIFuKvf8esdIW/DadwSKWAdLJwQTJY9xK/8PQv+SEzd7wiitPAx+mCw2By1xiNQ==
dependencies:
"@sentry/hub" "6.7.2"
"@sentry/minimal" "6.7.2"
"@sentry/types" "6.7.2"
"@sentry/utils" "6.7.2"
tslib "^1.9.3"
"@sentry/hub@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.7.2.tgz#31b250e74aa303877620dfa500aa89e4411e2dec"
integrity sha512-05qVW6ymChJsXag4+fYCQokW3AcABIgcqrVYZUBf6GMU/Gbz5SJqpV7y1+njwWvnPZydMncP9LaDVpMKbE7UYQ==
dependencies:
"@sentry/types" "6.7.2"
"@sentry/utils" "6.7.2"
tslib "^1.9.3"
"@sentry/minimal@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.7.2.tgz#9e6c0c587daea64a9042041694a4ad5d559d16cd"
integrity sha512-jkpwFv2GFHoVl5vnK+9/Q+Ea8eVdbJ3hn3/Dqq9MOLFnVK7ED6MhdHKLT79puGSFj+85OuhM5m2Q44mIhyS5mw==
dependencies:
"@sentry/hub" "6.7.2"
"@sentry/types" "6.7.2"
tslib "^1.9.3"
"@sentry/react@^6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.7.2.tgz#68edb082ea42cabcf86939f254457436b82b4a0a"
integrity sha512-gjXRuhgd3l2s18Y4dw9ZMWCiFKyeAU79fBiYdv8lqu9EFPFquU0qkZbgep8D37Xq2GWjQM0qEBmD758L6bUwvQ==
dependencies:
"@sentry/browser" "6.7.2"
"@sentry/minimal" "6.7.2"
"@sentry/types" "6.7.2"
"@sentry/utils" "6.7.2"
hoist-non-react-statics "^3.3.2"
tslib "^1.9.3"
"@sentry/tracing@^6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.7.2.tgz#78a6934837143ae5e200b49bd256bc8a917477bc"
integrity sha512-juKlI7FICKONWJFJxDxerj0A+8mNRhmtrdR+OXFqOkqSAy/QXlSFZcA/j//O19k2CfwK1BrvoMcQ/4gnffUOVg==
dependencies:
"@sentry/hub" "6.7.2"
"@sentry/minimal" "6.7.2"
"@sentry/types" "6.7.2"
"@sentry/utils" "6.7.2"
tslib "^1.9.3"
"@sentry/types@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.7.2.tgz#8108272c98ad7784ddf9ddda0b7bdc6880ed6e50"
integrity sha512-h21Go/PfstUN+ZV6SbwRSZVg9GXRJWdLfHoO5PSVb3TVEMckuxk8tAE57/u+UZDwX8wu+Xyon2TgsKpiWKxqUg==
"@sentry/utils@6.7.2":
version "6.7.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.7.2.tgz#c7f957ebe16de3e701a0c5477ac2dba04e7b4b68"
integrity sha512-9COL7aaBbe61Hp5BlArtXZ1o/cxli1NGONLPrVT4fMyeQFmLonhUiy77NdsW19XnvhvaA+2IoV5dg3dnFiF/og==
dependencies:
"@sentry/types" "6.7.2"
tslib "^1.9.3"
"@sinonjs/commons@^1.7.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
@ -5810,6 +5885,13 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"
homedir-polyfill@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"
@ -9510,7 +9592,7 @@ react-error-overlay@^6.0.9:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
react-is@^16.8.1:
react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
@ -11169,7 +11251,7 @@ tsconfig-paths@^3.9.0:
minimist "^1.2.0"
strip-bom "^3.0.0"
tslib@^1.8.1, tslib@^1.9.0:
tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==