Skip to content

Commit 6ef6d97

Browse files
authored
ref: Apply user field from scope to transaction event (#596)
1 parent 3e687f1 commit 6ef6d97

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sentry-core/src/scope/real.rs

+6
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ impl Scope {
304304

305305
/// Applies the contained scoped data to fill a transaction.
306306
pub fn apply_to_transaction(&self, transaction: &mut Transaction<'static>) {
307+
if transaction.user.is_none() {
308+
if let Some(user) = self.user.as_deref() {
309+
transaction.user = Some(user.clone());
310+
}
311+
}
312+
307313
transaction
308314
.extra
309315
.extend(self.extra.iter().map(|(k, v)| (k.to_owned(), v.to_owned())));

sentry-types/src/protocol/v7.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,9 @@ pub struct Transaction<'a> {
19581958
/// An optional environment identifier.
19591959
#[serde(default, skip_serializing_if = "Option::is_none")]
19601960
pub environment: Option<Cow<'a, str>>,
1961+
/// Optionally user data to be sent along.
1962+
#[serde(default, skip_serializing_if = "Option::is_none")]
1963+
pub user: Option<User>,
19611964
/// Optional tags to be attached to the event.
19621965
#[serde(default, skip_serializing_if = "Map::is_empty")]
19631966
pub tags: Map<String, String>,
@@ -2002,6 +2005,7 @@ impl<'a> Default for Transaction<'a> {
20022005
Transaction {
20032006
event_id: event::default_id(),
20042007
name: Default::default(),
2008+
user: Default::default(),
20052009
tags: Default::default(),
20062010
extra: Default::default(),
20072011
release: Default::default(),
@@ -2028,6 +2032,7 @@ impl<'a> Transaction<'a> {
20282032
Transaction {
20292033
event_id: self.event_id,
20302034
name: self.name,
2035+
user: self.user,
20312036
tags: self.tags,
20322037
extra: self.extra,
20332038
release: self.release.map(|x| Cow::Owned(x.into_owned())),

0 commit comments

Comments
 (0)