From 6b8e5a4c924a8a652c1fbe90283b13fb7780d7f0 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 12 Oct 2021 14:46:35 +0200 Subject: [PATCH] log the index created route --- meilisearch-http/src/routes/indexes/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/meilisearch-http/src/routes/indexes/mod.rs b/meilisearch-http/src/routes/indexes/mod.rs index 0d0132d05..ee1c47ac9 100644 --- a/meilisearch-http/src/routes/indexes/mod.rs +++ b/meilisearch-http/src/routes/indexes/mod.rs @@ -4,7 +4,9 @@ use log::debug; use meilisearch_lib::index_controller::IndexSettings; use meilisearch_lib::MeiliSearch; use serde::{Deserialize, Serialize}; +use serde_json::json; +use crate::analytics::Analytics; use crate::error::ResponseError; use crate::extractors::authentication::{policies::*, GuardedData}; use crate::routes::IndexParam; @@ -54,8 +56,14 @@ pub struct IndexCreateRequest { pub async fn create_index( meilisearch: GuardedData, body: web::Json, + analytics: web::Data<&'static dyn Analytics>, ) -> Result { let body = body.into_inner(); + + analytics.publish( + "Index Created".to_string(), + json!({ "with_primary_key": body.primary_key}), + ); let meta = meilisearch.create_index(body.uid, body.primary_key).await?; Ok(HttpResponse::Created().json(meta)) }