Created
September 17, 2021 20:38
-
-
Save jeznag/b4a7a5ed3479269d4976d5667d0bb819 to your computer and use it in GitHub Desktop.
log deluge errors to sentry
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
try | |
{ | |
if(error_message == null || error_message == "" || error_message.toString().length() < 5) | |
{ | |
return; | |
} | |
// Put your DSN here | |
dsn = "https://****@sentry.delugeonaluge.com/2"; | |
processed_dsn = dsn.replaceAll("https://","").replaceAll("@",""); | |
// Replace with the base URL (e.g. sentry.io/ ) | |
dsn_parts = processed_dsn.toList("sentry.delugeonaluge.com/"); | |
sentry_key = dsn_parts.get(0); | |
project_id = dsn_parts.get(1); | |
headers = Map(); | |
headers.put("Content-Type","application/json"); | |
headers.put("X-Sentry-Auth"," Sentry sentry_version=7, sentry_key=" + sentry_key + ", sentry_client=deluge/0.1"); | |
url = "https://sentry.delugeonaluge.com/api/" + project_id + "/store/"; | |
full_error_message = twiliosmsextension0.current_version() + ": " + if(error_message.length() < 1000,error_message,error_message.substring(0,1000)); | |
short_error_message = if(full_error_message.length() < 50,full_error_message,full_error_message.substring(0,50)); | |
payload = {"message":short_error_message,"user":{"email":zoho.adminuserid},"level":"error","extra":{"version":twiliosmsextension0.current_version(),"full_error_message":full_error_message}}; | |
payload_str = payload.toString(); | |
resp = invokeurl | |
[ | |
url :url | |
type :POST | |
parameters:payload_str | |
headers:headers | |
]; | |
} | |
catch (e) | |
{ info "Error logging sentry" + e + "message " + error_message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment