-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Prepare to have more than one event type (#77)
Refactored our PatchInstallEvent to be just PatchEvent and allow us to have more than one event type. I moved it into its own events.rs file and added privacy warnings to both this and the network code (eventually we may move all this into a separate privacy.rs file). I also fixed our build.rs file to not panic when our build is otherwise broken. For whatever reason that seems to cause the rust-analyzer to stop and not show any future warnings (thus it's hard to fix things). I moved away from having a "new" method for PatchEvent with a series of Strings (which could be confused in order) and instead am now using just the normal default struct construction which effectively has named args. Since EventType is now an enum, it's easy to use the right enum not have to call PatchInstallEvent::new to get the right magic string for "identifier". Also added a bit more documentation to c_api.rs
- Loading branch information
Showing
5 changed files
with
131 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// This file's job is to deal with the update_server and network side | ||
// of the updater library. | ||
|
||
use serde::{Serialize, Serializer}; | ||
|
||
#[derive(Debug)] | ||
pub enum EventType { | ||
PatchInstallSuccess, | ||
// PatchInstallFailure, | ||
} | ||
|
||
impl Serialize for EventType { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
serializer.serialize_str(match self { | ||
EventType::PatchInstallSuccess => "__patch_install__", | ||
// EventType::PatchInstallFailure => "__patch_install_failure__", | ||
}) | ||
} | ||
} | ||
|
||
/// Any edits to this struct should be made carefully and in accordance | ||
/// with our privacy policy: | ||
/// https://docs.shorebird.dev/privacy | ||
/// An event that is sent to the server when a patch is successfully installed. | ||
#[derive(Debug, Serialize)] | ||
pub struct PatchEvent { | ||
/// The Shorebird app_id built into the shorebird.yaml in the app. | ||
pub app_id: String, | ||
|
||
/// The architecture we're running (e.g. "aarch64", "x86", "x86_64"). | ||
pub arch: String, | ||
|
||
/// The unique ID of this device. | ||
pub client_id: String, | ||
|
||
/// The identifier of this event. | ||
#[serde(rename = "type")] | ||
pub identifier: EventType, | ||
|
||
/// The patch number that was installed. | ||
pub patch_number: usize, | ||
|
||
/// The platform we're running on (e.g. "android", "ios", "windows", "macos", "linux"). | ||
pub platform: String, | ||
|
||
/// The release version from AndroidManifest.xml, Info.plist in the app. | ||
pub release_version: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters