2019-04-11 16:03:05 -07:00
|
|
|
/*
|
|
|
|
* IXSentryClient.h
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-06-06 13:48:53 -07:00
|
|
|
#include <algorithm>
|
2019-05-30 08:46:50 -07:00
|
|
|
#include <ixwebsocket/IXHttpClient.h>
|
2019-04-11 16:03:05 -07:00
|
|
|
#include <jsoncpp/json/json.h>
|
|
|
|
#include <regex>
|
|
|
|
|
|
|
|
namespace ix
|
|
|
|
{
|
|
|
|
class SentryClient
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SentryClient(const std::string& dsn);
|
|
|
|
~SentryClient() = default;
|
|
|
|
|
2019-06-05 18:47:48 -07:00
|
|
|
std::pair<HttpResponsePtr, std::string> send(const Json::Value& msg, bool verbose);
|
2019-04-11 16:03:05 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
int64_t getTimestamp();
|
|
|
|
std::string computeAuthHeader();
|
|
|
|
std::string getIso8601();
|
|
|
|
std::string computePayload(const Json::Value& msg);
|
|
|
|
|
|
|
|
Json::Value parseLuaStackTrace(const std::string& stack);
|
|
|
|
|
|
|
|
std::string _dsn;
|
|
|
|
bool _validDsn;
|
|
|
|
std::string _url;
|
|
|
|
|
|
|
|
// Used for authentication with a header
|
|
|
|
std::string _publicKey;
|
|
|
|
std::string _secretKey;
|
|
|
|
|
|
|
|
Json::FastWriter _jsonWriter;
|
|
|
|
|
|
|
|
std::regex _luaFrameRegex;
|
|
|
|
|
|
|
|
HttpClient _httpClient;
|
|
|
|
};
|
2019-04-17 20:31:34 -07:00
|
|
|
|
2019-04-11 16:03:05 -07:00
|
|
|
} // namespace ix
|