Comments (14)
How about something like this? (Uses callbacks to avoid the need for passing params)
https://gist.github.com/b225fc3566e4adcc241a
from airbrake-js.
Hi @iainbeeston I'm open, and I welcome a pull request. Would you be able to show in a demo? View source of blog.airbrake.io/js-test/ for a demo (Note: This has a ton of alpha and other funky stuff)
from airbrake-js.
How about this? http://www.iainbeeston.com/airbrake-test.html (I'm getting xss errors though using the same airbrake credentials as the original blog page)
from airbrake-js.
Hi @iainbeeston . Hit me up on IM, [email protected] I need to make a few tweaks, but I've a notifier that works.
from airbrake-js.
Rather than a simple asynchronous load, I'd suggest going into full non-blocking mode so that server/CDN failure does not block the hosting page from loading. Method described here: http://calendar.perfplanet.com/2012/the-non-blocking-script-loader-pattern/
from airbrake-js.
@duncanbeevers , can you please look at this?
from airbrake-js.
I personally prefer relying on the browser's handling of the defer
attribute, though we should probably add the async
attribute as well. As it stands, all the inline code directly addresses creating a shim notifier implementation and not at all with browser-quirks gymnastics.
Anyone else care to weigh in on this?
from airbrake-js.
neither defer
nor async
will prevent blocking the onload
handler. If the server your script is on goes down, this will cause the host page to not complete loading. I'm not sure too many site owners like adding another SPOF to their site, especially one that they cannot control.
The technique I've described above takes you out of the loading queue so that failures in your infrastructure do not affect your customers. It is more effort, but ultimately it's about being a responsible third party.
from airbrake-js.
The FIF technique requires quite a lot of inline code. @benarent @vmihailenco What do you think of just registering a hook onto window.onload
and pulling down the notifier after everything else? Something like this:
// Setup shim
window.Airbrake = [];
window.Airbrake.wrap = function(fn) { return function() {
try { return fn.apply(this, arguments); }
catch (exc) { Airbrake.push({error: exc}); throw exc; } }; };
// Invoke script-loader
(function() {
// We'll do this once the page's onload has fired
function get() {
var s = document.createElement('script'),
p = document.getElementsByTagName('script')[0];
s.src = 'https://ssljscdn.airbrake.io/airbrake-js-tracekit-sourcemap.min.js';
p.parentNode.insertBefore(s, p);
}
// Attach event handler to window onload
if (window.addEventListener) { window.addEventListener('load', get, false); }
} else { window.attachEvent('onload', get); }
}());
from airbrake-js.
That works too, but then you won't capture errors that happen before onload fires.
from airbrake-js.
@duncanbeevers I'm not 100% on this. I'll leave it to you.
from airbrake-js.
Fortunately the shim implementation can capture and queue up errors that
are later processed by the full implementation.
On Nov 18, 2013 4:01 PM, "Philip Tellis" [email protected] wrote:
That works too, but then you won't capture errors that happen before
onload fires.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-28742523
.
from airbrake-js.
SGTM.
Can I ask you to not "compact" code like that? You hardly save 50 bytes, but reading such code is complicated.
from airbrake-js.
Addressed by e2629e6
from airbrake-js.
Related Issues (20)
- Reduce package size HOT 6
- Params not passed on notify method with React ErrorBoundary HOT 1
- This dependency was not found: * async_hooks in ./node_modules/@airbrake/node/esm/scope.js
- Object Not Found Matching Id:3
- Github security alerts
- Cross-Fetch dep is trying to use XHR in service-worker context. HOT 2
- [Documentation] Version 1 to Version 2 Migration Guide
- Unable to post sourcemaps to /v4/projects/:projectId/sourcemaps HOT 2
- Too aggressive error grouping
- No backtrace on error HOT 3
- Uncaught ReferenceError: Notifier is not defined airbrake angularjs HOT 1
- security update: cross-fetch HOT 7
- Airbrake not globally available when using webpacker
- Using blocklist with "name" filters out notifier name HOT 2
- error-stack-parser versions < 2.1.4 causes stack parsing to fail with `ErrorStackParser.parse is not a function` error HOT 2
- Simplify "notify" for error reporting
- Test suite shouldn't make network calls
- AbortError: The user aborted a request.
- Use of instrumentation.fetch for Performance Statistics HOT 1
- Rejected error with Cybersource Flex Microform JS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airbrake-js.