@@ -501,11 +501,17 @@ static
501501/**
502502 * This function assumes that `value` is owned, so we have to make sure that the
503503 * `value` was created or cloned by the caller or even better inc_refed.
504+ *
505+ * Replaces attributes[name] if it already exists.
504506 */
505507static void
506508add_attribute (sentry_value_t attributes , sentry_value_t value , const char * type ,
507509 const char * name )
508510{
511+ if (!sentry_value_is_null (sentry_value_get_by_key (attributes , name ))) {
512+ // already exists, so we remove and create a new one
513+ sentry_value_remove_by_key (attributes , name );
514+ }
509515 sentry_value_t param_obj = sentry_value_new_object ();
510516 sentry_value_set_by_key (param_obj , "value" , value );
511517 sentry_value_set_by_key (param_obj , "type" , sentry_value_new_string (type ));
@@ -598,6 +604,10 @@ add_scope_and_options_data(sentry_value_t log, sentry_value_t attributes)
598604 }
599605 }
600606
607+ // fallback in case options doesn't set it
608+ add_attribute (attributes , sentry_value_new_string (SENTRY_SDK_NAME ),
609+ "string" , "sentry.sdk.name" );
610+
601611 SENTRY_WITH_OPTIONS (options ) {
602612 if (options -> environment ) {
603613 add_attribute (attributes ,
@@ -608,10 +618,11 @@ add_scope_and_options_data(sentry_value_t log, sentry_value_t attributes)
608618 add_attribute (attributes , sentry_value_new_string (options -> release ),
609619 "string" , "sentry.release" );
610620 }
621+ add_attribute (attributes ,
622+ sentry_value_new_string (sentry_options_get_sdk_name (options )),
623+ "string" , "sentry.sdk.name" );
611624 }
612625
613- add_attribute (attributes , sentry_value_new_string ("sentry.native" ),
614- "string" , "sentry.sdk.name" );
615626 add_attribute (attributes , sentry_value_new_string (sentry_sdk_version ()),
616627 "string" , "sentry.sdk.version" );
617628}
0 commit comments