Skip to content
This repository was archived by the owner on Jun 10, 2019. It is now read-only.

add if statement to check if Raven object has been instantiated #958

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 7 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
<body>
<div id="root"></div>
<script>
Raven.config('https://[email protected]/147247', {
shouldSendCallback: function () {
return window.location.host === 'operationcode.org';
}
}).install();
if (window.Raven) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacharyKearns Wrapping the inline <script> tag in an if-statement prevents the Raven-related console errors, but that's because the if-statement will never be true. So this also prevents the Raven.config method from ever being called. That's because when this script tag runs, Raven hasn't been loaded because it's loaded asynchronously w/ a defer attribute on line 37 in the head (this was introduced as a performance improvement in PR #932).

Removing the defer would probably fix this (and there would be no need for the if-statement either, since Raven would have already been loaded synchronously from CDN).

@kylemh I see three options here:

  1. Remove the defer from the Raven CDN script for now (simple fix)
  2. Explore one of the more complicated ways to load Raven asynchronously (Asynchronous Loading and Capturing Errors getsentry/sentry-javascript#169 outlines some of these)
  3. Remove Raven completely - I've never used it, and I don't know of any of the current maintainers who have, either. YAGNI

Thoughts?

Raven.config('https://[email protected]/147247', {
shouldSendCallback: function () {
return window.location.host === 'operationcode.org';
}
}).install();
}
</script>
</body>

Expand Down