@@ -10,7 +10,7 @@ use rand::random;
1010use regex:: Regex ;
1111use uuid:: Uuid ;
1212
13- use api:: protocol:: { DebugMeta , Event , RepoReference } ;
13+ use api:: protocol:: { Breadcrumb , DebugMeta , Event , RepoReference } ;
1414use api:: Dsn ;
1515use backtrace_support:: { function_starts_with, is_sys_function, trim_stacktrace} ;
1616use constants:: { SDK_INFO , USER_AGENT } ;
@@ -36,8 +36,8 @@ impl fmt::Debug for Client {
3636 }
3737}
3838
39- /// Type alias for before send handlers
40- pub type BeforeSend = Box < Fn ( Event < ' static > ) -> Option < Event < ' static > > + Send + Sync > ;
39+ /// Type alias for before event/breadcrumb handlers.
40+ pub type BeforeCallback < T > = Arc < Box < Fn ( T ) -> Option < T > + Send + Sync > > ;
4141
4242/// Configuration settings for the client.
4343pub struct ClientOptions {
@@ -87,8 +87,10 @@ pub struct ClientOptions {
8787 pub attach_stacktrace : bool ,
8888 /// If turned on some default PII informat is attached.
8989 pub send_default_pii : bool ,
90- /// Before send method.
91- pub before_send : Option < Arc < BeforeSend > > ,
90+ /// Before send callback.
91+ pub before_send : Option < BeforeCallback < Event < ' static > > > ,
92+ /// Before breadcrumb add callback.
93+ pub before_breadcrumb : Option < BeforeCallback < Breadcrumb > > ,
9294}
9395
9496impl fmt:: Debug for ClientOptions {
@@ -97,6 +99,8 @@ impl fmt::Debug for ClientOptions {
9799 struct TransportFactory ;
98100 #[ derive( Debug ) ]
99101 struct BeforeSendSet ( bool ) ;
102+ #[ derive( Debug ) ]
103+ struct BeforeBreadcrumbSet ( bool ) ;
100104 f. debug_struct ( "ClientOptions" )
101105 . field ( "dsn" , & self . dsn )
102106 . field ( "transport" , & TransportFactory )
@@ -117,6 +121,10 @@ impl fmt::Debug for ClientOptions {
117121 . field ( "attach_stacktrace" , & self . attach_stacktrace )
118122 . field ( "send_default_pii" , & self . send_default_pii )
119123 . field ( "before_send" , & BeforeSendSet ( self . before_send . is_some ( ) ) )
124+ . field (
125+ "before_send" ,
126+ & BeforeBreadcrumbSet ( self . before_breadcrumb . is_some ( ) ) ,
127+ )
120128 . finish ( )
121129 }
122130}
@@ -143,6 +151,7 @@ impl Clone for ClientOptions {
143151 attach_stacktrace : self . attach_stacktrace ,
144152 send_default_pii : self . send_default_pii ,
145153 before_send : self . before_send . clone ( ) ,
154+ before_breadcrumb : self . before_breadcrumb . clone ( ) ,
146155 }
147156 }
148157}
@@ -180,6 +189,7 @@ impl Default for ClientOptions {
180189 attach_stacktrace : false ,
181190 send_default_pii : false ,
182191 before_send : None ,
192+ before_breadcrumb : None ,
183193 }
184194 }
185195}
0 commit comments