Skip to content

Commit

Permalink
Add sentry config (#47)
Browse files Browse the repository at this point in the history
* update gitignore

* add sentry config and callback
  • Loading branch information
thostetler authored Dec 12, 2024
1 parent 0513518 commit 7ef64c7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@ python/
logs/
local_config.py

scripts/
scripts/
.idea/
60 changes: 60 additions & 0 deletions adscore/templates/base-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,65 @@
})();
</script>
{% endif %}

<!-- Add Sentry SDK -->
<script src="https://js.sentry-cdn.com/46062cbe0aeb7a3b2bb4c3a9b8cd1ac7.min.js" crossorigin="anonymous"></script>
<script>
// Set the environment variable
window.process = { env: { NODE_ENV: window.ENV ?? 'production' } };

window.getSentry = (cb, errCb) => {
if (typeof errCb === 'function') {
errCb.call(null, new Error('Failed to get Sentry'));
}
};

window.sentryOnLoad = function() {
try {
Sentry.init({
dsn: 'https://46062cbe0aeb7a3b2bb4c3a9b8cd1ac7@o1060269.ingest.us.sentry.io/4507341192036352',

// Performance Monitoring
tracesSampleRate: window.ENV === 'development' ? 1.0 : 0.75,

// Session Replay
replaysSessionSampleRate: window.ENV === 'development' ? 1.0 : 0.1,
replaysOnErrorSampleRate: 1.0,
environment: window.ENV ?? 'production',
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: false,
unmask: ['[name=q]'],
}),
],
tracePropagationTargets: [
'localhost',
'https://ui.adsabs.harvard.edu',
'https://devui.adsabs.harvard.edu',
'https://qa.adsabs.harvard.edu',
],
});
} catch (e) {
console.error('Could not initialize Sentry', e);
}
};

window.getSentry = function(cb, errCb = () => {}) {
try {
if (!window.Sentry) {
throw new Error('Sentry not found');
}
return cb.call(window, Sentry);
} catch (e) {
console.warn('unable to run sentry callback', e);
if (typeof errCb === 'function') {
errCb.call(window, e);
}
}
};
</script>
<!-- END Add Sentry SDK -->
</body>
</html>

0 comments on commit 7ef64c7

Please sign in to comment.