Skip to content

Commit 144fa58

Browse files
committed
feat: Added transaction support
1 parent 19a4f40 commit 144fa58

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ failure = { version = "0.1", optional = true }
3535
log = { version = "0.4", optional = true }
3636
serde = "1.0"
3737
serde_json = "1.0"
38-
sentry-types = "0.3.0"
38+
sentry-types = "0.3.1"
3939
reqwest = { version = "0.8.5", optional = true }
4040
uuid = { version = "0.6.2", features = ["v4"] }
4141
lazy_static = "1.0.0"

src/client/real.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ impl Client {
278278
);
279279
}
280280

281+
if event.transaction.is_none() {
282+
if let Some(ref txn) = scope.transaction {
283+
event.transaction = Some((**txn).clone());
284+
}
285+
}
286+
281287
if event.fingerprint.len() == 1
282288
&& (event.fingerprint[0] == "{{ default }}"
283289
|| event.fingerprint[0] == "{{default}}")

src/scope/noop.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ impl Scope {
7272
shim_unreachable!();
7373
}
7474

75+
pub fn set_transaction(&mut self, transaction: Option<&str>) {
76+
let _transaction = transaction;
77+
shim_unreachable!();
78+
}
79+
7580
pub fn set_user(&mut self, user: Option<User>) {
7681
let _user = user;
7782
shim_unreachable!();

src/scope/real.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub(crate) fn scope_panic_safe() -> bool {
5656
#[derive(Debug, Clone)]
5757
pub struct Scope {
5858
pub(crate) fingerprint: Option<Arc<Vec<Cow<'static, str>>>>,
59+
pub(crate) transaction: Option<Arc<String>>,
5960
pub(crate) breadcrumbs: im::Vector<Breadcrumb>,
6061
pub(crate) user: Option<Arc<User>>,
6162
pub(crate) extra: im::HashMap<String, Value>,
@@ -66,6 +67,7 @@ pub struct Scope {
6667
fn default_scope() -> Scope {
6768
Scope {
6869
fingerprint: None,
70+
transaction: None,
6971
breadcrumbs: Default::default(),
7072
user: None,
7173
extra: Default::default(),
@@ -322,6 +324,11 @@ impl Scope {
322324
fingerprint.map(|fp| Arc::new(fp.iter().map(|x| Cow::Owned(x.to_string())).collect()))
323325
}
324326

327+
/// Sets the transaction.
328+
pub fn set_transaction(&mut self, transaction: Option<&str>) {
329+
self.transaction = transaction.map(|txn| Arc::new(txn.to_string()));
330+
}
331+
325332
/// Sets the user for the current scope.
326333
pub fn set_user(&mut self, user: Option<User>) {
327334
self.user = user.map(Arc::new);

0 commit comments

Comments
 (0)