Skip to content

Instantly share code, notes, and snippets.

@robertohuertasm
Last active June 23, 2023 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertohuertasm/6281a7710a23fcba561f0286b45a74e8 to your computer and use it in GitHub Desktop.
Save robertohuertasm/6281a7710a23fcba561f0286b45a74e8 to your computer and use it in GitHub Desktop.
Datadog Error Tracking AI
// ==UserScript==
// @name Datadog - Error Tracking AI
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Roberto Huertas
// @match https://dd.datad0g.com/apm/error-tracking?*
// @icon https://www.google.com/s2/favicons?sz=64&domain=datad0g.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addElement(time) {
setTimeout(() => {
try {
console.log('Trying to create the link');
const node = document.querySelectorAll('div.druids_typography_markdown')[1];
let issueId = location.search.match(/issueId=(.*?)&/)[1];
// issueId = 'e23261bc-0956-11ee-82e2-da7ad0900001';
const link = `vscode://datadog.datadog-vscode/action?&org-id=2&org-name=Datadog HQ&name=Generated fix&https://dd.datad0g.com/api/v2/error-tracking/issues/${issueId}/ide-actions/fetch-ai-fix?track=rum`;
const el = document.createElement('a');
el.innerHTML = 'Add the test in VSCode';
el.href=link;
// el.href='vscode://datadog.datadog-vscode/action?&org-id=2&org-name=Datadog HQ&name=Generated fix&https://dd.datad0g.com/api/v2/error-tracking/issues/e23261bc-0956-11ee-82e2-da7ad0900001/ide-actions/fetch-ai-fix?track=rum';
// el.href = 'vscode://datadog.datadog-vscode/action?&org-id=2&org-name=Datadog%20HQ&name=Generated%20fix&https%3A%2F%2Fdd.datad0g.com%2Fapi%2Fv2%2Ferror-tracking%2Fissues%2Fe23261bc-0956-11ee-82e2-da7ad0900001%2Fide-actions%2Ffetch-ai-fix%3Ftrack%3Drum';
el.target= '_blank';
el.style.fontSize = '13px';
el.style.paddingRight = '10px';
el.style.paddingBottom = '10px';
el.style.marginRight = '8px';
// el.style.borderRight = '1px solid #e2e5ed';
const sibling = node.parentNode.parentNode.parentNode.previousSibling;
sibling.insertAdjacentElement('afterend', el)
console.log('Element added!');
/*
font-size: 13px;
padding-right: 10px;
border-right: 1px solid #e2e5ed;
margin-right: 8px;
*/
} catch (e) {
console.error(e);
console.log('Trying to add the element again');
addElement(time + 1000);
}
}, time);
}
addElement(5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment