fix(cron): prevent telemetry ping when telemetry is disabled (#3313)

this updates the cron to avoid running the telemetry ping when
telemetry is disabled so that personally identifiable information
is not sent off to other parties (an IP address, an installation ID)
This commit is contained in:
James Ward
2026-03-12 20:43:28 -06:00
committed by GitHub
parent 9e1ff527e8
commit cac557b74e
2 changed files with 30 additions and 9 deletions
@@ -42,8 +42,7 @@ public class CronService {
@Scheduled(fixedDelay = 24, timeUnit = TimeUnit.HOURS, initialDelay = 24)
public void sendTelemetryData() {
AppSettings settings = appSettingService.getAppSettings();
if (settings != null && settings.isTelemetryEnabled()) {
if (isTelemetryEnabled()) {
String url = appProperties.getTelemetry().getBaseUrl() + "/api/v1/ingest";
BookloreTelemetry telemetry = telemetryService.collectTelemetry();
if (postData(url, telemetry)) {
@@ -54,11 +53,13 @@ public class CronService {
@Scheduled(fixedDelay = 24, timeUnit = TimeUnit.HOURS, initialDelay = 12)
public void sendPing() {
String url = appProperties.getTelemetry().getBaseUrl() + "/api/v1/heartbeat";
InstallationPing ping = telemetryService.getInstallationPing();
if (ping != null && postData(url, ping)) {
appSettingService.saveSetting(LAST_PING_KEY, Instant.now().toString());
appSettingService.saveSetting(LAST_PING_APP_VERSION_KEY, ping.getAppVersion());
if (isTelemetryEnabled()) {
String url = appProperties.getTelemetry().getBaseUrl() + "/api/v1/heartbeat";
InstallationPing ping = telemetryService.getInstallationPing();
if (ping != null && postData(url, ping)) {
appSettingService.saveSetting(LAST_PING_KEY, Instant.now().toString());
appSettingService.saveSetting(LAST_PING_APP_VERSION_KEY, ping.getAppVersion());
}
}
}
@@ -76,6 +77,11 @@ public class CronService {
}
}
private void isTelemetryEnabled() {
AppSettings settings = appSettingService.getAppSettings();
return settings != null && settings.isTelemetryEnabled();
}
private void checkAndRunTelemetry() {
AppSettings settings = appSettingService.getAppSettings();
if (settings == null || !settings.isTelemetryEnabled()) {