Skip to content

Commit 76a7912

Browse files
committed
feat: plumb module_version through as a separate field
Add module_version as an optional field through the full updater stack: - YamlConfig: parse module_version from shorebird.yaml - UpdateConfig: propagate module_version from yaml config - PatchCheckRequest: send module_version alongside release_version (skipped when null via serde skip_serializing_if) The server uses module_version for patch lookup when present, while release_version always contains the host app's version for analytics. This avoids polluting release_version data with git hashes from module releases. Part of shorebirdtech/shorebird#793
1 parent 07fa11c commit 76a7912

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

library/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub struct UpdateConfig {
8686
pub file_provider: Box<dyn ExternalFileProvider>,
8787
pub patch_public_key: Option<String>,
8888
pub patch_verification: PatchVerificationMode,
89+
pub module_version: Option<String>,
8990
}
9091

9192
/// Returns Ok if the config was set successfully, Err if it was already set.
@@ -129,6 +130,7 @@ pub fn set_config(
129130
file_provider,
130131
patch_public_key: yaml.patch_public_key.to_owned(),
131132
patch_verification: yaml.patch_verification.unwrap_or_default(),
133+
module_version: yaml.module_version.to_owned(),
132134
};
133135
shorebird_debug!("Updater configured with: {:?}", new_config);
134136
*config = Some(new_config);

library/src/network.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ pub struct PatchCheckRequest {
247247
/// The unique ID of this device. This is a random UUID generated by Shorebird and _not_ the
248248
/// device's UUID or any other identifier that has meaning outside of Shorebird.
249249
pub client_id: String,
250+
/// Module version for add-to-app releases (AAR/iOS framework).
251+
/// When present, used instead of release_version for patch lookup.
252+
/// The release_version still contains the host app's version for analytics.
253+
#[serde(skip_serializing_if = "Option::is_none")]
254+
pub module_version: Option<String>,
250255
// We specifically do not send a patch number as part of this request because we always want to
251256
// know what the latest available patch is.
252257
}
@@ -260,6 +265,7 @@ impl PatchCheckRequest {
260265
platform: current_platform().to_string(),
261266
arch: current_arch().to_string(),
262267
client_id: client_id.to_string(),
268+
module_version: config.module_version.clone(),
263269
}
264270
}
265271
}

library/src/yaml.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct YamlConfig {
3030
pub patch_public_key: Option<String>,
3131
/// When to verify patch signatures. Defaults to "strict" (verify at boot time).
3232
pub patch_verification: Option<PatchVerificationMode>,
33+
/// Module version for add-to-app releases (AAR/iOS framework).
34+
/// When present, used instead of release_version for patch lookup.
35+
pub module_version: Option<String>,
3336
}
3437

3538
impl YamlConfig {

0 commit comments

Comments
 (0)