@@ -6,14 +6,18 @@ use std::sync::{Arc, RwLock};
66use std:: time:: Duration ;
77
88use rand:: random;
9+ #[ cfg( feature = "release-health" ) ]
910use sentry_types:: protocol:: v7:: SessionUpdate ;
1011use sentry_types:: random_uuid;
1112
1213use crate :: constants:: SDK_INFO ;
1314use crate :: protocol:: { ClientSdkInfo , Event } ;
15+ #[ cfg( feature = "release-health" ) ]
1416use crate :: session:: SessionFlusher ;
1517use crate :: types:: { Dsn , Uuid } ;
16- use crate :: { ClientOptions , Envelope , Hub , Integration , Scope , SessionMode , Transport } ;
18+ #[ cfg( feature = "release-health" ) ]
19+ use crate :: SessionMode ;
20+ use crate :: { ClientOptions , Envelope , Hub , Integration , Scope , Transport } ;
1721
1822impl < T : Into < ClientOptions > > From < T > for Client {
1923 fn from ( o : T ) -> Client {
@@ -43,6 +47,7 @@ pub(crate) type TransportArc = Arc<RwLock<Option<Arc<dyn Transport>>>>;
4347pub struct Client {
4448 options : ClientOptions ,
4549 transport : TransportArc ,
50+ #[ cfg( feature = "release-health" ) ]
4651 session_flusher : RwLock < Option < SessionFlusher > > ,
4752 integrations : Vec < ( TypeId , Arc < dyn Integration > ) > ,
4853 pub ( crate ) sdk_info : ClientSdkInfo ,
@@ -60,13 +65,17 @@ impl fmt::Debug for Client {
6065impl Clone for Client {
6166 fn clone ( & self ) -> Client {
6267 let transport = Arc :: new ( RwLock :: new ( self . transport . read ( ) . unwrap ( ) . clone ( ) ) ) ;
68+
69+ #[ cfg( feature = "release-health" ) ]
6370 let session_flusher = RwLock :: new ( Some ( SessionFlusher :: new (
6471 transport. clone ( ) ,
6572 self . options . session_mode ,
6673 ) ) ) ;
74+
6775 Client {
6876 options : self . options . clone ( ) ,
6977 transport,
78+ #[ cfg( feature = "release-health" ) ]
7079 session_flusher,
7180 integrations : self . integrations . clone ( ) ,
7281 sdk_info : self . sdk_info . clone ( ) ,
@@ -131,6 +140,7 @@ impl Client {
131140 sdk_info. integrations . push ( integration. name ( ) . to_string ( ) ) ;
132141 }
133142
143+ #[ cfg( feature = "release-health" ) ]
134144 let session_flusher = RwLock :: new ( Some ( SessionFlusher :: new (
135145 transport. clone ( ) ,
136146 options. session_mode ,
@@ -139,6 +149,7 @@ impl Client {
139149 Client {
140150 options,
141151 transport,
152+ #[ cfg( feature = "release-health" ) ]
142153 session_flusher,
143154 integrations,
144155 sdk_info,
@@ -266,6 +277,7 @@ impl Client {
266277 let mut envelope: Envelope = event. into ( ) ;
267278 // For request-mode sessions, we aggregate them all instead of
268279 // flushing them out early.
280+ #[ cfg( feature = "release-health" ) ]
269281 if self . options . session_mode == SessionMode :: Application {
270282 let session_item = scope. and_then ( |scope| {
271283 scope
@@ -300,6 +312,7 @@ impl Client {
300312 }
301313 }
302314
315+ #[ cfg( feature = "release-health" ) ]
303316 pub ( crate ) fn enqueue_session ( & self , session_update : SessionUpdate < ' static > ) {
304317 if let Some ( ref flusher) = * self . session_flusher . read ( ) . unwrap ( ) {
305318 flusher. enqueue ( session_update) ;
@@ -308,6 +321,7 @@ impl Client {
308321
309322 /// Drains all pending events without shutting down.
310323 pub fn flush ( & self , timeout : Option < Duration > ) -> bool {
324+ #[ cfg( feature = "release-health" ) ]
311325 if let Some ( ref flusher) = * self . session_flusher . read ( ) . unwrap ( ) {
312326 flusher. flush ( ) ;
313327 }
@@ -326,6 +340,7 @@ impl Client {
326340 /// If no timeout is provided the client will wait for as long a
327341 /// `shutdown_timeout` in the client options.
328342 pub fn close ( & self , timeout : Option < Duration > ) -> bool {
343+ #[ cfg( feature = "release-health" ) ]
329344 drop ( self . session_flusher . write ( ) . unwrap ( ) . take ( ) ) ;
330345 let transport_opt = self . transport . write ( ) . unwrap ( ) . take ( ) ;
331346 if let Some ( transport) = transport_opt {
0 commit comments