diff --git a/include/sentry.h b/include/sentry.h index 86ea2eb07..3675e5527 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1103,7 +1103,8 @@ SENTRY_API void sentry_user_consent_reset(void); SENTRY_API sentry_user_consent_t sentry_user_consent_get(void); /** - * Sends a sentry event. + * Sends a sentry event. Returns a nil UUID if the event being passed in is a + * transaction; `sentry_transaction_finish` should be used to send transactions. */ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); diff --git a/src/sentry_core.c b/src/sentry_core.c index 4c3180486..6eb2e8418 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -362,6 +362,16 @@ sentry__event_is_transaction(sentry_value_t event) sentry_uuid_t sentry_capture_event(sentry_value_t event) +{ + if (sentry__event_is_transaction(event)) { + return sentry_uuid_nil(); + } else { + return sentry__capture_event(event); + } +} + +sentry_uuid_t +sentry__capture_event(sentry_value_t event) { sentry_uuid_t event_id; sentry_envelope_t *envelope = NULL; @@ -369,7 +379,11 @@ sentry_capture_event(sentry_value_t event) bool was_captured = false; SENTRY_WITH_OPTIONS (options) { was_captured = true; - envelope = sentry__prepare_event(options, event, &event_id); + if (sentry__event_is_transaction(event)) { + return sentry_uuid_nil(); + } else { + envelope = sentry__prepare_event(options, event, &event_id); + } if (envelope) { if (options->session) { SENTRY_WITH_OPTIONS_MUT (mut_options) { diff --git a/src/sentry_core.h b/src/sentry_core.h index 0bcaff858..bec05ef5a 100644 --- a/src/sentry_core.h +++ b/src/sentry_core.h @@ -51,6 +51,11 @@ bool sentry__event_is_transaction(sentry_value_t event); sentry_envelope_t *sentry__prepare_event(const sentry_options_t *options, sentry_value_t event, sentry_uuid_t *event_id); +/** + * Sends a sentry event, regardless of its type. + */ +sentry_uuid_t sentry__capture_event(sentry_value_t event); + /** * This function will submit the `envelope` to the given `transport`, first * checking for consent.