Skip to content

Instantly share code, notes, and snippets.

@justnom
Last active August 29, 2015 13:56
Show Gist options
  • Save justnom/9080062 to your computer and use it in GitHub Desktop.
Save justnom/9080062 to your computer and use it in GitHub Desktop.
Userscript to remove all Sentry event groups on the current page.
// ==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