-
Notifications
You must be signed in to change notification settings - Fork 476
Add support for integrating with external reporting #196
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
Changes from all commits
c89540f
8698dd6
6f78e58
02c4f38
b72995e
97eddc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ var warnedAbout = {}; | |
|
||
// List of warnings already given; public read only | ||
jQuery.migrateWarnings = []; | ||
jQuery.migrateWarnings.asErrors = []; | ||
|
||
// Set to false to disable traces that appear with warnings | ||
if ( jQuery.migrateTrace === undefined ) { | ||
|
@@ -40,20 +41,22 @@ if ( jQuery.migrateTrace === undefined ) { | |
// Forget any warnings we've already given; public | ||
jQuery.migrateReset = function() { | ||
warnedAbout = {}; | ||
jQuery.migrateWarnings.length = 0; | ||
jQuery.migrateWarnings.length = jQuery.migrateWarnings.asErrors.length = 0; | ||
}; | ||
|
||
function migrateWarn( msg ) { | ||
var console = window.console; | ||
if ( !warnedAbout[ msg ] ) { | ||
warnedAbout[ msg ] = true; | ||
jQuery.migrateWarnings.push( msg ); | ||
jQuery.migrateWarnings.asErrors.push( new Error( msg ) ); | ||
if ( console && console.warn && !jQuery.migrateMute ) { | ||
console.warn( "JQMIGRATE: " + msg ); | ||
if ( jQuery.migrateTrace && console.trace ) { | ||
console.trace(); | ||
} | ||
} | ||
jQuery( window ).trigger( "migrateWarning" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only time we currently call back into jQuery is to shim a method for warnings. This introduces a situation where we are using the host jQuery's functionality, which makes me nervous. It could potentially cause a recursive crash if Migrate was to give There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd consider it bad form to leak global events, but would be happy to see a hook that gets invoked here, including event emitter style (e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to say I hadn't thought of intercepting the console. Obviously that would require unmuting jquery-migrate, and adding the wrapper in that intercept would be another uninformative line in the stack trace, but that's certainly no dealbreaker. Would scraping for /^JQMIGRATE:/ be safe both now and in the future for consumers who have other cruft in their console they aren't interested in recording? I understand your hesitation about looping back through .trigger, although it would certainly be possible if you were duckpunching trigger to call the original directly in that one case (or presumably if you were raising warnings, there's a decent chance it'd be because some other way would be preferred). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Then duckpunch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'll work. |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @mgol; this is completely redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Error( msg ).stack makes a difference (I managed to forget to put the wrapping in at first). We have a warning I'll have to try to track down after the weekend because we're muted for production and migrateWarnings doesn't provide context.