From 17d03b342d05fd43af52f982770acfe677a8cd0b Mon Sep 17 00:00:00 2001 From: stack72 Date: Tue, 30 Jul 2024 18:32:27 +0100 Subject: [PATCH] fix(dal): Ensure we send the correct contribute details to posthog Our trigger for slack wasn't firing correctly --- lib/dal/src/module.rs | 12 ++++++++++- lib/dal/tests/integration_test/module.rs | 2 +- .../server/service/v2/module/contribute.rs | 21 +++++++++++-------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/dal/src/module.rs b/lib/dal/src/module.rs index f2b4b82f3f..64614b9c2b 100644 --- a/lib/dal/src/module.rs +++ b/lib/dal/src/module.rs @@ -538,7 +538,15 @@ impl Module { name: impl AsRef, version: impl AsRef, schema_variant_id: SchemaVariantId, - ) -> ModuleResult<(String, String, Option, Option, Vec)> { + ) -> ModuleResult<( + String, + String, + Option, + Option, + Vec, + String, + String, + )> { let user = match ctx.history_actor() { HistoryActor::User(user_pk) => User::get_by_pk(ctx, *user_pk).await?, _ => None, @@ -592,6 +600,8 @@ impl Module { local_module_based_on_hash, local_module_schema_id, module_payload, + created_by_name, + created_by_email, )) } } diff --git a/lib/dal/tests/integration_test/module.rs b/lib/dal/tests/integration_test/module.rs index c4dca3d6e9..e4c16a398d 100644 --- a/lib/dal/tests/integration_test/module.rs +++ b/lib/dal/tests/integration_test/module.rs @@ -252,7 +252,7 @@ async fn prepare_contribution_works(ctx: &DalContext) { .expect("unable to get a default variant") .expect("error getting the default variant id"); - let (actual_name, actual_version, _, _, _) = + let (actual_name, actual_version, _, _, _, _, _) = Module::prepare_contribution(ctx, name, version, default_variant_id) .await .expect("could not prepare contribution"); diff --git a/lib/sdf-server/src/server/service/v2/module/contribute.rs b/lib/sdf-server/src/server/service/v2/module/contribute.rs index 9bcf2e1574..d04272bd39 100644 --- a/lib/sdf-server/src/server/service/v2/module/contribute.rs +++ b/lib/sdf-server/src/server/service/v2/module/contribute.rs @@ -35,13 +35,14 @@ pub async fn contribute( }; let index_client = ModuleIndexClient::new(module_index_url.try_into()?, &raw_access_token); - let (name, version, based_on_hash, schema_id, payload) = Module::prepare_contribution( - &ctx, - request.name.as_str(), - request.version.as_str(), - request.schema_variant_id.into(), - ) - .await?; + let (name, version, based_on_hash, schema_id, payload, created_by_name, created_by_email) = + Module::prepare_contribution( + &ctx, + request.name.as_str(), + request.version.as_str(), + request.schema_variant_id.into(), + ) + .await?; let response = index_client .upload_module( @@ -61,9 +62,11 @@ pub async fn contribute( &original_uri, "export_module", serde_json::json!({ - "name": name, - "version": version, + "pkg_name": name, + "pkg_version": version, "based_on_hash": based_on_hash, + "pkg_created_by_name": created_by_name, + "pkg_created_by_email": created_by_email, "schema_variant_id": request.schema_variant_id, "schema_id": schema_id, "pkg_hash": response.latest_hash,