Last active
August 29, 2015 13:56
-
-
Save justnom/9080062 to your computer and use it in GitHub Desktop.
Userscript to remove all Sentry event groups on the current page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Sentry clear all | |
// @namespace https://gist.github.com/justnom/9080062/ | |
// @version 0.1 | |
// @description clear all visible Sentry events | |
// @author justnom | |
// @match http://sentry.my-corp.com/* | |
// @grant none | |
// ==/UserScript== | |
// Add button to toolbar | |
var buttonEl = $('<div class="btn-group"><a class="btn" href="#">Clear All Events</a></div>'); | |
buttonEl.click(function() { | |
(function($) { | |
var alwaysPromise = function(promise) { | |
var def = $.Deferred(); | |
promise.always(function() { | |
def.resolve(); | |
}); | |
return def; | |
}; | |
var promises = []; | |
$('#event_list > ul.group-list > li.group > .details > h3 > a').each(function() { | |
var href = $(this).attr('href'); | |
var hostname = window.location.hostname; | |
var uriPos = href.indexOf(hostname) + hostname.length; | |
var url = href.slice(0, uriPos) + '/api' + href.slice(uriPos) + 'remove/'; | |
console.log(url); | |
var ajaxPromise = $.ajax({ | |
url: url | |
}); | |
promises.push(alwaysPromise(ajaxPromise)); | |
}); | |
$.when.apply($, promises).done(function() { | |
alert('All Sentry events removed on current page!'); | |
}); | |
})(window.$); | |
}); | |
$('#content > div > div > div.main > div:nth-child(2)').append(buttonEl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment