|
| 1 | +// Query event filtered users returns "Successful response with filtered user |
| 2 | +// data" response |
| 3 | +use datadog_api_client::datadog; |
| 4 | +use datadog_api_client::datadogV2::api_rum_audience_management::RumAudienceManagementAPI; |
| 5 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequest; |
| 6 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequestData; |
| 7 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequestDataAttributes; |
| 8 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequestDataAttributesEventQuery; |
| 9 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequestDataAttributesEventQueryTimeFrame; |
| 10 | +use datadog_api_client::datadogV2::model::QueryEventFilteredUsersRequestDataType; |
| 11 | + |
| 12 | +#[tokio::main] |
| 13 | +async fn main() { |
| 14 | + let body = |
| 15 | + QueryEventFilteredUsersRequest |
| 16 | + ::new().data( |
| 17 | + QueryEventFilteredUsersRequestData::new( |
| 18 | + QueryEventFilteredUsersRequestDataType::QUERY_EVENT_FILTERED_USERS_REQUEST, |
| 19 | + ) |
| 20 | + .attributes( |
| 21 | + QueryEventFilteredUsersRequestDataAttributes::new() |
| 22 | + .event_query( |
| 23 | + QueryEventFilteredUsersRequestDataAttributesEventQuery::new() |
| 24 | + .query( |
| 25 | + "@type:view AND @view.loading_time:>3000 AND @application.name:ecommerce-platform".to_string(), |
| 26 | + ) |
| 27 | + .time_frame( |
| 28 | + QueryEventFilteredUsersRequestDataAttributesEventQueryTimeFrame::new() |
| 29 | + .end(1761309676) |
| 30 | + .start(1760100076), |
| 31 | + ), |
| 32 | + ) |
| 33 | + .include_row_count(true) |
| 34 | + .limit(25) |
| 35 | + .query("user_org_id:5001 AND first_country_code:US AND first_browser_name:Chrome".to_string()) |
| 36 | + .select_columns( |
| 37 | + vec![ |
| 38 | + "user_id".to_string(), |
| 39 | + "user_email".to_string(), |
| 40 | + "first_country_code".to_string(), |
| 41 | + "first_browser_name".to_string(), |
| 42 | + "events_count".to_string(), |
| 43 | + "session_count".to_string(), |
| 44 | + "error_count".to_string(), |
| 45 | + "avg_loading_time".to_string() |
| 46 | + ], |
| 47 | + ), |
| 48 | + ) |
| 49 | + .id("query_event_filtered_users_request".to_string()), |
| 50 | + ); |
| 51 | + let mut configuration = datadog::Configuration::new(); |
| 52 | + configuration.set_unstable_operation_enabled("v2.QueryEventFilteredUsers", true); |
| 53 | + let api = RumAudienceManagementAPI::with_config(configuration); |
| 54 | + let resp = api.query_event_filtered_users(body).await; |
| 55 | + if let Ok(value) = resp { |
| 56 | + println!("{:#?}", value); |
| 57 | + } else { |
| 58 | + println!("{:#?}", resp.unwrap_err()); |
| 59 | + } |
| 60 | +} |
0 commit comments