| 719 | } |
| 720 | |
| 721 | fn user_context(&self) -> Option<UserContext> { |
| 722 | let operating_system = match std::env::consts::OS { |
| 723 | "linux" => OperatingSystem::Linux, |
| 724 | "macos" => OperatingSystem::Mac, |
| 725 | "windows" => OperatingSystem::Windows, |
| 726 | os => { |
| 727 | error!(%os, "Unsupported operating system"); |
| 728 | return None; |
| 729 | }, |
| 730 | }; |
| 731 | |
| 732 | match UserContext::builder() |
| 733 | .client_id(self.client_id.hyphenated().to_string()) |
| 734 | .operating_system(operating_system) |
| 735 | .product(PRODUCT) |
| 736 | .ide_category(IdeCategory::Cli) |
| 737 | .ide_version(PRODUCT_VERSION) |
| 738 | .build() |
| 739 | { |
| 740 | Ok(user_context) => Some(user_context), |
| 741 | Err(err) => { |
| 742 | error!(%err, "Failed to build user context"); |
| 743 | None |
| 744 | }, |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | pub trait ReasonCode: std::error::Error { |