Last active
December 24, 2021 06:36
-
-
Save shairyar/763752739e3b2c278352100bfd188a3d to your computer and use it in GitHub Desktop.
Sending error to AppSignal using the frontend API
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
# https://docs.appsignal.com/api/public-endpoint/errors.html#body-parameters | |
require "uri" | |
require "json" | |
require "net/http" | |
url = URI("https://appsignal-endpoint.net/errors?api_key=FRONTEND-API-KEY") | |
https = Net::HTTP.new(url.host, url.port) | |
https.use_ssl = true | |
request = Net::HTTP::Post.new(url) | |
request["Content-Type"] = "application/json" | |
request.body = JSON.dump({ | |
"action": "BlogpostController#show", | |
"namespace": "frontend", | |
"timestamp": 1640327525, | |
"error": { | |
"name": "StandardError", | |
"message": "Error message", | |
"backtrace": [ | |
"backtrace/line:1", | |
"backtrace/line:2" | |
] | |
}, | |
"environment": { | |
"os": "windows", | |
"agent": "super secret user agent" | |
}, | |
"params": { | |
"foo": "bar" | |
}, | |
"tags": { | |
"account_id": "abc-123" | |
}, | |
"revision": "revision-abc-123", | |
"breadcrumbs": [ | |
{ | |
"timestamp": 1640327525, | |
"category": "request", | |
"action": "http://google.com", | |
"message": "request failed", | |
"metadata": { | |
"code": "not_found" | |
} | |
} | |
], | |
"language": "javascript" | |
}) | |
response = https.request(request) | |
puts response.read_body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment