Skip to content

Implement analytics marker events#6090

Open
aecsocket wants to merge 12 commits into
mainfrom
boris/more-analytics-qa
Open

Implement analytics marker events#6090
aecsocket wants to merge 12 commits into
mainfrom
boris/more-analytics-qa

Conversation

@aecsocket
Copy link
Copy Markdown
Contributor

No description provided.

@modrinth-bot
Copy link
Copy Markdown
Member

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

Comment on lines +355 to +402
pub enum DownloadSource {
Website,
ModrinthApp,
ModrinthHosting,
ModrinthMaven,
Other,
Named(String),
}

impl Serialize for DownloadSource {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::Named(name) => serializer.serialize_str(name),
Self::Website => serializer.serialize_str("website"),
Self::ModrinthApp => serializer.serialize_str("modrinth_app"),
Self::ModrinthHosting => {
serializer.serialize_str("modrinth_hosting")
}
Self::ModrinthMaven => serializer.serialize_str("modrinth_maven"),
Self::Other => serializer.serialize_str("other"),
}
}
}

impl<'de> Deserialize<'de> for DownloadSource {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let source = String::deserialize(deserializer)?;
Ok(match source.as_str() {
"website" => Self::Website,
"modrinth_app" => Self::ModrinthApp,
"modrinth_hosting" => Self::ModrinthHosting,
"modrinth_maven" => Self::ModrinthMaven,
"other" => Self::Other,
_ if !source.is_empty() => Self::Named(source),
_ => {
return Err(D::Error::custom(
"download source cannot be empty",
));
}
})
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can mark the Other variant as serde(untagged) to avoid needing a custom deserializer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants