Skip to content

Commit

Permalink
Use specified Sentry environment
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 25, 2024
1 parent cdb3222 commit ec4f9b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ target_link_libraries(_CuraEngine

target_compile_definitions(_CuraEngine PRIVATE
$<$<BOOL:${ENABLE_SENTRY}>:SENTRY_URL=\"${SENTRY_URL}\">
SENTRY_ENVIRONMENT=\"${SENTRY_ENVIRONMENT}\"
)

if (NOT WIN32)
Expand Down Expand Up @@ -301,6 +302,7 @@ target_link_libraries(CuraEngine PRIVATE
)
target_compile_definitions(CuraEngine PRIVATE
$<$<BOOL:${ENABLE_SENTRY}>:SENTRY_URL=\"${SENTRY_URL}\">
SENTRY_ENVIRONMENT=\"${SENTRY_ENVIRONMENT}\"
VERSION=\"${CURA_ENGINE_VERSION}\"
)

Expand Down
16 changes: 5 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,13 @@ int main(int argc, char** argv)
#endif
spdlog::info("Sentry config path: {}", config_path);
sentry_options_set_database_path(options, std::filesystem::absolute(config_path).generic_string().c_str());
constexpr std::string_view cura_engine_version{ CURA_ENGINE_VERSION };
const auto version = semver::from_string(cura_engine_version.substr(0, cura_engine_version.find_first_of('+')));
if (ranges::contains(cura_engine_version, '+') || version.prerelease_type == semver::prerelease::alpha)
{
// Not a production build
sentry_options_set_environment(options, "development");
}
else
{
sentry_options_set_environment(options, "production");
}

#ifdef SENTRY_ENVIRONMENT
sentry_options_set_environment(options, std::string(SENTRY_ENVIRONMENT).c_str());
#endif

// Set the actual CuraEngine version
constexpr std::string_view cura_engine_version{ CURA_ENGINE_VERSION };
sentry_options_set_release(options, fmt::format("curaengine@{}", cura_engine_version).c_str());
spdlog::info("Starting sentry");
sentry_init(options);
Expand Down

0 comments on commit ec4f9b9

Please sign in to comment.