diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1c28be85..ae7c440f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [9.2.7] - 2020-04-14 + +(ixsentry) add a library method to upload a payload directly to sentry + ## [9.2.6] - 2020-04-14 (ixcobra) snake server / handle invalid incoming json messages + cobra subscriber in fluentd mode insert a created_at timestamp entry diff --git a/ixsentry/ixsentry/IXSentryClient.cpp b/ixsentry/ixsentry/IXSentryClient.cpp index 81d82ae9..a88c0a7b 100644 --- a/ixsentry/ixsentry/IXSentryClient.cpp +++ b/ixsentry/ixsentry/IXSentryClient.cpp @@ -64,7 +64,8 @@ namespace ix std::string SentryClient::computeAuthHeader() { std::string securityHeader("Sentry sentry_version=5"); - securityHeader += ",sentry_client=ws/1.0.0"; + securityHeader += ",sentry_client=ws/"; + securityHeader += std::string(IX_WEBSOCKET_VERSION); securityHeader += ",sentry_timestamp=" + std::to_string(SentryClient::getTimestamp()); securityHeader += ",sentry_key=" + _publicKey; securityHeader += ",sentry_secret=" + _secretKey; @@ -286,4 +287,26 @@ namespace ix _httpClient->performRequest(args, onResponseCallback); } + + void SentryClient::uploadPayload( + const Json::Value& payload, + const std::string& project, + const std::string& key, + bool verbose, + const OnResponseCallback& onResponseCallback) + { + auto args = _httpClient->createRequest(); + args->extraHeaders["X-Sentry-Auth"] = SentryClient::computeAuthHeader(); + args->verb = HttpClient::kPost; + args->connectTimeout = 60; + args->transferTimeout = 5 * 60; + args->followRedirects = true; + args->verbose = verbose; + args->logger = [](const std::string& msg) { ix::IXCoreLogger::Log(msg.c_str()); }; + + args->url = _url; + args->body = _jsonWriter.write(payload); + + _httpClient->performRequest(args, onResponseCallback); + } } // namespace ix diff --git a/ixsentry/ixsentry/IXSentryClient.h b/ixsentry/ixsentry/IXSentryClient.h index 7fcd62fb..62877d6a 100644 --- a/ixsentry/ixsentry/IXSentryClient.h +++ b/ixsentry/ixsentry/IXSentryClient.h @@ -36,6 +36,13 @@ namespace ix bool verbose, const OnResponseCallback& onResponseCallback); + void uploadPayload( + const Json::Value& payload, + const std::string& project, + const std::string& key, + bool verbose, + const OnResponseCallback& onResponseCallback); + private: int64_t getTimestamp(); std::string computeAuthHeader(); diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 503fc49e..cf0e9500 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "9.2.6" +#define IX_WEBSOCKET_VERSION "9.2.7"