Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: forward console errors to Sentry #115

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cdn/dev/js/sentry.bundle.5.28.0.min.js

This file was deleted.

34 changes: 26 additions & 8 deletions inc/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@

<title>KeymanWeb.com <?php if($tier != 'stable') echo "($tier)"; ?></title>

<?php
/* Our local CDN version is identical to this file:
<!-- note: using CDN and not bundle for now -->
<script
src="https://browser.sentry-cdn.com/7.111.0/bundle.tracing.min.js"
integrity="sha384-zbLcy9H6obT3ZcKjGlb5Ai7vi4G0vXMLB1UU56WRyPJWarHEDeLOkuJ3HwR/7IDd"
crossorigin="anonymous"
></script>
<script
src="https://browser.sentry-cdn.com/5.28.0/bundle.min.js"
integrity="sha384-1HcgUzJmxPL9dRnZD2wMIj5+xsJfHS+WR+pT2yJNEldbOr9ESTzgHMQOcsb2yyDl"
src="https://browser.sentry-cdn.com/7.111.0/captureconsole.min.js"
integrity="sha384-29aW5YLMCGJnTd6js4VqwRHQk4lBe44qavgMQDtiMsXya0LpJqw5UqQDVyenw+SW"
crossorigin="anonymous"
></script>*/
?>
<script src="<?= cdn('js/sentry.bundle.5.28.0.min.js'); ?>"></script>
></script>

<script>
// Tags all exceptions with the active KMW instance's metadata.
// Compare against the definition in the main repo:
Expand Down Expand Up @@ -81,16 +84,31 @@
var sentryRelease = "<?=$version."-".$tier?>";
<?php } ?>

// Note: not currently using js Loader as it does not seem to work correctly
// with integrations
doInitSentry();

function doInitSentry() {
if(!Sentry) {
// may be blocked by client
return;
}
Sentry.init({
beforeSend: prepareEvent,
dsn: "https://[email protected]/5983523",
dsn: "https://[email protected].us.sentry.io/5983523",
release: sentryRelease,
integrations: [
Sentry.captureConsoleIntegration({
levels: ['error', 'warning']
})
],
environment:
// TODO: https://github.com/keymanapp/shared-sites/issues/13
['www.keymanweb.com','keymanweb.com', 'web.keyman.com'].includes(location.host) ? 'production' :
['web.keyman-staging.com'].includes(location.host) ? 'staging' :
'development',
});
}
</script>

<link rel='shortcut icon' href="<?php echo cdn("img/keymanweb-icon-16.png"); ?>">
Expand Down
Loading