@@ -1226,6 +1226,58 @@ impl<'a> AuthenticatedApi<'a> {
12261226 Ok ( rv)
12271227 }
12281228
1229+ /// Fetch organization events from the specified dataset
1230+ pub fn fetch_organization_events (
1231+ & self ,
1232+ org : & str ,
1233+ dataset : & str ,
1234+ fields : & [ & str ] ,
1235+ project_id : Option < & str > ,
1236+ cursor : Option < & str > ,
1237+ query : Option < & str > ,
1238+ per_page : Option < usize > ,
1239+ stats_period : Option < & str > ,
1240+ sort : Option < & str > ,
1241+ ) -> ApiResult < Vec < LogEntry > > {
1242+ let mut params = vec ! [ format!( "dataset={}" , QueryArg ( dataset) ) ] ;
1243+
1244+ for field in fields {
1245+ params. push ( format ! ( "field={}" , QueryArg ( field) ) ) ;
1246+ }
1247+
1248+ if let Some ( cursor) = cursor {
1249+ params. push ( format ! ( "cursor={}" , QueryArg ( cursor) ) ) ;
1250+ }
1251+
1252+ if let Some ( project_id) = project_id {
1253+ params. push ( format ! ( "project={}" , QueryArg ( project_id) ) ) ;
1254+ }
1255+
1256+ if let Some ( query) = query {
1257+ params. push ( format ! ( "query={}" , QueryArg ( query) ) ) ;
1258+ }
1259+
1260+ params. push ( format ! ( "per_page={}" , per_page. unwrap_or( 100 ) ) ) ;
1261+ params. push ( format ! ( "statsPeriod={}" , stats_period. unwrap_or( "1h" ) ) ) ;
1262+ params. push ( "referrer=sentry-cli-tail" . to_string ( ) ) ;
1263+ params. push ( format ! ( "sort={}" , sort. unwrap_or( "-timestamp" ) ) ) ;
1264+
1265+ let url = format ! (
1266+ "/organizations/{}/events/?{}" ,
1267+ PathArg ( org) ,
1268+ params. join( "&" )
1269+ ) ;
1270+
1271+ let resp = self . get ( & url) ?;
1272+
1273+ if resp. status ( ) == 404 {
1274+ return Err ( ApiErrorKind :: OrganizationNotFound . into ( ) ) ;
1275+ }
1276+
1277+ let logs_response: LogsResponse = resp. convert ( ) ?;
1278+ Ok ( logs_response. data )
1279+ }
1280+
12291281 /// List all issues associated with an organization and a project
12301282 pub fn list_organization_project_issues (
12311283 & self ,
@@ -2320,7 +2372,7 @@ pub struct GitCommit {
23202372 pub id : String ,
23212373}
23222374
2323- #[ derive( Clone , Debug , Deserialize ) ]
2375+ #[ derive( Clone , Debug , Deserialize , Serialize ) ]
23242376pub struct ProcessedEvent {
23252377 #[ serde( alias = "eventID" ) ]
23262378 pub event_id : Uuid ,
@@ -2343,7 +2395,7 @@ pub struct ProcessedEvent {
23432395 pub tags : Option < Vec < ProcessedEventTag > > ,
23442396}
23452397
2346- #[ derive( Clone , Debug , Deserialize ) ]
2398+ #[ derive( Clone , Debug , Deserialize , Serialize ) ]
23472399pub struct ProcessedEventUser {
23482400 #[ serde( skip_serializing_if = "Option::is_none" ) ]
23492401 pub id : Option < String > ,
@@ -2377,7 +2429,7 @@ impl fmt::Display for ProcessedEventUser {
23772429 }
23782430}
23792431
2380- #[ derive( Clone , Debug , Deserialize ) ]
2432+ #[ derive( Clone , Debug , Deserialize , Serialize ) ]
23812433pub struct ProcessedEventTag {
23822434 pub key : String ,
23832435 pub value : String ,
@@ -2401,3 +2453,20 @@ pub struct Region {
24012453pub struct RegionResponse {
24022454 pub regions : Vec < Region > ,
24032455}
2456+
2457+ /// Response structure for logs API
2458+ #[ derive( Debug , Deserialize ) ]
2459+ struct LogsResponse {
2460+ data : Vec < LogEntry > ,
2461+ }
2462+
2463+ /// Log entry structure from the logs API
2464+ #[ derive( Debug , Deserialize ) ]
2465+ pub struct LogEntry {
2466+ #[ serde( rename = "sentry.item_id" ) ]
2467+ pub item_id : String ,
2468+ pub trace : Option < String > ,
2469+ pub severity : Option < String > ,
2470+ pub timestamp : String ,
2471+ pub message : Option < String > ,
2472+ }
0 commit comments