Audacity 3.2.0
SentryReport.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file SentryReport.h
6 @brief Declare a class to report errors to Sentry.
7
8 Dmitry Vedenko
9 **********************************************************************/
10
11#pragma once
12
13#include <string>
14#include <utility>
15#include <vector>
16#include <memory>
17#include <functional>
18
19#include "AnonymizedMessage.h"
20
21namespace audacity
22{
23namespace sentry
24{
25
27using ExceptionData = std::pair<std::string, AnonymizedMessage>;
28
30struct SENTRY_REPORTING_API Exception final
31{
33 std::string Type;
37 std::vector<ExceptionData> Data;
38
40 static Exception Create(std::string type, AnonymizedMessage value);
42 static Exception Create(AnonymizedMessage value);
44 Exception& AddData(std::string key, AnonymizedMessage value);
45};
46
48struct SENTRY_REPORTING_API Message final
49{
53 std::vector<AnonymizedMessage> Params;
55 static Message Create(AnonymizedMessage message);
57 Message& AddParam(AnonymizedMessage value);
58};
59
61SENTRY_REPORTING_API void AddExceptionContext(
62 std::string parameterName, AnonymizedMessage parameterValue);
63
65class SENTRY_REPORTING_API Report final
66{
67public:
69 using CompletionHandler = std::function<void (int httpCode, std::string responseBody)>;
70
72 explicit Report(const Exception& exception);
73
75 explicit Report(const Message& message);
76
77 ~Report();
78
80 void AddUserComment(const std::string& comment);
81
83 std::string GetReportPreview() const;
84
86 void Send(CompletionHandler completionHandler) const;
87
88private:
89 class ReportImpl;
90
91 std::unique_ptr<ReportImpl> mImpl;
92};
93
94} // namespace sentry
95} // namespace audacity
Declare a class to store anonymized messages.
static const AudacityProject::AttachedObjects::RegisteredFactory key
A class, that stores anonymized message.
A report to Sentry.
Definition: SentryReport.h:66
std::unique_ptr< ReportImpl > mImpl
Definition: SentryReport.h:89
std::function< void(int httpCode, std::string responseBody)> CompletionHandler
A callback, that will be called when Send completes.
Definition: SentryReport.h:69
void AddExceptionContext(std::string parameterName, AnonymizedMessage parameterValue)
Saves a parameter, that will be appended to the next Exception report.
std::pair< std::string, AnonymizedMessage > ExceptionData
Additional payload to the exception.
Definition: SentryReport.h:27
A DTO for the Sentry Exception interface.
Definition: SentryReport.h:31
AnonymizedMessage Value
Message, associated with the Exception.
Definition: SentryReport.h:35
std::string Type
Exception type. Should not have spaces.
Definition: SentryReport.h:33
std::vector< ExceptionData > Data
Arbitrary payload.
Definition: SentryReport.h:37
A DTO for the Sentry Message interface.
Definition: SentryReport.h:49
AnonymizedMessage Value
A string, possibly with s placeholders, containing the message.
Definition: SentryReport.h:51
std::vector< AnonymizedMessage > Params
Values for the placeholders.
Definition: SentryReport.h:53