Skip to content
8 changes: 8 additions & 0 deletions rust/feature-flags/src/handler/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub enum Library {
PosthogReactNative,
/// posthog-flutter SDK
PosthogFlutter,
/// posthog-server SDK (deprecated: users are migrating to posthog-java)
PosthogServer,
/// Unknown or unrecognized SDK
Other,
}
Expand All @@ -120,6 +122,7 @@ impl Library {
Library::PosthogIos => "posthog-ios",
Library::PosthogReactNative => "posthog-react-native",
Library::PosthogFlutter => "posthog-flutter",
Library::PosthogServer => "posthog-server",
Library::Other => "other",
}
}
Expand All @@ -141,6 +144,7 @@ impl Library {
Library::PosthogIos,
Library::PosthogReactNative,
Library::PosthogFlutter,
Library::PosthogServer,
];
}

Expand Down Expand Up @@ -236,6 +240,8 @@ mod tests {
#[case("posthog-java/1.2.0", Library::PosthogJava)]
#[case("posthog-dotnet/1.0.0", Library::PosthogDotnet)]
#[case("posthog-elixir/0.2.0", Library::PosthogElixir)]
#[case("posthog-server/1.0.0", Library::PosthogServer)]
#[case("posthog-server/3.2.1 (Android SDK)", Library::PosthogServer)]
// Client-side SDKs
#[case("posthog-js/1.88.0", Library::PosthogJs)]
#[case("posthog-android/3.0.0", Library::PosthogAndroid)]
Expand Down Expand Up @@ -322,6 +328,7 @@ mod tests {
#[case(Library::PosthogIos, "posthog-ios")]
#[case(Library::PosthogReactNative, "posthog-react-native")]
#[case(Library::PosthogFlutter, "posthog-flutter")]
#[case(Library::PosthogServer, "posthog-server")]
#[case(Library::Other, "other")]
fn test_library_display(#[case] library: Library, #[case] expected: &str) {
assert_eq!(library.to_string(), expected);
Expand All @@ -341,6 +348,7 @@ mod tests {
#[case(Library::PosthogIos, "\"posthog-ios\"")]
#[case(Library::PosthogReactNative, "\"posthog-react-native\"")]
#[case(Library::PosthogFlutter, "\"posthog-flutter\"")]
#[case(Library::PosthogServer, "\"posthog-server\"")]
#[case(Library::Other, "\"other\"")]
fn test_library_serialization(#[case] library: Library, #[case] expected_json: &str) {
assert_eq!(serde_json::to_string(&library).unwrap(), expected_json);
Expand Down
16 changes: 16 additions & 0 deletions rust/feature-flags/src/utils/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ impl UserAgentInfo {
"node" => ("posthog-node", RuntimeType::Server),
"dotnet" => ("posthog-dotnet", RuntimeType::Server),
"elixir" => ("posthog-elixir", RuntimeType::Server),
// Deprecated: posthog-server users are migrating to posthog-java
"server" => ("posthog-server", RuntimeType::Server),
// Client-side SDKs (mobile and browser)
"js" => ("posthog-js", RuntimeType::Client),
"android" => ("posthog-android", RuntimeType::Client),
Expand Down Expand Up @@ -231,6 +233,18 @@ mod tests {
Some("0.2.0"),
RuntimeType::Server
)]
#[case(
"posthog-server/1.0.0",
Some("posthog-server"),
Some("1.0.0"),
RuntimeType::Server
)]
#[case(
"posthog-server/3.2.1 (Android SDK)",
Some("posthog-server"),
Some("3.2.1"),
RuntimeType::Server
)]
#[case(
"posthog-js/1.88.0",
Some("posthog-js"),
Expand Down Expand Up @@ -341,6 +355,7 @@ mod tests {
#[case(Some("posthog-node/2.2.0"), "posthog-node")]
#[case(Some("posthog-dotnet/1.0.0"), "posthog-dotnet")]
#[case(Some("posthog-elixir/0.2.0"), "posthog-elixir")]
#[case(Some("posthog-server/1.0.0"), "posthog-server")]
#[case(
Some("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"),
"browser"
Expand All @@ -366,6 +381,7 @@ mod tests {
#[case("posthog-python/3.0.0", Some("posthog-python"))]
#[case("posthog-node/1.2.3", Some("posthog-node"))]
#[case("posthog-android/3.0.0", Some("posthog-android"))]
#[case("posthog-server/1.0.0", Some("posthog-server"))]
#[case("Mozilla/5.0 (Windows NT 10.0; Win64; x64)", Some("web"))]
#[case("Chrome/120.0.0.0 Safari/537.36", Some("web"))]
#[case("curl/7.68.0", None)]
Expand Down
Loading