-
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathGenericPlatformSentryFeedback.cpp
More file actions
126 lines (98 loc) · 3.76 KB
/
GenericPlatformSentryFeedback.cpp
File metadata and controls
126 lines (98 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright (c) 2025 Sentry. All Rights Reserved.
#include "GenericPlatformSentryFeedback.h"
#include "GenericPlatformSentryAttachment.h"
#include "Infrastructure/GenericPlatformSentryConverters.h"
#if USE_SENTRY_NATIVE
FGenericPlatformSentryFeedback::FGenericPlatformSentryFeedback()
: Hint(nullptr)
{
Feedback = sentry_value_new_object();
}
FGenericPlatformSentryFeedback::FGenericPlatformSentryFeedback(const FString& message)
: Hint(nullptr)
{
Feedback = sentry_value_new_object();
sentry_value_set_by_key(Feedback, "message", sentry_value_new_string(TCHAR_TO_UTF8(*message)));
}
FGenericPlatformSentryFeedback::~FGenericPlatformSentryFeedback()
{
// Put custom destructor logic here if needed
}
sentry_value_t FGenericPlatformSentryFeedback::GetNativeObject()
{
return Feedback;
}
FString FGenericPlatformSentryFeedback::GetMessage() const
{
sentry_value_t message = sentry_value_get_by_key(Feedback, "message");
return FString(UTF8_TO_TCHAR(sentry_value_as_string(message)));
}
void FGenericPlatformSentryFeedback::SetName(const FString& name)
{
sentry_value_set_by_key(Feedback, "name", sentry_value_new_string(TCHAR_TO_UTF8(*name)));
}
FString FGenericPlatformSentryFeedback::GetName() const
{
sentry_value_t username = sentry_value_get_by_key(Feedback, "name");
return FString(UTF8_TO_TCHAR(sentry_value_as_string(username)));
}
void FGenericPlatformSentryFeedback::SetContactEmail(const FString& email)
{
sentry_value_set_by_key(Feedback, "contact_email", sentry_value_new_string(TCHAR_TO_UTF8(*email)));
}
FString FGenericPlatformSentryFeedback::GetContactEmail() const
{
sentry_value_t email = sentry_value_get_by_key(Feedback, "contact_email");
return FString(UTF8_TO_TCHAR(sentry_value_as_string(email)));
}
void FGenericPlatformSentryFeedback::SetAssociatedEvent(const FString& eventId)
{
if (eventId.IsEmpty())
return;
sentry_value_set_by_key(Feedback, "associated_event_id", sentry_value_new_string(TCHAR_TO_UTF8(*eventId)));
}
FString FGenericPlatformSentryFeedback::GetAssociatedEvent() const
{
sentry_value_t comment = sentry_value_get_by_key(Feedback, "associated_event_id");
return FString(UTF8_TO_TCHAR(sentry_value_as_string(comment)));
}
void FGenericPlatformSentryFeedback::AddAttachment(TSharedPtr<ISentryAttachment> attachment)
{
if (!Hint)
{
Hint = sentry_hint_new();
}
TSharedPtr<FGenericPlatformSentryAttachment> platformAttachment = StaticCastSharedPtr<FGenericPlatformSentryAttachment>(attachment);
if (!platformAttachment->GetPath().IsEmpty())
{
AddFileAttachment(platformAttachment);
}
else
{
AddByteAttachment(platformAttachment);
}
}
sentry_hint_t* FGenericPlatformSentryFeedback::GetHintNativeObject()
{
return Hint;
}
void FGenericPlatformSentryFeedback::AddFileAttachment(TSharedPtr<FGenericPlatformSentryAttachment> attachment)
{
sentry_attachment_t* nativeAttachment =
sentry_hint_attach_file(Hint, TCHAR_TO_UTF8(*attachment->GetPath()));
if (!attachment->GetFilename().IsEmpty())
sentry_attachment_set_filename(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetFilename()));
if (!attachment->GetContentType().IsEmpty())
sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType()));
attachment->SetNativeObject(nativeAttachment);
}
void FGenericPlatformSentryFeedback::AddByteAttachment(TSharedPtr<FGenericPlatformSentryAttachment> attachment)
{
const TArray<uint8>& byteBuf = attachment->GetDataByRef();
sentry_attachment_t* nativeAttachment =
sentry_hint_attach_bytes(Hint, reinterpret_cast<const char*>(byteBuf.GetData()), byteBuf.Num(), TCHAR_TO_UTF8(*attachment->GetFilename()));
if (!attachment->GetContentType().IsEmpty())
sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*attachment->GetContentType()));
attachment->SetNativeObject(nativeAttachment);
}
#endif