Introduce new analytics to the export route

This commit is contained in:
Clément Renault 2025-06-26 15:45:24 +02:00
parent 63031219c5
commit e6e9a033aa
No known key found for this signature in database
GPG key ID: F250A4C4E3AE5F5F
3 changed files with 74 additions and 1 deletions

View file

@ -22,6 +22,7 @@ use utoipa::{OpenApi, ToSchema};
use crate::analytics::Analytics;
use crate::extractors::authentication::policies::ActionPolicy;
use crate::extractors::authentication::GuardedData;
use crate::routes::export_analytics::ExportAnalytics;
use crate::routes::{get_task_id, is_dry_run, SummarizedTaskView};
use crate::Opt;
@ -67,7 +68,7 @@ async fn export(
export: AwebJson<Export, DeserrJsonError>,
req: HttpRequest,
opt: web::Data<Opt>,
_analytics: Data<Analytics>,
analytics: Data<Analytics>,
) -> Result<HttpResponse, ResponseError> {
// TODO make it experimental?
// index_scheduler.features().check_network("Using the /network route")?;
@ -75,6 +76,8 @@ async fn export(
let export = export.into_inner();
debug!(returns = ?export, "Trigger export");
let analytics_aggregate = ExportAnalytics::from_export(&export);
let Export { url, api_key, payload_size, indexes } = export;
let indexes = if indexes.is_empty() {
@ -101,6 +104,8 @@ async fn export(
.await??
.into();
analytics.publish(analytics_aggregate, &req);
Ok(HttpResponse::Ok().json(task))
}