Change SEGMENT_API_URL to SEGMENT_BASE_URL and append endpoint path

Store only the base URL (e.g. https://api.segment.io) so that
different endpoints (/v1/batch, /v1/track, etc.) can reuse it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-19 14:02:29 -04:00
parent 04424017b2
commit 5c047beaeb
No known key found for this signature in database

View file

@ -6,9 +6,9 @@ use uuid::Uuid;
use crate::event::Track;
const SEGMENT_API_URL: &str = match option_env!("SEGMENT_API_URL") {
const SEGMENT_BASE_URL: &str = match option_env!("SEGMENT_BASE_URL") {
Some(url) => url,
None => "https://api.segment.io/v1/batch",
None => "https://api.segment.io",
};
const SEGMENT_WRITE_KEY: Option<&str> = option_env!("SEGMENT_WRITE_KEY");
@ -92,7 +92,7 @@ pub async fn upload(path: &Path) -> anyhow::Result<()> {
let auth = STANDARD.encode(format!("{write_key}:"));
let resp = reqwest::Client::new()
.post(SEGMENT_API_URL)
.post(format!("{SEGMENT_BASE_URL}/v1/batch"))
.header("Authorization", format!("Basic {auth}"))
.json(&payload)
.send()