(env: &Env, database: &mut Database, telemetry_enabled: bool)
| 536 | }; |
| 537 | |
| 538 | fn client_id(env: &Env, database: &mut Database, telemetry_enabled: bool) -> Result<Uuid, TelemetryError> { |
| 539 | if !telemetry_enabled { |
| 540 | return Ok(uuid!("ffffffff-ffff-ffff-ffff-ffffffffffff")); |
| 541 | } |
| 542 | |
| 543 | if let Ok(client_id) = crate::util::env_var::get_telemetry_client_id(env) { |
| 544 | if let Ok(uuid) = Uuid::from_str(&client_id) { |
| 545 | return Ok(uuid); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | Ok(match database.get_client_id()? { |
| 550 | Some(uuid) => uuid, |
| 551 | None => { |
| 552 | let uuid = database |
| 553 | .settings |
| 554 | .get_string(Setting::OldClientId) |
| 555 | .and_then(|id| Uuid::try_parse(&id).ok()) |
| 556 | .unwrap_or_else(Uuid::new_v4); |
| 557 | |
| 558 | if let Err(err) = database.set_client_id(uuid) { |
| 559 | error!(%err, "Failed to set client id in state"); |
| 560 | } |
| 561 | |
| 562 | uuid |
| 563 | }, |
| 564 | }) |
| 565 | } |
| 566 | |
| 567 | // cw telemetry is only available with bearer token auth. |
| 568 | let codewhisperer_client = if crate::util::env_var::is_sigv4_enabled(&Env::new()) { |
no test coverage detected