Skip to content

Commit e6824fe

Browse files
committed
feat: add DISABLE_ANALYTICS check
1 parent 966d339 commit e6824fe

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

crates/cli/src/commands/publish.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,21 @@ pub async fn handler(args: &Command, telemetry: &PostHogSender) -> Result<()> {
200200

201201
let cli_version = env!("CARGO_PKG_VERSION");
202202

203-
let _ = telemetry.send_event(
204-
BaseEvent {
205-
kind: "codemodPublished".to_string(),
206-
properties: HashMap::from([
207-
("codemodName".to_string(), manifest.name.clone()),
208-
("version".to_string(), manifest.version.clone()),
209-
("cliVersion".to_string(), cli_version.to_string()),
210-
]),
211-
},
212-
None,
213-
);
203+
if std::env::var("DISABLE_ANALYTICS") == Ok("false".to_string())
204+
|| std::env::var("DISABLE_ANALYTICS").is_err()
205+
{
206+
let _ = telemetry.send_event(
207+
BaseEvent {
208+
kind: "codemodPublished".to_string(),
209+
properties: HashMap::from([
210+
("codemodName".to_string(), manifest.name.clone()),
211+
("version".to_string(), manifest.version.clone()),
212+
("cliVersion".to_string(), cli_version.to_string()),
213+
]),
214+
},
215+
None,
216+
);
217+
}
214218

215219
println!("✅ Package published successfully!");
216220
println!("📦 {}", format_package_name(&response.package));

crates/cli/src/commands/run.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,23 @@ pub async fn handler(engine: &Engine, args: &Command, telemetry: &PostHogSender)
104104
&base64::engine::general_purpose::URL_SAFE_NO_PAD,
105105
execution_id,
106106
);
107-
let _ = telemetry.send_event(
108-
BaseEvent {
109-
kind: "codemodExecuted".to_string(),
110-
properties: HashMap::from([
111-
("codemodName".to_string(), args.package.clone()),
112-
("executionId".to_string(), execution_id.clone()),
113-
("fileCount".to_string(), stats.files_modified.to_string()),
114-
("cliVersion".to_string(), cli_version.to_string()),
115-
]),
116-
},
117-
None,
118-
);
107+
108+
if std::env::var("DISABLE_ANALYTICS") == Ok("false".to_string())
109+
|| std::env::var("DISABLE_ANALYTICS").is_err()
110+
{
111+
let _ = telemetry.send_event(
112+
BaseEvent {
113+
kind: "codemodExecuted".to_string(),
114+
properties: HashMap::from([
115+
("codemodName".to_string(), args.package.clone()),
116+
("executionId".to_string(), execution_id.clone()),
117+
("fileCount".to_string(), stats.files_modified.to_string()),
118+
("cliVersion".to_string(), cli_version.to_string()),
119+
]),
120+
},
121+
None,
122+
);
123+
}
119124

120125
Ok(())
121126
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy