diff --git a/meilisearch-http/src/routes/swap_indexes.rs b/meilisearch-http/src/routes/swap_indexes.rs index fa28fe27c..bc0c1705a 100644 --- a/meilisearch-http/src/routes/swap_indexes.rs +++ b/meilisearch-http/src/routes/swap_indexes.rs @@ -1,11 +1,13 @@ use actix_web::web::Data; -use actix_web::{web, HttpResponse}; +use actix_web::{web, HttpRequest, HttpResponse}; use index_scheduler::IndexScheduler; use meilisearch_types::error::ResponseError; use meilisearch_types::tasks::{IndexSwap, KindWithContent}; use serde::Deserialize; +use serde_json::json; use super::SummarizedTaskView; +use crate::analytics::Analytics; use crate::error::MeilisearchHttpError; use crate::extractors::authentication::policies::*; use crate::extractors::authentication::{AuthenticationError, GuardedData}; @@ -23,7 +25,16 @@ pub struct SwapIndexesPayload { pub async fn swap_indexes( index_scheduler: GuardedData, Data>, params: web::Json>, + req: HttpRequest, + analytics: web::Data, ) -> Result { + analytics.publish( + "Indexes Swapped".to_string(), + json!({ + "swap_operation_number": params.len(), + }), + Some(&req), + ); let search_rules = &index_scheduler.filters().search_rules; let mut swaps = vec![];