mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-07-04 05:00:00 +08:00
fix(analytics): respect data collection setting for all tracking events (#14390)
## Summary - `trackAppLaunch` (called unconditionally in `init()`) and `trackAppUpdate` currently **bypass** the `enableDataCollection` user setting, sending telemetry to `analytics.cherry-ai.com` even when users have explicitly disabled data collection. - Only `trackTokenUsage` correctly checks `configManager.getEnableDataCollection()`. - This regression was introduced in6061d472(2026-03-22), which removed the original opt-out guard from `init()` that existed since the initial implementation in1734467f. ## Changes - Add `enableDataCollection` check before `trackAppLaunch` in `init()` - Add `enableDataCollection` check in `trackAppUpdate()` - All three tracking methods now consistently respect the user's data collection preference ## Test plan - [x] `pnpm lint` passes - [x] `pnpm test` passes (2 pre-existing symlink failures on Windows, unrelated) - [ ] Verify with data collection **enabled**: all three events (`app_launch`, `token_usage`, `app_update`) are sent normally - [ ] Verify with data collection **disabled**: no events are sent to `analytics.cherry-ai.com` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: suyao <sy20010504@gmail.com>
This commit is contained in:
@@ -21,6 +21,11 @@ class AnalyticsService {
|
||||
}
|
||||
|
||||
public init(): void {
|
||||
if (!configManager.getEnableDataCollection()) {
|
||||
logger.info('Analytics service disabled by user preference')
|
||||
return
|
||||
}
|
||||
|
||||
this.client = new AnalyticsClient({
|
||||
clientId: configManager.getClientId(),
|
||||
channel: 'cherry-studio',
|
||||
@@ -53,7 +58,7 @@ class AnalyticsService {
|
||||
}
|
||||
|
||||
public async trackAppUpdate(): Promise<void> {
|
||||
if (!this.client) {
|
||||
if (!this.client || !configManager.getEnableDataCollection()) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user