From e7e135a165c492237e8f5d1f7609859d08c8dfe6 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Wed, 20 Mar 2024 09:35:22 +0200 Subject: [PATCH 1/5] Add user feedback support for desktop --- .../Desktop/SentrySubsystemDesktop.cpp | 4 +- .../Desktop/SentryUserFeedbackDesktop.cpp | 65 +++++++++++++++++++ .../Desktop/SentryUserFeedbackDesktop.h | 33 ++++++++++ .../Sentry/Private/SentryUserFeedback.cpp | 4 ++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp create mode 100644 plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h diff --git a/plugin-dev/Source/Sentry/Private/Desktop/SentrySubsystemDesktop.cpp b/plugin-dev/Source/Sentry/Private/Desktop/SentrySubsystemDesktop.cpp index dd700e13..95c5a148 100644 --- a/plugin-dev/Source/Sentry/Private/Desktop/SentrySubsystemDesktop.cpp +++ b/plugin-dev/Source/Sentry/Private/Desktop/SentrySubsystemDesktop.cpp @@ -19,6 +19,7 @@ #include "SentryBeforeSendHandler.h" #include "SentryTraceSampler.h" #include "SentryTransactionContext.h" +#include "SentryUserFeedbackDesktop.h" #include "Infrastructure/SentryConvertorsDesktop.h" @@ -283,7 +284,8 @@ USentryId* SentrySubsystemDesktop::CaptureEventWithScope(USentryEvent* event, co void SentrySubsystemDesktop::CaptureUserFeedback(USentryUserFeedback* userFeedback) { - UE_LOG(LogSentrySdk, Log, TEXT("CaptureUserFeedback method is not supported for the current platform.")); + TSharedPtr userFeedbackDesktop = StaticCastSharedPtr(userFeedback->GetNativeImpl()); + sentry_capture_user_feedback(userFeedbackDesktop->GetNativeObject()); } void SentrySubsystemDesktop::SetUser(USentryUser* user) diff --git a/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp b/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp new file mode 100644 index 00000000..df88b05c --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp @@ -0,0 +1,65 @@ +// Copyright (c) 2022 Sentry. All Rights Reserved. + +#include "SentryUserFeedbackDesktop.h" + +#include "SentryId.h" + +#include "Infrastructure/SentryConvertorsDesktop.h" + +#if USE_SENTRY_NATIVE + +SentryUserFeedbackDesktop::SentryUserFeedbackDesktop() +{ + UserFeedbackDesktop = sentry_value_new_object(); +} + +SentryUserFeedbackDesktop::SentryUserFeedbackDesktop(USentryId* eventId) +{ + UserFeedbackDesktop = sentry_value_new_object(); + sentry_value_set_by_key(UserFeedbackDesktop, "event_id", sentry_value_new_string(TCHAR_TO_ANSI(*eventId->ToString()))); +} + +SentryUserFeedbackDesktop::~SentryUserFeedbackDesktop() +{ + // Put custom destructor logic here if needed +} + +sentry_value_t SentryUserFeedbackDesktop::GetNativeObject() +{ + return UserFeedbackDesktop; +} + +void SentryUserFeedbackDesktop::SetName(const FString& name) +{ + sentry_value_set_by_key(UserFeedbackDesktop, "name", sentry_value_new_string(TCHAR_TO_ANSI(*name))); +} + +FString SentryUserFeedbackDesktop::GetName() const +{ + sentry_value_t username = sentry_value_get_by_key(UserFeedbackDesktop, "name"); + return FString(sentry_value_as_string(username)); +} + +void SentryUserFeedbackDesktop::SetEmail(const FString& email) +{ + sentry_value_set_by_key(UserFeedbackDesktop, "email", sentry_value_new_string(TCHAR_TO_ANSI(*email))); +} + +FString SentryUserFeedbackDesktop::GetEmail() const +{ + sentry_value_t email = sentry_value_get_by_key(UserFeedbackDesktop, "email"); + return FString(sentry_value_as_string(email)); +} + +void SentryUserFeedbackDesktop::SetComment(const FString& comment) +{ + sentry_value_set_by_key(UserFeedbackDesktop, "comments", sentry_value_new_string(TCHAR_TO_ANSI(*comment))); +} + +FString SentryUserFeedbackDesktop::GetComment() const +{ + sentry_value_t comment = sentry_value_get_by_key(UserFeedbackDesktop, "comments"); + return FString(sentry_value_as_string(comment)); +} + +#endif \ No newline at end of file diff --git a/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h b/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h new file mode 100644 index 00000000..a76bc750 --- /dev/null +++ b/plugin-dev/Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h @@ -0,0 +1,33 @@ +// Copyright (c) 2022 Sentry. All Rights Reserved. + +#pragma once + +#include "Convenience/SentryInclude.h" + +#include "Interface/SentryUserFeedbackInterface.h" + +#if USE_SENTRY_NATIVE + +class USentryId; + +class SentryUserFeedbackDesktop : public ISentryUserFeedback +{ +public: + SentryUserFeedbackDesktop(); + SentryUserFeedbackDesktop(USentryId* eventId); + virtual ~SentryUserFeedbackDesktop() override; + + sentry_value_t GetNativeObject(); + + virtual void SetName(const FString& name) override; + virtual FString GetName() const override; + virtual void SetEmail(const FString& email) override; + virtual FString GetEmail() const override; + virtual void SetComment(const FString& comment) override; + virtual FString GetComment() const override; + +private: + sentry_value_t UserFeedbackDesktop; +}; + +#endif diff --git a/plugin-dev/Source/Sentry/Private/SentryUserFeedback.cpp b/plugin-dev/Source/Sentry/Private/SentryUserFeedback.cpp index f0dc0ea2..e6db9d35 100644 --- a/plugin-dev/Source/Sentry/Private/SentryUserFeedback.cpp +++ b/plugin-dev/Source/Sentry/Private/SentryUserFeedback.cpp @@ -9,6 +9,8 @@ #include "Android/SentryUserFeedbackAndroid.h" #elif PLATFORM_IOS || PLATFORM_MAC #include "Apple/SentryUserFeedbackApple.h" +#elif PLATFORM_WINDOWS || PLATFORM_LINUX +#include "Desktop/SentryUserFeedbackDesktop.h" #endif void USentryUserFeedback::Initialize(USentryId* EventId) @@ -17,6 +19,8 @@ void USentryUserFeedback::Initialize(USentryId* EventId) UserFeedbackNativeImpl = MakeShareable(new SentryUserFeedbackAndroid(EventId)); #elif PLATFORM_IOS || PLATFORM_MAC UserFeedbackNativeImpl = MakeShareable(new SentryUserFeedbackApple(EventId)); +#elif PLATFORM_WINDOWS || PLATFORM_LINUX + UserFeedbackNativeImpl = MakeShareable(new SentryUserFeedbackDesktop(EventId)); #endif } From fe265fa463e8454e41f1168b9080b6cb60a2e1b8 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Wed, 20 Mar 2024 09:35:42 +0200 Subject: [PATCH 2/5] Update script for local deps build --- scripts/build-deps.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/build-deps.ps1 b/scripts/build-deps.ps1 index 434f803d..d5928aa8 100644 --- a/scripts/build-deps.ps1 +++ b/scripts/build-deps.ps1 @@ -17,7 +17,7 @@ $modulesDir = Resolve-Path "$PSScriptRoot/../modules" $outDir = Resolve-Path "$PSScriptRoot/../plugin-dev/Source/ThirdParty" $macPlatfromDeps = @("mac", "ios", "android") -$winPlatfromDeps = @("win", "android") +$winPlatfromDeps = @("win") function buildSentryCocoaIos() { @@ -106,12 +106,14 @@ function buildSentryNative() { Push-Location -Path "$modulesDir/sentry-native" - cmake -B "build" -D SENTRY_BACKEND=breakpad -D SENTRY_SDK_NAME=sentry.native.unreal + cmake -B "build" -D SENTRY_BACKEND=crashpad -D SENTRY_SDK_NAME=sentry.native.unreal -D SENTRY_BUILD_SHARED_LIBS=OFF cmake --build "build" --target sentry --config RelWithDebInfo --parallel + cmake --build "build" --target crashpad_handler --config RelWithDebInfo --parallel + cmake --install "build" --prefix "install" --config RelWithDebInfo Pop-Location - $nativeOutDir = "$outDir/Win64" + $nativeOutDir = "$outDir/Win64/Crashpad" $nativeOutDirLibs = "$nativeOutDir/lib" $nativeOutDirBinaries = "$nativeOutDir/bin" $nativeOutDirIncludes = "$nativeOutDir/include" @@ -126,11 +128,9 @@ function buildSentryNative() New-Item $nativeOutDirBinaries -ItemType Directory > $null New-Item $nativeOutDirIncludes -ItemType Directory > $null - Copy-Item "$modulesDir/sentry-native/build/RelWithDebInfo/sentry.lib" -Destination "$nativeOutDirLibs/sentry.lib" - Copy-Item "$modulesDir/sentry-native/build/RelWithDebInfo/sentry.dll" -Destination "$nativeOutDirBinaries/sentry.dll" - Copy-Item "$modulesDir/sentry-native/build/RelWithDebInfo/sentry.pdb" -Destination "$nativeOutDirBinaries/sentry.pdb" - Copy-Item "$modulesDir/sentry-native/build/external/RelWithDebInfo/breakpad_client.lib" -Destination "$nativeOutDirLibs/breakpad_client.lib" - Copy-Item "$modulesDir/sentry-native/include/sentry.h" -Destination "$nativeOutDirIncludes/sentry.h" + Get-ChildItem -Path "$modulesDir/sentry-native/install/lib" -Filter "*.lib" -Recurse | Copy-Item -Destination $nativeOutDirLibs + Copy-Item "$modulesDir/sentry-native/install/bin/crashpad_handler.exe" -Destination $nativeOutDirBinaries + Copy-Item "$modulesDir/sentry-native/install/include/sentry.h" -Destination $nativeOutDirIncludes } function buildPlatformDependency([string] $platform) From c555f63b6ff7b7818fe558c0af63198aef77b6a4 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 25 Mar 2024 09:40:23 +0200 Subject: [PATCH 3/5] Update package snapshot --- scripts/packaging/package-github.snapshot | 2 ++ scripts/packaging/package-marketplace.snapshot | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/packaging/package-github.snapshot b/scripts/packaging/package-github.snapshot index 9f70c92c..3ed1cea7 100644 --- a/scripts/packaging/package-github.snapshot +++ b/scripts/packaging/package-github.snapshot @@ -118,6 +118,8 @@ Source/Sentry/Private/Desktop/SentryTransactionDesktop.cpp Source/Sentry/Private/Desktop/SentryTransactionDesktop.h Source/Sentry/Private/Desktop/SentryUserDesktop.cpp Source/Sentry/Private/Desktop/SentryUserDesktop.h +Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp +Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h Source/Sentry/Private/Desktop/Transport/ Source/Sentry/Private/Desktop/Transport/SentryDsnUrl.cpp Source/Sentry/Private/Desktop/Transport/SentryDsnUrl.h diff --git a/scripts/packaging/package-marketplace.snapshot b/scripts/packaging/package-marketplace.snapshot index 4742d3d4..b2e22860 100644 --- a/scripts/packaging/package-marketplace.snapshot +++ b/scripts/packaging/package-marketplace.snapshot @@ -116,6 +116,8 @@ Source/Sentry/Private/Desktop/SentryTransactionDesktop.cpp Source/Sentry/Private/Desktop/SentryTransactionDesktop.h Source/Sentry/Private/Desktop/SentryUserDesktop.cpp Source/Sentry/Private/Desktop/SentryUserDesktop.h +Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.cpp +Source/Sentry/Private/Desktop/SentryUserFeedbackDesktop.h Source/Sentry/Private/Desktop/Transport/ Source/Sentry/Private/Desktop/Transport/SentryDsnUrl.cpp Source/Sentry/Private/Desktop/Transport/SentryDsnUrl.h From 0e39a30567a53d2e3e1097e7a6231e68781fdf8f Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 25 Mar 2024 09:52:32 +0200 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd7a7ad..a4cacc28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add user feedback capturing support for desktop ([#521](https://github.com/getsentry/sentry-unreal/pull/521)) + ### Dependencies - Bump CLI from v2.29.1 to v2.30.2 ([#512](https://github.com/getsentry/sentry-unreal/pull/512), [#515](https://github.com/getsentry/sentry-unreal/pull/515), [#517](https://github.com/getsentry/sentry-unreal/pull/517)) From f7b8ad504a53cfa7d9bbdba795cd5c001ef644b3 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 25 Mar 2024 10:32:58 +0200 Subject: [PATCH 5/5] Restore Android deps build --- scripts/build-deps.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-deps.ps1 b/scripts/build-deps.ps1 index d5928aa8..95b26247 100644 --- a/scripts/build-deps.ps1 +++ b/scripts/build-deps.ps1 @@ -17,7 +17,7 @@ $modulesDir = Resolve-Path "$PSScriptRoot/../modules" $outDir = Resolve-Path "$PSScriptRoot/../plugin-dev/Source/ThirdParty" $macPlatfromDeps = @("mac", "ios", "android") -$winPlatfromDeps = @("win") +$winPlatfromDeps = @("win", "android") function buildSentryCocoaIos() {