Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a825c49

Browse files
committedMar 12, 2025
feat: gate auto_session_tracking and session_mode behind feature
1 parent 610034d commit a825c49

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed
 

‎sentry-core/src/client.rs

+1
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ impl Client {
274274
let mut envelope: Envelope = event.into();
275275
// For request-mode sessions, we aggregate them all instead of
276276
// flushing them out early.
277+
#[cfg(feature = "release-health")]
277278
if self.options.session_mode == SessionMode::Application {
278279
let session_item = scope.and_then(|scope| {
279280
scope

‎sentry-core/src/clientoptions.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ pub struct ClientOptions {
171171
/// When automatic session tracking is enabled, a new "user-mode" session
172172
/// is started at the time of `sentry::init`, and will persist for the
173173
/// application lifetime.
174+
#[cfg(feature = "release-health")]
174175
pub auto_session_tracking: bool,
175176
/// Determine how Sessions are being tracked.
177+
#[cfg(feature = "release-health")]
176178
pub session_mode: SessionMode,
177179
/// Border frames which indicate a border from a backtrace to
178180
/// useless internals. Some are automatically included.
@@ -223,7 +225,8 @@ impl fmt::Debug for ClientOptions {
223225

224226
let integrations: Vec<_> = self.integrations.iter().map(|i| i.name()).collect();
225227

226-
f.debug_struct("ClientOptions")
228+
let mut debug_struct = f.debug_struct("ClientOptions");
229+
debug_struct
227230
.field("dsn", &self.dsn)
228231
.field("debug", &self.debug)
229232
.field("release", &self.release)
@@ -251,9 +254,14 @@ impl fmt::Debug for ClientOptions {
251254
.field("http_proxy", &self.http_proxy)
252255
.field("https_proxy", &self.https_proxy)
253256
.field("shutdown_timeout", &self.shutdown_timeout)
254-
.field("accept_invalid_certs", &self.accept_invalid_certs)
257+
.field("accept_invalid_certs", &self.accept_invalid_certs);
258+
259+
#[cfg(feature = "release-health")]
260+
debug_struct
255261
.field("auto_session_tracking", &self.auto_session_tracking)
256-
.field("session_mode", &self.session_mode)
262+
.field("session_mode", &self.session_mode);
263+
264+
debug_struct
257265
.field("extra_border_frames", &self.extra_border_frames)
258266
.field("trim_backtraces", &self.trim_backtraces)
259267
.field("user_agent", &self.user_agent)
@@ -286,7 +294,9 @@ impl Default for ClientOptions {
286294
https_proxy: None,
287295
shutdown_timeout: Duration::from_secs(2),
288296
accept_invalid_certs: false,
297+
#[cfg(feature = "release-health")]
289298
auto_session_tracking: false,
299+
#[cfg(feature = "release-health")]
290300
session_mode: SessionMode::Application,
291301
extra_border_frames: vec![],
292302
trim_backtraces: true,

‎sentry-core/src/session.rs

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ mod tests {
447447
},
448448
crate::ClientOptions {
449449
release: Some("some-release".into()),
450+
#[cfg(feature = "release-health")]
450451
session_mode: SessionMode::Request,
451452
..Default::default()
452453
},

‎sentry/src/init.rs

+4
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ where
9494
C: Into<ClientOptions>,
9595
{
9696
let opts = apply_defaults(opts.into());
97+
98+
#[cfg(feature = "release-health")]
9799
let auto_session_tracking = opts.auto_session_tracking;
100+
#[cfg(feature = "release-health")]
98101
let session_mode = opts.session_mode;
102+
99103
let client = Arc::new(Client::from(opts));
100104

101105
Hub::with(|hub| hub.bind_client(Some(client.clone())));

0 commit comments

Comments
 (0)
Please sign in to comment.