Skip to content

Commit

Permalink
Merge pull request #4250 from systeminit/fix(dal)--Ensure-we-send-the…
Browse files Browse the repository at this point in the history
…-correct-contribute-details-to-posthog

fix(dal): Ensure we send the correct contribute details to posthog
  • Loading branch information
stack72 authored Jul 30, 2024
2 parents 6629ad9 + 17d03b3 commit a807ca0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
12 changes: 11 additions & 1 deletion lib/dal/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,15 @@ impl Module {
name: impl AsRef<str>,
version: impl AsRef<str>,
schema_variant_id: SchemaVariantId,
) -> ModuleResult<(String, String, Option<String>, Option<SchemaId>, Vec<u8>)> {
) -> ModuleResult<(
String,
String,
Option<String>,
Option<SchemaId>,
Vec<u8>,
String,
String,
)> {
let user = match ctx.history_actor() {
HistoryActor::User(user_pk) => User::get_by_pk(ctx, *user_pk).await?,
_ => None,
Expand Down Expand Up @@ -592,6 +600,8 @@ impl Module {
local_module_based_on_hash,
local_module_schema_id,
module_payload,
created_by_name,
created_by_email,
))
}
}
2 changes: 1 addition & 1 deletion lib/dal/tests/integration_test/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
21 changes: 12 additions & 9 deletions lib/sdf-server/src/server/service/v2/module/contribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit a807ca0

Please sign in to comment.