diff --git a/CMakeLists.txt b/CMakeLists.txt index ddb79f5353..9ae99709be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,8 +225,13 @@ target_link_libraries(_CuraEngine asio-grpc::asio-grpc grpc::grpc protobuf::libprotobuf + $<$:sentry::sentry> $<$:GTest::gtest>) +target_compile_definitions(_CuraEngine PRIVATE + $<$:SENTRY_URL=\"${SENTRY_URL}\"> +) + if (NOT WIN32) add_executable(CuraEngine src/main.cpp) # Then compile main.cpp as separate executable, and link the library to it. else () diff --git a/src/Slice.cpp b/src/Slice.cpp index eb92ae1d68..8b9defa7ad 100644 --- a/src/Slice.cpp +++ b/src/Slice.cpp @@ -1,9 +1,12 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2023 UltiMaker // CuraEngine is released under the terms of the AGPLv3 or higher #include "Slice.h" #include +#ifdef SENTRY_URL +#include +#endif #include "ExtruderTrain.h" @@ -18,6 +21,12 @@ Slice::Slice(const size_t num_mesh_groups) void Slice::compute() { spdlog::info("All settings: {}", scene.getAllSettingsString()); +#ifdef SENTRY_URL + { + sentry_set_tag("cura.machine_name", scene.settings.get("machine_name").c_str()); + } +#endif + for (std::vector::iterator mesh_group = scene.mesh_groups.begin(); mesh_group != scene.mesh_groups.end(); mesh_group++) { scene.current_mesh_group = mesh_group; diff --git a/src/communication/ArcusCommunication.cpp b/src/communication/ArcusCommunication.cpp index f715e3cfe7..73ec403cfc 100644 --- a/src/communication/ArcusCommunication.cpp +++ b/src/communication/ArcusCommunication.cpp @@ -11,6 +11,9 @@ #include //The socket to communicate to. #include #include +#ifdef SENTRY_URL +#include +#endif #include "Application.h" //To get and set the current slice command. #include "ExtruderTrain.h" @@ -521,6 +524,11 @@ void ArcusCommunication::sliceNext() #ifdef ENABLE_PLUGINS for (const auto& plugin : slice_message->engine_plugins()) { +#ifdef SENTRY_URL + { + sentry_set_tag(fmt::format("plugin.{}", plugin.plugin_name()).c_str(), plugin.plugin_version().c_str()); + } +#endif const auto slot_id = static_cast(plugin.id()); slots::instance().connect(slot_id, plugin.plugin_name(), plugin.plugin_version(), utils::createChannel({ plugin.address(), plugin.port() })); } diff --git a/src/main.cpp b/src/main.cpp index 1965a329cb..b372ee39a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,23 +84,21 @@ int main(int argc, char** argv) { // Not a production build sentry_options_set_environment(options, "development"); - sentry_options_set_release( - options, - fmt::format( - "curaengine@{}.{}.{}-{}.{}", - version.major, - version.minor, - version.patch, - version.prerelease_type == semver::prerelease::alpha ? "alpha" : "beta", - version.prerelease_number) - .c_str()); } else { sentry_options_set_environment(options, "production"); - sentry_options_set_release(options, fmt::format("curaengine@{}", version.to_string()).c_str()); } + + // Set the actual CuraEngine version + sentry_options_set_release(options, fmt::format("curaengine@{}", cura_engine_version).c_str()); sentry_init(options); + + // Set the presumed Cura version as a Sentry tag (this is unknown at the time of compiling + auto prerelease = version.prerelease_type == semver::prerelease::none + ? "" + : fmt::format("-{}.{}", version.prerelease_type == semver::prerelease::alpha ? "alpha" : "beta", version.prerelease_number); + sentry_set_tag("cura.version", fmt::format("{}.{}.{}{}", version.major, version.minor, version.patch, prerelease).c_str()); } #endif