diff --git a/integrationos-api/src/endpoints/connection_definition.rs b/integrationos-api/src/endpoints/connection_definition.rs index fa74bb70..d2d5e35e 100644 --- a/integrationos-api/src/endpoints/connection_definition.rs +++ b/integrationos-api/src/endpoints/connection_definition.rs @@ -309,7 +309,7 @@ impl RequestExt for CreateRequest { test_connection: self.test_connection, auth_secrets, auth_method: self.auth_method.clone(), - multi_env: self.multi_env.clone(), + multi_env: self.multi_env, paths: self.paths.clone(), settings: self.settings.clone(), hidden: false, @@ -332,7 +332,7 @@ impl RequestExt for CreateRequest { record.frontend.spec.tags.clone_from(&self.tags); record.test_connection = self.test_connection; record.platform.clone_from(&self.platform); - record.multi_env = self.multi_env.clone(); + record.multi_env = self.multi_env; record.record_metadata.active = self.active; record } diff --git a/integrationos-api/src/endpoints/unified.rs b/integrationos-api/src/endpoints/unified.rs index 902a0a3b..d90c8f6c 100644 --- a/integrationos-api/src/endpoints/unified.rs +++ b/integrationos-api/src/endpoints/unified.rs @@ -11,7 +11,7 @@ use convert_case::{Case, Casing}; use http::{HeaderMap, HeaderName}; use integrationos_domain::{ connection_model_definition::CrudAction, destination::Action, - encrypted_access_key::EncryptedAccessKey, encrypted_data::PASSWORD_LENGTH, environment, + encrypted_access_key::EncryptedAccessKey, encrypted_data::PASSWORD_LENGTH, event_access::EventAccess, AccessKey, ApplicationError, Event, InternalError, }; use serde::{Deserialize, Serialize}; @@ -57,6 +57,8 @@ pub async fn get_request( .await } +const META: &str = "meta"; + pub async fn update_request( event_access: Extension>, state: State>, @@ -242,7 +244,8 @@ pub async fn process_request( e })?; - *response.headers_mut() = response + *response.response.headers_mut() = response + .response .headers() .iter() .map(|(key, value)| { @@ -253,7 +256,7 @@ pub async fn process_request( }) .collect::(); - let (parts, body) = response.into_parts(); + let (parts, body) = response.response.into_parts(); if let Some(Ok(encrypted_access_key)) = access_key_header_value.map(|v| v.to_str().map(|s| s.to_string())) @@ -276,9 +279,15 @@ pub async fn process_request( error!("Could not decrypt access key: {e}"); InternalError::decryption_error("Could not decrypt access key", None) })?; - const META: &str = "meta"; + let status_code = parts.status.as_u16(); + + let mut metadata = body.get(META).unwrap_or(&response.metadata).clone(); + if let Some(meta) = metadata.as_object_mut() { + meta.insert("status_code".to_string(), json!(status_code)); + }; + let body = serde_json::to_string(&json!({ - META: body.get(META) + META: metadata, })) .map_err(|e| { error!("Could not serialize meta body to string: {e}"); diff --git a/integrationos-api/src/metrics.rs b/integrationos-api/src/metrics.rs index 84f25a16..8d41f7cb 100644 --- a/integrationos-api/src/metrics.rs +++ b/integrationos-api/src/metrics.rs @@ -112,6 +112,7 @@ impl Metric { pub fn segment_track(&self) -> Track { use MetricType::*; + match &self.metric_type { Unified(conn) => Track { user: User::UserId { diff --git a/integrationos-domain/src/domain/configuration/environment.rs b/integrationos-domain/src/domain/configuration/environment.rs index 97312732..cae330cc 100644 --- a/integrationos-domain/src/domain/configuration/environment.rs +++ b/integrationos-domain/src/domain/configuration/environment.rs @@ -17,10 +17,7 @@ pub enum Environment { impl Environment { pub fn is_production(&self) -> bool { - match self { - Environment::Production | Environment::Live => true, - _ => false, - } + matches!(self, Environment::Production | Environment::Live) } } diff --git a/integrationos-unified/src/unified.rs b/integrationos-unified/src/unified.rs index 12d782fc..2ebcdb25 100644 --- a/integrationos-unified/src/unified.rs +++ b/integrationos-unified/src/unified.rs @@ -37,7 +37,7 @@ use mongodb::{ options::{Collation, CollationStrength, FindOneOptions}, Client, }; -use serde_json::{json, Map, Number, Value}; +use serde_json::{json, Number, Value}; use std::{cell::RefCell, collections::HashMap, str::FromStr, sync::Arc}; use tracing::{debug, error}; @@ -45,6 +45,11 @@ thread_local! { static JS_RUNTIME: RefCell