{"action":"created","issue":{"url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/204","repository_url":"https://api.github.com/repos/bugsnag/bugsnag-js","labels_url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/204/labels{/name}","comments_url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/204/comments","events_url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/204/events","html_url":"https://github.com/bugsnag/bugsnag-js/issues/204","id":183407670,"number":204,"title":"Provide snippet so bugs that occur when bugsnag is still loading are still captured","user":{"login":"joshunger","id":2301847,"avatar_url":"https://avatars.githubusercontent.com/u/2301847?v=3","gravatar_id":"","url":"https://api.github.com/users/joshunger","html_url":"https://github.com/joshunger","followers_url":"https://api.github.com/users/joshunger/followers","following_url":"https://api.github.com/users/joshunger/following{/other_user}","gists_url":"https://api.github.com/users/joshunger/gists{/gist_id}","starred_url":"https://api.github.com/users/joshunger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshunger/subscriptions","organizations_url":"https://api.github.com/users/joshunger/orgs","repos_url":"https://api.github.com/users/joshunger/repos","events_url":"https://api.github.com/users/joshunger/events{/privacy}","received_events_url":"https://api.github.com/users/joshunger/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-17T12:51:50Z","updated_at":"2016-10-21T22:23:15Z","closed_at":"2016-10-21T22:11:26Z","body":"When you load bugsnag asynchronously, bugs can still occur that are not captured.\r\n\r\n```\r\nimport scriptjs from 'scriptjs';\r\n\r\nwindow.addEventListener('unhandledrejection', (event) => {\r\n  Bugsnag.notifyException(event.reason);\r\n});\r\n\r\nscriptjs('https://d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js', () => {\r\n  Bugsnag.apiKey = 'xx';\r\n});\r\n\r\n// in this scenario, unhandledrejection happens before Bugsnag is loaded\r\n```\r\n\r\nWe can fix this by using a snippet inspired by Google Analytics.\r\n\r\n1. Provide a small snippet that created Bugsnag inline and stores any exceptions.\r\n2. When bugsnag loads, it detects Bugsnag and the stored exceptions.\r\n3. If those exceptions exist, it sends them immediately\r\n\r\nI'd like to avoid blocking the page from loading by not loading it async."},"comment":{"url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/comments/255479427","html_url":"https://github.com/bugsnag/bugsnag-js/issues/204#issuecomment-255479427","issue_url":"https://api.github.com/repos/bugsnag/bugsnag-js/issues/204","id":255479427,"user":{"login":"eanakashima","id":187987,"avatar_url":"https://avatars.githubusercontent.com/u/187987?v=3","gravatar_id":"","url":"https://api.github.com/users/eanakashima","html_url":"https://github.com/eanakashima","followers_url":"https://api.github.com/users/eanakashima/followers","following_url":"https://api.github.com/users/eanakashima/following{/other_user}","gists_url":"https://api.github.com/users/eanakashima/gists{/gist_id}","starred_url":"https://api.github.com/users/eanakashima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eanakashima/subscriptions","organizations_url":"https://api.github.com/users/eanakashima/orgs","repos_url":"https://api.github.com/users/eanakashima/repos","events_url":"https://api.github.com/users/eanakashima/events{/privacy}","received_events_url":"https://api.github.com/users/eanakashima/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T22:23:15Z","updated_at":"2016-10-21T22:23:15Z","body":"There are definitely tradeoffs. If you read the docs page linked above, we describe how to load bugsnag-js async, and I'd definitely recommend the method described in there for sites that want to load _all_ of their JS async, but we want the default setup instructions to balance performance with ease of setup and collecting the most useful data possible."}}
{"actor":{"display_login":"eanakashima"}}