Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s/.com/.workers.dev #241

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/sputnik/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ serde_json = "1.0"
sha2 = "0.9"
structopt = "0.3"
thiserror = "1.0"
tracing = "0.1"
url = "2.2"
uuid = { version = "0.8", features = ["serde", "v4"] }

Expand Down
4 changes: 3 additions & 1 deletion crates/sputnik/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ impl Session {
// set timeout to 400 ms to prevent blocking for too long on reporting
let timeout = Duration::from_millis(4000);
let body = serde_json::to_string(&self)?;
tracing::debug!("POSTing to {}", &self.reporting_info.endpoint);
tracing::debug!("{}", body);
reqwest::blocking::Client::new()
.post(self.reporting_info.endpoint.to_owned())
.post(self.reporting_info.endpoint.clone())
.body(body)
.header("User-Agent", &self.reporting_info.user_agent)
.header("Content-Type", "application/json")
Expand Down
23 changes: 8 additions & 15 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use sputnik::{Command, Report, SputnikError};

use std::collections::HashMap;

const DEV_TELEMETRY_URL: &str = "http://localhost:8787/telemetry";
const PROD_TELEMETRY_URL: &str = "https://install.apollographql.com/telemetry";
const TELEMETRY_URL: &str = "https://install.apollographql.workers.dev/telemetry";

fn get_command_from_args(mut raw_arguments: &mut serde_json::Value) -> Command {
let mut commands = Vec::new();
Expand Down Expand Up @@ -89,25 +88,19 @@ impl Report for Rover {
}

fn endpoint(&self) -> Result<Url, SputnikError> {
if let Some(url) = self.env_store.get(RoverEnvKey::TelemetryUrl)? {
Ok(Url::parse(&url)?)
} else if cfg!(debug_assertions) {
Ok(DEV_TELEMETRY_URL.parse()?)
} else {
Ok(PROD_TELEMETRY_URL.parse()?)
}
let url = self
.env_store
.get(RoverEnvKey::TelemetryUrl)?
.unwrap_or_else(|| TELEMETRY_URL.to_string());
Ok(Url::parse(&url)?)
}

fn tool_name(&self) -> String {
option_env!("CARGO_PKG_NAME")
.unwrap_or("unknown")
.to_string()
env!("CARGO_PKG_NAME").to_string()
}

fn version(&self) -> String {
option_env!("CARGO_PKG_VERSION")
.unwrap_or("unknown")
.to_string()
env!("CARGO_PKG_VERSION").to_string()
}

fn machine_id_config(&self) -> Result<PathBuf, SputnikError> {
Expand Down