diff --git a/.gitignore b/.gitignore index f121c7d22..7e72ac0c9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ __pycache__ # Devtools CodeChecker +.ccls-cache # Coverage coverage diff --git a/include/sentry.h b/include/sentry.h index 6bbaf3549..2440da129 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1774,6 +1774,21 @@ SENTRY_EXPERIMENTAL_API int sentry_get_crashed_last_run(); */ SENTRY_EXPERIMENTAL_API int sentry_clear_crashed_last_run(); +/** + * Sentry SDK version. + */ +SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version(); + +/** + * Sentry SDK name. + */ +SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name(); + +/** + * Sentry SDK User-Agent. + */ +SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent(); + #ifdef __cplusplus } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8175dc3d..1a7ba5949 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,7 @@ sentry_target_sources_cwd(sentry sentry_database.h sentry_envelope.c sentry_envelope.h + sentry_info.c sentry_json.c sentry_json.h sentry_logger.c diff --git a/src/sentry_info.c b/src/sentry_info.c new file mode 100644 index 000000000..b2918127b --- /dev/null +++ b/src/sentry_info.c @@ -0,0 +1,19 @@ +#include "sentry_boot.h" + +const char * +sentry_sdk_version() +{ + return SENTRY_SDK_VERSION; +} + +const char * +sentry_sdk_name() +{ + return SENTRY_SDK_NAME; +} + +const char * +sentry_sdk_user_agent() +{ + return SENTRY_SDK_USER_AGENT; +} diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index db18b0f95..7c9dc6d17 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -24,6 +24,7 @@ add_executable(sentry_test_unit test_envelopes.c test_failures.c test_fuzzfailures.c + test_info.c test_logger.c test_modulefinder.c test_mpack.c diff --git a/tests/unit/test_info.c b/tests/unit/test_info.c new file mode 100644 index 000000000..c3c889b76 --- /dev/null +++ b/tests/unit/test_info.c @@ -0,0 +1,16 @@ +#include "sentry_testsupport.h" + +SENTRY_TEST(assert_sdk_version) +{ + TEST_CHECK_STRING_EQUAL(sentry_sdk_version(), SENTRY_SDK_VERSION); +} + +SENTRY_TEST(assert_sdk_name) +{ + TEST_CHECK_STRING_EQUAL(sentry_sdk_name(), SENTRY_SDK_NAME); +} + +SENTRY_TEST(assert_sdk_user_agent) +{ + TEST_CHECK_STRING_EQUAL(sentry_sdk_user_agent(), SENTRY_SDK_USER_AGENT); +} diff --git a/tests/unit/tests.inc b/tests/unit/tests.inc index 5b46780ea..f46f330b4 100644 --- a/tests/unit/tests.inc +++ b/tests/unit/tests.inc @@ -1,3 +1,6 @@ +XX(assert_sdk_name) +XX(assert_sdk_user_agent) +XX(assert_sdk_version) XX(background_worker) XX(basic_consent_tracking) XX(basic_function_transport) @@ -15,15 +18,15 @@ XX(child_spans) XX(concurrent_init) XX(concurrent_uninit) XX(count_sampled_events) -XX(crash_marker) XX(crashed_last_run) +XX(crash_marker) XX(custom_logger) XX(distributed_headers) XX(drop_unfinished_spans) XX(dsn_parsing_complete) XX(dsn_parsing_invalid) -XX(dsn_store_url_with_path) XX(dsn_store_url_without_path) +XX(dsn_store_url_with_path) XX(empty_transport) XX(fuzz_json) XX(init_failure) @@ -86,7 +89,7 @@ XX(value_null) XX(value_object) XX(value_object_merge) XX(value_object_merge_nested) +XX(value_set_stacktrace) XX(value_string) XX(value_unicode) XX(value_wrong_type) -XX(value_set_stacktrace)