respect telemetry settings

This commit is contained in:
andrepimenta
2025-07-30 03:36:37 +01:00
parent d225ff2596
commit 62163dbc32
2 changed files with 9 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import * as cp from 'child_process';
import * as util from 'util';
import * as path from 'path';
import html from './ui';
import getHtml from './ui';
const exec = util.promisify(cp.exec);
@@ -2136,7 +2136,7 @@ class ClaudeChatProvider {
}
private _getHtmlForWebview(): string {
return html;
return getHtml(vscode.env?.isTelemetryEnabled);
}
private _sendCurrentSettings(): void {

View File

@@ -1,5 +1,5 @@
import styles from './ui-styles'
const html = `<!DOCTYPE html>
const getHtml = (isTelemetryEnabled: boolean) => `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
@@ -1470,13 +1470,15 @@ const html = `<!DOCTYPE html>
// Send usage statistics
function sendStats(eventName) {
try {
${isTelemetryEnabled ?
`try {
if (typeof umami !== 'undefined' && umami.track) {
umami.track(eventName);
}
} catch (error) {
console.error('Error sending stats:', error);
}
}` :
`// Telemetry disabled - no tracking`}
}
function updateStatus(text, state = 'ready') {
@@ -3669,8 +3671,8 @@ const html = `<!DOCTYPE html>
2. Do I need to display a cookie notice to users?
No, Umami does not use any cookies in the tracking code.
-->
<script defer src="https://cloud.umami.is/script.js" data-website-id="d050ac9b-2b6d-4c67-b4c6-766432f95644"></script>
${isTelemetryEnabled ? '<script defer src="https://cloud.umami.is/script.js" data-website-id="d050ac9b-2b6d-4c67-b4c6-766432f95644"></script>' : '<!-- Umami analytics disabled due to VS Code telemetry settings -->'}
</body>
</html>`;
export default html;
export default getHtml;